mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🐛 Can't switch workspaces on mobile https://github.com/siyuan-note/siyuan/issues/16544
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
444b38aa26
commit
00d00b54ef
6 changed files with 24 additions and 23 deletions
|
|
@ -280,20 +280,20 @@ export const kernelError = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const exitSiYuan = async () => {
|
export const exitSiYuan = async (setCurrentWorkspace = true) => {
|
||||||
hideAllElements(["util"]);
|
hideAllElements(["util"]);
|
||||||
/// #if MOBILE
|
/// #if MOBILE
|
||||||
if (window.siyuan.mobile.editor) {
|
if (window.siyuan.mobile.editor) {
|
||||||
await saveScroll(window.siyuan.mobile.editor.protyle);
|
await saveScroll(window.siyuan.mobile.editor.protyle);
|
||||||
}
|
}
|
||||||
/// #endif
|
/// #endif
|
||||||
fetchPost("/api/system/exit", {force: false}, (response) => {
|
fetchPost("/api/system/exit", {force: false, setCurrentWorkspace}, (response) => {
|
||||||
if (response.code === 1) { // 同步执行失败
|
if (response.code === 1) { // 同步执行失败
|
||||||
const msgId = showMessage(response.msg, response.data.closeTimeout, "error");
|
const msgId = showMessage(response.msg, response.data.closeTimeout, "error");
|
||||||
const buttonElement = document.querySelector(`#message [data-id="${msgId}"] button`);
|
const buttonElement = document.querySelector(`#message [data-id="${msgId}"] button`);
|
||||||
if (buttonElement) {
|
if (buttonElement) {
|
||||||
buttonElement.addEventListener("click", () => {
|
buttonElement.addEventListener("click", () => {
|
||||||
fetchPost("/api/system/exit", {force: true}, () => {
|
fetchPost("/api/system/exit", {force: true, setCurrentWorkspace}, () => {
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
ipcRenderer.send(Constants.SIYUAN_QUIT, location.port);
|
ipcRenderer.send(Constants.SIYUAN_QUIT, location.port);
|
||||||
/// #else
|
/// #else
|
||||||
|
|
@ -318,6 +318,7 @@ export const exitSiYuan = async () => {
|
||||||
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,
|
||||||
|
setCurrentWorkspace,
|
||||||
execInstallPkg: 2 // 0:默认检查新版本,1:不执行新版本安装,2:执行新版本安装
|
execInstallPkg: 2 // 0:默认检查新版本,1:不执行新版本安装,2:执行新版本安装
|
||||||
}, () => {
|
}, () => {
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
|
|
@ -335,6 +336,7 @@ export const exitSiYuan = async () => {
|
||||||
}, () => {
|
}, () => {
|
||||||
fetchPost("/api/system/exit", {
|
fetchPost("/api/system/exit", {
|
||||||
force: true,
|
force: true,
|
||||||
|
setCurrentWorkspace,
|
||||||
execInstallPkg: 1 // 0:默认检查新版本,1:不执行新版本安装,2:执行新版本安装
|
execInstallPkg: 1 // 0:默认检查新版本,1:不执行新版本安装,2:执行新版本安装
|
||||||
}, () => {
|
}, () => {
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,7 @@ import {getOpenNotebookCount, originalPath, pathPosix, useShell} from "../util/p
|
||||||
import {fetchNewDailyNote, mountHelp, newDailyNote} from "../util/mount";
|
import {fetchNewDailyNote, mountHelp, newDailyNote} from "../util/mount";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {
|
import {isInAndroid, isInHarmony, isInIOS, isIPad, setStorageVal, writeText} from "../protyle/util/compatibility";
|
||||||
isInAndroid,
|
|
||||||
isInHarmony,
|
|
||||||
isInIOS,
|
|
||||||
isIPad,
|
|
||||||
setStorageVal,
|
|
||||||
writeText
|
|
||||||
} from "../protyle/util/compatibility";
|
|
||||||
import {openCard} from "../card/openCard";
|
import {openCard} from "../card/openCard";
|
||||||
import {openSetting} from "../config";
|
import {openSetting} from "../config";
|
||||||
import {getAllDocks} from "../layout/getAll";
|
import {getAllDocks} from "../layout/getAll";
|
||||||
|
|
@ -287,7 +280,7 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
|
||||||
fetchPost("/api/system/setWorkspaceDir", {
|
fetchPost("/api/system/setWorkspaceDir", {
|
||||||
path: openPath
|
path: openPath
|
||||||
}, () => {
|
}, () => {
|
||||||
exitSiYuan();
|
exitSiYuan(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -317,7 +310,7 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
|
||||||
fetchPost("/api/system/setWorkspaceDir", {
|
fetchPost("/api/system/setWorkspaceDir", {
|
||||||
path: item.path
|
path: item.path
|
||||||
}, () => {
|
}, () => {
|
||||||
exitSiYuan();
|
exitSiYuan(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -358,7 +358,7 @@ export const initAbout = () => {
|
||||||
fetchPost("/api/system/setWorkspaceDir", {
|
fetchPost("/api/system/setWorkspaceDir", {
|
||||||
path: openPath
|
path: openPath
|
||||||
}, () => {
|
}, () => {
|
||||||
exitSiYuan();
|
exitSiYuan(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -412,7 +412,7 @@ export const initAbout = () => {
|
||||||
fetchPost("/api/system/setWorkspaceDir", {
|
fetchPost("/api/system/setWorkspaceDir", {
|
||||||
path: target.getAttribute("data-path")
|
path: target.getAttribute("data-path")
|
||||||
}, () => {
|
}, () => {
|
||||||
exitSiYuan();
|
exitSiYuan(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
|
||||||
|
|
@ -785,7 +785,13 @@ func exit(c *gin.Context) {
|
||||||
execInstallPkg = int(execInstallPkgArg.(float64))
|
execInstallPkg = int(execInstallPkgArg.(float64))
|
||||||
}
|
}
|
||||||
|
|
||||||
exitCode := model.Close(force, true, execInstallPkg)
|
setCurrentWorkspaceArg := arg["setCurrentWorkspace"]
|
||||||
|
setCurrentWorkspace := true
|
||||||
|
if nil != setCurrentWorkspaceArg {
|
||||||
|
setCurrentWorkspace = setCurrentWorkspaceArg.(bool)
|
||||||
|
}
|
||||||
|
|
||||||
|
exitCode := model.Close(force, setCurrentWorkspace, execInstallPkg)
|
||||||
ret.Code = exitCode
|
ret.Code = exitCode
|
||||||
switch exitCode {
|
switch exitCode {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
|
||||||
|
|
@ -333,13 +333,8 @@ func setWorkspaceDir(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if util.ContainerAndroid == util.Container || util.ContainerIOS == util.Container || util.ContainerHarmony == util.Container {
|
util.PushMsg(model.Conf.Language(42), 1000*15)
|
||||||
util.PushMsg(model.Conf.Language(42), 1000*15)
|
time.Sleep(1 * time.Second)
|
||||||
go func() {
|
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
model.Close(false, false, 1)
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func isInvalidWorkspacePath(absPath string) bool {
|
func isInvalidWorkspacePath(absPath string) bool {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"mime"
|
"mime"
|
||||||
|
|
@ -222,6 +223,10 @@ func Serve(fastMode bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = util.HttpServer.Serve(ln); err != nil {
|
if err = util.HttpServer.Serve(ln); err != nil {
|
||||||
|
if errors.Is(err, http.ErrServerClosed) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if !fastMode {
|
if !fastMode {
|
||||||
logging.LogErrorf("boot kernel failed: %s", err)
|
logging.LogErrorf("boot kernel failed: %s", err)
|
||||||
os.Exit(logging.ExitCodeUnavailablePort)
|
os.Exit(logging.ExitCodeUnavailablePort)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue