mirror of
https://github.com/HugoAura/Seewo-HugoAura.git
synced 2026-06-22 08:14:26 +08:00
[🛠️ Fix] Emergency fix for invalid config read logic
1. [/] 紧急修复了上个 commit 中引入的错误路径获取逻辑
This commit is contained in:
@@ -54,6 +54,20 @@ const applyBaseIpcHandler = (ipcMain) => {
|
||||
browserWindowIns.close();
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.handle(`${methodBase}.getAuraDirAsync`, (_evt, _arg) => {
|
||||
return {
|
||||
success: true,
|
||||
data: global.__HUGO_AURA__.auraDir,
|
||||
};
|
||||
});
|
||||
|
||||
ipcMain.on(`${methodBase}.getAuraDirSync`, (event, _arg) => {
|
||||
event.returnValue = {
|
||||
success: true,
|
||||
data: global.__HUGO_AURA__.auraDir,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = { applyBaseIpcHandler };
|
||||
|
||||
@@ -8,13 +8,6 @@ const __SCOPE = "main";
|
||||
*/
|
||||
const applyDebugIpcHandler = (ipcMain) => {
|
||||
const methodBase = "$aura.debug";
|
||||
|
||||
ipcMain.handle(`${methodBase}.getLogDirAsync`, (_evt, _arg) => {
|
||||
return {
|
||||
success: true,
|
||||
data: global.__HUGO_AURA__.logDir,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = { applyDebugIpcHandler };
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ const deepMerge = (target, source) => {
|
||||
|
||||
class ConfigManager {
|
||||
constructor() {
|
||||
this.configDir = path.join(global.__HUGO_AURA__.logDir, "..");
|
||||
this.configDir = global.__HUGO_AURA__.auraDir;
|
||||
this.configPath = path.join(this.configDir, "config.json");
|
||||
this.encConfigPath = path.join(this.configDir, ".cache_2eafc8d0.dat"); // (雾
|
||||
/* ↑ 不使用 .tmp 扩展名, 不然容易真被清理了 */
|
||||
@@ -99,6 +99,7 @@ class ConfigManager {
|
||||
if (this.configDir === path.join(os.homedir(), "Documents", "HugoAura")) {
|
||||
return;
|
||||
}
|
||||
|
||||
const oldConfigPath = path.join(
|
||||
os.homedir(),
|
||||
"Documents",
|
||||
@@ -111,6 +112,7 @@ class ConfigManager {
|
||||
"HugoAura",
|
||||
".cache_2eafc8d0.dat"
|
||||
);
|
||||
|
||||
if (fs.existsSync(oldConfigPath)) {
|
||||
fs.copyFileSync(oldConfigPath, this.configPath);
|
||||
fs.unlinkSync(oldConfigPath);
|
||||
|
||||
Reference in New Issue
Block a user