This commit is contained in:
parent
0776b93130
commit
78c1dd5026
17
main.js
17
main.js
|
|
@ -57,14 +57,17 @@ function showWindow() {
|
||||||
// 如果主窗口已经存在但被最小化了,则恢复显示
|
// 如果主窗口已经存在但被最小化了,则恢复显示
|
||||||
if (mainWindow && mainWindow.isMinimized()) {
|
if (mainWindow && mainWindow.isMinimized()) {
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
|
console.log(3);
|
||||||
}
|
}
|
||||||
// 如果主窗口已存在但不是焦点窗口,则将其置为焦点
|
// 如果主窗口已存在但不是焦点窗口,则将其置为焦点
|
||||||
if (mainWindow && !mainWindow.isFocused()) {
|
if (mainWindow && !mainWindow.isFocused()) {
|
||||||
|
console.log(2);
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
mainWindow.focus();
|
mainWindow.focus();
|
||||||
}
|
}
|
||||||
// 如果主窗口还没有被创建,则创建它
|
// 如果主窗口还没有被创建,则创建它
|
||||||
if (!mainWindow) {
|
if (!mainWindow) {
|
||||||
|
console.log(1);
|
||||||
createWindow();
|
createWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -80,7 +83,7 @@ function createTray() {
|
||||||
const contextMenu = Menu.buildFromTemplate([
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
{
|
{
|
||||||
label: '打开', click: () => {
|
label: '打开', click: () => {
|
||||||
showWindow()
|
mainWindow.webContents.send('isOpenWindows');
|
||||||
},
|
},
|
||||||
// icon: iconPath,
|
// icon: iconPath,
|
||||||
},
|
},
|
||||||
|
|
@ -108,11 +111,7 @@ function createTray() {
|
||||||
tray.setToolTip('智汇享');
|
tray.setToolTip('智汇享');
|
||||||
tray.setContextMenu(contextMenu);
|
tray.setContextMenu(contextMenu);
|
||||||
tray.on('click', () => {
|
tray.on('click', () => {
|
||||||
if (mainWindow.isVisible()) {
|
mainWindow.webContents.send('isOpenWindows');
|
||||||
mainWindow.hide()
|
|
||||||
} else {
|
|
||||||
mainWindow.show()
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -191,6 +190,7 @@ app.on('ready', () => {
|
||||||
break;
|
break;
|
||||||
case 'show':
|
case 'show':
|
||||||
mainWindow.show()
|
mainWindow.show()
|
||||||
|
mainWindow.focus();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -202,6 +202,10 @@ app.on('ready', () => {
|
||||||
ipcMain.handle('getVersion', () => {
|
ipcMain.handle('getVersion', () => {
|
||||||
return app.getVersion();
|
return app.getVersion();
|
||||||
});
|
});
|
||||||
|
// 获取窗口是否显示
|
||||||
|
ipcMain.handle('isVisible', () => {
|
||||||
|
return mainWindow.isVisible();
|
||||||
|
});
|
||||||
// 获取共享屏幕列表
|
// 获取共享屏幕列表
|
||||||
ipcMain.handle('getSources', async () => {
|
ipcMain.handle('getSources', async () => {
|
||||||
return await desktopCapturer.getSources({
|
return await desktopCapturer.getSources({
|
||||||
|
|
@ -327,6 +331,7 @@ app.on('ready', () => {
|
||||||
child.once('ready-to-show', () => {
|
child.once('ready-to-show', () => {
|
||||||
childWindow[config.key].show()
|
childWindow[config.key].show()
|
||||||
childWindow[config.key].setAlwaysOnTop(true, 'pop-up-menu')
|
childWindow[config.key].setAlwaysOnTop(true, 'pop-up-menu')
|
||||||
|
childWindow[config.key].setSkipTaskbar(true)
|
||||||
windowOperation(config)
|
windowOperation(config)
|
||||||
})
|
})
|
||||||
child.webContents.on('before-input-event', (event, input) => {
|
child.webContents.on('before-input-event', (event, input) => {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,10 @@ window.electron = {
|
||||||
getVersion: () => {
|
getVersion: () => {
|
||||||
return ipcRenderer.invoke('getVersion')
|
return ipcRenderer.invoke('getVersion')
|
||||||
},
|
},
|
||||||
|
// 获取窗口是否显示
|
||||||
|
isVisible: () => {
|
||||||
|
return ipcRenderer.invoke('isVisible')
|
||||||
|
},
|
||||||
// 获取共享屏幕列表
|
// 获取共享屏幕列表
|
||||||
getSources: () => {
|
getSources: () => {
|
||||||
return ipcRenderer.invoke('getSources')
|
return ipcRenderer.invoke('getSources')
|
||||||
|
|
@ -49,6 +53,10 @@ window.electron = {
|
||||||
quitAndInstall: (callback) => {
|
quitAndInstall: (callback) => {
|
||||||
ipcRenderer.on('quitAndInstall', callback)
|
ipcRenderer.on('quitAndInstall', callback)
|
||||||
},
|
},
|
||||||
|
// 点击任务栏图标是否打开窗口
|
||||||
|
isOpenWindows: (callback) => {
|
||||||
|
ipcRenderer.on('isOpenWindows', callback)
|
||||||
|
},
|
||||||
// 通知下载最新的包
|
// 通知下载最新的包
|
||||||
onDownload: (type) => {
|
onDownload: (type) => {
|
||||||
ipcRenderer.invoke('updateDownload', type)
|
ipcRenderer.invoke('updateDownload', type)
|
||||||
|
|
|
||||||
12
src/App.tsx
12
src/App.tsx
|
|
@ -24,6 +24,7 @@ import ChatSmallWindow from "@/page/Meeting/ChatSmallWindow";
|
||||||
import ChatBigWindow from "@/page/Meeting/ChatBigWindow";
|
import ChatBigWindow from "@/page/Meeting/ChatBigWindow";
|
||||||
import CurrentSpeakUserWindow from "@/page/Meeting/CurrentSpeakUserWindow";
|
import CurrentSpeakUserWindow from "@/page/Meeting/CurrentSpeakUserWindow";
|
||||||
import NoticeWindow from "@/page/Meeting/NoticeWindow";
|
import NoticeWindow from "@/page/Meeting/NoticeWindow";
|
||||||
|
import { getKeyOpenChildWindow } from "./utils/package/public";
|
||||||
const fs = require('fs').promises;
|
const fs = require('fs').promises;
|
||||||
const { exec } = require('child_process');
|
const { exec } = require('child_process');
|
||||||
const App: React.FC = () => {
|
const App: React.FC = () => {
|
||||||
|
|
@ -105,6 +106,17 @@ const App: React.FC = () => {
|
||||||
window.electron.quitAndInstall(async (_e: any) => {
|
window.electron.quitAndInstall(async (_e: any) => {
|
||||||
storage.setItem('quitMeeting', true)
|
storage.setItem('quitMeeting', true)
|
||||||
})
|
})
|
||||||
|
window.electron.isOpenWindows(async (_e: any) => {
|
||||||
|
let bool = await window.electron.isVisible()
|
||||||
|
if (location.hash.indexOf('/meeting') === -1) {
|
||||||
|
window.electron.setViewStatus(bool ? 'hide' : 'show')
|
||||||
|
} else {
|
||||||
|
let shareScreenWindow = await getKeyOpenChildWindow('shareScreenWindow')
|
||||||
|
if (!shareScreenWindow) {
|
||||||
|
window.electron.setViewStatus(bool ? 'hide' : 'show')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}, [])
|
}, [])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.electron.onUpdate((_e: any, data: any) => {
|
window.electron.onUpdate((_e: any, data: any) => {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,9 @@ export interface IElectronAPI {
|
||||||
quit: (bool) => any;
|
quit: (bool) => any;
|
||||||
downFile: (callBack: Function) => void;
|
downFile: (callBack: Function) => void;
|
||||||
quitAndInstall: (callBack: Function) => void;
|
quitAndInstall: (callBack: Function) => void;
|
||||||
|
isOpenWindows: (callBack: Function) => void;
|
||||||
getVersion: () => Promise<string>;
|
getVersion: () => Promise<string>;
|
||||||
|
isVisible: () => Promise<string>;
|
||||||
setRegistry: (uuid: string) => any;
|
setRegistry: (uuid: string) => any;
|
||||||
getRegistry: () => any;
|
getRegistry: () => any;
|
||||||
createChildWindow: (config: any) => void;
|
createChildWindow: (config: any) => void;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue