[🛠️ Fix] Emergency fix for invalid config read logic

1. [/] 紧急修复了上个 commit 中引入的错误路径获取逻辑
This commit is contained in:
Minoricew
2025-06-17 00:16:43 +08:00
parent 6be31652f9
commit 0494394fd8
8 changed files with 69 additions and 45 deletions

View File

@@ -2,40 +2,13 @@ const path = require("path");
const fs = require("fs");
const os = require("os");
const util = require("util");
const RegistryManager = require("../shared/registryManager");
const getUserDocumentsDirPath = () => {
const registryManager = new RegistryManager();
const pathInfo = registryManager.readRegKeySync(
'"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders"',
"Personal",
false,
true,
/REG_EXPAND_SZ\s+(.+)/
);
if (pathInfo.success) {
const resolvedPath = pathInfo.data.replace(
/%([^%]+)%/g,
(match, varName) => {
return process.env[varName] || match;
}
);
return resolvedPath;
} else {
console.error(
"[HugoAura / Init / Logger] Failed to get the path of documents dir, using default val."
);
return path.join(os.homedir(), "Documents");
}
};
/**
*
* @param {import("../aura/types/main/core").WindowName} windowName
*/
const initLogger = (windowName) => {
const logDir = path.join(getUserDocumentsDirPath(), "HugoAura", "logs");
const logDir = path.join(global.__HUGO_AURA__.auraDir, "logs");
global.__HUGO_AURA__.logDir = logDir;