vue.jselectronelectron-vue

Electron-vue creating new window


I'm trying to create new window with following code:

createBotWindow() {
    const winUrl = process.env.NODE_ENV === 'development' ? `http://localhost:9080/bot` : `file://${__dirname}/index.html`;

    this.availableWindows[1] = new BrowserWindow({
        x: -8, //to be exacly x:0 in windows...
        y: 0,
        height: 500,
        width: 500,
        useContentSize: true,
        show: false
    });
    this.availableWindows[1].loadURL(winUrl);
    this.availableWindows[1].on('closed', () => {
        this.availableWindows[1] = null;
    });
},

in vue router I have

{
  path: '/bot',
  name: 'bot-page',
  component: require('@/components/BotPage').default
},

and in components directory I have BotPage.vue file:

<template>
    <h2>Hello World</h2>
</template>
<script>
    export default {}
</script>

In new window in console there are 2 errors:

Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-hY0Tz9CeWmB42Cjr7IVuwuBk5B6PQB2D/+LGDs8jrZY='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.

Failed to load resource: the server responded with a status of 404 (Not Found)

And it doesn't show Hello World in new window.

I'm doing something wrong?


Solution

  • I had to disabled mode: 'history' in vue router and load this url: http://localhost:9080/#/bot.