Skip to content

Commit 2ff4a28

Browse files
committed
[🛠️ Fix] Issue #32 & #33
1. [/] 为 Revive 元素添加了自定义事件触发, 从而正确处理 Remount 发生时的情况 2. [/] 为 Input 元素添加了正确的 onSubmit 事件处理
1 parent d5b4c4b commit 2ff4a28

7 files changed

Lines changed: 66 additions & 15 deletions

File tree

src/aura/init/rendererHook/injection.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@
168168
observers.set(moduleKey, observer);
169169
};
170170

171-
const loadResources = async (resources, type, moduleKey, isRevive) => {
172-
if (!resources || isRevive) return [];
171+
const loadResources = async (resources, type, moduleKey) => {
172+
if (!resources) return [];
173173

174174
const resourceArray = Array.isArray(resources) ? resources : [resources];
175175
const loadedResources = [];
@@ -232,12 +232,11 @@
232232
const resources = new Set();
233233
moduleResources.set(moduleKey, resources);
234234

235-
if (config.pageCSS) {
235+
if (config.pageCSS && !isRevive) {
236236
const cssResources = await loadResources(
237237
config.pageCSS,
238238
"css",
239-
moduleKey,
240-
isRevive
239+
moduleKey
241240
);
242241
cssResources.forEach((resource) => resources.add(resource));
243242
}
@@ -250,16 +249,22 @@
250249
insertElement(target, container, config.selectorMode);
251250
monitorParent(moduleKey, target, container, config.selectorMode);
252251

253-
if (config.pageScript) {
252+
if (config.pageScript && !isRevive) {
254253
const jsResources = await loadResources(
255254
config.pageScript,
256255
"js",
257-
moduleKey,
258-
isRevive
256+
moduleKey
259257
);
260258
jsResources.forEach((resource) => resources.add(resource));
261259
}
262260

261+
if (isRevive) {
262+
const onReviveEvent = new CustomEvent(
263+
`onLoaderElRevive:${moduleKey}`
264+
);
265+
document.dispatchEvent(onReviveEvent);
266+
}
267+
263268
const observer = new MutationObserver(() => {
264269
if (
265270
!document.contains(container) &&

src/aura/ui/composables/settingsRenderer.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,10 @@ const renderInputArea = (entry, operationArea, descriptionArea) => {
145145
inputEl.value = entry.valueGetter();
146146
inputEl.placeholder = entry.placeHolder;
147147
inputEl.id = entry.id;
148-
inputEl.addEventListener("change", async (event) => {
148+
149+
const handleSubmit = async (event = null) => {
149150
const result = await entry.callbackFn(
150-
event.target.value,
151+
event ? event.target.value : inputEl.value,
151152
inputEl,
152153
operationArea,
153154
descriptionArea
@@ -166,7 +167,17 @@ const renderInputArea = (entry, operationArea, descriptionArea) => {
166167
descriptionArea.textContent = result.hint;
167168
descriptionArea.classList.add("ase-desc-error-hint");
168169
}
170+
};
171+
172+
inputEl.addEventListener("change", async (event) => {
173+
await handleSubmit(event);
169174
});
175+
176+
inputEl.onsubmit = async (evt) => {
177+
evt.preventDefault();
178+
await handleSubmit();
179+
};
180+
170181
operationArea.classList.add("ase-operation-area-expanded");
171182
return inputEl;
172183
}

src/aura/ui/pages/config/config.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
<!-- Chevron Left Icon -->
1414
</div>
1515
<p>雨光之环</p>
16-
<div class="aura-config-page-app-bar-hr-vertical" id="auraConfigPageAppBarVerticalHr"></div>
16+
<div
17+
class="aura-config-page-app-bar-hr-vertical"
18+
id="auraConfigPageAppBarVerticalHr"
19+
></div>
1720
<div class="aura-config-page-app-bar-spacer space-none"></div>
1821
<div
1922
onclick="global.__HUGO_AURA_UI_FUNCTIONS__.config.handleNavHome()"

src/aura/ui/pages/config/config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
235235
inputEl.value = "";
236236
inputEl.classList.remove("invalid");
237237
inputEl.classList.remove("is-invalid");
238+
239+
global.__HUGO_AURA_UI_FUNCTIONS__.config.resetAuthDialogInputElOnSubmit(
240+
global.__HUGO_AURA_UI_FUNCTIONS__.config.verifyAuthPassword
241+
);
242+
238243
acpDialogConfirmBtnEl.onclick = (_evt) => {
239244
global.__HUGO_AURA_UI_FUNCTIONS__.config.verifyAuthPassword();
240245
};
@@ -243,6 +248,16 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
243248
};
244249
},
245250

251+
resetAuthDialogInputElOnSubmit: (func) => {
252+
const inputEl = document.getElementById("acp-auth-user-input");
253+
inputEl.onsubmit = (evt) => evt.preventDefault();
254+
inputEl.onkeydown = (event) => {
255+
if (event.key === "Enter") {
256+
func();
257+
}
258+
};
259+
},
260+
246261
handleACSNShow: async () => {
247262
const acsnRootEl = document.getElementsByClassName(
248263
"acp-config-status-notify"
@@ -386,6 +401,9 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
386401
"aura-config-page-header-area"
387402
)[0];
388403
acsDialogAreaEl.style = "";
404+
global.__HUGO_AURA_UI_FUNCTIONS__.config.resetAuthDialogInputElOnSubmit(
405+
global.__HUGO_AURA_UI_FUNCTIONS__.config.verifyAuthPassword
406+
);
389407
await window.__HUGO_AURA_GLOBAL__.utils.sleep(500);
390408
acsDialogAreaEl.classList.remove("acp-ada-hidden");
391409
acpAppBarEl.classList.add("color-reverse");

src/aura/ui/pages/configSubPages/preferences/settings/aura.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ const functions = {
142142
}
143143
};
144144

145+
global.__HUGO_AURA_UI_FUNCTIONS__.config.resetAuthDialogInputElOnSubmit(
146+
verifyPassword
147+
);
148+
145149
// @ts-expect-error
146150
acpDialogConfirmBtnEl.onclick = verifyPassword;
147151
// @ts-expect-error

src/aura/ui/pages/headerIcon/headerIcon.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ global.__HUGO_AURA_UI_FUNCTIONS__.headerIcon = {
99
let clickCounter = 0;
1010
let clickTimeout = null;
1111

12-
const onMounted = () => {
12+
const onMounted = (revive = false) => {
1313
if (
14-
!global.__HUGO_AURA_CONFIG__.auraSettings.uiAccessMethod.showEntryIcon
14+
!global.__HUGO_AURA_CONFIG__.auraSettings.uiAccessMethod.showEntryIcon &&
15+
!revive
1516
) {
1617
const rootEl = document.getElementById("root");
1718
rootEl.classList.add("aura-header-icon-hidden");
1819
}
1920

2021
if (
2122
global.__HUGO_AURA_CONFIG__.auraSettings.uiAccessMethod
22-
.fallbackAccessMethods.hotkey
23+
.fallbackAccessMethods.hotkey &&
24+
!revive
2325
) {
2426
document.addEventListener("keydown", (event) => {
2527
if (event.ctrlKey && event.shiftKey && event.key === "A") {
@@ -53,4 +55,11 @@ global.__HUGO_AURA_UI_FUNCTIONS__.headerIcon = {
5355
};
5456

5557
onMounted();
58+
59+
document.addEventListener(
60+
"onLoaderElRevive:Aura.UI.Assistant.HeaderEntry",
61+
() => {
62+
onMounted(true);
63+
}
64+
);
5665
})();

src/aura/utils/pls.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const createWsWindow = (electron) => {
1212
frame: false,
1313
skipTaskbar: true,
1414
transparent: true,
15-
alwaysOnTop: true,
15+
alwaysOnTop: false,
1616
webPreferences: {
1717
nodeIntegration: true,
1818
contextIsolation: false,
@@ -21,6 +21,7 @@ const createWsWindow = (electron) => {
2121
});
2222

2323
window.setIgnoreMouseEvents(true);
24+
window.minimize();
2425
window.loadFile(
2526
path.join(
2627
__dirname,

0 commit comments

Comments
 (0)