🐛 Can't switch workspaces on mobile app Fix https://github.com/siyuan-note/siyuan/issues/10654

This commit is contained in:
Daniel 2024-03-19 23:11:44 +08:00
parent 71a7a71b3a
commit b72b832007
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017
4 changed files with 18 additions and 14 deletions

View File

@ -490,7 +490,7 @@ func exit(c *gin.Context) {
execInstallPkg = int(execInstallPkgArg.(float64)) execInstallPkg = int(execInstallPkgArg.(float64))
} }
exitCode := model.Close(force, execInstallPkg) exitCode := model.Close(force, true, execInstallPkg)
ret.Code = exitCode ret.Code = exitCode
switch exitCode { switch exitCode {
case 0: case 0:

View File

@ -312,7 +312,7 @@ func setWorkspaceDir(c *gin.Context) {
if util.ContainerAndroid == util.Container || util.ContainerIOS == util.Container { if util.ContainerAndroid == util.Container || util.ContainerIOS == util.Container {
util.PushMsg(model.Conf.Language(42), 1000*15) util.PushMsg(model.Conf.Language(42), 1000*15)
time.Sleep(time.Second * 2) time.Sleep(time.Second * 2)
model.Close(false, 1) model.Close(false, false, 1)
} }
} }

View File

@ -527,6 +527,8 @@ var exitLock = sync.Mutex{}
// //
// force是否不执行同步过程而直接退出 // force是否不执行同步过程而直接退出
// //
// setCurrentWorkspace是否将当前工作空间放到工作空间列表的最后一个
//
// execInstallPkg是否执行新版本安装包 // execInstallPkg是否执行新版本安装包
// //
// 0默认按照设置项 System.DownloadInstallPkg 检查并推送提示 // 0默认按照设置项 System.DownloadInstallPkg 检查并推送提示
@ -540,7 +542,7 @@ var exitLock = sync.Mutex{}
// 2提示新安装包 // 2提示新安装包
// //
// 当 force 为 true强制退出并且 execInstallPkg 为 0默认检查更新并且同步失败并且新版本安装版已经准备就绪时执行新版本安装 https://github.com/siyuan-note/siyuan/issues/10288 // 当 force 为 true强制退出并且 execInstallPkg 为 0默认检查更新并且同步失败并且新版本安装版已经准备就绪时执行新版本安装 https://github.com/siyuan-note/siyuan/issues/10288
func Close(force bool, execInstallPkg int) (exitCode int) { func Close(force, setCurrentWorkspace bool, execInstallPkg int) (exitCode int) {
exitLock.Lock() exitLock.Lock()
defer exitLock.Unlock() defer exitLock.Unlock()
@ -588,6 +590,7 @@ func Close(force bool, execInstallPkg int) (exitCode int) {
clearCorruptedNotebooks() clearCorruptedNotebooks()
clearPortJSON() clearPortJSON()
if setCurrentWorkspace {
// 将当前工作空间放到工作空间列表的最后一个 // 将当前工作空间放到工作空间列表的最后一个
// Open the last workspace by default https://github.com/siyuan-note/siyuan/issues/10570 // Open the last workspace by default https://github.com/siyuan-note/siyuan/issues/10570
workspacePaths, err := util.ReadWorkspacePaths() workspacePaths, err := util.ReadWorkspacePaths()
@ -598,6 +601,7 @@ func Close(force bool, execInstallPkg int) (exitCode int) {
workspacePaths = append(workspacePaths, util.WorkspaceDir) workspacePaths = append(workspacePaths, util.WorkspaceDir)
util.WriteWorkspacePaths(workspacePaths) util.WriteWorkspacePaths(workspacePaths)
} }
}
util.UnlockWorkspace() util.UnlockWorkspace()

View File

@ -34,7 +34,7 @@ func HandleSignal() {
signal.Notify(c, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM) signal.Notify(c, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM)
s := <-c s := <-c
logging.LogInfof("received os signal [%s], exit kernel process now", s) logging.LogInfof("received os signal [%s], exit kernel process now", s)
Close(false, 1) Close(false, true, 1)
} }
var ( var (
@ -78,7 +78,7 @@ func HookDesktopUIProcJob() {
} }
logging.LogWarnf("confirmed no active UI proc, exit kernel process now") logging.LogWarnf("confirmed no active UI proc, exit kernel process now")
Close(false, 1) Close(false, true, 1)
} }
var uiProcNames = []string{"siyuan", "electron"} var uiProcNames = []string{"siyuan", "electron"}