electron-vue-router-url

1.0.1-3 • Public • Published

electron-vue-router-url

Version Documentation Maintenance

Install

npm i electron-vue-router-url --save

Usage

First of all, you need to disable mode: 'history' in your vue-router, check in vue-router docs

Then do the following:

src/main/index.js example:

const getVueUrl = require("electron-vue-router-url");

ipc.on('showChart', function (e, data) {
  // loads process.env.WEBPACK_DEV_SERVER_URL + #/showChart` or `app://./index.html#/showChart` when build
  const url = getVueUrl("showChart");
  let win = new BrowserWindow({ width: 400, height: 320, webPreferences: {webSecurity: false} })
  win.on('close', function () { win = null })
  win.loadURL(url)
})

function createWindow() {
  win = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      // this is important!
      nodeIntegration: true,
    },
  });

  // loads process.env.WEBPACK_DEV_SERVER_URL + #/` or `app://./index.html#/` when build
  win.loadURL(getVueUrl());

  win.on("closed", () => {
    win = null;
  });
}

In your router, use the exact path to your url

src/renderer/router.js example

{
   path: '/showChart',
   name: 'showChart',
   component: require('your-router'),
 },

nodeIntegration must be set to true (nodeIntegration was true by default in previous electron versions, but false by default in 5.0.0.)

Author

👤 3zbumban

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2019 3zbumban.

This project is BSD-3-Clause licensed.


This README was generated with ❤️ by readme-md-generator

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1-3
    1
    • latest

Version History

Package Sidebar

Install

npm i electron-vue-router-url

Weekly Downloads

1

Version

1.0.1-3

License

BSD-3-Clause

Unpacked Size

2.83 kB

Total Files

4

Last publish

Collaborators

  • 3zebumbanner