Open Lothindir opened 4 years ago
Hi, @Lothindir ! Thanks for posting the issue.
It is expected behavior.
BrowserWindow::loadFile
don't set window.location
correctly.
If you want to implement reload
command, you can use BrowserWindow::loadURL
instead of BrowserWindow::loadFile
.
Hi, I want to start hot loading. How do I start it? I used this for the first time. @Lothindir
Hey @dengyushuai, do you want to use it for developpement or for production purposes ? If you want to hot reload while developping you can use smth like nodemon to watch your files for changes and then rebuild and restart your application. It's more complicated to implement a hot reload in your app. If you really want to be able to reload a page look at this answer. Hope this helps...
Hi, @Lothindir ! Thanks for posting the issue.
It is expected behavior.
BrowserWindow::loadFile
don't setwindow.location
correctly.If you want to implement
reload
command, you can useBrowserWindow::loadURL
instead ofBrowserWindow::loadFile
.See also: electron/electron#11895
Hi @Lothindir, The real reasons to see a blank page on reload are these:
baseUrl
or publicPath
in the current Vue CLI configuration is set to the default value /
,./
, it doesn't work well when the URL schema is file:
.hash mode
of Vue Router.When you reloading, current location of page have already changed to root directory by Vue Router.
You can add path conversion (/
-> path/to/dist/main-window.html
) to following code.
https://github.com/shellyln/vue-electron-typescript-quickstart/blob/e44daa30b22a65cbd7d3f355cefb12f64b584160/src.mainproc/main.ts#L44-L49
If you should use multiple entry points, try to change baseUrl
of Vue CLI config for each entry points.
https://cli.vuejs.org/config/#vue-config-js
Hi @dengyushuai,
If you want to do hot loading during development, you need to use lite-server etc.
Whether it's dev / prod, you need to use BrowserWindow::loadURL
, as @Lothindir says.
Thank you. Let me check again @Lothindir @shellyln
Hello, I found an issue where the window goes blank after doing a Reload or a Force Reload.
Reproduction steps :
npm run build:dev
andnpm run build:mainproc
npm run start
Ctrl+R
orCtrl+Shift+R
(or clicking on View->Reload or Force Reload)Result : The page goes blank, the html looks like this :
and the console outputs an error :
chromewebdata/:1 Not allowed to load local resource: file:///C:/
The only way to (temporary) resolve the problem is to close and re-open the app.