Przeglądaj źródła

:art: Improve checking for updates on exit https://github.com/siyuan-note/siyuan/issues/13608

Daniel 6 miesięcy temu
rodzic
commit
e24a462003

+ 11 - 0
app/electron/main.js

@@ -1007,6 +1007,17 @@ app.whenReady().then(() => {
     ipcMain.on("siyuan-quit", (event, port) => {
     ipcMain.on("siyuan-quit", (event, port) => {
         exitApp(port);
         exitApp(port);
     });
     });
+    ipcMain.on("siyuan-show-window", (event) => {
+        const mainWindow = getWindowByContentId(event.sender.id);
+        if (!mainWindow) {
+            return;
+        }
+
+        if (mainWindow.isMinimized()) {
+            mainWindow.restore();
+        }
+        mainWindow.show();
+    });
     ipcMain.on("siyuan-open-window", (event, data) => {
     ipcMain.on("siyuan-open-window", (event, data) => {
         const mainWindow = BrowserWindow.getFocusedWindow() || BrowserWindow.getAllWindows()[0];
         const mainWindow = BrowserWindow.getFocusedWindow() || BrowserWindow.getAllWindows()[0];
         const mainBounds = mainWindow.getBounds();
         const mainBounds = mainWindow.getBounds();

+ 2 - 0
app/src/constants.ts

@@ -57,6 +57,8 @@ export abstract class Constants {
 
 
     public static readonly SIYUAN_CONTEXT_MENU: string = "siyuan-context-menu";
     public static readonly SIYUAN_CONTEXT_MENU: string = "siyuan-context-menu";
 
 
+    public static readonly SIYUAN_SHOW_WINDOW: string = "siyuan-show-window";
+
     // custom
     // custom
     public static readonly CUSTOM_SY_READONLY: string = "custom-sy-readonly";
     public static readonly CUSTOM_SY_READONLY: string = "custom-sy-readonly";
     public static readonly CUSTOM_SY_FULLWIDTH: string = "custom-sy-fullwidth";
     public static readonly CUSTOM_SY_FULLWIDTH: string = "custom-sy-fullwidth";

+ 5 - 0
app/src/dialog/processSystem.ts

@@ -310,6 +310,11 @@ export const exitSiYuan = async () => {
             }
             }
         } else if (response.code === 2) { // 提示新安装包
         } else if (response.code === 2) { // 提示新安装包
             hideMessage();
             hideMessage();
+
+            if ("std" === window.siyuan.config.system.container) {
+                ipcRenderer.send(Constants.SIYUAN_SHOW_WINDOW);
+            }
+
             confirmDialog(window.siyuan.languages.tip, response.msg, () => {
             confirmDialog(window.siyuan.languages.tip, response.msg, () => {
                 fetchPost("/api/system/exit", {
                 fetchPost("/api/system/exit", {
                     force: true,
                     force: true,

+ 10 - 12
kernel/model/conf.go

@@ -629,19 +629,17 @@ func Close(force, setCurrentWorkspace bool, execInstallPkg int) (exitCode int) {
 
 
 	util.IsExiting.Store(true)
 	util.IsExiting.Store(true)
 	waitSecondForExecInstallPkg := false
 	waitSecondForExecInstallPkg := false
-	if !skipNewVerInstallPkg() {
-		if newVerInstallPkgPath := getNewVerInstallPkgPath(); "" != newVerInstallPkgPath {
-			if 2 == execInstallPkg || (force && 0 == execInstallPkg) { // 执行新版本安装
-				waitSecondForExecInstallPkg = true
-				if gulu.OS.IsWindows() {
-					util.PushMsg(Conf.Language(130), 1000*30)
-				}
-				go execNewVerInstallPkg(newVerInstallPkgPath)
-			} else if 0 == execInstallPkg { // 新版本安装包已经准备就绪
-				exitCode = 2
-				logging.LogInfof("the new version install pkg is ready [%s], waiting for the user's next instruction", newVerInstallPkgPath)
-				return
+	if !skipNewVerInstallPkg() && "" != newVerInstallPkgPath {
+		if 2 == execInstallPkg || (force && 0 == execInstallPkg) { // 执行新版本安装
+			waitSecondForExecInstallPkg = true
+			if gulu.OS.IsWindows() {
+				util.PushMsg(Conf.Language(130), 1000*30)
 			}
 			}
+			go execNewVerInstallPkg(newVerInstallPkgPath)
+		} else if 0 == execInstallPkg { // 新版本安装包已经准备就绪
+			exitCode = 2
+			logging.LogInfof("the new version install pkg is ready [%s], waiting for the user's next instruction", newVerInstallPkgPath)
+			return
 		}
 		}
 	}
 	}
 
 

+ 8 - 3
kernel/model/updater.go

@@ -54,23 +54,28 @@ func execNewVerInstallPkg(newVerInstallPkgPath string) {
 	}
 	}
 }
 }
 
 
+var newVerInstallPkgPath string
+
 func getNewVerInstallPkgPath() string {
 func getNewVerInstallPkgPath() string {
 	if skipNewVerInstallPkg() {
 	if skipNewVerInstallPkg() {
+		newVerInstallPkgPath = ""
 		return ""
 		return ""
 	}
 	}
 
 
 	downloadPkgURLs, checksum, err := getUpdatePkg()
 	downloadPkgURLs, checksum, err := getUpdatePkg()
 	if err != nil || 1 > len(downloadPkgURLs) || "" == checksum {
 	if err != nil || 1 > len(downloadPkgURLs) || "" == checksum {
+		newVerInstallPkgPath = ""
 		return ""
 		return ""
 	}
 	}
 
 
 	pkg := path.Base(downloadPkgURLs[0])
 	pkg := path.Base(downloadPkgURLs[0])
-	ret := filepath.Join(util.TempDir, "install", pkg)
-	localChecksum, _ := sha256Hash(ret)
+	newVerInstallPkgPath = filepath.Join(util.TempDir, "install", pkg)
+	localChecksum, _ := sha256Hash(newVerInstallPkgPath)
 	if checksum != localChecksum {
 	if checksum != localChecksum {
+		newVerInstallPkgPath = ""
 		return ""
 		return ""
 	}
 	}
-	return ret
+	return newVerInstallPkgPath
 }
 }
 
 
 var checkDownloadInstallPkgLock = sync.Mutex{}
 var checkDownloadInstallPkgLock = sync.Mutex{}