This commit is contained in:
Daniel 2024-12-25 21:59:10 +08:00
parent 746226054a
commit e24a462003
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
5 changed files with 36 additions and 15 deletions

View file

@ -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();

View file

@ -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";

View file

@ -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,

View file

@ -629,8 +629,7 @@ 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() {
@ -643,7 +642,6 @@ func Close(force, setCurrentWorkspace bool, execInstallPkg int) (exitCode int) {
return return
} }
} }
}
Conf.Close() Conf.Close()
sql.CloseDatabase() sql.CloseDatabase()

View file

@ -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{}