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);
|
observers.set(moduleKey, observer);
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadResources = async (resources, type, moduleKey, isRevive) => {
|
const loadResources = async (resources, type, moduleKey) => {
|
||||||
if (!resources || isRevive) return [];
|
if (!resources) return [];
|
||||||
|
|
||||||
const resourceArray = Array.isArray(resources) ? resources : [resources];
|
const resourceArray = Array.isArray(resources) ? resources : [resources];
|
||||||
const loadedResources = [];
|
const loadedResources = [];
|
||||||
@@ -232,12 +232,11 @@
|
|||||||
const resources = new Set();
|
const resources = new Set();
|
||||||
moduleResources.set(moduleKey, resources);
|
moduleResources.set(moduleKey, resources);
|
||||||
|
|
||||||
if (config.pageCSS) {
|
if (config.pageCSS && !isRevive) {
|
||||||
const cssResources = await loadResources(
|
const cssResources = await loadResources(
|
||||||
config.pageCSS,
|
config.pageCSS,
|
||||||
"css",
|
"css",
|
||||||
moduleKey,
|
moduleKey
|
||||||
isRevive
|
|
||||||
);
|
);
|
||||||
cssResources.forEach((resource) => resources.add(resource));
|
cssResources.forEach((resource) => resources.add(resource));
|
||||||
}
|
}
|
||||||
@@ -250,16 +249,22 @@
|
|||||||
insertElement(target, container, config.selectorMode);
|
insertElement(target, container, config.selectorMode);
|
||||||
monitorParent(moduleKey, target, container, config.selectorMode);
|
monitorParent(moduleKey, target, container, config.selectorMode);
|
||||||
|
|
||||||
if (config.pageScript) {
|
if (config.pageScript && !isRevive) {
|
||||||
const jsResources = await loadResources(
|
const jsResources = await loadResources(
|
||||||
config.pageScript,
|
config.pageScript,
|
||||||
"js",
|
"js",
|
||||||
moduleKey,
|
moduleKey
|
||||||
isRevive
|
|
||||||
);
|
);
|
||||||
jsResources.forEach((resource) => resources.add(resource));
|
jsResources.forEach((resource) => resources.add(resource));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isRevive) {
|
||||||
|
const onReviveEvent = new CustomEvent(
|
||||||
|
`onLoaderElRevive:${moduleKey}`
|
||||||
|
);
|
||||||
|
document.dispatchEvent(onReviveEvent);
|
||||||
|
}
|
||||||
|
|
||||||
const observer = new MutationObserver(() => {
|
const observer = new MutationObserver(() => {
|
||||||
if (
|
if (
|
||||||
!document.contains(container) &&
|
!document.contains(container) &&
|
||||||
|
|||||||
@@ -145,9 +145,10 @@ const renderInputArea = (entry, operationArea, descriptionArea) => {
|
|||||||
inputEl.value = entry.valueGetter();
|
inputEl.value = entry.valueGetter();
|
||||||
inputEl.placeholder = entry.placeHolder;
|
inputEl.placeholder = entry.placeHolder;
|
||||||
inputEl.id = entry.id;
|
inputEl.id = entry.id;
|
||||||
inputEl.addEventListener("change", async (event) => {
|
|
||||||
|
const handleSubmit = async (event = null) => {
|
||||||
const result = await entry.callbackFn(
|
const result = await entry.callbackFn(
|
||||||
event.target.value,
|
event ? event.target.value : inputEl.value,
|
||||||
inputEl,
|
inputEl,
|
||||||
operationArea,
|
operationArea,
|
||||||
descriptionArea
|
descriptionArea
|
||||||
@@ -166,7 +167,17 @@ const renderInputArea = (entry, operationArea, descriptionArea) => {
|
|||||||
descriptionArea.textContent = result.hint;
|
descriptionArea.textContent = result.hint;
|
||||||
descriptionArea.classList.add("ase-desc-error-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");
|
operationArea.classList.add("ase-operation-area-expanded");
|
||||||
return inputEl;
|
return inputEl;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,10 @@
|
|||||||
<!-- Chevron Left Icon -->
|
<!-- Chevron Left Icon -->
|
||||||
</div>
|
</div>
|
||||||
<p>雨光之环</p>
|
<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 class="aura-config-page-app-bar-spacer space-none"></div>
|
||||||
<div
|
<div
|
||||||
onclick="global.__HUGO_AURA_UI_FUNCTIONS__.config.handleNavHome()"
|
onclick="global.__HUGO_AURA_UI_FUNCTIONS__.config.handleNavHome()"
|
||||||
|
|||||||
@@ -235,6 +235,11 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
|||||||
inputEl.value = "";
|
inputEl.value = "";
|
||||||
inputEl.classList.remove("invalid");
|
inputEl.classList.remove("invalid");
|
||||||
inputEl.classList.remove("is-invalid");
|
inputEl.classList.remove("is-invalid");
|
||||||
|
|
||||||
|
global.__HUGO_AURA_UI_FUNCTIONS__.config.resetAuthDialogInputElOnSubmit(
|
||||||
|
global.__HUGO_AURA_UI_FUNCTIONS__.config.verifyAuthPassword
|
||||||
|
);
|
||||||
|
|
||||||
acpDialogConfirmBtnEl.onclick = (_evt) => {
|
acpDialogConfirmBtnEl.onclick = (_evt) => {
|
||||||
global.__HUGO_AURA_UI_FUNCTIONS__.config.verifyAuthPassword();
|
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 () => {
|
handleACSNShow: async () => {
|
||||||
const acsnRootEl = document.getElementsByClassName(
|
const acsnRootEl = document.getElementsByClassName(
|
||||||
"acp-config-status-notify"
|
"acp-config-status-notify"
|
||||||
@@ -386,6 +401,9 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
|||||||
"aura-config-page-header-area"
|
"aura-config-page-header-area"
|
||||||
)[0];
|
)[0];
|
||||||
acsDialogAreaEl.style = "";
|
acsDialogAreaEl.style = "";
|
||||||
|
global.__HUGO_AURA_UI_FUNCTIONS__.config.resetAuthDialogInputElOnSubmit(
|
||||||
|
global.__HUGO_AURA_UI_FUNCTIONS__.config.verifyAuthPassword
|
||||||
|
);
|
||||||
await window.__HUGO_AURA_GLOBAL__.utils.sleep(500);
|
await window.__HUGO_AURA_GLOBAL__.utils.sleep(500);
|
||||||
acsDialogAreaEl.classList.remove("acp-ada-hidden");
|
acsDialogAreaEl.classList.remove("acp-ada-hidden");
|
||||||
acpAppBarEl.classList.add("color-reverse");
|
acpAppBarEl.classList.add("color-reverse");
|
||||||
|
|||||||
@@ -142,6 +142,10 @@ const functions = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
global.__HUGO_AURA_UI_FUNCTIONS__.config.resetAuthDialogInputElOnSubmit(
|
||||||
|
verifyPassword
|
||||||
|
);
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
acpDialogConfirmBtnEl.onclick = verifyPassword;
|
acpDialogConfirmBtnEl.onclick = verifyPassword;
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
|
|||||||
@@ -9,9 +9,10 @@ global.__HUGO_AURA_UI_FUNCTIONS__.headerIcon = {
|
|||||||
let clickCounter = 0;
|
let clickCounter = 0;
|
||||||
let clickTimeout = null;
|
let clickTimeout = null;
|
||||||
|
|
||||||
const onMounted = () => {
|
const onMounted = (revive = false) => {
|
||||||
if (
|
if (
|
||||||
!global.__HUGO_AURA_CONFIG__.auraSettings.uiAccessMethod.showEntryIcon
|
!global.__HUGO_AURA_CONFIG__.auraSettings.uiAccessMethod.showEntryIcon &&
|
||||||
|
!revive
|
||||||
) {
|
) {
|
||||||
const rootEl = document.getElementById("root");
|
const rootEl = document.getElementById("root");
|
||||||
rootEl.classList.add("aura-header-icon-hidden");
|
rootEl.classList.add("aura-header-icon-hidden");
|
||||||
@@ -19,7 +20,8 @@ global.__HUGO_AURA_UI_FUNCTIONS__.headerIcon = {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
global.__HUGO_AURA_CONFIG__.auraSettings.uiAccessMethod
|
global.__HUGO_AURA_CONFIG__.auraSettings.uiAccessMethod
|
||||||
.fallbackAccessMethods.hotkey
|
.fallbackAccessMethods.hotkey &&
|
||||||
|
!revive
|
||||||
) {
|
) {
|
||||||
document.addEventListener("keydown", (event) => {
|
document.addEventListener("keydown", (event) => {
|
||||||
if (event.ctrlKey && event.shiftKey && event.key === "A") {
|
if (event.ctrlKey && event.shiftKey && event.key === "A") {
|
||||||
@@ -53,4 +55,11 @@ global.__HUGO_AURA_UI_FUNCTIONS__.headerIcon = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMounted();
|
onMounted();
|
||||||
|
|
||||||
|
document.addEventListener(
|
||||||
|
"onLoaderElRevive:Aura.UI.Assistant.HeaderEntry",
|
||||||
|
() => {
|
||||||
|
onMounted(true);
|
||||||
|
}
|
||||||
|
);
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const createWsWindow = (electron) => {
|
|||||||
frame: false,
|
frame: false,
|
||||||
skipTaskbar: true,
|
skipTaskbar: true,
|
||||||
transparent: true,
|
transparent: true,
|
||||||
alwaysOnTop: true,
|
alwaysOnTop: false,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
contextIsolation: false,
|
contextIsolation: false,
|
||||||
@@ -21,6 +21,7 @@ const createWsWindow = (electron) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
window.setIgnoreMouseEvents(true);
|
window.setIgnoreMouseEvents(true);
|
||||||
|
window.minimize();
|
||||||
window.loadFile(
|
window.loadFile(
|
||||||
path.join(
|
path.join(
|
||||||
__dirname,
|
__dirname,
|
||||||
|
|||||||
Reference in New Issue
Block a user