mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🐛 The tray is generated repeatedly after the new window is locked and then entered https://github.com/siyuan-note/siyuan/issues/15357
This commit is contained in:
parent
262957d4de
commit
917a5125af
1 changed files with 23 additions and 14 deletions
|
|
@ -678,6 +678,10 @@ for (let i = argStart; i < process.argv.length; i++) {
|
|||
|
||||
app.whenReady().then(() => {
|
||||
const resetTrayMenu = (tray, lang, mainWindow) => {
|
||||
if (!mainWindow || mainWindow.isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const trayMenuTemplate = [{
|
||||
label: mainWindow.isVisible() ? lang.hideWindow : lang.showWindow, click: () => {
|
||||
showHideWindow(tray, lang, mainWindow);
|
||||
|
|
@ -726,6 +730,10 @@ app.whenReady().then(() => {
|
|||
}
|
||||
};
|
||||
const showHideWindow = (tray, lang, mainWindow) => {
|
||||
if (!mainWindow || mainWindow.isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mainWindow.isVisible()) {
|
||||
if (mainWindow.isMinimized()) {
|
||||
mainWindow.restore();
|
||||
|
|
@ -1113,23 +1121,24 @@ app.whenReady().then(() => {
|
|||
if (exitWS) {
|
||||
return;
|
||||
}
|
||||
let tray;
|
||||
if ("win32" === process.platform || "linux" === process.platform) {
|
||||
// 系统托盘
|
||||
tray = new Tray(path.join(appDir, "stage", "icon-large.png"));
|
||||
tray.setToolTip(`${path.basename(data.workspaceDir)} - SiYuan v${appVer}`);
|
||||
const mainWindow = getWindowByContentId(event.sender.id);
|
||||
if (!mainWindow) {
|
||||
return;
|
||||
}
|
||||
resetTrayMenu(tray, data.languages, mainWindow);
|
||||
tray.on("click", () => {
|
||||
showHideWindow(tray, data.languages, mainWindow);
|
||||
});
|
||||
}
|
||||
|
||||
workspaces.find(item => {
|
||||
if (!item.workspaceDir) {
|
||||
item.workspaceDir = data.workspaceDir;
|
||||
let tray;
|
||||
if ("win32" === process.platform || "linux" === process.platform) {
|
||||
// 系统托盘
|
||||
tray = new Tray(path.join(appDir, "stage", "icon-large.png"));
|
||||
tray.setToolTip(`${path.basename(data.workspaceDir)} - SiYuan v${appVer}`);
|
||||
const mainWindow = getWindowByContentId(event.sender.id);
|
||||
if (!mainWindow || mainWindow.isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
resetTrayMenu(tray, data.languages, mainWindow);
|
||||
tray.on("click", () => {
|
||||
showHideWindow(tray, data.languages, mainWindow);
|
||||
});
|
||||
}
|
||||
item.tray = tray;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue