🎨 The desktop initialization interface workspace defaults to ~/SiYuan/ Fix https://github.com/siyuan-note/siyuan/issues/8879

This commit is contained in:
Daniel 2023-08-01 22:08:23 +08:00
parent 7e1d5c0a26
commit 16cdc66398
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017

View File

@ -349,8 +349,13 @@
item.addEventListener('click', () => {
const {dialog} = require('@electron/remote')
const path = require('path')
const fs = require('fs')
const defaultWorkspace = path.join(decodeURIComponent(getSearch('home')), "SiYuan")
if (!fs.existsSync(defaultWorkspace)) {
fs.mkdirSync(defaultWorkspace, {mode: 0o755, recursive: true})
}
dialog.showOpenDialog({
defaultPath: decodeURIComponent(getSearch('home')),
defaultPath: defaultWorkspace,
properties: ['openDirectory', 'createDirectory'],
}).then((result) => {
if (result.canceled) {
@ -358,8 +363,11 @@
}
const {ipcRenderer} = require('electron')
const fs = require('fs')
const initPath = result.filePaths[0]
if (defaultWorkspace !== initPath) {
fs.rmdirSync(defaultWorkspace, {recursive: true})
}
if (isICloudPath(initPath)) {
let msg = '⚠️ This folder is under the iCloud sync path, please change another path'
if (isChinese(currentLang)) {