Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Avoid creating empty SiYuan directories using `getPath("userData")` (#17431)

Jeffrey Chenb35308005ba8
diff --git a/app/electron/main.js b/app/electron/main.js
index 5ed754ab44..5188221ca6 100644
--- a/app/electron/main.js
+++ b/app/electron/main.js
@@ -55,12 +55,9 @@ const isOpenAsHidden = function () {
remote.initialize();
-app.setPath("userData", app.getPath("userData") + "-Electron"); // `~/.config` 下 Electron 相关文件夹名称改为 `SiYuan-Electron` https://github.com/siyuan-note/siyuan/issues/3349
-
-if ("darwin" !== process.platform) {
- // macOS 上不能删除该路径,因为该路径是默认的工作空间路径 Default workspace data will be lost on macOS https://github.com/siyuan-note/siyuan/issues/17430
- fs.rmSync(app.getPath("appData") + "/" + app.name, {recursive: true}); // 删除自动创建的应用目录 https://github.com/siyuan-note/siyuan/issues/13150
-}
+// `~/.config` 下 Electron 相关文件夹名称改为 `SiYuan-Electron` https://github.com/siyuan-note/siyuan/issues/3349
+// getPath("userData") 会创建空的 SiYuan 目录,改为 app.getPath("appData")
+app.setPath("userData", path.join(app.getPath("appData"), app.getName() + "-Electron"));
if (process.platform === "win32") {
// Windows 需要设置 AppUserModelId 才能正确显示应用名称和应用图标 https://github.com/siyuan-note/siyuan/issues/17022