From fbc5cf1f5719467c80d3c249a5018eaf42b3a0fc Mon Sep 17 00:00:00 2001 From: Minoricew <154642983+Minoricew@users.noreply.github.com> Date: Tue, 3 Jun 2025 02:11:39 +0800 Subject: [PATCH] [Feat] Screen Lock overrides & Move Aura Settings to pref page --- package.json | 21 + src/aura/init/main/windowHooksManager.js | 79 + .../{hooksManager.js => uiHooksManager.js} | 36 +- src/aura/init/shared/default.json | 10 +- src/aura/jsRewrite/vendor/screenLock.js | 1356 +++++++++++++++++ src/aura/mainProcess/hooks/screenLock.js | 17 + src/aura/ui/composables/settingsRenderer.js | 19 +- src/aura/ui/css/form.css | 6 + src/aura/ui/hookDefinitions/assistant.js | 8 + src/aura/ui/pages/config/config.html | 11 +- src/aura/ui/pages/config/config.js | 13 + .../disableLimitations.html | 20 - .../disableLimitations/disableLimitations.js | 7 - .../disableLimitations/settings/auth.js | 128 ++ .../preferences/preferences.css | 8 + .../preferences/preferences.html | 49 + .../configSubPages/preferences/preferences.js | 23 + .../settings/aura.js | 6 +- src/core/hook.js | 55 +- src/core/preload.js | 2 +- 20 files changed, 1807 insertions(+), 67 deletions(-) create mode 100755 package.json create mode 100755 src/aura/init/main/windowHooksManager.js rename src/aura/init/rendererHook/{hooksManager.js => uiHooksManager.js} (73%) create mode 100755 src/aura/jsRewrite/vendor/screenLock.js create mode 100755 src/aura/mainProcess/hooks/screenLock.js create mode 100755 src/aura/ui/pages/configSubPages/preferences/preferences.css create mode 100755 src/aura/ui/pages/configSubPages/preferences/preferences.html create mode 100755 src/aura/ui/pages/configSubPages/preferences/preferences.js rename src/aura/ui/pages/configSubPages/{disableLimitations => preferences}/settings/aura.js (91%) diff --git a/package.json b/package.json new file mode 100755 index 0000000..96025bd --- /dev/null +++ b/package.json @@ -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" +} diff --git a/src/aura/init/main/windowHooksManager.js b/src/aura/init/main/windowHooksManager.js new file mode 100755 index 0000000..e8d860d --- /dev/null +++ b/src/aura/init/main/windowHooksManager.js @@ -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; diff --git a/src/aura/init/rendererHook/hooksManager.js b/src/aura/init/rendererHook/uiHooksManager.js similarity index 73% rename from src/aura/init/rendererHook/hooksManager.js rename to src/aura/init/rendererHook/uiHooksManager.js index bf9a766..3e8e462 100755 --- a/src/aura/init/rendererHook/hooksManager.js +++ b/src/aura/init/rendererHook/uiHooksManager.js @@ -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; diff --git a/src/aura/init/shared/default.json b/src/aura/init/shared/default.json index 48b30ac..6bb4f9c 100755 --- a/src/aura/init/shared/default.json +++ b/src/aura/init/shared/default.json @@ -7,7 +7,15 @@ "passwordWithSalt": "89f6c4d57d0202a05c32d37cc6a2c6a0", "salt": "aura" }, - "authModeRewrite": "default" + "authModeRewrite": "none" + }, + "vendor/screenLock": { + "enabled": true, + "disableKeyboardHook": false, + "authRewriteType": "customActivationCode", + "customActivationCode": { + "activationCodeWithSalt": "cbbd87c419b1c2dbc412ae238f1f4be3" + } } }, "networkRewrite": { diff --git a/src/aura/jsRewrite/vendor/screenLock.js b/src/aura/jsRewrite/vendor/screenLock.js new file mode 100755 index 0000000..ef092d5 --- /dev/null +++ b/src/aura/jsRewrite/vendor/screenLock.js @@ -0,0 +1,1356 @@ +/// Rewrite rules basic config section begins /// + +const feature = `['/api/v1/screenlock/updateQrUrl', 'getScreenLockQrcode'].every(str => stringifyFunc.includes(str))`; + +const method = "legacy"; + +const methodArg = ""; + +const __config = window.__HUGO_AURA_CONFIG__.rewrite["vendor/screenLock"]; + +/// End of the rewrite rules basic config section /// + +// >> Begin of new function << // + +const newFunction = function (e, t, n) { + "use strict"; + var r = n(3), + s = n.n(r), + a = n(4), + o = n.n(a), + i = n(5), + u = n.n(i), + l = n(6), + c = n.n(l), + d = n(2), + A = n.n(d), + m = n(10), + f = n.n(m), + h = n(0), + p = n.n(h), + _ = n(41), + M = n.n(_), + g = (n(808), n(7)), + b = n(9), + y = n(8), + v = n.n(y), + w = + (n(810), + { + "./numberKeyboard.less": { + "ps-icon": "numberKeyboard__ps-icon__1KO_WOCz", + forbid: "numberKeyboard__forbid__3ZwtIdlz", + password: "numberKeyboard__password__2cz3jn8t", + "shaky-slow": "numberKeyboard__shaky-slow__6pc46EPF", + solid: "numberKeyboard__solid__WnwaYvi1", + error: "numberKeyboard__error__JPFhBvTV", + hollow: "numberKeyboard__hollow__oAboh0j6", + "number-board": "numberKeyboard__number-board__2jc2t7Cp", + button: "numberKeyboard__button__2x8eAPIm", + choose: "numberKeyboard__choose__1yTuk0dD", + delete: "numberKeyboard__delete__37p6RudB", + }, + }); + function D(t, e) { + var n = Object.keys(t); + if (Object.getOwnPropertySymbols) { + var r = Object.getOwnPropertySymbols(t); + e && + (r = r.filter(function (e) { + return Object.getOwnPropertyDescriptor(t, e).enumerable; + })), + n.push.apply(n, r); + } + return n; + } + function T(r) { + var a = (function () { + if ("undefined" == typeof Reflect || !Reflect.construct) return !1; + if (Reflect.construct.sham) return !1; + if ("function" == typeof Proxy) return !0; + try { + return ( + Boolean.prototype.valueOf.call( + Reflect.construct(Boolean, [], function () {}) + ), + !0 + ); + } catch (e) { + return !1; + } + })(); + return function () { + var e, + t = A()(r); + if (a) { + var n = A()(this).constructor; + e = Reflect.construct(t, arguments, n); + } else e = t.apply(this, arguments); + return c()(this, e); + }; + } + var j, + E = ["", "", "", "", "", ""], + I = (function (e) { + u()(a, e); + var r = T(a); + function a() { + var i; + s()(this, a); + for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++) + t[n] = arguments[n]; + return ( + ((i = r.call.apply(r, [this].concat(t))).state = { + PASSWORD_TEXT_ERROR: "密码错误,请重新输入6位数密码", + PASSWORD_TEXT_PENDDING: "请输入6位密码" + i.props.title, + passwordText: "请输入6位密码" + i.props.title, + inputPassword: [].concat(E), + chooseIndex: -1, + nowInputIndex: 0, + passwordError: !1, + forbid: !1, + checking: !1, + }), + (i.timeout = null), + (i.clearErrorTimeout = null), + (i.BOARD_LIST = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0].sort(function () { + return Math.random() - 0.5; + })), + (i.checkPasswordCorrect = function () {}), + (i.handleButtonClick = function (e) { + return function () { + i.state.forbid || + i.state.checking || + i.saveValue(i.BOARD_LIST[e], { chooseIndex: e }); + }; + }), + (i.handleDelete = function () { + if (!i.state.checking) { + var e = i.state, + t = e.inputPassword, + n = e.nowInputIndex; + 0 < n && + ((t[n - 1] = E[n - 1]), + clearTimeout(i.clearErrorTimeout), + i.setState({ + inputPassword: t, + nowInputIndex: n - 1, + passwordText: i.state.PASSWORD_TEXT_PENDDING, + passwordError: !1, + })); + } + }), + (i.passwordCheckFail = function () { + i.setState( + { + passwordError: !0, + passwordText: i.state.PASSWORD_TEXT_ERROR, + }, + function () { + i.clearErrorTimeout = setTimeout(function () { + var e = {}; + i.state.nowInputIndex === i.state.inputPassword.length && + (e.inputPassword = [].concat(E)), + i.setState( + (function (t) { + for (var e = 1; e < arguments.length; e++) { + var n = null != arguments[e] ? arguments[e] : {}; + e % 2 + ? D(Object(n), !0).forEach(function (e) { + f()(t, e, n[e]); + }) + : Object.getOwnPropertyDescriptors + ? Object.defineProperties( + t, + Object.getOwnPropertyDescriptors(n) + ) + : D(Object(n)).forEach(function (e) { + Object.defineProperty( + t, + e, + Object.getOwnPropertyDescriptor(n, e) + ); + }); + } + return t; + })( + { + passwordError: !1, + passwordText: i.state.PASSWORD_TEXT_PENDDING, + }, + e + ) + ); + }, 2e3); + } + ); + }), + (i.saveValue = function (e) { + var t = + 1 < arguments.length && void 0 !== arguments[1] + ? arguments[1] + : {}, + n = i.state, + r = n.inputPassword, + a = n.nowInputIndex; + a <= r.length - 1 && + ((r[a] = e), (t.inputPassword = r), (t.nowInputIndex = a + 1)), + a === r.length - 1 && i.checkPasswordCorrect(), + a === r.length && + (clearTimeout(i.clearErrorTimeout), + ((r = [].concat(E))[0] = e), + (t.inputPassword = r), + (t.nowInputIndex = 1), + (t.passwordText = i.state.PASSWORD_TEXT_PENDDING), + (t.passwordError = !1)), + i.setState(t), + clearTimeout(i.timeout), + (i.timeout = setTimeout(function () { + i.setState({ chooseIndex: -1 }); + }, 500)); + }), + (i.listenInput = function () { + if (__config.enabled && __config.disableKeyboardHook) return; + document.addEventListener("keyup", function (e) { + if (!i.state.forbid) { + if ( + (48 <= e.keyCode && e.keyCode <= 57) || + (96 <= e.keyCode && e.keyCode <= 105) + ) { + var t = 0; + (t = e.keyCode <= 57 ? 48 : 96), + i.saveValue(e.keyCode - t, { + chooseIndex: i.BOARD_LIST.indexOf(e.keyCode - t), + }); + } + 8 === e.keyCode && i.handleDelete(); + } + }); + }), + (i.insertHtml = function () {}), + (i.componentDidMountFunc = function () {}), + (i.handleReset = function () { + i.setState({ + passwordError: !1, + passwordText: i.state.PASSWORD_TEXT_PENDDING, + inputPassword: [].concat(E), + forbid: !1, + nowInputIndex: 0, + }); + }), + i + ); + } + return ( + o()(a, [ + { + key: "componentDidMount", + value: function () { + this.componentDidMountFunc(), this.listenInput(); + }, + }, + { + key: "render", + value: function () { + var n = this, + e = this.state, + t = e.passwordText, + r = e.inputPassword, + a = e.chooseIndex, + i = e.passwordError, + o = e.forbid; + return p.a.createElement( + p.a.Fragment, + null, + p.a.createElement( + "p", + { className: v()(o ? "ps-icon forbid" : "ps-icon", w) }, + t + ), + !o && + p.a.createElement( + "div", + { className: "numberKeyboard__password__2cz3jn8t" }, + r.map(function (e, t) { + return p.a.createElement("span", { + key: t, + className: v()( + -1 < n.BOARD_LIST.indexOf(e) + ? i + ? "solid error" + : "solid" + : i + ? "hollow error" + : "hollow", + w + ), + }); + }) + ), + p.a.createElement( + "div", + { className: "numberKeyboard__number-board__2jc2t7Cp" }, + this.BOARD_LIST.map(function (e, t) { + return p.a.createElement( + "div", + { + key: t, + onClick: n.handleButtonClick(t), + className: v()( + o + ? "button forbid" + : a === t + ? "button choose" + : "button", + w + ), + }, + p.a.createElement("p", null, e) + ); + }), + p.a.createElement( + "div", + { + onClick: this.handleDelete, + className: v()("delete ".concat(o ? "forbid" : ""), w), + }, + p.a.createElement("p", null, "删除") + ) + ), + this.insertHtml() + ); + }, + }, + ]), + a + ); + })(h.PureComponent); + function N(t, e) { + var n = Object.keys(t); + if (Object.getOwnPropertySymbols) { + var r = Object.getOwnPropertySymbols(t); + e && + (r = r.filter(function (e) { + return Object.getOwnPropertyDescriptor(t, e).enumerable; + })), + n.push.apply(n, r); + } + return n; + } + function z(t) { + for (var e = 1; e < arguments.length; e++) { + var n = null != arguments[e] ? arguments[e] : {}; + e % 2 + ? N(Object(n), !0).forEach(function (e) { + f()(t, e, n[e]); + }) + : Object.getOwnPropertyDescriptors + ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) + : N(Object(n)).forEach(function (e) { + Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(n, e)); + }); + } + return t; + } + function Y(r) { + var a = (function () { + if ("undefined" == typeof Reflect || !Reflect.construct) return !1; + if (Reflect.construct.sham) return !1; + if ("function" == typeof Proxy) return !0; + try { + return ( + Boolean.prototype.valueOf.call( + Reflect.construct(Boolean, [], function () {}) + ), + !0 + ); + } catch (e) { + return !1; + } + })(); + return function () { + var e, + t = A()(r); + if (a) { + var n = A()(this).constructor; + e = Reflect.construct(t, arguments, n); + } else e = t.apply(this, arguments); + return c()(this, e); + }; + } + var L = "passwordEmpty", + x = "passwordFail", + k = "requestLimit", + S = "requestError", + O = + Object(b.a)()( + (j = (function (e) { + u()(n, e); + var t = Y(n); + function n(e) { + var o; + return ( + s()(this, n), + ((o = t.call(this, e)).checkPasswordCorrect = function () { + o.props.onPasswordInputOver(o.state.inputPassword.join("")), + o.forbidBoardInputForChecking(); + }), + (o.forbidBoardInputForChecking = function () { + o.setState({ checking: !0 }); + }), + (o.releaseForbidInputForChecking = function () { + o.setState({ checking: !1 }); + }), + (o.listenEvent = function () { + var a = o.props.actions, + i = M()(o); + g.a.on("passwordAuthenResult", function (e) { + var t = e.action, + n = e.data, + r = void 0 === n ? {} : n; + switch ( + (console.log("passwordAuthenResult", t, r), + i.releaseForbidInputForChecking(), + t) + ) { + case L: + a.sendMessage({ + type: "error", + text: "后台密码获取失败,请关机重启后再使用,给您带来的不便深表歉意!", + }); + break; + case S: + console.log("请求触发错误,请重试"), + o.setState({ + passwordError: !0, + passwordText: "请求错误,请重试", + }); + break; + case k: + console.log("请求触发限流", r), + g.a.send("passwordInputLockRequestLimit", { + name: o.props.type + "_REQUEST_LIMIT", + time: r.retryAfter / 60, + }); + break; + case x: + o.errorCount++, + g.a.send("passwordInputLockError", { + name: o.props.type, + time: 10, + }), + o.passwordCheckFail(); + break; + default: + return; + } + }); + }), + (o.handleLockTimeFeedBack = function (e) { + var t, + n = + 1 < arguments.length && void 0 !== arguments[1] + ? arguments[1] + : "密码连续输错5次", + r = o.props.onSetTitle; + "number" == typeof e && + (e <= 0 + ? (o.handleReset(), r(""), (o.errorCount = 0)) + : (o.setState({ + forbid: !0, + passwordText: "" + .concat(n, ",请切换解锁方式或") + .concat( + (t = e) < 60 + ? t + "秒" + : Math.ceil(t / 60) + "分钟", + "后重试" + ), + }), + clearTimeout(o.clearErrorTimeout), + r("密码已锁定"))); + }), + (o.handleLockRequestLimitFeedBack = function (e) { + o.handleLockTimeFeedBack(e, "密码错误次数过多"); + }), + (o.componentDidMountFunc = function () { + o.listenEvent(), + _ACCEPT_DATA.getAndRegister( + o.props.type + "_FEEDBACK", + o.handleLockTimeFeedBack + ), + _ACCEPT_DATA.getAndRegister( + o.props.type + "_REQUEST_LIMIT_FEEDBACK", + o.handleLockRequestLimitFeedBack + ); + }), + (o.state = z( + z({}, o.state), + {}, + { + PASSWORD_TEXT_ERROR: "密码错误", + PASSWORD_TEXT_PENDDING: "", + passwordText: "", + } + )), + o + ); + } + return ( + o()(n, [ + { + key: "componentWillUnmount", + value: function () { + this.props.onSetTitle(""), + _ACCEPT_DATA.removeOne( + this.props.type + "_FEEDBACK", + this.handleLockTimeFeedBack + ), + _ACCEPT_DATA.removeOne( + this.props.type + "_REQUEST_LIMIT_FEEDBACK", + this.handleLockRequestLimitFeedBack + ); + }, + }, + ]), + n + ); + })(I)) + ) || j, + C = n(78), + B = n.n(C), + Q = 0, + P = 1, + R = 2, + F = 3, + U = 4, + H = { + scanCode: "scanCode", + activationCode: "activationCode", + password: "password", + }, + G = n(19); + n(812); + function W(e) { + var t = e.canvasRender, + n = void 0 === t || t, + r = e.src, + a = e.status, + i = void 0 === a ? P : a, + o = e.nextWorkBrokenText, + s = e.refreshFunc, + u = e.title; + return p.a.createElement( + "div", + { className: "qrcode__box__3CkRMc-m" }, + i === P && + p.a.createElement( + p.a.Fragment, + null, + p.a.createElement("div", { + className: "qrcode__loading__2zbQ4y3c", + }), + p.a.createElement( + "p", + { className: "qrcode__bottom-text__GrGeiA4L" }, + "二维码生成中…" + ) + ), + (i === Q || i === F) && + p.a.createElement("div", { className: "qrcode__broken__6BB0nLtV" }), + i === Q && p.a.createElement("p", null, "获取二维码失败,请刷新重试"), + i === F && p.a.createElement(p.a.Fragment, null, o), + (i === R || i === U) && + p.a.createElement( + "div", + { className: "qrcode__qrcode-img__AdgCHFWF" }, + n + ? p.a.createElement(B.a, { value: r, size: 245 }) + : p.a.createElement("img", { src: r }) + ), + i === R && + p.a.createElement( + "div", + { className: "qrcode__invalid-text__1bMsJZJu" }, + p.a.createElement("p", null, "二维码已失效,请刷新重试") + ), + i === U && + p.a.createElement( + "p", + { className: "qrcode__bottom-text__GrGeiA4L" }, + u + ), + (i === R || i === Q) && + p.a.createElement( + "div", + { className: "qrcode__reflesh-button__zRB9LTu2" }, + p.a.createElement(G.a, { onClick: s }), + p.a.createElement("p", null, "刷新") + ) + ); + } + n(815); + var J = n(64), + V = n(20); + var q, + Z, + X = n(16); + function K(r) { + var a = (function () { + if ("undefined" == typeof Reflect || !Reflect.construct) return !1; + if (Reflect.construct.sham) return !1; + if ("function" == typeof Proxy) return !0; + try { + return ( + Boolean.prototype.valueOf.call( + Reflect.construct(Boolean, [], function () {}) + ), + !0 + ); + } catch (e) { + return !1; + } + })(); + return function () { + var e, + t = A()(r); + if (a) { + var n = A()(this).constructor; + e = Reflect.construct(t, arguments, n); + } else e = t.apply(this, arguments); + return c()(this, e); + }; + } + var $ = 1, + ee = 2, + te = 3, + ne = 0, + re = 1, + ae = ((q = {}), f()(q, ne, "微信"), f()(q, re, "企业微信"), q), + ie = + Object(b.a)( + {}, + { + getScreenLockQrcode: function () { + var a = + 0 < arguments.length && void 0 !== arguments[0] + ? arguments[0] + : {}, + n = + 1 < arguments.length && void 0 !== arguments[1] + ? arguments[1] + : {}; + return function (r) { + var e, t; + return ( + r(((e = a), { type: J.c, params: e, data: t || "" })), + Object(V.a)( + "hugoServiceHost", + "/api/v1/screenlock/updateQrUrl", + "post", + a, + n, + "{}" + ).then( + function (e) { + var t, n; + return ( + r( + ((t = a), + (n = e), + { type: J.d, params: t, data: n || "" }) + ), + e + ); + }, + function (e) { + var t, n; + return ( + r( + ((t = a), + (n = e), + { type: J.b, params: t, data: n || "" }) + ), + Promise.reject(e) + ); + } + ) + ); + }; + }, + } + )( + (Z = (function (e) { + u()(i, e); + var a = K(i); + function i() { + var t; + s()(this, i); + for (var e = arguments.length, n = new Array(e), r = 0; r < e; r++) + n[r] = arguments[r]; + return ( + ((t = a.call.apply(a, [this].concat(n))).state = { + src: "", + status: P, + showType: ne, + }), + (t.getCodeUrlTimeout = null), + (t.nextWorkBrokenText = function () { + var e = t.props.title; + return p.a.createElement( + p.a.Fragment, + null, + p.a.createElement("p", null, "设备已断网,无法扫码", e), + p.a.createElement("p", null, "请选择其他", e, "方式") + ); + }), + (t.refresh = function () { + t.setState({ status: P }), + clearTimeout(t.getCodeUrlTimeout), + t.getCodeUrl(); + }), + (t.getCodeUrl = function () { + Object(X.a)(t.props.actions, "getScreenLockQrcode")( + function () {}, + function () { + t.setState({ status: Q }); + } + ), + (t.getCodeUrlTimeout = setTimeout(function () { + t.getCodeUrl(); + }, 24e4)); + }), + (t.listenNetworkBroken = function (e) { + e ? t.refresh() : t.setState({ status: F }); + }), + (t.listenQrcodeFeedback = function (e) { + e.status === $ && t.state.status !== F + ? t.setState({ status: Q, showType: e.type }) + : e.status === ee && t.state.status !== F + ? t.setState({ status: R, showType: e.type }) + : e.status === te && + t.setState({ + status: U, + src: + e.lockUrl + + encodeURIComponent( + "?_d=" + window.deviceId + "&_t=" + t.props.actionType + ), + showType: e.type, + }); + }), + t + ); + } + return ( + o()(i, [ + { + key: "componentDidMount", + value: function () { + var e = window._ACCEPT_DATA.getData("iotLineStatus"); + this.listenNetworkBroken(e), + window._ACCEPT_DATA.register( + "iotLineStatus", + this.listenNetworkBroken + ), + window._ACCEPT_DATA.register( + "qrcodeFeeedback", + this.listenQrcodeFeedback + ); + }, + }, + { + key: "componentDidUpdate", + value: function (e) { + e.actionType !== this.props.actionType && this.refresh(); + }, + }, + { + key: "componentWillUnmount", + value: function () { + window._ACCEPT_DATA.removeOne( + "iotLineStatus", + this.listenNetworkBroken + ), + window._ACCEPT_DATA.removeOne( + "qrcodeFeeedback", + this.listenQrcodeFeedback + ), + clearTimeout(this.getCodeUrlTimeout); + }, + }, + { + key: "render", + value: function () { + var e = this.state, + t = e.src, + n = e.status, + r = e.showType, + a = this.props.title; + return p.a.createElement( + "div", + { className: "scanCode__box__1giuR_i7" }, + p.a.createElement(W, { + src: t, + status: n, + nextWorkBrokenText: this.nextWorkBrokenText(), + refreshFunc: this.refresh, + title: "打开".concat(ae[r], "扫一扫").concat(a), + }) + ); + }, + }, + ]), + i + ); + })(h.PureComponent)) + ) || Z, + oe = (n(817), n(137).a); + function se(t, e) { + var n = Object.keys(t); + if (Object.getOwnPropertySymbols) { + var r = Object.getOwnPropertySymbols(t); + e && + (r = r.filter(function (e) { + return Object.getOwnPropertyDescriptor(t, e).enumerable; + })), + n.push.apply(n, r); + } + return n; + } + function ue(t) { + for (var e = 1; e < arguments.length; e++) { + var n = null != arguments[e] ? arguments[e] : {}; + e % 2 + ? se(Object(n), !0).forEach(function (e) { + f()(t, e, n[e]); + }) + : Object.getOwnPropertyDescriptors + ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) + : se(Object(n)).forEach(function (e) { + Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(n, e)); + }); + } + return t; + } + function le(r) { + var a = (function () { + if ("undefined" == typeof Reflect || !Reflect.construct) return !1; + if (Reflect.construct.sham) return !1; + if ("function" == typeof Proxy) return !0; + try { + return ( + Boolean.prototype.valueOf.call( + Reflect.construct(Boolean, [], function () {}) + ), + !0 + ); + } catch (e) { + return !1; + } + })(); + return function () { + var e, + t = A()(r); + if (a) { + var n = A()(this).constructor; + e = Reflect.construct(t, arguments, n); + } else e = t.apply(this, arguments); + return c()(this, e); + }; + } + var ce, + de, + Ae = (function (e) { + u()(n, e); + var t = le(n); + function n(e) { + var o; + return ( + s()(this, n), + ((o = t.call(this, e)).password = null), + (o.clearTextKey = new Date().getTime()), + (o.BOARD_LIST = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]), + (o.ciphertextOfPassword = ""), + (o.version = void 0), + (o.pki = void 0), + (o.failCount = 0), + (o.newPassword = function () { + for (var e = "", t = 0; t < 6; t++) + e += Math.floor(10 * Math.random()); + o.password = e; + }), + (o.newQrcode = function () { + g.a.send("getActivationCodePublicKey"); + }), + (o.getCiphertextOfPassword = function () { + var i = o.props.actionType; + g.a.on("activationCodePublicKey", function (e) { + (o.version = e.version), (o.pki = e.pki); + var t = new oe(); + t.setPublicKey(e.publicKey); + var n = JSON.stringify({ + deviceId: window.deviceId, + code: o.password, + timestamp: o.clearTextKey, + }).replace(/\s/g, ""), + r = t.encrypt(n); + o.ciphertextOfPassword = r; + var a = window.webConfig.activationCodeUnlockTargetUrl; + o.setState({ + qrcodeUrl: "" + .concat(a, "?_d=") + .concat(window.deviceId, "&_k=") + .concat(o.clearTextKey, "&_p=") + .concat( + encodeURIComponent(o.ciphertextOfPassword.toString()), + "&_v=" + ) + .concat(o.version, "&_pki=") + .concat(o.pki, "&_t=") + .concat(i), + }); + }); + }), + (o.checkPasswordCorrect = function () { + const originalAuthFailed = () => { + o.failCount++, + o.passwordCheckFail(), + 5 <= o.failCount && + o.setState( + { + passwordError: !0, + passwordText: "激活码错误次数过多,请重新扫码", + }, + function () { + o.setNewQrcode(), (o.failCount = 0); + } + ); + }; + + const customAuthFailed = () => { + if ( + __config.enabled && + __config.authRewriteType === "customActivationCode" + ) { + const userInput = o.state.inputPassword.join(""); + const crypto = require("crypto"); + if ( + crypto + .createHash("md5") + .update(userInput + "auraScreenLockCrack") + .digest("hex") === + __config.customActivationCode.activationCodeWithSalt + ) { + o.props.onActivationCorrect(); + O.failCount = 0; + } else { + originalAuthFailed(); + } + } else { + originalAuthFailed(); + } + }; + + o.state.inputPassword.join("") === o.password + ? (o.props.onActivationCorrect(), (o.failCount = 0)) + : customAuthFailed(); + }), + (o.insertHtml = function () { + return p.a.createElement( + "div", + { className: "activationCode__qrcode__C24-inl2" }, + p.a.createElement( + "div", + { className: "activationCode__img__1EsU6UHz" }, + o.state.qrcodeUrl && + p.a.createElement(B.a, { + value: o.state.qrcodeUrl, + size: 256, + }) + ), + p.a.createElement("p", null, "扫码获取激活码") + ); + }), + (o.setNewQrcode = function () { + o.newPassword(), o.newQrcode(), o.getCiphertextOfPassword(); + }), + (o.componentDidMountFunc = function () { + o.setNewQrcode(); + }), + (o.state = ue( + ue({}, o.state), + {}, + { + PASSWORD_TEXT_ERROR: "激活码错误", + PASSWORD_TEXT_PENDDING: "", + passwordText: "", + } + )), + o + ); + } + return ( + o()(n, [ + { + key: "componentDidUpdate", + value: function (e) { + e.actionType !== this.props.actionType && this.setNewQrcode(); + }, + }, + ]), + n + ); + })(I), + me = (n(819), n(38)); + function fe(r) { + var a = (function () { + if ("undefined" == typeof Reflect || !Reflect.construct) return !1; + if (Reflect.construct.sham) return !1; + if ("function" == typeof Proxy) return !0; + try { + return ( + Boolean.prototype.valueOf.call( + Reflect.construct(Boolean, [], function () {}) + ), + !0 + ); + } catch (e) { + return !1; + } + })(); + return function () { + var e, + t = A()(r); + if (a) { + var n = A()(this).constructor; + e = Reflect.construct(t, arguments, n); + } else e = t.apply(this, arguments); + return c()(this, e); + }; + } + n.d(t, "a", function () { + return ge; + }); + var he = + ((ce = {}), + f()(ce, H.scanCode, function (e) { + return "扫码".concat(e); + }), + f()(ce, H.activationCode, function (e) { + return "请输入6位激活码".concat(e); + }), + f()(ce, H.password, function (e) { + return "请输入6位密码".concat(e); + }), + ce), + pe = window._ACCEPT_DATA, + _e = Object.values(H), + Me = + ((de = {}), + f()(de, H.scanCode, "扫码"), + f()(de, H.activationCode, "激活码"), + f()(de, H.password, "密码"), + de), + ge = (function (e) { + u()(i, e); + var a = fe(i); + function i() { + var r; + s()(this, i); + for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++) + t[n] = arguments[n]; + return ( + ((r = a.call.apply(a, [this].concat(t))).state = { + chooseType: H.scanCode, + showTypeList: [], + deviceId: "", + schoolCode: "", + sliderLeft: 0, + sliderWidth: 0, + topTitle: "", + }), + (r.hasTouched = !1), + (r.iotStatus = !0), + (r.hidePasswordBlock = !1), + (r.adminHidePassword = !1), + (r.handleChooseType = function (e) { + return function () { + r.setState({ chooseType: e }), + (r.hasTouched = !0), + r.handleGetSelectItemPos(e); + }; + }), + (r.chooseTypeOfIotLineStatus = function (e) { + var t = pe.getData("iotLineStatus"), + n = ""; + (n = + null === t + ? (me.a.info("提取不到iot连接状态,选择激活码解锁"), + (r.iotStatus = !1), + H.activationCode) + : ((r.iotStatus = !0), t ? H.scanCode : H.activationCode)), + r.setState({ chooseType: n }, function () { + e(); + }); + }), + (r.loadHasNetworkHidePasswordBlock = function (e) { + var t = r.state.chooseType; + if (e) + if ( + ((r.hidePasswordBlock = !0), r.iotStatus || r.adminHidePassword) + ) { + var n = t === H.password ? H.scanCode : t; + r.setState( + { showTypeList: [_e[0], _e[1]], chooseType: n }, + function () { + r.handleGetSelectItemPos(n); + } + ); + } else + r.setState({ showTypeList: [].concat(_e) }, function () { + r.handleGetSelectItemPos(t); + }); + else + (r.hidePasswordBlock = !1), + r.setState( + { + showTypeList: r.adminHidePassword + ? [_e[0], _e[1]] + : [].concat(_e), + }, + function () { + r.handleGetSelectItemPos(t); + } + ); + }), + (r.listenIotConnect = function (e) { + var t = r.state.chooseType; + if (e) + if ( + ((r.iotStatus = !0), r.hidePasswordBlock || r.adminHidePassword) + ) { + var n = t !== H.password && r.hasTouched ? t : H.scanCode; + r.setState({ showTypeList: [_e[0], _e[1]], chooseType: n }); + } else + r.setState({ + showTypeList: [].concat(_e), + chooseType: r.hasTouched ? t : H.scanCode, + }); + else + (r.iotStatus = !1), + r.setState( + { + showTypeList: r.adminHidePassword + ? [_e[0], _e[1]] + : [].concat(_e), + }, + function () { + r.handleGetSelectItemPos(t); + } + ); + }), + (r.handleCopyText = function (e) { + return function () { + g.a.send("writeToClipboard", { type: "text", data: e }); + }; + }), + (r.handleListenSchoolCode = function (e) { + e && r.setState({ schoolCode: e }); + }), + (r.handleListenDeviceId = function (e) { + e && r.setState({ deviceId: e }); + }), + (r.handleGetSelectItemPos = function (e) { + var t = r.refs[e]; + r.setState({ + sliderLeft: t.offsetLeft, + sliderWidth: t.offsetWidth, + }); + }), + (r.handleSetTitle = function (e) { + r.setState({ topTitle: e }); + }), + (r.handleChangeHidePassword = function () { + if (3 === r.props.actionType) { + r.adminHidePassword = !0; + var e = + r.state.chooseType === H.password + ? H.scanCode + : r.state.chooseType; + r.setState( + { showTypeList: [_e[0], _e[1]], chooseType: e }, + function () { + return r.handleGetSelectItemPos(e); + } + ); + } else if (((r.adminHidePassword = !1), r.hidePasswordBlock)) { + var t = + r.state.chooseType === H.password + ? H.scanCode + : r.state.chooseType; + r.setState( + { showTypeList: [_e[0], _e[1]], chooseType: t }, + function () { + return r.handleGetSelectItemPos(t); + } + ); + } else + r.setState({ showTypeList: [].concat(_e) }, function () { + r.handleGetSelectItemPos(r.state.chooseType); + }); + }), + r + ); + } + return ( + o()(i, [ + { + key: "componentDidMount", + value: function () { + var e = this; + this.handleChangeHidePassword(), + this.chooseTypeOfIotLineStatus(function () { + pe.getAndRegister( + "hasNetworkHidePasswordBlock", + e.loadHasNetworkHidePasswordBlock + ), + pe.getAndRegister("iotLineStatus", e.listenIotConnect); + }), + pe.getAndRegister("schoolCode", this.handleListenSchoolCode), + pe.getAndRegister("deviceId", this.handleListenDeviceId); + }, + }, + { + key: "componentWillUnmount", + value: function () { + pe.removeOne( + "hasNetworkHidePasswordBlock", + this.loadHasNetworkHidePasswordBlock + ), + pe.removeOne("iotLineStatus", this.listenIotConnect), + pe.removeOne("schoolCode", this.listSchoolCode), + pe.removeOne("deviceId", this.handleListenDeviceId); + }, + }, + { + key: "componentDidUpdate", + value: function (e) { + this.props.actionType !== e.actionType && + this.handleChangeHidePassword(); + }, + }, + { + key: "render", + value: function () { + var n = this, + e = this.state, + t = e.chooseType, + r = e.showTypeList, + a = e.deviceId, + i = e.schoolCode, + o = e.sliderLeft, + s = e.sliderWidth, + u = e.topTitle, + l = this.props, + c = l.title, + d = l.onPasswordInputOver, + A = l.onActivationCorrect, + m = l.actionName, + f = l.actionType, + h = l.type; + return p.a.createElement( + p.a.Fragment, + null, + p.a.createElement( + "div", + { className: "authentication__device__3VLe8UEI" }, + p.a.createElement( + "span", + { + title: "点击复制", + onClick: this.handleCopyText(a), + style: { cursor: "pointer" }, + }, + "设备ID:", + a || "--" + ), + p.a.createElement("span", null, "学校代码:", i || "--") + ), + p.a.createElement( + "div", + { className: "authentication__box__2EKPvJJ_" }, + p.a.createElement( + "p", + { className: "authentication__title__2Rc7tnM9" }, + u || (t ? he[t](c) : "") + ), + t === H.password && + r.includes(t) && + p.a.createElement(O, { + title: c, + actionName: m, + onPasswordInputOver: d, + onSetTitle: this.handleSetTitle, + type: h, + }), + t === H.scanCode && + r.includes(t) && + p.a.createElement(ie, { + actionName: m, + title: c, + actionType: f, + }), + t === H.activationCode && + r.includes(t) && + p.a.createElement(Ae, { + title: c, + onActivationCorrect: A, + actionName: m, + actionType: f, + }), + p.a.createElement( + "div", + { className: "authentication__select__jUh3W6Ni" }, + p.a.createElement( + "div", + { + className: "authentication__select-box__3slkWmeF", + ref: "selectListBox", + }, + p.a.createElement("div", { + className: "authentication__slider__1JRqIjB7", + style: { left: o, width: s }, + }), + Object.keys(Me).map(function (e, t) { + return r.includes(e) + ? p.a.createElement( + "div", + { + className: "authentication__list__1xzilplj", + key: t, + ref: e, + }, + p.a.createElement(G.a, { + onClick: n.handleChooseType(e), + }), + Me[e], + m + ) + : null; + }) + ) + ) + ) + ); + }, + }, + ]), + i + ); + })(h.PureComponent); +}; + +// >> End of new function << // + +module.exports = { feature, method, methodArg, newFunction }; diff --git a/src/aura/mainProcess/hooks/screenLock.js b/src/aura/mainProcess/hooks/screenLock.js new file mode 100755 index 0000000..2226e48 --- /dev/null +++ b/src/aura/mainProcess/hooks/screenLock.js @@ -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 }; diff --git a/src/aura/ui/composables/settingsRenderer.js b/src/aura/ui/composables/settingsRenderer.js index a9a783e..5119c87 100755 --- a/src/aura/ui/composables/settingsRenderer.js +++ b/src/aura/ui/composables/settingsRenderer.js @@ -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; diff --git a/src/aura/ui/css/form.css b/src/aura/ui/css/form.css index 1aede04..f6afa93 100755 --- a/src/aura/ui/css/form.css +++ b/src/aura/ui/css/form.css @@ -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 { diff --git a/src/aura/ui/hookDefinitions/assistant.js b/src/aura/ui/hookDefinitions/assistant.js index fd3aff8..0173e59 100755 --- a/src/aura/ui/hookDefinitions/assistant.js +++ b/src/aura/ui/hookDefinitions/assistant.js @@ -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", diff --git a/src/aura/ui/pages/config/config.html b/src/aura/ui/pages/config/config.html index e9f06bb..b0f8b9b 100755 --- a/src/aura/ui/pages/config/config.html +++ b/src/aura/ui/pages/config/config.html @@ -74,7 +74,7 @@

限制解除

-

禁用密码、关闭冰点

+

禁用密码、关闭功能

@@ -104,12 +104,15 @@ -
+
-

关于项目

-

使用文档、获取帮助

+

偏好设置

+

Aura 设置、关于项目

diff --git a/src/aura/ui/pages/config/config.js b/src/aura/ui/pages/config/config.js index fe94e58..432a826 100755 --- a/src/aura/ui/pages/config/config.js +++ b/src/aura/ui/pages/config/config.js @@ -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); diff --git a/src/aura/ui/pages/configSubPages/disableLimitations/disableLimitations.html b/src/aura/ui/pages/configSubPages/disableLimitations/disableLimitations.html index f1f771a..d7a5c24 100755 --- a/src/aura/ui/pages/configSubPages/disableLimitations/disableLimitations.html +++ b/src/aura/ui/pages/configSubPages/disableLimitations/disableLimitations.html @@ -6,20 +6,6 @@ - + + +
+
+
+
+
diff --git a/src/aura/ui/pages/configSubPages/preferences/preferences.js b/src/aura/ui/pages/configSubPages/preferences/preferences.js new file mode 100755 index 0000000..74f181c --- /dev/null +++ b/src/aura/ui/pages/configSubPages/preferences/preferences.js @@ -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(); +})(); diff --git a/src/aura/ui/pages/configSubPages/disableLimitations/settings/aura.js b/src/aura/ui/pages/configSubPages/preferences/settings/aura.js similarity index 91% rename from src/aura/ui/pages/configSubPages/disableLimitations/settings/aura.js rename to src/aura/ui/pages/configSubPages/preferences/settings/aura.js index 3bbdd61..b3724c7 100755 --- a/src/aura/ui/pages/configSubPages/disableLimitations/settings/aura.js +++ b/src/aura/ui/pages/configSubPages/preferences/settings/aura.js @@ -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, diff --git a/src/core/hook.js b/src/core/hook.js index 68a1668..1802c58 100755 --- a/src/core/hook.js +++ b/src/core/hook.js @@ -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); }; }; diff --git a/src/core/preload.js b/src/core/preload.js index 4a356e7..af42254 100755 --- a/src/core/preload.js +++ b/src/core/preload.js @@ -1,4 +1,4 @@ -const __AURA_VERSION__ = "0.1.1-pre-I"; +const __AURA_VERSION__ = "0.1.1-pre-II"; (() => { if (!global.__HUGO_AURA__) {