diff --git a/main.js b/main.js index b8d0d61..dc5d2b0 100644 --- a/main.js +++ b/main.js @@ -17,15 +17,13 @@ class AppWindow extends BrowserWindow { }, show: false, frame: false, - icon: '', - icon: '', backgroundColor: '#00000000', transparent: true, }; const finalConfig = { ...basicConfig, ...config }; super(finalConfig); const env = process.argv.find((arg) => arg.startsWith('--env='))?.split('=')[1]; - if (env) { + if (env === 'development') { // 开发 this.loadURL('http://localhost:3000'); } else { @@ -181,5 +179,14 @@ app.on('ready', () => { const y = Math.round((display.workArea.height - mainWindow.getSize()[1]) / 2); mainWindow.setPosition(x, y); }); + + // 打开新页面 + ipcMain.handle('openNewPage', (event, url) => { + const env = process.argv.find((arg) => arg.startsWith('--env='))?.split('=')[1]; + const winURL = env === 'development' + ? `http://localhost:3000` + : path.resolve(__dirname, './dist/index.html') + }); + }); diff --git a/preload.js b/preload.js index 9622aec..5cd0e57 100644 --- a/preload.js +++ b/preload.js @@ -20,5 +20,9 @@ window.electron = { // 加入房间通知 joinNotification: (user) => { ipcRenderer.invoke('joinNotification', user) + }, + // 打开新页面 + openNewPage: (url) => { + ipcRenderer.invoke('openNewPage', url) } } \ No newline at end of file diff --git a/src/render.d.ts b/src/render.d.ts index 49c45ae..5b7ada1 100644 --- a/src/render.d.ts +++ b/src/render.d.ts @@ -4,6 +4,7 @@ export interface IElectronAPI { setViewStatus: (status: 'quit' | 'maximize' | 'minimize' | 'unmaximize') => void; getIsMaximized: () => Promise; setWriteText: (text: string) => void; + openNewPage: (url: string) => void; joinNotification: (data: { name: string, body: string }) => void } declare global {