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) => {
|
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();
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
|
||||||
|
|
@ -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 !skipNewVerInstallPkg() && "" != newVerInstallPkgPath {
|
||||||
if newVerInstallPkgPath := getNewVerInstallPkgPath(); "" != newVerInstallPkgPath {
|
if 2 == execInstallPkg || (force && 0 == execInstallPkg) { // 执行新版本安装
|
||||||
if 2 == execInstallPkg || (force && 0 == execInstallPkg) { // 执行新版本安装
|
waitSecondForExecInstallPkg = true
|
||||||
waitSecondForExecInstallPkg = true
|
if gulu.OS.IsWindows() {
|
||||||
if gulu.OS.IsWindows() {
|
util.PushMsg(Conf.Language(130), 1000*30)
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)
|
newVerInstallPkgPath = filepath.Join(util.TempDir, "install", pkg)
|
||||||
localChecksum, _ := sha256Hash(ret)
|
localChecksum, _ := sha256Hash(newVerInstallPkgPath)
|
||||||
if checksum != localChecksum {
|
if checksum != localChecksum {
|
||||||
|
newVerInstallPkgPath = ""
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return ret
|
return newVerInstallPkgPath
|
||||||
}
|
}
|
||||||
|
|
||||||
var checkDownloadInstallPkgLock = sync.Mutex{}
|
var checkDownloadInstallPkgLock = sync.Mutex{}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue