From 16cdc663987f12d0042d895e7bb5b180c5bed79f Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Tue, 1 Aug 2023 22:08:23 +0800 Subject: [PATCH] :art: The desktop initialization interface workspace defaults to ~/SiYuan/ Fix https://github.com/siyuan-note/siyuan/issues/8879 --- app/electron/init.html | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/electron/init.html b/app/electron/init.html index 9d643df88..fd63acaa1 100644 --- a/app/electron/init.html +++ b/app/electron/init.html @@ -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)) {