mirror of
https://github.com/HugoAura/Seewo-HugoAura.git
synced 2026-06-20 23:14:28 +08:00
[Feat] Screen Lock overrides & Move Aura Settings to pref page
This commit is contained in:
21
package.json
Executable file
21
package.json
Executable file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "HugoAura",
|
||||
"version": "0.1.1-pre-II",
|
||||
"description": "Aura for SeewoHugo",
|
||||
"main": "app.asar/main.js",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"electron": "^36.3.2"
|
||||
},
|
||||
"scripts": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/HugoAura/Seewo-HugoAura.git"
|
||||
},
|
||||
"author": "Minoricew",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"bugs": {
|
||||
"url": "https://github.com/HugoAura/Seewo-HugoAura/issues"
|
||||
},
|
||||
"homepage": "https://github.com/HugoAura/Seewo-HugoAura"
|
||||
}
|
||||
79
src/aura/init/main/windowHooksManager.js
Executable file
79
src/aura/init/main/windowHooksManager.js
Executable file
@@ -0,0 +1,79 @@
|
||||
// @ts-check
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
class WindowHooksManager {
|
||||
loadHooks() {
|
||||
if (
|
||||
global.__HUGO_AURA__.windowHooks &&
|
||||
Object.keys(global.__HUGO_AURA__.windowHooks).length !== 0
|
||||
) {
|
||||
return global.__HUGO_AURA__.windowHooks;
|
||||
}
|
||||
|
||||
const hooksPath = path.join(__dirname, "../../../aura/mainProcess/hooks");
|
||||
|
||||
/** @type {import("../../types/main/core").HooksMap} */
|
||||
const hooks = new Map();
|
||||
|
||||
try {
|
||||
const files = fs.readdirSync(hooksPath);
|
||||
files.forEach((file) => {
|
||||
if (!file.endsWith(".js")) return;
|
||||
|
||||
try {
|
||||
const hook = require(path.join(hooksPath, file));
|
||||
/** @type {import("../../types/main/core").WindowName} */
|
||||
const targetWindow = hook.windowName || path.basename(file, ".js");
|
||||
hooks.set(targetWindow, hook);
|
||||
console.log(
|
||||
`[HugoAura / Init / WDH] Loaded main process hook for window: ${targetWindow}`
|
||||
);
|
||||
} catch (err) {
|
||||
console.error(
|
||||
`[HugoAura / Init / WDH / Error] Failed to load main process hook ${file}:`,
|
||||
err
|
||||
);
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(
|
||||
"[HugoAura / Init / WDH / Error] Failed to read hooks directory:",
|
||||
err
|
||||
);
|
||||
}
|
||||
|
||||
global.__HUGO_AURA__.windowHooks = hooks;
|
||||
return hooks;
|
||||
}
|
||||
|
||||
initHookForWindow(
|
||||
windowName,
|
||||
centralIns,
|
||||
mainProcessAppInstance,
|
||||
browserWindowInstance
|
||||
) {
|
||||
const stripWindowName = windowName.split("_")[0];
|
||||
if (!global.__HUGO_AURA__.windowHooks.has(stripWindowName)) {
|
||||
console.log(
|
||||
`[HugoAura / Init / WDH] Window ${windowName} has no corresponding main process hooks, ignoring...`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const { hookFunc } = global.__HUGO_AURA__.windowHooks.get(stripWindowName);
|
||||
hookFunc(
|
||||
centralIns,
|
||||
mainProcessAppInstance,
|
||||
browserWindowInstance,
|
||||
windowName
|
||||
);
|
||||
|
||||
console.log(
|
||||
`[HugoAura / Init / WDH / Success / ${windowName}] Main process hook initialized.`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = WindowHooksManager;
|
||||
@@ -3,13 +3,13 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
class HooksManager {
|
||||
class RendererHooksManager {
|
||||
loadHooks() {
|
||||
if (
|
||||
global.__HUGO_AURA__.hooks &&
|
||||
Object.keys(global.__HUGO_AURA__.hooks).length !== 0
|
||||
global.__HUGO_AURA__.uiHooks &&
|
||||
Object.keys(global.__HUGO_AURA__.uiHooks).length !== 0
|
||||
) {
|
||||
return global.__HUGO_AURA__.hooks;
|
||||
return global.__HUGO_AURA__.uiHooks;
|
||||
}
|
||||
|
||||
const hooksPath = path.join(__dirname, "../../../aura/ui/hookDefinitions");
|
||||
@@ -28,23 +28,23 @@ class HooksManager {
|
||||
const targetWindow = hook.windowName || path.basename(file, ".js");
|
||||
hooks.set(targetWindow, hook);
|
||||
console.log(
|
||||
`[HugoAura / Init] Loaded hook for window: ${targetWindow}`
|
||||
`[HugoAura / Init / RDH] Loaded ui hook for window: ${targetWindow}`
|
||||
);
|
||||
} catch (err) {
|
||||
console.error(
|
||||
`[HugoAura / Init / Error] Failed to load hook ${file}:`,
|
||||
`[HugoAura / Init / RDH / Error] Failed to load ui hook ${file}:`,
|
||||
err
|
||||
);
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(
|
||||
"[HugoAura / Init / Error] Failed to read hooks directory:",
|
||||
"[HugoAura / Init / RDH / Error] Failed to ui hooks directory:",
|
||||
err
|
||||
);
|
||||
}
|
||||
|
||||
global.__HUGO_AURA__.hooks = hooks;
|
||||
global.__HUGO_AURA__.uiHooks = hooks;
|
||||
return hooks;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class HooksManager {
|
||||
*/
|
||||
cleanupWindow(windowKey, hookedWindowProps) {
|
||||
console.log(
|
||||
`[HugoAura / Cleanup / ${windowKey}] Window destroyed, cleaning up...`
|
||||
`[HugoAura / Cleanup / RDH / ${windowKey}] Window destroyed, cleaning up...`
|
||||
);
|
||||
|
||||
if (hookedWindowProps) {
|
||||
@@ -82,20 +82,20 @@ class HooksManager {
|
||||
const windowKey = `${hookConfig.windowName || windowName}`;
|
||||
if (global.__HUGO_AURA__.hookedWindows.has(windowKey)) {
|
||||
console.log(
|
||||
`[HugoAura / Init] Duplicate hook for ${windowKey}, ignoring...`
|
||||
`[HugoAura / Init / RDH] Duplicate ui hook for ${windowKey}, ignoring...`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`[HugoAura / Init] Hook is initializing for ${windowKey}...`);
|
||||
console.log(`[HugoAura / Init / RDH] UI Hook is initializing for ${windowKey}...`);
|
||||
console.log(
|
||||
`[HugoAura / Init] Hook loaded at: ${new Date().toISOString()}`
|
||||
`[HugoAura / Init / RDH] UI Hook loaded at: ${new Date().toISOString()}`
|
||||
);
|
||||
|
||||
const domReadyListener = () => {
|
||||
try {
|
||||
console.log(
|
||||
`[HugoAura / UI / Verb / ${windowKey}] Loading injection script...`
|
||||
`[HugoAura / RDH / Verb / ${windowKey}] Loading injection script...`
|
||||
);
|
||||
|
||||
const injectionScript = fs
|
||||
@@ -115,18 +115,18 @@ class HooksManager {
|
||||
.executeJavaScript(injectionScript, true)
|
||||
.then(() =>
|
||||
console.log(
|
||||
`[HugoAura / UI / Done / ${windowKey}] Injection script executed`
|
||||
`[HugoAura / RDH / Done / ${windowKey}] Injection script executed`
|
||||
)
|
||||
)
|
||||
.catch((err) =>
|
||||
console.error(
|
||||
`[HugoAura / UI / Error / ${windowKey}] Failed to execute injection script:`,
|
||||
`[HugoAura / RDH / Error / ${windowKey}] Failed to execute injection script:`,
|
||||
err
|
||||
)
|
||||
);
|
||||
} catch (err) {
|
||||
console.error(
|
||||
`[HugoAura / UI / Error / ${windowKey}] Failed to load UI hook:`,
|
||||
`[HugoAura / RDH / Error / ${windowKey}] Failed to load UI hook:`,
|
||||
err
|
||||
);
|
||||
}
|
||||
@@ -149,9 +149,9 @@ class HooksManager {
|
||||
});
|
||||
|
||||
console.log(
|
||||
`[HugoAura / Init / Success / ${windowKey}] Hook initialized successfully!`
|
||||
`[HugoAura / Init / RDH / Success / ${windowKey}] UI Hook initialized.`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = HooksManager;
|
||||
module.exports = RendererHooksManager;
|
||||
@@ -7,7 +7,15 @@
|
||||
"passwordWithSalt": "89f6c4d57d0202a05c32d37cc6a2c6a0",
|
||||
"salt": "aura"
|
||||
},
|
||||
"authModeRewrite": "default"
|
||||
"authModeRewrite": "none"
|
||||
},
|
||||
"vendor/screenLock": {
|
||||
"enabled": true,
|
||||
"disableKeyboardHook": false,
|
||||
"authRewriteType": "customActivationCode",
|
||||
"customActivationCode": {
|
||||
"activationCodeWithSalt": "cbbd87c419b1c2dbc412ae238f1f4be3"
|
||||
}
|
||||
}
|
||||
},
|
||||
"networkRewrite": {
|
||||
|
||||
1356
src/aura/jsRewrite/vendor/screenLock.js
vendored
Executable file
1356
src/aura/jsRewrite/vendor/screenLock.js
vendored
Executable file
File diff suppressed because it is too large
Load Diff
17
src/aura/mainProcess/hooks/screenLock.js
Executable file
17
src/aura/mainProcess/hooks/screenLock.js
Executable file
@@ -0,0 +1,17 @@
|
||||
const hookFn = (central, appIns, browserWindowIns) => {
|
||||
const __config = global.__HUGO_AURA_CONFIG__.rewrite["vendor/screenLock"];
|
||||
|
||||
const removeKeyboardHook = () => {
|
||||
const { dllForHookBoard } = central(29);
|
||||
|
||||
setTimeout(() => {
|
||||
dllForHookBoard.UnHookKeyBoard();
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
if (__config.disableKeyboardHook) {
|
||||
removeKeyboardHook();
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = { hookFunc: hookFn };
|
||||
@@ -25,7 +25,7 @@ const showRelaunchPLSToast = () => {
|
||||
if (global.__HUGO_AURA_GLOBAL__.plsStatus.detached) {
|
||||
const relaunchBtn = document.getElementById("plsRelaunchBtn");
|
||||
relaunchBtn.disabled = true;
|
||||
relaunchBtn.textContent = "分离模式下无法执行"
|
||||
relaunchBtn.textContent = "分离模式下无法执行";
|
||||
}
|
||||
|
||||
if (!toastBs.isShown()) toastBs.show();
|
||||
@@ -95,18 +95,31 @@ const settingsRenderer = (pendingEl, settingsObj, isPls = false) => {
|
||||
reloadIcon.setAttribute("data-bs-title", "需要重载页面");
|
||||
entryTitle.appendChild(reloadIcon);
|
||||
}
|
||||
if (entry.tip) {
|
||||
|
||||
const createToolTipIcon = (type, content) => {
|
||||
const tipIcon = document.createElement("i");
|
||||
tipIcon.classList.add(
|
||||
"layui-icon",
|
||||
"layui-icon-tips",
|
||||
"aura-settings-entry-property-icon"
|
||||
);
|
||||
if (type === "warning") {
|
||||
tipIcon.classList.add("aura-settings-entry-warning-icon");
|
||||
}
|
||||
tipIcon.setAttribute("data-bs-toggle", "tooltip");
|
||||
tipIcon.setAttribute("data-bs-placement", "top");
|
||||
tipIcon.setAttribute("data-bs-title", entry.tipTitle);
|
||||
tipIcon.setAttribute("data-bs-title", content);
|
||||
entryTitle.appendChild(tipIcon);
|
||||
};
|
||||
|
||||
if (entry.tip) {
|
||||
createToolTipIcon("tip", entry.tipTitle);
|
||||
}
|
||||
|
||||
if (entry.warning) {
|
||||
createToolTipIcon("warning", entry.warningContent);
|
||||
}
|
||||
|
||||
const entryDescription = document.createElement("p");
|
||||
entryDescription.classList.add("aura-settings-entry-desc");
|
||||
entryDescription.textContent = entry.description;
|
||||
|
||||
@@ -69,6 +69,12 @@
|
||||
color: rgb(0, 106, 188);
|
||||
}
|
||||
|
||||
.aura-settings-entry-warning-icon {
|
||||
transform: rotate(180deg);
|
||||
display: inline-block;
|
||||
color: rgb(241, 155, 0);
|
||||
}
|
||||
|
||||
/* Animations */
|
||||
|
||||
@keyframes invalidShake {
|
||||
|
||||
@@ -49,6 +49,14 @@ const def = {
|
||||
selectorMode: "appendChild",
|
||||
pageCSS: "ui/pages/configSubPages/behaviourCtrl/plsStatus.css",
|
||||
},
|
||||
"Aura.UI.Assistant.Config.Preferences": {
|
||||
active: false,
|
||||
pageURI: "ui/pages/configSubPages/preferences/preferences.html",
|
||||
pageScript: "ui/pages/configSubPages/preferences/preferences.js",
|
||||
pageSelector: ".aura-config-page-subpage-container",
|
||||
selectorMode: "appendChild",
|
||||
pageCSS: "ui/pages/configSubPages/preferences/preferences.css",
|
||||
},
|
||||
},
|
||||
globalStyles: [
|
||||
"ui/css/global.css",
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
<img src="../../aura/ui/static/config/no_limitations.svg" />
|
||||
<div>
|
||||
<p class="config-operation-title">限制解除</p>
|
||||
<p class="config-operation-description">禁用密码、关闭冰点</p>
|
||||
<p class="config-operation-description">禁用密码、关闭功能</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -104,12 +104,15 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="operation-el-hidden aura-config-page-operation-el">
|
||||
<div
|
||||
class="operation-el-hidden aura-config-page-operation-el"
|
||||
onclick="window.__HUGO_AURA_UI_FUNCTIONS__.config.toggleSubConfig('preferences', true)"
|
||||
>
|
||||
<div class="aura-config-page-operation-body">
|
||||
<img src="../../aura/ui/static/config/about.svg" />
|
||||
<div>
|
||||
<p class="config-operation-title">关于项目</p>
|
||||
<p class="config-operation-description">使用文档、获取帮助</p>
|
||||
<p class="config-operation-title">偏好设置</p>
|
||||
<p class="config-operation-description">Aura 设置、关于项目</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
global.__HUGO_AURA_UI_REACTIVES__.config = {
|
||||
isInSubPage: false,
|
||||
currentActiveSubPage: "",
|
||||
authenticated: false,
|
||||
};
|
||||
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
||||
@@ -34,6 +35,7 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
||||
|
||||
toggleSubConfig: (subPage, side) => {
|
||||
if (side === global.__HUGO_AURA_UI_REACTIVES__.config.isInSubPage) return;
|
||||
if (!global.__HUGO_AURA_UI_REACTIVES__.config.authenticated) return;
|
||||
if (!side) {
|
||||
side = !global.__HUGO_AURA_UI_REACTIVES__.config.isInSubPage;
|
||||
}
|
||||
@@ -66,6 +68,15 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
||||
}, 500);
|
||||
}
|
||||
break;
|
||||
case "plugins":
|
||||
// To Be Done
|
||||
preserveOperationIdx = 2;
|
||||
pendingSubPageId = "Aura.UI.Assistant.Config.Plugins";
|
||||
break;
|
||||
case "preferences":
|
||||
preserveOperationIdx = 3;
|
||||
pendingSubPageId = "Aura.UI.Assistant.Config.Preferences";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -152,6 +163,7 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
||||
await window.__HUGO_AURA_GLOBAL__.utils.sleep(500);
|
||||
acsDialogAreaEl.style = "display: none;";
|
||||
await window.__HUGO_AURA_GLOBAL__.utils.sleep(250);
|
||||
global.__HUGO_AURA_UI_REACTIVES__.config.authenticated = true;
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.config.showSecondPhaseAnim();
|
||||
return true;
|
||||
} else {
|
||||
@@ -218,6 +230,7 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
||||
global.__HUGO_AURA_CONFIG__.auraSettings.settingsPasswordEnabled;
|
||||
|
||||
if (!isAuthEnabled) {
|
||||
global.__HUGO_AURA_UI_REACTIVES__.config.authenticated = true;
|
||||
showOperationsAnimation();
|
||||
} else {
|
||||
await window.__HUGO_AURA_GLOBAL__.utils.sleep(50);
|
||||
|
||||
@@ -6,20 +6,6 @@
|
||||
<li class="nav-item" role="presentation">
|
||||
<button
|
||||
class="nav-link active"
|
||||
id="aura-subpage-tab"
|
||||
data-bs-toggle="pill"
|
||||
data-bs-target="#aura-subpage"
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-controls="aura-subpage"
|
||||
aria-selected="true"
|
||||
>
|
||||
Aura 设置
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button
|
||||
class="nav-link"
|
||||
id="auth-subpage-tab"
|
||||
data-bs-toggle="pill"
|
||||
data-bs-target="#auth-subpage"
|
||||
@@ -49,12 +35,6 @@
|
||||
<div class="tab-content">
|
||||
<div
|
||||
class="tab-pane fade show active"
|
||||
id="aura-subpage"
|
||||
role="tabpanel"
|
||||
aria-labelledby="aura-subpage-tab"
|
||||
></div>
|
||||
<div
|
||||
class="tab-pane fade show"
|
||||
id="auth-subpage"
|
||||
role="tabpanel"
|
||||
aria-labelledby="auth-subpage-tab"
|
||||
|
||||
@@ -5,15 +5,9 @@
|
||||
const {
|
||||
settingsRenderer,
|
||||
} = require("../../aura/ui/composables/settingsRenderer");
|
||||
const { auraSettings } = require(`${pathBase}/aura`);
|
||||
const { authSettings } = require(`${pathBase}/auth`);
|
||||
const { banAuditSettings } = require(`${pathBase}/audit`);
|
||||
|
||||
const initAuraSubPage = () => {
|
||||
const auraSettingsSubPageEl = document.getElementById("aura-subpage");
|
||||
settingsRenderer(auraSettingsSubPageEl, auraSettings);
|
||||
};
|
||||
|
||||
const initAuthSubPage = () => {
|
||||
const authSubPageEl = document.getElementById("auth-subpage");
|
||||
settingsRenderer(authSubPageEl, authSettings);
|
||||
@@ -25,7 +19,6 @@
|
||||
};
|
||||
|
||||
const onMounted = () => {
|
||||
initAuraSubPage();
|
||||
initAuthSubPage();
|
||||
initBanAuditSubPage();
|
||||
|
||||
|
||||
@@ -131,6 +131,131 @@ const authSettings = [
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
categoryName: "屏幕锁",
|
||||
child: [
|
||||
{
|
||||
index: 0,
|
||||
id: "enableScreenLockOverride",
|
||||
type: "switch",
|
||||
name: "启用屏幕锁覆写功能",
|
||||
description: "覆写希沃管家的屏幕锁组件, 绕过限制",
|
||||
restart: false,
|
||||
reload: false,
|
||||
associateVal: null,
|
||||
auraIf: () => true,
|
||||
defaultValue: true,
|
||||
valueGetter: () => {
|
||||
return global.__HUGO_AURA_CONFIG__.rewrite["vendor/screenLock"]
|
||||
.enabled;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
if (typeof newVal !== "boolean") return;
|
||||
global.__HUGO_AURA_CONFIG__.rewrite["vendor/screenLock"].enabled =
|
||||
newVal;
|
||||
},
|
||||
},
|
||||
{
|
||||
index: 1,
|
||||
id: "disableKeyboardHook",
|
||||
type: "switch",
|
||||
name: "允许快捷键操作",
|
||||
description: "屏蔽键盘 DLL Hook, 允许在屏幕锁中操作快捷键",
|
||||
restart: false,
|
||||
reload: false,
|
||||
tip: true,
|
||||
tipTitle: "此功能正在测试中, 可能并不稳定",
|
||||
associateVal: ["rewrite.vendor/screenLock.enabled"],
|
||||
auraIf: () => {
|
||||
return global.__HUGO_AURA_CONFIG__.rewrite["vendor/screenLock"]
|
||||
.enabled;
|
||||
},
|
||||
defaultValue: false,
|
||||
valueGetter: () => {
|
||||
return global.__HUGO_AURA_CONFIG__.rewrite["vendor/screenLock"]
|
||||
.disableKeyboardHook;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
if (typeof newVal !== "boolean") return;
|
||||
global.__HUGO_AURA_CONFIG__.rewrite[
|
||||
"vendor/screenLock"
|
||||
].disableKeyboardHook = newVal;
|
||||
},
|
||||
},
|
||||
{
|
||||
index: 2,
|
||||
id: "screenLockAuthOverrideType",
|
||||
type: "radio",
|
||||
name: "覆写模式",
|
||||
description: "选择一个认证覆写模式",
|
||||
restart: false,
|
||||
reload: false,
|
||||
associateVal: ["rewrite.vendor/screenLock.enabled"],
|
||||
auraIf: () => {
|
||||
return global.__HUGO_AURA_CONFIG__.rewrite["vendor/screenLock"]
|
||||
.enabled;
|
||||
},
|
||||
defaultValue: "none",
|
||||
templates: ["customActivationCode", "none"],
|
||||
templateLabels: ["自定义激活码", "不修改"],
|
||||
valueGetter: () => {
|
||||
return global.__HUGO_AURA_CONFIG__.rewrite["vendor/screenLock"]
|
||||
.authRewriteType;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
global.__HUGO_AURA_CONFIG__.rewrite[
|
||||
"vendor/screenLock"
|
||||
].authRewriteType = newVal;
|
||||
},
|
||||
},
|
||||
{
|
||||
index: 3,
|
||||
id: "customActivationCode",
|
||||
type: "input",
|
||||
subType: "password",
|
||||
name: "自定义激活码",
|
||||
description: '请在屏幕锁页面下方选择 "激活码解锁" 以使用',
|
||||
restart: false,
|
||||
reload: false,
|
||||
warning: true,
|
||||
warningContent: "密码为 6 位纯数字",
|
||||
associateVal: [
|
||||
"rewrite.vendor/screenLock.enabled",
|
||||
"rewrite.vendor/screenLock.authRewriteType",
|
||||
],
|
||||
auraIf: () => {
|
||||
return (
|
||||
global.__HUGO_AURA_CONFIG__.rewrite["vendor/screenLock"].enabled &&
|
||||
global.__HUGO_AURA_CONFIG__.rewrite["vendor/screenLock"].authRewriteType ===
|
||||
"customActivationCode"
|
||||
);
|
||||
},
|
||||
defaultValue: "",
|
||||
placeHolder: "留空表示不修改, 保留已设置值",
|
||||
valueGetter: () => {
|
||||
return "";
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
if (newVal === "" || !newVal) return { valid: true };
|
||||
if (newVal.length !== 6)
|
||||
return { valid: false, hint: "仅可输入 6 位密码" };
|
||||
if (!/^\d+$/.test(newVal)) {
|
||||
return { valid: false, hint: "仅允许纯数字密码" };
|
||||
}
|
||||
const __config =
|
||||
global.__HUGO_AURA_CONFIG__.rewrite["vendor/screenLock"];
|
||||
const crypto = require("crypto");
|
||||
const result = crypto
|
||||
.createHash("md5")
|
||||
.update(newVal + "auraScreenLockCrack")
|
||||
.digest("hex");
|
||||
__config.customActivationCode.activationCodeWithSalt = result;
|
||||
return { valid: true };
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
categoryName: "基础设施",
|
||||
child: [
|
||||
{
|
||||
@@ -143,6 +268,9 @@ const authSettings = [
|
||||
reload: false,
|
||||
tip: true,
|
||||
tipTitle: "启用后, 按下 Ctrl + Shift + I 即可打开 DevTools",
|
||||
warning: true,
|
||||
warningContent:
|
||||
"在操作不当的情况下, 有可能造成 DevTools 永久无法激活 (Electron 的 Bug), 此时请使用 Chrome 远程调试",
|
||||
associateVal: null,
|
||||
auraIf: () => true,
|
||||
defaultValue: false,
|
||||
|
||||
8
src/aura/ui/pages/configSubPages/preferences/preferences.css
Executable file
8
src/aura/ui/pages/configSubPages/preferences/preferences.css
Executable file
@@ -0,0 +1,8 @@
|
||||
.aura-config-subpage-preferences-root {
|
||||
opacity: 1;
|
||||
transition: opacity 0.5s;
|
||||
}
|
||||
|
||||
.aura-config-subpage-preferences-root.acs-preferences-root-hidden {
|
||||
opacity: 0;
|
||||
}
|
||||
49
src/aura/ui/pages/configSubPages/preferences/preferences.html
Executable file
49
src/aura/ui/pages/configSubPages/preferences/preferences.html
Executable file
@@ -0,0 +1,49 @@
|
||||
<div
|
||||
id="acs-preferences-root-el"
|
||||
class="aura-config-subpage-preferences-root acs-preferences-root-hidden"
|
||||
>
|
||||
<ul class="nav nav-underline mb-3" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button
|
||||
class="nav-link active"
|
||||
id="aura-subpage-tab"
|
||||
data-bs-toggle="pill"
|
||||
data-bs-target="#aura-subpage"
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-controls="aura-subpage"
|
||||
aria-selected="true"
|
||||
>
|
||||
Aura 设置
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button
|
||||
class="nav-link"
|
||||
id="about-subpage-tab"
|
||||
data-bs-toggle="pill"
|
||||
data-bs-target="#about-subpage"
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-controls="about-subpage"
|
||||
aria-selected="true"
|
||||
>
|
||||
关于项目
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div
|
||||
class="tab-pane fade show active"
|
||||
id="aura-subpage"
|
||||
role="tabpanel"
|
||||
aria-labelledby="aura-subpage-tab"
|
||||
></div>
|
||||
<div
|
||||
class="tab-pane fade"
|
||||
id="about-subpage"
|
||||
role="tabpanel"
|
||||
aria-labelledby="about-subpage-tab"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
23
src/aura/ui/pages/configSubPages/preferences/preferences.js
Executable file
23
src/aura/ui/pages/configSubPages/preferences/preferences.js
Executable file
@@ -0,0 +1,23 @@
|
||||
(() => {
|
||||
const pathBase = "../../aura/ui/pages/configSubPages/preferences/settings";
|
||||
|
||||
const {
|
||||
settingsRenderer,
|
||||
} = require("../../aura/ui/composables/settingsRenderer");
|
||||
const { auraSettings } = require(`${pathBase}/aura`);
|
||||
|
||||
const initAuraSubPage = () => {
|
||||
const auraSettingsSubPageEl = document.getElementById("aura-subpage");
|
||||
settingsRenderer(auraSettingsSubPageEl, auraSettings);
|
||||
};
|
||||
const onMounted = () => {
|
||||
initAuraSubPage();
|
||||
|
||||
const rootEl = document.getElementById("acs-preferences-root-el");
|
||||
setTimeout(() => {
|
||||
rootEl.classList.remove("acs-preferences-root-hidden");
|
||||
}, 500);
|
||||
};
|
||||
|
||||
onMounted();
|
||||
})();
|
||||
@@ -36,6 +36,8 @@ const auraSettings = [
|
||||
description: "此密码将用于访问 Aura 设置 UI",
|
||||
restart: false,
|
||||
reload: false,
|
||||
tip: true,
|
||||
tipTitle: "密码将在本地使用 SHA512 加盐存储",
|
||||
associateVal: ["auraSettings.settingsPasswordEnabled"],
|
||||
auraIf: () => {
|
||||
return global.__HUGO_AURA_CONFIG__.auraSettings
|
||||
@@ -91,8 +93,8 @@ const auraSettings = [
|
||||
description: "启用后, 密码验证时, 背景将具有毛玻璃效果",
|
||||
restart: false,
|
||||
reload: false,
|
||||
tip: true,
|
||||
tipTitle: "不建议在较旧 (如 i5 8 代) 机型上开启, 可能导致性能问题",
|
||||
warning: true,
|
||||
warningContent: "不建议在较旧 (如 i5 8 代) 机型上开启, 可能导致性能问题",
|
||||
associateVal: null,
|
||||
auraIf: () => true,
|
||||
defaultValue: true,
|
||||
@@ -24,12 +24,17 @@ const util = require("util");
|
||||
const path = require("path");
|
||||
const os = require("os");
|
||||
|
||||
const HooksManager = require("../aura/init/rendererHook/hooksManager");
|
||||
const MainProcessHooksManager = require("../aura/init/main/windowHooksManager");
|
||||
const RendererHooksManager = require("../aura/init/rendererHook/uiHooksManager");
|
||||
const NetworkHook = require("../aura/init/rendererHook/networkHook");
|
||||
const configManager = require("../aura/init/shared/configManager");
|
||||
const { buildIpcMain } = require("../aura/init/main/ipcHandler");
|
||||
|
||||
const initLogger = () => {
|
||||
/**
|
||||
*
|
||||
* @param {import("../aura/types/main/core").WindowName} windowName
|
||||
*/
|
||||
const initLogger = (windowName) => {
|
||||
const logDir = path.join(os.homedir(), "Documents", "HugoAura", "logs");
|
||||
if (!fs.existsSync(logDir)) {
|
||||
fs.mkdirSync(logDir, { recursive: true });
|
||||
@@ -37,7 +42,7 @@ const initLogger = () => {
|
||||
|
||||
const logFile = path.join(
|
||||
logDir,
|
||||
`main-process-${new Date().toISOString().replace(/:/g, "-")}.log`
|
||||
`main-${windowName}-${new Date().toISOString().replace(/:/g, "-")}.log`
|
||||
);
|
||||
const logStream = fs.createWriteStream(logFile, { flags: "a" });
|
||||
|
||||
@@ -84,7 +89,10 @@ const initLogger = () => {
|
||||
console.error("UNCAUGHT EXCEPTION:", err);
|
||||
});
|
||||
|
||||
console.log("Logger initialized. Log file:", logFile);
|
||||
console.log(
|
||||
"[HugoAura / Init / Logger] Logger initialized. Log file:",
|
||||
logFile
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -96,6 +104,7 @@ const launcher = ({ central, windowName, config }) => {
|
||||
process.stdout.isTTY = true;
|
||||
process.stderr.isTTY = true;
|
||||
|
||||
/** @type {Electron} */
|
||||
const electron = central(1);
|
||||
const app = electron.app;
|
||||
if (!global.__HUGO_AURA__.central) global.__HUGO_AURA__.central = central;
|
||||
@@ -105,9 +114,10 @@ const launcher = ({ central, windowName, config }) => {
|
||||
app.exit(0);
|
||||
};
|
||||
|
||||
initLogger();
|
||||
initLogger(windowName);
|
||||
|
||||
console.log("[HugoAura / Loaded] Aura is loaded!");
|
||||
console.debug(`[HugoAura / Debug] curWindowName: ${windowName}`);
|
||||
|
||||
configManager.ensureConfigExists();
|
||||
const loadedConfig = configManager.loadConfig();
|
||||
@@ -120,16 +130,34 @@ const launcher = ({ central, windowName, config }) => {
|
||||
global.__HUGO_AURA__.ipcInit = true;
|
||||
}
|
||||
|
||||
const hooksManager = new HooksManager();
|
||||
const mainProcessHooksManager = new MainProcessHooksManager();
|
||||
|
||||
const hooks = hooksManager.loadHooks();
|
||||
const _windowHooks = mainProcessHooksManager.loadHooks();
|
||||
|
||||
const uiHooksManager = new RendererHooksManager();
|
||||
|
||||
const uiHooks = uiHooksManager.loadHooks();
|
||||
|
||||
if (loadedConfig.devTools && !config.canOpenDevTool) {
|
||||
config.canOpenDevTool = true;
|
||||
}
|
||||
|
||||
const browserWindowCreatedListener = (_event, browserWindow) => {
|
||||
mainProcessHooksManager.initHookForWindow(
|
||||
windowName,
|
||||
central,
|
||||
app,
|
||||
browserWindow
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Event} _event
|
||||
* @param {import("electron").WebContents} webContents
|
||||
*/
|
||||
const webContentsCreatedListener = (_event, webContents) => {
|
||||
const hookConfig = hooks.get(windowName);
|
||||
const hookConfig = uiHooks.get(windowName.split("_")[0]);
|
||||
|
||||
const initNetworkHook = () => {
|
||||
const networkHook = new NetworkHook();
|
||||
@@ -143,17 +171,22 @@ const launcher = ({ central, windowName, config }) => {
|
||||
initNetworkHook();
|
||||
|
||||
if (hookConfig) {
|
||||
hooksManager.handleWindowHook(webContents, hookConfig, windowName);
|
||||
uiHooksManager.handleWindowHook(webContents, hookConfig, windowName);
|
||||
} else {
|
||||
console.debug(
|
||||
`[HugoAura / Init] Window ${windowName} has no corresponding hook, ignoring...`
|
||||
console.log(
|
||||
`[HugoAura / Init / RDH] Window ${windowName} has no corresponding ui hooks, ignoring...`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
app.once("browser-window-created", browserWindowCreatedListener);
|
||||
// @ts-expect-error
|
||||
// ↑ idk why
|
||||
app.once("web-contents-created", webContentsCreatedListener);
|
||||
|
||||
return () => {
|
||||
app.removeListener("browser-window-created", browserWindowCreatedListener);
|
||||
// @ts-expect-error
|
||||
app.removeListener("web-contents-created", webContentsCreatedListener);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const __AURA_VERSION__ = "0.1.1-pre-I";
|
||||
const __AURA_VERSION__ = "0.1.1-pre-II";
|
||||
|
||||
(() => {
|
||||
if (!global.__HUGO_AURA__) {
|
||||
|
||||
Reference in New Issue
Block a user