ArcherGu / fast-vite-nestjs-electron

Vite + Vue + Electron + Nestjs with esbuild, crazy fast! ⚡

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to load page after app packed

aiocn opened this issue · comments

commented

dear ArcherGu @ArcherGu
if the app starts with more than one window, how to set loadUrl's params?
e.g
window A
const URL = isDev ? process.env.DS_RENDERER_URL :file://${join(app.getAppPath(), 'dist/render/index.html)}

windowB
const URL = isDev ?${process.env.DS_RENDERER_URL}/#/windowB:file://${join(app.getAppPath(), 'dist/render/index.html/ ? ')}
wrong method:
file://${join(app.getAppPath(), 'dist/render/index.html/#/windowB')}

thanks!

commented

同时启动两个窗口,主窗口按模板自带的正常运行, 另一个窗口该怎么设置打包之后的URL?
file://${join(app.getAppPath(), 'dist/render/index.html/ 这个该怎么写?用的是vue3
开发环境直接 ${process.env.DS_RENDERER_URL}/#/windowB,可以访问,打包之后该 怎么办?

这个问题其实用 electron 的 api 就能解决了:

if (isDev) {
  win.loadURL(`${process.env.DS_RENDERER_URL}/#/other`)
}
else {
  // 注意:这里是使用 loadFile, 直接用路径就行,不需要带文件协议
  win.loadFile('dist/render/index.html', {
    hash: '/other',
  })
}
commented

谢谢大佬,新年快乐!

commented

thanks for your reply! Best Wishes!