This commit is contained in:
yj 2024-07-23 15:56:27 +08:00
parent 5477d491f6
commit 8c4ce170b7
3 changed files with 15 additions and 3 deletions

13
main.js
View File

@ -17,15 +17,13 @@ class AppWindow extends BrowserWindow {
}, },
show: false, show: false,
frame: false, frame: false,
icon: '',
icon: '',
backgroundColor: '#00000000', backgroundColor: '#00000000',
transparent: true, transparent: true,
}; };
const finalConfig = { ...basicConfig, ...config }; const finalConfig = { ...basicConfig, ...config };
super(finalConfig); super(finalConfig);
const env = process.argv.find((arg) => arg.startsWith('--env='))?.split('=')[1]; const env = process.argv.find((arg) => arg.startsWith('--env='))?.split('=')[1];
if (env) { if (env === 'development') {
// 开发 // 开发
this.loadURL('http://localhost:3000'); this.loadURL('http://localhost:3000');
} else { } else {
@ -181,5 +179,14 @@ app.on('ready', () => {
const y = Math.round((display.workArea.height - mainWindow.getSize()[1]) / 2); const y = Math.round((display.workArea.height - mainWindow.getSize()[1]) / 2);
mainWindow.setPosition(x, y); 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')
});
}); });

View File

@ -20,5 +20,9 @@ window.electron = {
// 加入房间通知 // 加入房间通知
joinNotification: (user) => { joinNotification: (user) => {
ipcRenderer.invoke('joinNotification', user) ipcRenderer.invoke('joinNotification', user)
},
// 打开新页面
openNewPage: (url) => {
ipcRenderer.invoke('openNewPage', url)
} }
} }

1
src/render.d.ts vendored
View File

@ -4,6 +4,7 @@ export interface IElectronAPI {
setViewStatus: (status: 'quit' | 'maximize' | 'minimize' | 'unmaximize') => void; setViewStatus: (status: 'quit' | 'maximize' | 'minimize' | 'unmaximize') => void;
getIsMaximized: () => Promise<boolean>; getIsMaximized: () => Promise<boolean>;
setWriteText: (text: string) => void; setWriteText: (text: string) => void;
openNewPage: (url: string) => void;
joinNotification: (data: { name: string, body: string }) => void joinNotification: (data: { name: string, body: string }) => void
} }
declare global { declare global {