mirror of
https://github.com/HugoAura/Seewo-HugoAura.git
synced 2026-06-20 23:14:28 +08:00
1. [/] 为 Revive 元素添加了自定义事件触发, 从而正确处理 Remount 发生时的情况 2. [/] 为 Input 元素添加了正确的 onSubmit 事件处理
This commit is contained in:
@@ -168,8 +168,8 @@
|
||||
observers.set(moduleKey, observer);
|
||||
};
|
||||
|
||||
const loadResources = async (resources, type, moduleKey, isRevive) => {
|
||||
if (!resources || isRevive) return [];
|
||||
const loadResources = async (resources, type, moduleKey) => {
|
||||
if (!resources) return [];
|
||||
|
||||
const resourceArray = Array.isArray(resources) ? resources : [resources];
|
||||
const loadedResources = [];
|
||||
@@ -232,12 +232,11 @@
|
||||
const resources = new Set();
|
||||
moduleResources.set(moduleKey, resources);
|
||||
|
||||
if (config.pageCSS) {
|
||||
if (config.pageCSS && !isRevive) {
|
||||
const cssResources = await loadResources(
|
||||
config.pageCSS,
|
||||
"css",
|
||||
moduleKey,
|
||||
isRevive
|
||||
moduleKey
|
||||
);
|
||||
cssResources.forEach((resource) => resources.add(resource));
|
||||
}
|
||||
@@ -250,16 +249,22 @@
|
||||
insertElement(target, container, config.selectorMode);
|
||||
monitorParent(moduleKey, target, container, config.selectorMode);
|
||||
|
||||
if (config.pageScript) {
|
||||
if (config.pageScript && !isRevive) {
|
||||
const jsResources = await loadResources(
|
||||
config.pageScript,
|
||||
"js",
|
||||
moduleKey,
|
||||
isRevive
|
||||
moduleKey
|
||||
);
|
||||
jsResources.forEach((resource) => resources.add(resource));
|
||||
}
|
||||
|
||||
if (isRevive) {
|
||||
const onReviveEvent = new CustomEvent(
|
||||
`onLoaderElRevive:${moduleKey}`
|
||||
);
|
||||
document.dispatchEvent(onReviveEvent);
|
||||
}
|
||||
|
||||
const observer = new MutationObserver(() => {
|
||||
if (
|
||||
!document.contains(container) &&
|
||||
|
||||
@@ -145,9 +145,10 @@ const renderInputArea = (entry, operationArea, descriptionArea) => {
|
||||
inputEl.value = entry.valueGetter();
|
||||
inputEl.placeholder = entry.placeHolder;
|
||||
inputEl.id = entry.id;
|
||||
inputEl.addEventListener("change", async (event) => {
|
||||
|
||||
const handleSubmit = async (event = null) => {
|
||||
const result = await entry.callbackFn(
|
||||
event.target.value,
|
||||
event ? event.target.value : inputEl.value,
|
||||
inputEl,
|
||||
operationArea,
|
||||
descriptionArea
|
||||
@@ -166,7 +167,17 @@ const renderInputArea = (entry, operationArea, descriptionArea) => {
|
||||
descriptionArea.textContent = result.hint;
|
||||
descriptionArea.classList.add("ase-desc-error-hint");
|
||||
}
|
||||
};
|
||||
|
||||
inputEl.addEventListener("change", async (event) => {
|
||||
await handleSubmit(event);
|
||||
});
|
||||
|
||||
inputEl.onsubmit = async (evt) => {
|
||||
evt.preventDefault();
|
||||
await handleSubmit();
|
||||
};
|
||||
|
||||
operationArea.classList.add("ase-operation-area-expanded");
|
||||
return inputEl;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,10 @@
|
||||
<!-- Chevron Left Icon -->
|
||||
</div>
|
||||
<p>雨光之环</p>
|
||||
<div class="aura-config-page-app-bar-hr-vertical" id="auraConfigPageAppBarVerticalHr"></div>
|
||||
<div
|
||||
class="aura-config-page-app-bar-hr-vertical"
|
||||
id="auraConfigPageAppBarVerticalHr"
|
||||
></div>
|
||||
<div class="aura-config-page-app-bar-spacer space-none"></div>
|
||||
<div
|
||||
onclick="global.__HUGO_AURA_UI_FUNCTIONS__.config.handleNavHome()"
|
||||
|
||||
@@ -235,6 +235,11 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
||||
inputEl.value = "";
|
||||
inputEl.classList.remove("invalid");
|
||||
inputEl.classList.remove("is-invalid");
|
||||
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.config.resetAuthDialogInputElOnSubmit(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.config.verifyAuthPassword
|
||||
);
|
||||
|
||||
acpDialogConfirmBtnEl.onclick = (_evt) => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.config.verifyAuthPassword();
|
||||
};
|
||||
@@ -243,6 +248,16 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
||||
};
|
||||
},
|
||||
|
||||
resetAuthDialogInputElOnSubmit: (func) => {
|
||||
const inputEl = document.getElementById("acp-auth-user-input");
|
||||
inputEl.onsubmit = (evt) => evt.preventDefault();
|
||||
inputEl.onkeydown = (event) => {
|
||||
if (event.key === "Enter") {
|
||||
func();
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
handleACSNShow: async () => {
|
||||
const acsnRootEl = document.getElementsByClassName(
|
||||
"acp-config-status-notify"
|
||||
@@ -386,6 +401,9 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
||||
"aura-config-page-header-area"
|
||||
)[0];
|
||||
acsDialogAreaEl.style = "";
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.config.resetAuthDialogInputElOnSubmit(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.config.verifyAuthPassword
|
||||
);
|
||||
await window.__HUGO_AURA_GLOBAL__.utils.sleep(500);
|
||||
acsDialogAreaEl.classList.remove("acp-ada-hidden");
|
||||
acpAppBarEl.classList.add("color-reverse");
|
||||
|
||||
@@ -142,6 +142,10 @@ const functions = {
|
||||
}
|
||||
};
|
||||
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.config.resetAuthDialogInputElOnSubmit(
|
||||
verifyPassword
|
||||
);
|
||||
|
||||
// @ts-expect-error
|
||||
acpDialogConfirmBtnEl.onclick = verifyPassword;
|
||||
// @ts-expect-error
|
||||
|
||||
@@ -9,9 +9,10 @@ global.__HUGO_AURA_UI_FUNCTIONS__.headerIcon = {
|
||||
let clickCounter = 0;
|
||||
let clickTimeout = null;
|
||||
|
||||
const onMounted = () => {
|
||||
const onMounted = (revive = false) => {
|
||||
if (
|
||||
!global.__HUGO_AURA_CONFIG__.auraSettings.uiAccessMethod.showEntryIcon
|
||||
!global.__HUGO_AURA_CONFIG__.auraSettings.uiAccessMethod.showEntryIcon &&
|
||||
!revive
|
||||
) {
|
||||
const rootEl = document.getElementById("root");
|
||||
rootEl.classList.add("aura-header-icon-hidden");
|
||||
@@ -19,7 +20,8 @@ global.__HUGO_AURA_UI_FUNCTIONS__.headerIcon = {
|
||||
|
||||
if (
|
||||
global.__HUGO_AURA_CONFIG__.auraSettings.uiAccessMethod
|
||||
.fallbackAccessMethods.hotkey
|
||||
.fallbackAccessMethods.hotkey &&
|
||||
!revive
|
||||
) {
|
||||
document.addEventListener("keydown", (event) => {
|
||||
if (event.ctrlKey && event.shiftKey && event.key === "A") {
|
||||
@@ -53,4 +55,11 @@ global.__HUGO_AURA_UI_FUNCTIONS__.headerIcon = {
|
||||
};
|
||||
|
||||
onMounted();
|
||||
|
||||
document.addEventListener(
|
||||
"onLoaderElRevive:Aura.UI.Assistant.HeaderEntry",
|
||||
() => {
|
||||
onMounted(true);
|
||||
}
|
||||
);
|
||||
})();
|
||||
|
||||
@@ -12,7 +12,7 @@ const createWsWindow = (electron) => {
|
||||
frame: false,
|
||||
skipTaskbar: true,
|
||||
transparent: true,
|
||||
alwaysOnTop: true,
|
||||
alwaysOnTop: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
@@ -21,6 +21,7 @@ const createWsWindow = (electron) => {
|
||||
});
|
||||
|
||||
window.setIgnoreMouseEvents(true);
|
||||
window.minimize();
|
||||
window.loadFile(
|
||||
path.join(
|
||||
__dirname,
|
||||
|
||||
Reference in New Issue
Block a user