Skip to content

3zbumban/electron-vue-router-url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

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

About

little helper to match BrowserWindow.loadURL() with vue-router routes

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published