[ Feat] {#21} Add AppBar window oper icons

1. [+] {#21} 增加了应用栏 (顶栏) 上的窗口操作按钮
2. [-] 删掉了几个调试时留下的 console.debug
This commit is contained in:
Minoricew
2025-06-14 16:07:10 +08:00
parent e63c989d88
commit 9a2a335742
6 changed files with 147 additions and 5 deletions

View File

@@ -76,6 +76,7 @@ const buildIpcMain = (electron) => {
} }
}; };
const { applyBaseIpcHandler } = require("./ipcModules/baseIpcHandler");
const { applyConfigIpcHandler } = require("./ipcModules/configIpcHandler"); const { applyConfigIpcHandler } = require("./ipcModules/configIpcHandler");
const { applyFsIpcHandler } = require("./ipcModules/fsIpcHandler"); const { applyFsIpcHandler } = require("./ipcModules/fsIpcHandler");
const { applyPlsIpcHandler } = require("./ipcModules/plsIpcHandler"); const { applyPlsIpcHandler } = require("./ipcModules/plsIpcHandler");
@@ -85,6 +86,7 @@ const buildIpcMain = (electron) => {
app.exit(0); app.exit(0);
}); });
applyBaseIpcHandler(ipcMain);
applyConfigIpcHandler(ipcMain); applyConfigIpcHandler(ipcMain);
applyFsIpcHandler(ipcMain); applyFsIpcHandler(ipcMain);
applyPlsIpcHandler(ipcMain); applyPlsIpcHandler(ipcMain);

View File

@@ -0,0 +1,59 @@
// @ts-check
const { BrowserWindow } = require("electron");
const composables = {
getBrowserWindowInstance: (windowKey) => {
if (!global.__HUGO_AURA__.hookedWindows) return null;
const hookedWindowIns = global.__HUGO_AURA__.hookedWindows.get(windowKey);
if (!hookedWindowIns) return undefined;
const browserWindowIns = BrowserWindow.fromWebContents(
hookedWindowIns.webContents
);
return browserWindowIns;
},
};
/**
*
* @param {import("electron").IpcMain} ipcMain
*/
const applyBaseIpcHandler = (ipcMain) => {
const methodBase = "$aura.base";
ipcMain.on(
`${methodBase}.minimizeWindow`,
/**
*
* @param {import("electron").IpcMainEvent} _event
* @param {{ targetWindowKey: string }} arg
*/
(_event, arg) => {
const browserWindowIns = composables.getBrowserWindowInstance(
arg.targetWindowKey
);
if (!browserWindowIns) return;
browserWindowIns.minimize();
}
);
ipcMain.on(
`${methodBase}.closeWindow`,
/**
*
* @param {import("electron").IpcMainEvent} _event
* @param {{ targetWindowKey: string }} arg
*/
(_event, arg) => {
const browserWindowIns = composables.getBrowserWindowInstance(
arg.targetWindowKey
);
if (!browserWindowIns) return;
browserWindowIns.close();
}
);
};
module.exports = { applyBaseIpcHandler };

View File

@@ -7,11 +7,48 @@
<div class="aura-config-page-app-bar" style="-webkit-app-region: drag"> <div class="aura-config-page-app-bar" style="-webkit-app-region: drag">
<div <div
onclick="global.__HUGO_AURA_UI_FUNCTIONS__.config.handleNavBack()" onclick="global.__HUGO_AURA_UI_FUNCTIONS__.config.handleNavBack()"
style="-webkit-app-region: no-drag; z-index: 2000" style="-webkit-app-region: no-drag; z-index: 2000; margin-right: 0.1rem"
> >
<i class="iconfont"></i> <i class="iconfont"></i>
<!-- Chevron Left Icon -->
</div> </div>
<p>雨光之环</p> <p>雨光之环</p>
<div class="aura-config-page-app-bar-hr-vertical"></div>
<div
onclick="global.__HUGO_AURA_UI_FUNCTIONS__.config.handleNavHome()"
style="-webkit-app-region: no-drag; z-index: 2000; margin-left: 6px"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="21"
height="21"
viewBox="0 0 24 24"
class="iconfont"
style="margin-top: -1.5px"
>
<path
fill="currentColor"
d="M6 19h3.692v-5.884h4.616V19H18v-9l-6-4.538L6 10zm-1 1V9.5l7-5.288L19 9.5V20h-5.692v-5.884h-2.616V20zm7-7.77"
stroke-width="0.5"
stroke="currentColor"
/>
</svg>
</div>
<div class="aura-config-page-app-bar-spacer"></div>
<div
onclick="global.__HUGO_AURA_UI_FUNCTIONS__.config.minimizeWindow()"
style="-webkit-app-region: no-drag; z-index: 2000"
>
<i class="iconfont"></i>
<!-- Minimize Icon -->
</div>
<div
onclick="global.__HUGO_AURA_UI_FUNCTIONS__.config.closeWindow()"
style="-webkit-app-region: no-drag; z-index: 2000; margin-left: 0.5rem"
>
<i class="iconfont"></i>
<!-- Failed / Cancel Icon -->
</div>
</div> </div>
</div> </div>

