mirror of
https://github.com/HugoAura/Seewo-HugoAura.git
synced 2026-06-23 00:54:30 +08:00
[🛠️ Fix] Emergency fix for invalid config read logic
1. [/] 紧急修复了上个 commit 中引入的错误路径获取逻辑
This commit is contained in:
@@ -6,7 +6,7 @@ if (!global.__HUGO_AURA__) {
|
||||
configInit: false,
|
||||
central: () => {},
|
||||
ipcInit: false,
|
||||
logDir: "",
|
||||
auraDir: "",
|
||||
plsStats: null,
|
||||
plsSettings: null,
|
||||
plsRules: null,
|
||||
@@ -37,15 +37,45 @@ if (!global.__HUGO_AURA_CONFIG__) {
|
||||
global.__HUGO_AURA_CONFIG__ = {};
|
||||
}
|
||||
|
||||
const path = require("path");
|
||||
const os = require("os");
|
||||
|
||||
const MainProcessHooksManager = require("../aura/init/main/windowHooksManager");
|
||||
const RendererHooksManager = require("../aura/init/rendererHook/uiHooksManager");
|
||||
const EventBus = require("../aura/utils/eventBus");
|
||||
const NetworkHook = require("../aura/init/rendererHook/networkHook");
|
||||
const ConfigManager = require("../aura/init/shared/configManager");
|
||||
const RegistryManager = require("../aura/init/shared/registryManager");
|
||||
const { buildIpcMain } = require("../aura/init/main/ipcHandler");
|
||||
|
||||
const { initLogger } = require("../aura/init/main/logger");
|
||||
|
||||
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 && pathInfo.data) {
|
||||
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").LauncherArgs} param0
|
||||
@@ -67,6 +97,8 @@ const launcher = ({ central, windowName, config }) => {
|
||||
app.exit(0);
|
||||
};
|
||||
|
||||
global.__HUGO_AURA__.auraDir = path.join(getUserDocumentsDirPath(), "HugoAura");
|
||||
|
||||
// >>> Init Logger <<< //
|
||||
initLogger(windowName);
|
||||
|
||||
|
||||
@@ -5,9 +5,14 @@ const __AURA_VERSION__ = "0.1.1-pre-IV";
|
||||
(() => {
|
||||
if (require.main) return; // 如果只是导入 Aura Version, 不运行闭包逻辑
|
||||
|
||||
const auraDir = require("electron").ipcRenderer.sendSync(
|
||||
"$aura.base.getAuraDirSync"
|
||||
);
|
||||
|
||||
// >>> Init Global Vars <<< //
|
||||
if (!global.__HUGO_AURA__) {
|
||||
global.__HUGO_AURA__ = {
|
||||
auraDir: auraDir.data,
|
||||
configInit: true, // preload 始终比 hook 晚, 默认 config 已初始化
|
||||
// ↑ 保留此参数的目的 -> 用于 configManager 中, configManager 的行为在 Renderer 和 Main 中是一致的
|
||||
version: __AURA_VERSION__,
|
||||
|
||||
Reference in New Issue
Block a user