I want to show my chart on the new window , but below code is not work . I need to send data to the new window . how can i do , thanks.
vue is a SAP APP, so i create a new page to do this , whether has another better way?
ipc.on('showChart', function (e, data) {
const modalPath = process.env.NODE_ENV === 'development'
? http://localhost:9080/showChart.html
: file://${__dirname}/showChart.html
let win = new BrowserWindow({ width: 400, height: 320, webPreferences: {webSecurity: false} })
win.on('close', function () { win = null })
win.loadURL(modalPath)
})
Your webpack should have multiple entries.
multiple entries
set plugins
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
ipc.on('showChart', function (e, data) {
const modalPath = process.env.NODE_ENV === 'development'
? 'http://localhost:9080/#/showChart'
: `file://${__dirname}/index.html#showChart`
let win = new BrowserWindow({ width: 400, height: 320, webPreferences: {webSecurity: false} })
win.on('close', function () { win = null })
win.loadURL(modalPath)
})
In your router, use the exactly path to your url
src/renderer/router.js example
{
path: '/showChart',
name: 'showChart',
component: require('your-router'),
},
If your need another approach, take a look at this repo:
it is work, thank you
Refs #207
Thanks for the help @marceloavf !
new BrowserWindow({
width: 400,
height: 320,
webPreferences: { webSecurity: false, nodeIntegration: true },
show: false,
});
In my case it worked after adding nodeIntegration: true to the BrowserWindow options.
First of all, you need to disable
mode: 'history'in your vue-router, check in vue-router docsThen do the following:
src/main/index.js example
ipc.on('showChart', function (e, data) { const modalPath = process.env.NODE_ENV === 'development' ? 'http://localhost:9080/#/showChart' : `file://${__dirname}/index.html#showChart` let win = new BrowserWindow({ width: 400, height: 320, webPreferences: {webSecurity: false} }) win.on('close', function () { win = null }) win.loadURL(modalPath) })In your router, use the exactly path to your url
src/renderer/router.js example{ path: '/showChart', name: 'showChart', component: require('your-router'), },If your need another approach, take a look at this repo:
_versions:_
chrome: "73.0.3683.121"
electron: "5.0.8"
node: "12.0.0"
v8: "7.3.492.27-electron.0"
@3zbumban My code like this
ipc.on('showChart', function (e, data) {
const modalPath = process.env.NODE_ENV === 'development'
? 'http://localhost:9080/#/showChart'
: `file://${__dirname}/index.html#showChart`
let win = new BrowserWindow({ width: 400, height: 320, webPreferences: {webSecurity: false} })
win.on('close', function () { win = null })
win.loadURL(modalPath)
})
After build it, new window is blank when open it in the main window
@hanjt
make sure that:
mode: 'history' (src/renderer/router/index.js)9080)process.env.NODE_ENV (try to log it to the console). you might be using the vue-cli-service to serve or build your app which desides based on the command wich NODE_ENV to use.you also might want to check out vue-cli-plugin-electron-builder in my opinion the simplest way to use vue inside electron.
Most helpful comment
First of all, you need to disable
mode: 'history'in your vue-router, check in vue-router docsThen do the following:
src/main/index.js example
In your router, use the exactly path to your url
src/renderer/router.js example
If your need another approach, take a look at this repo: