mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Improve checking for updates on exit https://github.com/siyuan-note/siyuan/issues/13608
This commit is contained in:
parent
746226054a
commit
e24a462003
5 changed files with 36 additions and 15 deletions
|
|
@ -1007,6 +1007,17 @@ app.whenReady().then(() => {
|
|||
ipcMain.on("siyuan-quit", (event, 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) => {
|
||||
const mainWindow = BrowserWindow.getFocusedWindow() || BrowserWindow.getAllWindows()[0];
|
||||
const mainBounds = mainWindow.getBounds();
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ export abstract class Constants {
|
|||
|
||||
public static readonly SIYUAN_CONTEXT_MENU: string = "siyuan-context-menu";
|
||||
|
||||
public static readonly SIYUAN_SHOW_WINDOW: string = "siyuan-show-window";
|
||||
|
||||
// custom
|
||||
public static readonly CUSTOM_SY_READONLY: string = "custom-sy-readonly";
|
||||
public static readonly CUSTOM_SY_FULLWIDTH: string = "custom-sy-fullwidth";
|
||||
|
|
|
|||
|
|
@ -310,6 +310,11 @@ export const exitSiYuan = async () => {
|
|||
}
|
||||
} else if (response.code === 2) { // 提示新安装包
|
||||
hideMessage();
|
||||
|
||||
if ("std" === window.siyuan.config.system.container) {
|
||||
ipcRenderer.send(Constants.SIYUAN_SHOW_WINDOW);
|
||||
}
|
||||
|
||||
confirmDialog(window.siyuan.languages.tip, response.msg, () => {
|
||||
fetchPost("/api/system/exit", {
|
||||
force: true,
|
||||
|
|
|
|||
|
|
@ -629,8 +629,7 @@ func Close(force, setCurrentWorkspace bool, execInstallPkg int) (exitCode int) {
|
|||
|
||||
util.IsExiting.Store(true)
|
||||
waitSecondForExecInstallPkg := false
|
||||
if !skipNewVerInstallPkg() {
|
||||
if newVerInstallPkgPath := getNewVerInstallPkgPath(); "" != newVerInstallPkgPath {
|
||||
if !skipNewVerInstallPkg() && "" != newVerInstallPkgPath {
|
||||
if 2 == execInstallPkg || (force && 0 == execInstallPkg) { // 执行新版本安装
|
||||
waitSecondForExecInstallPkg = true
|
||||
if gulu.OS.IsWindows() {
|
||||
|
|
@ -643,7 +642,6 @@ func Close(force, setCurrentWorkspace bool, execInstallPkg int) (exitCode int) {
|
|||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Conf.Close()
|
||||
sql.CloseDatabase()
|
||||
|
|
|
|||
|
|
@ -54,23 +54,28 @@ func execNewVerInstallPkg(newVerInstallPkgPath string) {
|
|||
}
|
||||
}
|
||||
|
||||
var newVerInstallPkgPath string
|
||||
|
||||
func getNewVerInstallPkgPath() string {
|
||||
if skipNewVerInstallPkg() {
|
||||
newVerInstallPkgPath = ""
|
||||
return ""
|
||||
}
|
||||
|
||||
downloadPkgURLs, checksum, err := getUpdatePkg()
|
||||
if err != nil || 1 > len(downloadPkgURLs) || "" == checksum {
|
||||
newVerInstallPkgPath = ""
|
||||
return ""
|
||||
}
|
||||
|
||||
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 {
|
||||
newVerInstallPkgPath = ""
|
||||
return ""
|
||||
}
|
||||
return ret
|
||||
return newVerInstallPkgPath
|
||||
}
|
||||
|
||||
var checkDownloadInstallPkgLock = sync.Mutex{}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue