[Init] First production version

This commit is contained in:
Minoricew
2024-11-28 01:47:04 +08:00
parent fd0eb0c0c4
commit d976184e42
27 changed files with 2707 additions and 0 deletions

View File

@@ -0,0 +1,135 @@
const fs = require("fs");
const path = require("path");
class HooksManager {
loadHooks() {
if (global.__HUGO_AURA__.hooks) {
return global.__HUGO_AURA__.hooks;
}
const hooksPath = path.join(__dirname, "../../../aura/ui/hooks");
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));
const targetWindow = hook.windowName || path.basename(file, ".js");
hooks.set(targetWindow, hook);
console.log(
`[HugoAura / Init] Loaded hook for window: ${targetWindow}`
);
} catch (err) {
console.error(
`[HugoAura / Init / Error] Failed to load hook ${file}:`,
err
);
}
});
} catch (err) {
console.error(
"[HugoAura / Init / Error] Failed to read hooks directory:",
err
);
}
global.__HUGO_AURA__.hooks = hooks;
return hooks;
}
cleanupWindow(windowKey, listeners) {
console.log(
`[HugoAura / Cleanup / ${windowKey}] Window destroyed, cleaning up...`
);
if (listeners) {
const { webContents, domReadyListener, destroyedListener } = listeners;
webContents.removeListener("dom-ready", domReadyListener);
webContents.removeListener("destroyed", destroyedListener);
}
global.__HUGO_AURA__.hookedWindows.delete(windowKey);
}
handleWindowHook(webContents, hookConfig, windowName) {
if (!hookConfig) return;
const windowKey = `${hookConfig.windowName || windowName}`;
if (global.__HUGO_AURA__.hookedWindows.has(windowKey)) {
console.log(
`[HugoAura / Init] Duplicate hook for ${windowKey}, ignoring...`
);
return;
}
console.log(`[HugoAura / Init] Hook is initializing for ${windowKey}...`);
console.log(
`[HugoAura / Init] Hook loaded at: ${new Date().toISOString()}`
);
const domReadyListener = () => {
try {
console.log(
`[HugoAura / UI / Verb / ${windowKey}] Loading injection script...`
);
const injectionScript = fs
.readFileSync(path.join(__dirname, "./injection.js"), "utf8")
.replace('"__TEMPLATE_TARGETS__"', JSON.stringify(hookConfig.targets))
.replace(
'"__TEMPLATE_GLOBAL_STYLES__"',
JSON.stringify(hookConfig.globalStyles || [])
)
.replace(
'"__TEMPLATE_GLOBAL_JS__"',
JSON.stringify(hookConfig.globalJS || [])
)
.replace("__TEMPLATE_ON_LOADED__", hookConfig.onLoaded || "");
webContents
.executeJavaScript(injectionScript, true)
.then(() =>
console.log(
`[HugoAura / UI / Done / ${windowKey}] Injection script executed`
)
)
.catch((err) =>
console.error(
`[HugoAura / UI / Error / ${windowKey}] Failed to execute injection script:`,
err
)
);
} catch (err) {
console.error(
`[HugoAura / UI / Error / ${windowKey}] Failed to load UI hook:`,
err
);
}
};
const destroyedListener = () => {
this.cleanupWindow(
windowKey,
global.__HUGO_AURA__.hookedWindows.get(windowKey)
);
};
webContents.on("dom-ready", domReadyListener);
webContents.on("destroyed", destroyedListener);
global.__HUGO_AURA__.hookedWindows.set(windowKey, {
webContents,
domReadyListener,
destroyedListener,
});
console.log(
`[HugoAura / Init / Success / ${windowKey}] Hook initialized successfully!`
);
}
}
module.exports = HooksManager;

View File

@@ -0,0 +1,337 @@
(() => {
const waitForElement = (selector, timeout = 5000) => {
return new Promise((resolve, reject) => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}
const observer = new MutationObserver((mutations) => {
if (document.querySelector(selector)) {
observer.disconnect();
resolve(document.querySelector(selector));
}
});
observer.observe(document.body, {
childList: true,
subtree: true,
});
setTimeout(() => {
observer.disconnect();
reject("[HugoAura / UI / Injection] Timeout waiting for element");
}, timeout);
});
};
const createStore = () => {
const store = {
router: "/",
};
const internal = {
get: (key) => store[key],
set: (key, value) => {
store[key] = value;
return true;
},
};
window.$store = {
get: (key) => {
const stack = new Error().stack;
if (stack.includes("aura/ui/pages/")) {
return internal.get(key);
}
return undefined;
},
set: (key, value) => {
const stack = new Error().stack;
if (stack.includes("aura/ui/pages/")) {
return internal.set(key, value);
}
return false;
},
};
return internal;
};
const store = createStore();
const createUILoader = () => {
const modules = "__TEMPLATE_TARGETS__";
const containers = new Map();
const observers = new Map();
const moduleResources = new Map();
const globalScripts = new Set();
const insertElement = (target, element, mode = "appendChild") => {
const elementId = element.id;
if (document.getElementById(elementId)) {
console.log(
`[HugoAura / UI / Warning] Element ${elementId} already exists, skipping insertion`
);
return;
}
switch (mode) {
case "insertBefore":
target.parentNode.insertBefore(element, target);
break;
case "insertAfter":
target.parentNode.insertBefore(element, target.nextSibling);
break;
case "appendChild":
default:
target.appendChild(element);
}
};
const loadGlobalJS = async () => {
const scripts = "__TEMPLATE_GLOBAL_JS__";
for (const scriptPath of scripts) {
try {
const script = document.createElement("script");
script.src = `../../aura/${scriptPath}`;
document.body.appendChild(script);
globalScripts.add(script);
await new Promise((resolve, reject) => {
script.onload = resolve;
script.onerror = reject;
});
console.log(
`[HugoAura / UI / Global] Loaded global script: ${scriptPath}`
);
} catch (err) {
console.error(
`[HugoAura / UI / Error] Failed to load global script ${scriptPath}:`,
err
);
}
}
};
const monitorParent = (moduleKey, target, _mode) => {
if (observers.has(moduleKey)) {
observers.get(moduleKey).disconnect();
}
const elementId = `aura-container-${moduleKey.replace(/\./g, "-")}`;
const observer = new MutationObserver((_mutations) => {
if (!document.getElementById(elementId)) {
let targetElement = document.querySelector(
modules[moduleKey].pageSelector
);
if (
targetElement &&
modules[moduleKey].active &&
modules[moduleKey].revive
) {
if (!document.getElementById(elementId)) {
console.log(
`[HugoAura / UI / Revival] Reviving module ${moduleKey}`
);
this.loadModule(moduleKey, true);
}
}
}
});
observer.observe(target.parentNode, {
childList: true,
subtree: false,
});
observers.set(moduleKey, observer);
};
const loader = {
async loadModule(moduleKey, isRevive = false) {
if (!modules[moduleKey]?.active) return;
try {
const config = modules[moduleKey];
const target = await waitForElement(config.pageSelector);
const elementId = `aura-container-${moduleKey.replace(/\./g, "-")}`;
if (document.getElementById(elementId)) {
console.log(
`[HugoAura / UI / Warning] Module ${moduleKey} already loaded, skipping`
);
return;
}
const container = document.createElement("div");
container.id = elementId;
containers.set(moduleKey, container);
const resources = new Set();
moduleResources.set(moduleKey, resources);
if (config.pageCSS && !isRevive) {
const link = document.createElement("link");
link.rel = "stylesheet";
link.href = `../../aura/${config.pageCSS}`;
document.head.appendChild(link);
resources.add(link);
}
const html = await fetch(`../../aura/${config.pageURI}`).then((r) =>
r.text()
);
container.innerHTML = html;
insertElement(target, container, config.selectorMode);
monitorParent(moduleKey, target, container, config.selectorMode);
if (config.pageScript && !isRevive) {
const script = document.createElement("script");
script.src = `../../aura/${config.pageScript}`;
document.body.appendChild(script);
resources.add(script);
}
const observer = new MutationObserver(() => {
if (
!document.contains(container) &&
modules[moduleKey].active &&
modules[moduleKey].revive
) {
this.loadModule(moduleKey, true);
}
});
observer.observe(document.body, {
childList: true,
subtree: true,
});
observers.set(moduleKey, observer);
} catch (err) {
console.error(
`[HugoAura / UI / Error] Failed to load module ${moduleKey}:`,
err
);
}
},
unloadModule(moduleKey) {
const container = containers.get(moduleKey);
const observer = observers.get(moduleKey);
const resources = moduleResources.get(moduleKey);
if (observer) {
observer.disconnect();
observers.delete(moduleKey);
}
if (container) {
container.remove();
containers.delete(moduleKey);
}
if (resources) {
resources.forEach((element) => element.remove());
moduleResources.delete(moduleKey);
}
},
handleModuleChange(moduleKey, path = []) {
const fullPath = [...path, moduleKey].join(".");
if (path.length === 0 && modules[moduleKey].active) {
this.loadModule(moduleKey);
} else if (path.length === 0) {
this.unloadModule(moduleKey);
} else {
if (moduleKey === "active") {
if (modules[path[0]].active) {
this.loadModule(path[0]);
} else {
this.unloadModule(path[0]);
}
} else {
this.unloadModule(path[0]);
this.loadModule(path[0]);
}
}
},
};
const createDeepProxy = (target, handler, path = []) => {
return new Proxy(target, {
get(target, prop) {
const value = Reflect.get(target, prop);
if (typeof value === "object" && value !== null) {
return createDeepProxy(value, handler, [...path, prop]);
}
return value;
},
set(target, prop, value) {
console.debug(
`[HugoAura / UI / Debug] Setting property: ${[...path, prop].join(
"."
)}`
);
const result = Reflect.set(target, prop, value);
if (result) {
handler([...path], prop, value);
}
return result;
},
deleteProperty(target, prop) {
console.debug(
`[HugoAura / UI / Debug] Deleting property: ${[...path, prop].join(
"."
)}`
);
const result = Reflect.deleteProperty(target, prop);
if (result) {
handler([...path], prop, undefined);
}
return result;
},
});
};
const initialLoad = async () => {
try {
await loadGlobalJS();
for (const [key, config] of Object.entries(modules)) {
if (config.active) {
await loader.loadModule(key);
}
}
} catch (err) {
console.error("[HugoAura / UI / Error] Initial load failed:", err);
}
};
initialLoad();
return createDeepProxy(modules, (path, prop, value) => {
loader.handleModuleChange(prop, path);
});
};
window.__HUGO_AURA_LOADER__ = createUILoader();
const loadGlobalStyles = async () => {
const styles = "__TEMPLATE_GLOBAL_STYLES__";
styles.forEach((style) => {
const link = document.createElement("link");
link.rel = "stylesheet";
link.href = `../../aura/${style}`;
document.head.appendChild(link);
});
};
const init = async () => {
await loadGlobalStyles();
__TEMPLATE_ON_LOADED__;
};
init().catch((err) =>
console.error("[HugoAura / UI / Error] Initialization failed:", err)
);
})();

View File

@@ -0,0 +1,141 @@
const path = require('path');
class WebpackHook {
#ruleCache = new Map();
loadRewriteRules(config) {
const rewriteConfig = config.rewrite || {};
const rules = [];
Object.entries(rewriteConfig).forEach(([rulePath, ruleConfig]) => {
if (this.#ruleCache.has(rulePath) && !ruleConfig.enabled) {
console.log(`[HugoAura / AppHook] Skipping disabled rule: ${rulePath}`);
return;
}
try {
let rule = this.#ruleCache.get(rulePath);
if (!rule) {
rule = require(path.join(
__dirname,
'../../../aura/jsRewrite/',
rulePath
));
this.#ruleCache.set(rulePath, rule);
}
if (ruleConfig.enabled) {
rules.push({
id: rulePath,
feature: rule.feature,
method: rule.method,
methodArg: rule.methodArg,
preHook: rule.preHook || null,
newFunction: rule.newFunction,
});
console.log(`[HugoAura / AppHook] Loaded rule: ${rulePath}`);
}
} catch (err) {
console.error(
`[HugoAura / AppHook] Failed to load rule ${rulePath}:`,
err
);
}
});
return rules;
}
patchModules(modules, rewrites) {
modules.forEach((mod, index) => {
if (typeof mod !== 'function') return;
const stringifyFunc = mod.toString();
rewrites.forEach((rewrite) => {
const ruleId = rewrite.id;
const method = rewrite.method;
try {
if (eval(`(stringifyFunc) => ${rewrite.feature}`)(stringifyFunc)) {
console.log(
`[HugoAura / AppHook] Found target function for rule ${ruleId} at index ${index}, engaging hook...`
);
console.log(`[HugoAura / AppHook] Using hook method: ${method}`);
let rewrittenFunction = mod;
switch (method) {
case 'reactComponent':
window.__HUGO_AURA_HOOK__[ruleId] = {
feature: rewrite.feature,
newFunction: rewrite.newFunction
}
rewrittenFunction = rewrite.preHook(mod);
break;
case 'legacy':
default:
rewrittenFunction = rewrite.newFunction;
break;
}
modules[index] = rewrittenFunction;
console.log(
`[HugoAura / AppHook] Successfully patched function for rule ${ruleId}`
);
}
} catch (err) {
console.error(
`[HugoAura / AppHook] Error evaluating feature for rule ${ruleId}:`,
err
);
}
});
});
if (typeof window !== 'undefined') {
window.__HUGO_AURA_DEBUG__ = {
getRuleCache: () => Array.from(this.#ruleCache.keys()),
};
}
}
installHook(window, config) {
let realWebpackJsonp = window.webpackJsonp;
Object.defineProperty(window, 'webpackJsonp', {
get: () => realWebpackJsonp,
set: (value) => {
console.log(
`[HugoAura / AppHook] Intercepted webpackJsonp initialization`
);
if (!realWebpackJsonp && Array.isArray(value)) {
const originalPush = value.push.bind(value);
value.push = (...args) => {
if (args[0] && Array.isArray(args[0][1])) {
const [chunkIds, modules] = args[0];
console.log(
`[HugoAura / AppHook] Intercepting chunk ${chunkIds.join(', ')}`
);
const rewrites = this.loadRewriteRules(config);
if (rewrites.length > 0) {
this.patchModules(modules, rewrites);
}
}
return originalPush.apply(value, args);
};
}
realWebpackJsonp = value;
},
configurable: true,
});
}
}
module.exports = WebpackHook;

View File

@@ -0,0 +1,137 @@
const fs = require('fs');
const path = require('path');
const os = require('os');
const deepMerge = (target, source) => {
const result = JSON.parse(JSON.stringify(target));
if (!source || typeof source !== 'object') {
return {};
}
const keysToDelete = [];
Object.keys(result).forEach((key) => {
if (!(key in source)) {
keysToDelete.push(key);
} else if (
typeof result[key] === 'object' &&
result[key] !== null &&
typeof source[key] === 'object' &&
source[key] !== null
) {
result[key] = deepMerge(result[key], source[key]);
if (Object.keys(result[key]).length === 0) {
keysToDelete.push(key);
}
}
});
keysToDelete.forEach((key) => {
delete result[key];
});
Object.keys(source).forEach((key) => {
if (!(key in result)) {
result[key] = JSON.parse(JSON.stringify(source[key]));
}
});
return result;
};
class ConfigManager {
constructor() {
this.configPath = path.join(
os.homedir(),
'Documents',
'HugoAura',
'config.json'
);
this.defaultConfigPath = path.join(__dirname, 'default.json');
}
getHugoAuraConfigPath() {
return path.dirname(this.configPath);
}
getConfigPath() {
return this.configPath;
}
getDefaultConfig() {
try {
return JSON.parse(fs.readFileSync(this.defaultConfigPath, 'utf8'));
} catch (err) {
console.warn(
'[HugoAura / Config] No default config found, using empty config'
);
return { rewrite: {} };
}
}
ensureConfigExists() {
if (global.__HUGO_AURA__.configInit) return;
const hugoAuraPath = this.getHugoAuraConfigPath();
if (!fs.existsSync(hugoAuraPath)) {
console.log('[HugoAura / Config] Creating HugoAura directory');
fs.mkdirSync(hugoAuraPath, { recursive: true });
}
if (!fs.existsSync(this.configPath)) {
console.log('[HugoAura / Config] Creating default config file');
const defaultConfig = this.getDefaultConfig();
this.writeConfig(defaultConfig);
}
}
readConfig() {
try {
const config = JSON.parse(fs.readFileSync(this.configPath, 'utf8'));
console.log('[HugoAura / Config] Successfully loaded config:', config);
return config;
} catch (err) {
console.error('[HugoAura / Config] Failed to read config:', err);
return this.getDefaultConfig();
}
}
writeConfig(config) {
try {
fs.writeFileSync(
this.configPath,
JSON.stringify(config, null, 2),
'utf8'
);
return true;
} catch (err) {
console.error('[HugoAura / Config] Failed to write config:', err);
return false;
}
}
loadConfig() {
let defaultConfig = this.getDefaultConfig();
let config = {};
try {
if (fs.existsSync(this.configPath)) {
const userConfig = JSON.parse(fs.readFileSync(this.configPath, 'utf8'));
if (global.__HUGO_AURA__.configInit) {
config = userConfig;
return userConfig;
} else {
config = deepMerge(userConfig, defaultConfig);
console.log('[HugoAura / Config] Merged with user config');
this.writeConfig(config);
}
}
} catch (err) {
console.error('[HugoAura / Config] Failed to load user config:', err);
config = defaultConfig;
}
return config;
}
}
module.exports = new ConfigManager();

View File

@@ -0,0 +1,13 @@
{
"rewrite": {
"vendor/passwordValidation": {
"enabled": true,
"type": "customPassword",
"customPassword": {
"passwordWithSalt": "770f27b0379ee6ba0f11731e49aa7af1",
"salt": "aura"
}
}
},
"devTools": false
}

View File

@@ -0,0 +1,716 @@
/// Rewrite rules basic config section begins ///
const feature = `['密码错误', 'a.handleListenPasswordValidation'].every(str => stringifyFunc.includes(str))`;
const method = "legacy";
const methodArg = "";
const __config =
window.__HUGO_AURA_CONFIG__.rewrite["vendor/passwordValidation"];
/// End of the rewrite rules basic config section ///
const newFunction = function (e, t, b) {
"use strict";
var n,
r = b(3),
o = b.n(r),
a = b(4),
s = b.n(a),
i = b(5),
u = b.n(i),
l = b(6),
c = b.n(l),
d = b(2),
A = b.n(d),
m = b(8),
f = b.n(m),
y = b(0),
v = b.n(y),
h = b(35),
p = b(9),
_ = b(14),
M = b(44),
g = b(22),
w = (b(432), b(7)),
D = b(17),
T = b.n(D),
j = b(10),
E = b.n(j),
I = b(39),
N = b(40),
z = b(19),
Y = b(78),
L = b.n(Y);
b(444);
var x,
k = 2,
S = 0,
O = 1,
C = 3,
B = 4,
Q =
((n = {}),
E()(n, B, "加载失败"),
E()(n, S, "二维码已失效"),
E()(n, k, "网络异常"),
n),
P = window._ACCEPT_DATA,
R = function (n) {
function t() {
clearTimeout(M.current),
(_.current = !0),
A(C),
Object(I.a)(N.a.GetCommonQrcode, { type: n.qrcodeType })
.then(function () {
A(C);
})
.catch(function () {
A(B), (_.current = !1);
}),
(M.current = setTimeout(function () {
(_.current = !1), A(B);
}, 1e4));
}
function e(e) {
if ((clearTimeout(M.current), e && e.type === n.qrcodeType)) {
if (e.status === S && g.current && g.current === e.qrKey)
return void A(e.status);
_.current = !1;
var t = ""
.concat(e.qrCode)
.concat(
encodeURIComponent(
"?_d=" +
window.deviceId +
"&_t=" +
n.qrcodeType +
"&_k=" +
e.qrKey +
(n.qrcodeExtraParams || "")
)
);
u(t), A(e.status), (g.current = e.qrKey);
}
}
function r(e) {
e &&
e.type === n.qrcodeType &&
e.qrKey === g.current &&
(e.auth ? (p(!0), n.onSuccess()) : t());
}
function a(e) {
A(
e
? function (e) {
return e === k && t(), e;
}
: k
);
}
var i = Object(y.useState)(""),
o = T()(i, 2),
s = o[0],
u = o[1],
l = Object(y.useState)(C),
c = T()(l, 2),
d = c[0],
A = c[1],
m = Object(y.useState)(!1),
f = T()(m, 2),
h = f[0],
p = f[1],
_ = Object(y.useRef)(!1),
M = Object(y.useRef)(null),
g = Object(y.useRef)(null);
return (
Object(y.useEffect)(function () {
return (
setTimeout(function () {
t();
}, 300),
P.register("COMMON_QRCODE_MESSAGE", e),
P.register("COMMON_QRCODE_RESULT", r),
P.register("iotLineStatus", a),
function () {
P.removeOne("COMMON_QRCODE_MESSAGE", e),
P.removeOne("COMMON_QRCODE_RESULT", r),
P.removeOne("iotLineStatus", a),
clearTimeout(M.current);
}
);
}, []),
v.a.createElement(
"div",
{ className: "index__box__3JK51ZMl" },
!h &&
v.a.createElement(
v.a.Fragment,
null,
d === C &&
v.a.createElement(
v.a.Fragment,
null,
v.a.createElement("div", {
className: "index__loading__3_GiKxR_",
})
),
d !== C &&
v.a.createElement(
"div",
{ className: "index__qrcode-img__1adCa8NJ" },
s
? v.a.createElement(L.a, {
value: s,
size: n.width || null,
})
: v.a.createElement("img", { src: b(447) })
),
d !== C &&
d !== O &&
v.a.createElement(
"div",
{ className: "index__load-fail__1TIfNnFd" },
v.a.createElement("p", null, Q[d]),
v.a.createElement(
"div",
{ className: "index__button__3SamV-90" },
v.a.createElement(z.a, { onClick: t }),
v.a.createElement("p", null, "点击刷新")
)
)
),
h &&
v.a.createElement(
"div",
{ className: "index__auth-success__1GR7L6Hm" },
v.a.createElement("p", null, "验证成功")
)
)
);
};
R = Object(y.memo)(R);
var F = {
"./index.less": {
"switch-type": "index__switch-type__1bkrQETQ",
input: "index__input__YXt6XKsv",
qrcode: "index__qrcode__YrKbWSHE",
"switch-btn": "index__switch-btn__11ZSw-Jw",
tab: "index__tab__5k53HIze",
slider: "index__slider__28g3VRJ6",
"qrcode-part": "index__qrcode-part__2WtgyjIC",
"input-part": "index__input-part__2PR-hnsC",
"input-title": "index__input-title__9XqNf8nj",
"main-title": "index__main-title__x6jJf0zc",
"sub-title": "index__sub-title__1W-OhMcw",
title: "index__title__3J7l6UDi",
close: "index__close__mUeIwYJs",
password: "index__password__nbpOESix",
error: "index__error__YPcLYmaS",
normal: "index__normal__1xpAxvig",
failure: "index__failure__1pin0osM",
default: "index__default__3kXpszYw",
forbid: "index__forbid__Lafq9LNO",
forbidden: "index__forbidden__1zUAyYjv",
"error-text": "index__error-text__1vxztMbo",
"button-confirm": "index__button-confirm__3yzKJeaI",
},
};
function U(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 H = "passwordSuccess",
G = "passwordFail",
W = "requestLimit",
J = "requestError",
V = window._ACCEPT_DATA,
q = "ADMIN_LOCK",
Z = "PASSWORD_INPUT",
X = "QRCODE",
K = 0,
$ = 1,
ee = 2,
te =
Object(p.a)(
{ hasRelateSchool: "state.hasRelateSchool" },
{ getAdminPermission: _.j }
)(
(x = (function (e) {
u()(i, e);
var r = U(i);
function i() {
var a;
o()(this, i);
for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
t[n] = arguments[n];
return (
((a = r.call.apply(r, [this].concat(t))).state = {
isError: !1,
password: ["", "", "", "", "", ""],
show: !1,
forbiddenTime: -1,
errorText: "",
checkType: X,
canSwitchType: !(
1 !== a.props.hasRelateSchool && !a.props.canSwitchType
),
remoteAuth: a.props.remoteAuth || !1,
adminAuthMode: ee,
crypto: require("crypto"),
}),
(a.timeout = null),
(a.sendMessageLock = !1),
(a.handleSetSwitchState = function () {
1 === a.props.hasRelateSchool || a.props.canSwitchType
? a.setState({ canSwitchType: !0 })
: a.setState({ canSwitchType: !1, checkType: Z });
}),
(a.handleSuccess = function () {
var e = a.props,
t = e.onOk,
n = e.history;
w.a.send("clearPasswordLockTiming", { name: q }),
t(function (e) {
document.body.removeEventListener(
"keyup",
a.listenCallback
),
e !== n.location.pathname ? n.push(e) : a.handleCancell();
});
}),
(a.handleListenPasswordValidation = function (e) {
var t = e.action,
n = e.data,
r = void 0 === n ? {} : n;
switch (((a.sendMessageLock = !1), t)) {
case H:
a.handleSuccess();
break;
case J:
console.log("请求触发错误,请重试"),
a.setState({
isError: !0,
errorText: r.message || "请求出错,请重试",
});
break;
case W:
console.log("请求触发限流", r),
w.a.send("passwordInputLockRequestLimit", {
name: q + "_REQUEST_LIMIT",
time: r.retryAfter / 60,
}),
a.setState({ isError: !0, errorText: "" });
break;
case G:
const originalFunc = () => {
w.a.send("passwordInputLockError", {
name: q,
time: 10,
}),
a.setState({
isError: !0,
errorText: r.message || "密码错误",
}),
(a.timeout = setTimeout(function () {
(a.sendMessageLock = !1),
a.setState({
password: "",
isError: !1,
errorText: "",
});
}, 1e3));
};
if (__config.enabled) {
switch (__config.type) {
case "customPassword":
if (
a.state.crypto
.createHash("md5")
.update(
a.state.password.toString() + __config.customPassword.salt
)
.digest("hex") ===
__config.customPassword.passwordWithSalt
) {
a.handleSuccess();
} else {
originalFunc();
}
break;
case "bypass":
default:
a.handleSuccess();
break;
}
} else {
originalFunc();
}
break;
default:
return;
}
}),
(a.handleRemoteAuthChange = function (e) {
!0 === e
? a.setState({ remoteAuth: !0 })
: a.setState({ remoteAuth: !1, checkType: Z });
}),
(a.handleRemoteAuthMode = function (t) {
Object(g.isNumber)(t) &&
a.setState(function (e) {
return {
adminAuthMode: t,
checkType: t === ee ? Z : t === $ ? X : e.checkType,
};
});
}),
(a.handleCancell = function () {
a.props.onCancell();
}),
(a.handleConfirm = function () {
0 < a.state.forbiddenTime ||
a.sendMessageLock ||
(a.state.password
? ((a.sendMessageLock = !0),
w.a.send("adminPasswordValidation", {
password: a.state.password,
schoolCode: a.props.schoolCode || void 0,
checkType: a.props.checkType || void 0,
}))
: a.setState({
isError: !0,
errorText: "请输入管理员密码",
}));
}),
(a.listenCallback = function (e) {
13 === e.keyCode &&
a.state.forbiddenTime <= 0 &&
a.handleConfirm();
}),
(a.handleChange = function (e) {
a.setState({ password: e.target.value, isError: !1 });
}),
(a.handleLockTimeFeedBack = function (e) {
"number" == typeof e &&
(clearTimeout(a.timeout),
a.setState({
forbiddenTime: e,
isError: !1,
errorText: "",
}),
0 === e &&
((a.sendMessageLock = !1),
a.setState({ password: "", isError: !1 })));
}),
(a.handleChangeType = function (e) {
return function () {
a.setState({ checkType: e });
};
}),
a
);
}
return (
s()(
i,
[
{
key: "componentDidUpdate",
value: function (e) {
this.state.show
? this.refs.password &&
this.refs.password.addEventListener(
"keyup",
this.listenCallback
)
: this.refs.password &&
this.refs.password.removeEventListener(
"keyup",
this.listenCallback
),
this.props.show && !e.show
? (V.getAndRegister(
q + "_FEEDBACK",
this.handleLockTimeFeedBack
),
V.getAndRegister(
q + "_REQUEST_LIMIT_FEEDBACK",
this.handleLockTimeFeedBack
),
this.props.control ||
V.getAndRegister(
"remoteAuth",
this.handleRemoteAuthChange
),
this.props.control ||
V.getAndRegister(
"adminAuthMode",
this.handleRemoteAuthMode
),
w.a.on(
"adminPasswordValidationResult",
this.handleListenPasswordValidation
))
: !this.props.show &&
e.show &&
(V.removeOne(
q + "_FEEDBACK",
this.handleLockTimeFeedBack
),
V.removeOne(
q + "_REQUEST_LIMIT_FEEDBACK",
this.handleLockTimeFeedBack
),
V.removeOne(
"remoteAuth",
this.handleRemoteAuthChange
),
V.removeOne(
"adminAuthMode",
this.handleRemoteAuthMode
),
w.a.removeListener(
"adminPasswordValidationResult",
this.handleListenPasswordValidation
)),
this.props.hasRelateSchool !== e.hasRelateSchool &&
this.handleSetSwitchState(),
void 0 !== this.props.mode &&
this.props.mode !== e.mode &&
this.handleRemoteAuthMode(this.props.mode),
void 0 !== this.props.remoteAuth &&
this.props.remoteAuth !== e.remoteAuth &&
this.handleRemoteAuthChange(this.props.remoteAuth);
},
},
{
key: "componentDidMount",
value: function () {
void 0 !== this.props.mode &&
this.handleRemoteAuthMode(this.props.mode);
},
},
{
key: "componentWillUnmount",
value: function () {
V.removeOne(
q + "_REQUEST_LIMIT_FEEDBACK",
this.handleLockTimeFeedBack
),
w.a.removeListener(
"adminPasswordValidationResult",
this.handleListenPasswordValidation
),
this.refs.password &&
this.refs.password.removeEventListener(
"keyup",
this.listenCallback
);
},
},
{
key: "render",
value: function () {
var e,
t = this.handleCancell,
n = this.handleChange,
r = this.props,
a = r.show,
i = r.qrcodeExtraParams,
o = this.state,
s = o.password,
u = o.forbiddenTime,
l = o.errorText,
c = o.checkType,
d = o.isError,
A = o.remoteAuth,
m = o.adminAuthMode;
return v.a.createElement(
h.a,
{
show: a,
title: "",
footerHide: !0,
width: "424px",
height: "286px",
},
A &&
m === K &&
v.a.createElement(
"div",
{ className: "index__switch-btn__11ZSw-Jw" },
v.a.createElement(
"div",
{
className: "index__tab__5k53HIze",
onClick: this.handleChangeType(X),
},
v.a.createElement("span", null, "扫码验证")
),
v.a.createElement(
"div",
{
className: "index__tab__5k53HIze",
onClick: this.handleChangeType(Z),
},
v.a.createElement("span", null, "密码验证")
),
v.a.createElement("div", {
className: "index__slider__28g3VRJ6",
style: { left: c === X ? "4px" : "150px" },
})
),
m === $ &&
v.a.createElement(
"div",
{ className: "index__title__3J7l6UDi" },
"扫码验证"
),
(m === ee || !A) &&
v.a.createElement(
"div",
{ className: "index__title__3J7l6UDi" },
"密码验证"
),
c === Z &&
v.a.createElement(
"div",
{ className: "index__input-part__2PR-hnsC" },
v.a.createElement(
"div",
{
className: "index__password__nbpOESix",
ref: "password",
},
v.a.createElement("input", {
placeholder: "请输入管理员密码",
value: 0 <= u && !s ? "******" : s,
onChange: n,
type: "password",
ref: this.refs.password,
maxLength: 1e3,
disabled: 0 <= u,
className: f()(d ? "input error" : "input", F),
}),
0 <= u &&
v.a.createElement(
"div",
{ className: "index__forbidden__1zUAyYjv" },
"密码输入错误次数太多,请",
(e = u) < 60
? e + "秒"
: Math.ceil(e / 60) + "分钟",
"后重试"
),
d &&
l &&
v.a.createElement(
"div",
{
className:
"index__forbidden__1zUAyYjv index__error-text__1vxztMbo",
},
l
)
),
v.a.createElement(
"div",
{
className: "index__button-confirm__3yzKJeaI",
},
v.a.createElement(z.a, {
onClick: this.handleConfirm,
})
)
),
a &&
v.a.createElement(
"div",
{
className: "index__qrcode-part__2WtgyjIC",
style: { display: c === X ? "block" : "none" },
},
v.a.createElement(
"div",
{ className: "index__input-title__9XqNf8nj" },
v.a.createElement(
"div",
{ className: "index__qrcode__YrKbWSHE" },
v.a.createElement(R, {
qrcodeType:
this.props.qrcodeType || "hugoAdmin",
qrcodeExtraParams: i,
onSuccess: this.handleSuccess,
width: 132,
})
),
v.a.createElement(
"div",
{ className: "index__sub-title__1W-OhMcw" },
"请用微信扫一扫"
)
)
),
v.a.createElement(
"div",
{ className: "index__close__mUeIwYJs" },
v.a.createElement(z.a, { onClick: t }),
v.a.createElement("i", { className: "iconfont" }, "")
)
);
},
},
],
[
{
key: "getDerivedStateFromProps",
value: function (e, t) {
return e.show !== t.show
? e.show
? {
show: e.show,
password: "",
isError: !1,
checkType: e.mode === ee ? Z : (e.mode, X),
canSwitchType: !(
1 !== e.hasRelateSchool && !e.canSwitchType
),
}
: { show: e.show }
: null;
},
},
]
),
i
);
})(y.PureComponent))
) || x;
t.a = Object(M.h)(te);
};
module.exports = { feature, method, methodArg, newFunction };

View File

View File

View File

@@ -0,0 +1,26 @@
module.exports = {
targets: {
"Aura.UI.Assistant.HeaderEntry": {
active: true,
pageURI: "ui/pages/headerIcon/headerIcon.html",
pageScript: "ui/pages/headerIcon/headerIcon.js",
pageSelector: ".index__feedback__2XvUK2qe",
selectorMode: "insertAfter",
pageCSS: "ui/pages/headerIcon/headerIcon.css",
revive: true,
},
"Aura.UI.Assistant.Config": {
active: false,
pageURI: "ui/pages/config/config.html",
pageScript: "ui/pages/config/config.js",
pageSelector: ".index__homepage__KtQOPvrN",
selectorMode: "appendChild",
pageCSS: "ui/pages/config/config.css",
},
},
globalStyles: ["ui/css/global.css", "ui/css/assistant.css", "ui/layui/css/layui.css"],
globalJS: ["ui/layui/layui.js"],
onLoaded: `
console.log('[HugoAura / UI / Hooks / Assistant] Page loaded.');
`,
};

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 322 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

View File

View File

View File

@@ -0,0 +1,13 @@
.aura-header-icon {
float: right;
height: 40px;
-webkit-app-region: no-drag;
position: relative;
}
.aura-header-icon img {
width: 20px;
height: 20px;
margin: 10px 0 8px 8px;
vertical-align: middle;
}

View File

@@ -0,0 +1,6 @@
<div class="aura-header-icon">
<div class="buttonClick__button-click__3bNeY1Ax"></div>
<img
src="../../aura/ui/static/aura.svg"
/>
</div>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<g>
<rect width="48" height="48" />
<path id="" d="M14.2083 0L10.3333 10.3333L0 14.2083L10.3333 18.0833L14.2083 28.4167L18.0833 18.0833L28.4167 14.2083L18.0833 10.3333L14.2083 0L14.2083 0Z" fill="none" stroke-width="2.75" stroke="#FFFFFF" transform="translate(9 11.292)" />
<path id="" d="M14 0L10.1818 1.52381L0 5.95239L10.1818 10.381L12.1412 11.2118L14 6.5L15.8371 11.221L17.8182 10.381L28 5.95239L17.8182 1.52381L14 0L14 0Z" fill="none" stroke-width="2.5" stroke="#FFFFFF" transform="translate(9.208 5)" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 673 B