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,
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')
});
});

View File

@ -20,5 +20,9 @@ window.electron = {
// 加入房间通知
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;
getIsMaximized: () => Promise<boolean>;
setWriteText: (text: string) => void;
openNewPage: (url: string) => void;
joinNotification: (data: { name: string, body: string }) => void
}
declare global {