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