This commit is contained in:
parent
5477d491f6
commit
8c4ce170b7
13
main.js
13
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')
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -20,5 +20,9 @@ window.electron = {
|
|||
// 加入房间通知
|
||||
joinNotification: (user) => {
|
||||
ipcRenderer.invoke('joinNotification', user)
|
||||
},
|
||||
// 打开新页面
|
||||
openNewPage: (url) => {
|
||||
ipcRenderer.invoke('openNewPage', url)
|
||||
}
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue