mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-16 17:10:53 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
b57e6cb47d
@ -52,10 +52,8 @@ try {
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
require('electron').
|
||||
dialog.
|
||||
showErrorBox('创建配置目录失败 Failed to create config directory',
|
||||
'思源需要在用户家目录下创建配置文件夹(~/.config/siyuan),请确保该路径具有写入权限。\n\nSiYuan needs to create a configuration folder (~/.config/siyuan) in the user\'s home directory. Please make sure that the path has write permissions.')
|
||||
require('electron').dialog.showErrorBox('创建配置目录失败 Failed to create config directory',
|
||||
'思源需要在用户家目录下创建配置文件夹(~/.config/siyuan),请确保该路径具有写入权限。\n\nSiYuan needs to create a configuration folder (~/.config/siyuan) in the user\'s home directory. Please make sure that the path has write permissions.')
|
||||
app.exit()
|
||||
}
|
||||
|
||||
@ -901,12 +899,17 @@ app.on('second-instance', (event, argv) => {
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const siyuanURL = argv.find((arg) => arg.startsWith('siyuan://'))
|
||||
workspaces.forEach(item => {
|
||||
if (item.browserWindow && !item.browserWindow.isDestroyed() && siyuanURL) {
|
||||
item.browserWindow.webContents.send('siyuan-openurl', siyuanURL)
|
||||
}
|
||||
})
|
||||
|
||||
if (!siyuanURL && 0 < workspaces.length) {
|
||||
showWindow(workspaces[0].browserWindow)
|
||||
}
|
||||
})
|
||||
|
||||
app.on('activate', () => {
|
||||
|
@ -212,36 +212,26 @@ func initWorkspaceDir(workspaceArg string) {
|
||||
if "" != workspaceArg {
|
||||
WorkspaceDir = workspaceArg
|
||||
}
|
||||
if !gulu.File.IsDir(WorkspaceDir) {
|
||||
log.Printf("use the default workspace [%s] since the specified workspace [%s] is not a dir", defaultWorkspaceDir, WorkspaceDir)
|
||||
WorkspaceDir = defaultWorkspaceDir
|
||||
}
|
||||
workspacePaths = append(workspacePaths, WorkspaceDir)
|
||||
} else {
|
||||
workspacePaths, _ = ReadWorkspacePaths()
|
||||
if 0 < len(workspacePaths) {
|
||||
// 取最后一个(也就是最近打开的)工作空间
|
||||
WorkspaceDir = workspacePaths[len(workspacePaths)-1]
|
||||
if "" != workspaceArg {
|
||||
WorkspaceDir = workspaceArg
|
||||
}
|
||||
if !gulu.File.IsDir(WorkspaceDir) {
|
||||
log.Printf("use the default workspace [%s] since the specified workspace [%s] is not a dir", WorkspaceDir, defaultWorkspaceDir)
|
||||
WorkspaceDir = defaultWorkspaceDir
|
||||
}
|
||||
workspacePaths[len(workspacePaths)-1] = WorkspaceDir
|
||||
} else {
|
||||
WorkspaceDir = defaultWorkspaceDir
|
||||
if "" != workspaceArg {
|
||||
WorkspaceDir = workspaceArg
|
||||
}
|
||||
if !gulu.File.IsDir(WorkspaceDir) {
|
||||
log.Printf("use the default workspace [%s] since the specified workspace [%s] is not a dir", WorkspaceDir, defaultWorkspaceDir)
|
||||
WorkspaceDir = defaultWorkspaceDir
|
||||
}
|
||||
workspacePaths = append(workspacePaths, WorkspaceDir)
|
||||
}
|
||||
|
||||
if "" != workspaceArg {
|
||||
WorkspaceDir = workspaceArg
|
||||
}
|
||||
}
|
||||
|
||||
if !gulu.File.IsDir(WorkspaceDir) {
|
||||
log.Printf("use the default workspace [%s] since the specified workspace [%s] is not a dir", WorkspaceDir, defaultWorkspaceDir)
|
||||
WorkspaceDir = defaultWorkspaceDir
|
||||
}
|
||||
workspacePaths = append(workspacePaths, WorkspaceDir)
|
||||
|
||||
if err := WriteWorkspacePaths(workspacePaths); nil != err {
|
||||
log.Fatalf("write workspace conf [%s] failed: %s", workspaceConf, err)
|
||||
}
|
||||
@ -284,8 +274,6 @@ func ReadWorkspacePaths() (ret []string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
ret = gulu.Str.RemoveDuplicatedElem(ret)
|
||||
|
||||
var tmp []string
|
||||
for _, d := range ret {
|
||||
d = strings.TrimRight(d, " \t\n") // 去掉工作空间路径尾部空格 https://github.com/siyuan-note/siyuan/issues/6353
|
||||
@ -294,6 +282,7 @@ func ReadWorkspacePaths() (ret []string, err error) {
|
||||
}
|
||||
}
|
||||
ret = tmp
|
||||
ret = gulu.Str.RemoveDuplicatedElem(ret)
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user