View File

@@ -6,6 +6,22 @@ global.__HUGO_AURA_UI_REACTIVES__.config = {
}; };
global.__HUGO_AURA_UI_FUNCTIONS__.config = { global.__HUGO_AURA_UI_FUNCTIONS__.config = {
closeWindow: async () => {
if (global.__HUGO_AURA_UI_REACTIVES__.config.isConfigPendingWrite) {
await global.__HUGO_AURA_UI_FUNCTIONS__.config.handleSaveConfig();
}
global.ipcRenderer.send("$aura.base.closeWindow", {
targetWindowKey: "assistant",
});
},
minimizeWindow: () => {
global.ipcRenderer.send("$aura.base.minimizeWindow", {
targetWindowKey: "assistant",
});
},
handleNavBack: () => { handleNavBack: () => {
if (global.__HUGO_AURA_UI_REACTIVES__.config.isInSubPage) { if (global.__HUGO_AURA_UI_REACTIVES__.config.isInSubPage) {
const acsDialogAreaEl = document.getElementsByClassName( const acsDialogAreaEl = document.getElementsByClassName(
@@ -30,6 +46,19 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
} }
}, },
handleNavHome: async () => {
if (global.__HUGO_AURA_UI_REACTIVES__.config.isConfigPendingWrite) {
global.__HUGO_AURA_UI_FUNCTIONS__.config.handleSaveConfig();
}
global.__HUGO_AURA_UI_FUNCTIONS__.config.hideConfigPage();
setTimeout(() => {
const onLeaveEvent = new CustomEvent("onCurConfigPageLeave");
document.dispatchEvent(onLeaveEvent);
}, 500);
},
hideConfigPage: async () => { hideConfigPage: async () => {
const defaultHeader = document.getElementsByClassName( const defaultHeader = document.getElementsByClassName(
"index__header__16DmR2a5" "index__header__16DmR2a5"

View File

@@ -19,6 +19,11 @@
color: rgba(0, 0, 0, 0.8); color: rgba(0, 0, 0, 0.8);
} }
.aura-config-page-header-area.color-reverse
.aura-config-page-app-bar-hr-vertical {
background: rgba(0, 0, 0, 0.5);
}
.aura-config-page-header-area .iconfont { .aura-config-page-header-area .iconfont {
font-size: 24px; font-size: 24px;
} }
@@ -33,7 +38,7 @@
} }
.aura-config-page-header-area p { .aura-config-page-header-area p {
margin-top: -1px; margin-top: -2px;
} }
.aura-config-page-header-area.header-collapsed { .aura-config-page-header-area.header-collapsed {
@@ -48,3 +53,16 @@
align-items: center; align-items: center;
width: 100%; width: 100%;
} }
.aura-config-page-app-bar-spacer {
flex-grow: 1;
}
.aura-config-page-app-bar-hr-vertical {
position: relative;
margin-left: 8px;
width: 1px;
background: rgba(255, 255, 255, 0.5);
height: 12px;
transition: background 0.5s;
}

View File

@@ -96,12 +96,9 @@ const functions = {
const handleExit = async () => { const handleExit = async () => {
const result = await awaitCompletePromise; const result = await awaitCompletePromise;
console.debug(result);
if (result) { if (result) {
console.debug("ret true");
return { valid: true }; return { valid: true };
} else { } else {
console.debug("ret false");
const inputEl = document.getElementById("auraSettingsPasswd"); const inputEl = document.getElementById("auraSettingsPasswd");
// @ts-expect-error // @ts-expect-error
inputEl.value = ""; inputEl.value = "";