2025-06-06 02:05:04 +08:00
|
|
|
if (!global.__HUGO_AURA_UI_FUNCTIONS__.subConfig)
|
|
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig = {};
|
|
|
|
|
|
2025-06-07 23:51:54 +08:00
|
|
|
if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
|
|
|
|
global.__HUGO_AURA_UI_REACTIVES__.subConfig = {};
|
|
|
|
|
|
2025-05-25 22:40:12 +08:00
|
|
|
(() => {
|
|
|
|
|
const REQUIRE_BASE = "../../aura/ui/pages/configSubPages/behaviourCtrl";
|
2025-11-14 02:58:09 +08:00
|
|
|
const IPC_METHOD_BASE = "$aura.aikari";
|
2025-05-25 22:40:12 +08:00
|
|
|
|
2025-06-07 23:51:54 +08:00
|
|
|
const lifecycleStatus = {
|
|
|
|
|
installed: false,
|
|
|
|
|
detached: false,
|
|
|
|
|
svcInstalled: false,
|
|
|
|
|
svcRunning: false,
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus = {
|
2025-06-07 23:51:54 +08:00
|
|
|
toastAutoHideTimeout: null,
|
2025-06-13 11:49:22 +08:00
|
|
|
curDlTaskId: null,
|
2025-06-07 23:51:54 +08:00
|
|
|
};
|
|
|
|
|
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus = {
|
2025-06-07 23:51:54 +08:00
|
|
|
updateToast: async (
|
|
|
|
|
variant,
|
|
|
|
|
title,
|
|
|
|
|
body = null,
|
|
|
|
|
closable = true,
|
|
|
|
|
autoHide = true,
|
|
|
|
|
hideAfter = 3000
|
|
|
|
|
) => {
|
2025-11-14 02:58:09 +08:00
|
|
|
const toastRootEl = document.getElementById("aikariStatusNotifyToast");
|
2025-06-07 23:51:54 +08:00
|
|
|
const toastHeaderEl = document.getElementById(
|
2025-11-14 02:58:09 +08:00
|
|
|
"aikariStatusNotifyToastTitle"
|
2025-06-07 23:51:54 +08:00
|
|
|
);
|
2025-11-16 18:35:53 +08:00
|
|
|
const toastBodyEl = document.getElementById(
|
|
|
|
|
"aikariStatusNotifyToastBody"
|
|
|
|
|
);
|
2025-06-07 23:51:54 +08:00
|
|
|
|
|
|
|
|
const bsToastIns = bootstrap.Toast.getOrCreateInstance(toastRootEl);
|
|
|
|
|
if (bsToastIns.isShown) {
|
|
|
|
|
bsToastIns.hide();
|
|
|
|
|
const timeout =
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus
|
2025-06-07 23:51:54 +08:00
|
|
|
.toastAutoHideTimeout;
|
|
|
|
|
if (timeout) {
|
|
|
|
|
clearTimeout(timeout);
|
|
|
|
|
}
|
|
|
|
|
await global.__HUGO_AURA_GLOBAL__.utils.sleep(160);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toastRootEl.setAttribute("variant", variant);
|
|
|
|
|
toastHeaderEl.innerHTML = title;
|
|
|
|
|
if (body) {
|
|
|
|
|
toastBodyEl.innerHTML = body;
|
|
|
|
|
toastRootEl.classList.remove("body-display-none");
|
|
|
|
|
} else {
|
|
|
|
|
toastRootEl.classList.add("body-display-none");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toastRootEl.setAttribute("closable", closable.toString());
|
|
|
|
|
|
|
|
|
|
bsToastIns.show();
|
|
|
|
|
if (autoHide && hideAfter) {
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus.toastAutoHideTimeout =
|
2025-06-07 23:51:54 +08:00
|
|
|
setTimeout(() => {
|
|
|
|
|
bsToastIns.hide();
|
|
|
|
|
}, hideAfter);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
updateOperationBtnStatus: async (
|
|
|
|
|
btnName,
|
|
|
|
|
isDisabled,
|
|
|
|
|
btnContent = null
|
|
|
|
|
) => {
|
2025-06-06 02:05:04 +08:00
|
|
|
const btnEl = document.getElementById(`acsBcPsp-operBtn-${btnName}`);
|
|
|
|
|
if (!btnEl) return false;
|
2025-06-07 23:51:54 +08:00
|
|
|
btnEl.setAttribute("aura-disabled", isDisabled ? "true" : "false");
|
2025-06-06 02:05:04 +08:00
|
|
|
if (btnContent) {
|
|
|
|
|
const btnPEl = btnEl.getElementsByTagName("p")[0];
|
|
|
|
|
btnPEl.textContent = btnContent;
|
|
|
|
|
}
|
2025-06-07 23:51:54 +08:00
|
|
|
if (isDisabled) {
|
2025-06-06 02:05:04 +08:00
|
|
|
btnEl.onclick = () => {};
|
|
|
|
|
} else {
|
|
|
|
|
switch (btnName) {
|
|
|
|
|
case "Refresh":
|
2025-06-07 23:51:54 +08:00
|
|
|
btnEl.onclick = () => {
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-07 23:51:54 +08:00
|
|
|
"warning",
|
|
|
|
|
"正在更新",
|
|
|
|
|
null,
|
|
|
|
|
false,
|
|
|
|
|
false,
|
|
|
|
|
null
|
|
|
|
|
);
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.refreshAikariStatus();
|
2025-06-07 23:51:54 +08:00
|
|
|
};
|
2025-06-06 02:05:04 +08:00
|
|
|
break;
|
2025-11-16 18:35:53 +08:00
|
|
|
case "Install":
|
2025-06-09 18:02:11 +08:00
|
|
|
btnEl.onclick = async () => {
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.downloadAndInstallAikariBin();
|
2025-06-09 18:02:11 +08:00
|
|
|
};
|
2025-06-06 02:05:04 +08:00
|
|
|
break;
|
2025-06-07 23:51:54 +08:00
|
|
|
|
|
|
|
|
// ↓ 这边的确可以把这些全都合并到一个可复用 fn 里去, 但没必要
|
2025-06-09 18:02:11 +08:00
|
|
|
// 如果后续要引入错误视觉反馈, 合并到单个 fn 反而会增加实现复杂度
|
2025-11-16 18:35:53 +08:00
|
|
|
case "InstallSvc":
|
2025-06-07 23:51:54 +08:00
|
|
|
btnEl.onclick = async () => {
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateOperationBtnStatus(
|
2025-11-16 18:35:53 +08:00
|
|
|
"InstallSvc",
|
2025-06-09 18:02:11 +08:00
|
|
|
true
|
|
|
|
|
);
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-07 23:51:54 +08:00
|
|
|
"info",
|
|
|
|
|
"正在请求安装",
|
|
|
|
|
null,
|
|
|
|
|
false,
|
|
|
|
|
false,
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
const ret = await ipcRenderer.invoke(
|
2025-11-14 02:58:09 +08:00
|
|
|
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
2025-06-07 23:51:54 +08:00
|
|
|
{ target: "instSvc" }
|
|
|
|
|
);
|
|
|
|
|
if (ret.success) {
|
|
|
|
|
lifecycleStatus.svcInstalled = true;
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-07 23:51:54 +08:00
|
|
|
"success",
|
|
|
|
|
"服务安装成功",
|
|
|
|
|
null,
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
2000
|
|
|
|
|
);
|
|
|
|
|
} else {
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-07 23:51:54 +08:00
|
|
|
"error",
|
|
|
|
|
"服务安装失败",
|
2025-06-11 17:25:55 +08:00
|
|
|
`<p>${ret.errorObj}</p>`,
|
2025-06-07 23:51:54 +08:00
|
|
|
true,
|
|
|
|
|
false,
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
2025-06-07 23:51:54 +08:00
|
|
|
};
|
2025-06-06 02:05:04 +08:00
|
|
|
break;
|
2025-11-16 18:35:53 +08:00
|
|
|
case "UninstallSvc":
|
|
|
|
|
if (btnContent === "卸载应用") {
|
2025-06-09 18:02:11 +08:00
|
|
|
btnEl.onclick = async () => {
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateOperationBtnStatus(
|
2025-11-16 18:35:53 +08:00
|
|
|
"UninstallSvc",
|
2025-06-09 18:02:11 +08:00
|
|
|
true
|
|
|
|
|
);
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-09 18:02:11 +08:00
|
|
|
"warning",
|
2025-11-16 18:35:53 +08:00
|
|
|
"正在卸载 Aikari",
|
|
|
|
|
`<p>
|
|
|
|
|
请在弹出窗口中完成操作
|
|
|
|
|
</p>`,
|
2025-06-09 18:02:11 +08:00
|
|
|
false,
|
|
|
|
|
false,
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
const ret = await ipcRenderer.invoke(
|
2025-11-14 02:58:09 +08:00
|
|
|
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
2025-11-16 18:35:53 +08:00
|
|
|
{ target: "uninst" }
|
2025-06-09 18:02:11 +08:00
|
|
|
);
|
|
|
|
|
if (ret.success) {
|
|
|
|
|
lifecycleStatus.installed = false;
|
|
|
|
|
lifecycleStatus.svcInstalled = false;
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA__.aikariStats.installed = false;
|
|
|
|
|
global.__HUGO_AURA__.aikariStats.connected = false;
|
|
|
|
|
global.__HUGO_AURA__.aikariStats.launched = false;
|
2025-06-11 17:25:55 +08:00
|
|
|
ipcRenderer.invoke(
|
2025-11-14 02:58:09 +08:00
|
|
|
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
|
|
|
|
global.__HUGO_AURA__.aikariStats
|
2025-06-11 17:25:55 +08:00
|
|
|
);
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-09 18:02:11 +08:00
|
|
|
"success",
|
2025-11-16 18:35:53 +08:00
|
|
|
"Aikari 已完成卸载",
|
2025-06-09 18:02:11 +08:00
|
|
|
null,
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
2000
|
|
|
|
|
);
|
|
|
|
|
} else {
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-09 18:02:11 +08:00
|
|
|
"error",
|
2025-11-16 18:35:53 +08:00
|
|
|
"Aikari 卸载失败",
|
2025-06-12 19:54:30 +08:00
|
|
|
`<p>
|
|
|
|
|
${ret.errorObj ? ret.errorObj : "检查日志以获取详细信息"}
|
|
|
|
|
</p>`,
|
2025-06-09 18:02:11 +08:00
|
|
|
true,
|
|
|
|
|
false,
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
2025-06-09 18:02:11 +08:00
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
btnEl.onclick = async () => {
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateOperationBtnStatus(
|
2025-11-16 18:35:53 +08:00
|
|
|
"UninstallSvc",
|
2025-06-09 18:02:11 +08:00
|
|
|
true
|
2025-06-07 23:51:54 +08:00
|
|
|
);
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-09 18:02:11 +08:00
|
|
|
"info",
|
|
|
|
|
lifecycleStatus.svcRunning
|
|
|
|
|
? "正在停止服务并卸载"
|
|
|
|
|
: "正在请求卸载",
|
|
|
|
|
null,
|
|
|
|
|
false,
|
2025-06-07 23:51:54 +08:00
|
|
|
false,
|
|
|
|
|
null
|
|
|
|
|
);
|
2025-06-09 18:02:11 +08:00
|
|
|
if (lifecycleStatus.svcRunning) {
|
|
|
|
|
const stopRet = await ipcRenderer.invoke(
|
2025-11-14 02:58:09 +08:00
|
|
|
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
2025-06-09 18:02:11 +08:00
|
|
|
{ target: "stopSvc" }
|
|
|
|
|
);
|
|
|
|
|
if (!stopRet.success) {
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-09 18:02:11 +08:00
|
|
|
"error",
|
|
|
|
|
"服务卸载失败: 无法停止服务",
|
2025-06-12 19:54:30 +08:00
|
|
|
`<p>${
|
|
|
|
|
stopRet.errorObj
|
|
|
|
|
? stopRet.errorObj
|
|
|
|
|
: "检查日志以获取详细信息"
|
|
|
|
|
}</p>
|
|
|
|
|
<p>
|
2025-11-14 02:58:09 +08:00
|
|
|
您可以尝试手动停止 Aikari 服务
|
2025-06-12 19:54:30 +08:00
|
|
|
</p>`,
|
2025-06-09 18:02:11 +08:00
|
|
|
true,
|
|
|
|
|
false,
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
lifecycleStatus.svcRunning = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const ret = await ipcRenderer.invoke(
|
2025-11-14 02:58:09 +08:00
|
|
|
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
2025-11-16 18:35:53 +08:00
|
|
|
{ target: "uninstSvc" }
|
2025-06-09 18:02:11 +08:00
|
|
|
);
|
|
|
|
|
if (ret.success) {
|
|
|
|
|
lifecycleStatus.svcInstalled = false;
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-09 18:02:11 +08:00
|
|
|
"success",
|
|
|
|
|
"服务卸载成功",
|
|
|
|
|
null,
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
2000
|
|
|
|
|
);
|
|
|
|
|
} else {
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-09 18:02:11 +08:00
|
|
|
"error",
|
|
|
|
|
"服务卸载失败",
|
|
|
|
|
"<p>检查日志以获取详细信息</p>",
|
|
|
|
|
true,
|
|
|
|
|
false,
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
2025-06-09 18:02:11 +08:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-07 23:51:54 +08:00
|
|
|
break;
|
|
|
|
|
case "Start":
|
|
|
|
|
btnEl.onclick = async () => {
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateOperationBtnStatus(
|
2025-06-09 18:02:11 +08:00
|
|
|
"Start",
|
|
|
|
|
true
|
|
|
|
|
);
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-07 23:51:54 +08:00
|
|
|
"info",
|
|
|
|
|
"正在请求启动",
|
|
|
|
|
null,
|
|
|
|
|
false,
|
|
|
|
|
false,
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
const ret = await ipcRenderer.invoke(
|
2025-11-14 02:58:09 +08:00
|
|
|
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
2025-06-07 23:51:54 +08:00
|
|
|
{ target: "startSvc" }
|
|
|
|
|
);
|
|
|
|
|
if (ret.success) {
|
|
|
|
|
lifecycleStatus.svcRunning = true;
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
|
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-07 23:51:54 +08:00
|
|
|
"success",
|
2025-11-14 02:58:09 +08:00
|
|
|
"Aikari 已启动",
|
2025-06-07 23:51:54 +08:00
|
|
|
null,
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
2000
|
|
|
|
|
);
|
|
|
|
|
await global.__HUGO_AURA_GLOBAL__.utils.sleep(100);
|
2025-11-16 18:35:53 +08:00
|
|
|
await ipcRenderer.invoke(
|
|
|
|
|
`${IPC_METHOD_BASE}.retryAikariConnect`
|
|
|
|
|
);
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
2025-06-07 23:51:54 +08:00
|
|
|
} else {
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
|
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-07 23:51:54 +08:00
|
|
|
"error",
|
2025-11-14 02:58:09 +08:00
|
|
|
"Aikari 启动失败",
|
|
|
|
|
"<p>检查 Aikari 日志目录以获取详细信息</p>",
|
2025-06-07 23:51:54 +08:00
|
|
|
true,
|
|
|
|
|
false,
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case "Stop":
|
|
|
|
|
btnEl.onclick = async () => {
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateOperationBtnStatus(
|
2025-06-09 18:02:11 +08:00
|
|
|
"Stop",
|
|
|
|
|
true
|
|
|
|
|
);
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-07 23:51:54 +08:00
|
|
|
"info",
|
|
|
|
|
"正在请求停止",
|
|
|
|
|
null,
|
|
|
|
|
false,
|
|
|
|
|
false,
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
const ret = await ipcRenderer.invoke(
|
2025-11-14 02:58:09 +08:00
|
|
|
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
2025-06-07 23:51:54 +08:00
|
|
|
{ target: "stopSvc" }
|
|
|
|
|
);
|
|
|
|
|
if (ret.success) {
|
|
|
|
|
lifecycleStatus.svcRunning = false;
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA__.aikariStats.launched = false;
|
|
|
|
|
global.__HUGO_AURA__.aikariStats.version = "unknown";
|
|
|
|
|
global.__HUGO_AURA__.aikariStats.status = "dead";
|
2025-06-21 19:20:01 +08:00
|
|
|
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-07 23:51:54 +08:00
|
|
|
"success",
|
2025-11-14 02:58:09 +08:00
|
|
|
"Aikari 已停止",
|
2025-06-07 23:51:54 +08:00
|
|
|
null,
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
2000
|
|
|
|
|
);
|
|
|
|
|
} else {
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-07 23:51:54 +08:00
|
|
|
"error",
|
2025-11-14 02:58:09 +08:00
|
|
|
"Aikari 停止失败",
|
2025-06-07 23:51:54 +08:00
|
|
|
null,
|
|
|
|
|
true,
|
|
|
|
|
false,
|
|
|
|
|
null
|
|
|
|
|
);
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
2025-06-07 23:51:54 +08:00
|
|
|
}
|
|
|
|
|
};
|
2025-06-06 02:05:04 +08:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
|
2025-06-07 23:51:54 +08:00
|
|
|
updateStatusContent: async () => {
|
2025-11-14 02:58:09 +08:00
|
|
|
const curAikariStats = await updateAikariStatusFromLocal();
|
2025-06-06 02:05:04 +08:00
|
|
|
|
2025-11-14 02:58:09 +08:00
|
|
|
if (curAikariStats.status === "downloading") {
|
|
|
|
|
GLOBAL_FUNCTIONS.downloadAndInstallAikariBin(true);
|
2025-06-13 11:49:22 +08:00
|
|
|
}
|
|
|
|
|
|
2025-06-06 02:05:04 +08:00
|
|
|
const acIdInst = "acs-bc-psp-installStatus-container";
|
|
|
|
|
const atIdInst = "acs-bc-psp-installStatus-text";
|
2025-06-07 23:51:54 +08:00
|
|
|
switch (lifecycleStatus.installed) {
|
2025-06-06 02:05:04 +08:00
|
|
|
case true:
|
2025-06-07 23:51:54 +08:00
|
|
|
if (!lifecycleStatus.svcInstalled) {
|
2025-11-16 18:35:53 +08:00
|
|
|
updateStatusEl(
|
|
|
|
|
acIdInst,
|
|
|
|
|
atIdInst,
|
|
|
|
|
"WARNING",
|
|
|
|
|
"应用已安装, 服务未安装"
|
|
|
|
|
);
|
|
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("InstallSvc", false);
|
2025-06-09 18:02:11 +08:00
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus(
|
2025-11-16 18:35:53 +08:00
|
|
|
"UninstallSvc",
|
2025-06-09 18:02:11 +08:00
|
|
|
false,
|
2025-11-16 18:35:53 +08:00
|
|
|
"卸载应用"
|
2025-06-09 18:02:11 +08:00
|
|
|
);
|
2025-06-07 23:51:54 +08:00
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", true);
|
|
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", true);
|
|
|
|
|
} else {
|
|
|
|
|
updateStatusEl(acIdInst, atIdInst, "SUCCESS", "已安装");
|
2025-11-16 18:35:53 +08:00
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("InstallSvc", true);
|
2025-06-09 18:02:11 +08:00
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus(
|
2025-11-16 18:35:53 +08:00
|
|
|
"UninstallSvc",
|
2025-06-09 18:02:11 +08:00
|
|
|
false,
|
|
|
|
|
"卸载服务"
|
|
|
|
|
);
|
2025-06-07 23:51:54 +08:00
|
|
|
}
|
2025-06-06 02:05:04 +08:00
|
|
|
break;
|
|
|
|
|
case false:
|
2025-06-07 23:51:54 +08:00
|
|
|
updateStatusEl(acIdInst, atIdInst, "PENDING", "未下载");
|
2025-11-16 18:35:53 +08:00
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Install", false);
|
|
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("InstallSvc", true);
|
|
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("UninstallSvc", true);
|
2025-06-07 23:51:54 +08:00
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", true);
|
|
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", true);
|
2025-06-06 02:05:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const acIdLaunch = "acs-bc-psp-launchStatus-container";
|
|
|
|
|
const atIdLaunch = "acs-bc-psp-launchStatus-text";
|
2025-06-07 23:51:54 +08:00
|
|
|
|
|
|
|
|
if (lifecycleStatus.detached) {
|
|
|
|
|
updateStatusEl(acIdLaunch, atIdLaunch, "INFO", "已分离");
|
|
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", true);
|
|
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", true);
|
|
|
|
|
} else if (lifecycleStatus.svcInstalled && lifecycleStatus.installed) {
|
2025-11-14 02:58:09 +08:00
|
|
|
switch (lifecycleStatus.svcRunning || curAikariStats.launched) {
|
2025-06-07 23:51:54 +08:00
|
|
|
case true:
|
2025-11-14 02:58:09 +08:00
|
|
|
if (curAikariStats.status !== "notReady") {
|
2025-06-07 23:51:54 +08:00
|
|
|
updateStatusEl(acIdLaunch, atIdLaunch, "SUCCESS", "已启动");
|
|
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", true);
|
|
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", false);
|
|
|
|
|
} else {
|
|
|
|
|
updateStatusEl(acIdLaunch, atIdLaunch, "WARNING", "启动中");
|
|
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", true);
|
|
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", false);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case false:
|
|
|
|
|
updateStatusEl(acIdLaunch, atIdLaunch, "PENDING", "未启动");
|
|
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", false);
|
|
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", true);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2025-06-06 02:05:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const acIdConn = "acs-bc-psp-connStatus-container";
|
|
|
|
|
const atIdConn = "acs-bc-psp-connStatus-text";
|
2025-11-14 02:58:09 +08:00
|
|
|
switch (curAikariStats.connected) {
|
2025-06-06 02:05:04 +08:00
|
|
|
case true:
|
|
|
|
|
updateStatusEl(acIdConn, atIdConn, "SUCCESS", "已连接");
|
|
|
|
|
break;
|
|
|
|
|
case false:
|
2025-11-14 02:58:09 +08:00
|
|
|
if (curAikariStats.status !== "notReady") {
|
2025-06-07 23:51:54 +08:00
|
|
|
updateStatusEl(acIdConn, atIdConn, "FAILED", "连接失败");
|
|
|
|
|
} else {
|
|
|
|
|
updateStatusEl(acIdConn, atIdConn, "PENDING", "等待启动");
|
|
|
|
|
}
|
2025-06-06 02:05:04 +08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-21 19:20:01 +08:00
|
|
|
const versionTextEl = document.getElementById("acs-bc-psp-version-text");
|
2025-11-14 02:58:09 +08:00
|
|
|
if (curAikariStats.version && curAikariStats.version !== "unknown") {
|
|
|
|
|
versionTextEl.textContent = curAikariStats.version;
|
2025-06-21 19:20:01 +08:00
|
|
|
} else {
|
2025-11-16 18:35:53 +08:00
|
|
|
versionTextEl.textContent = "不可用";
|
2025-06-06 02:05:04 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2025-11-14 02:58:09 +08:00
|
|
|
refreshAikariStatus: async (init = false) => {
|
|
|
|
|
const isDetachedRet = await ipcRenderer.invoke(
|
|
|
|
|
`${IPC_METHOD_BASE}.aikariLifecycleQuery`,
|
|
|
|
|
{ target: "isDetached" }
|
|
|
|
|
);
|
|
|
|
|
if (isDetachedRet.success && isDetachedRet.result) {
|
|
|
|
|
lifecycleStatus.detached = true;
|
|
|
|
|
} else {
|
|
|
|
|
lifecycleStatus.detached = false;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-07 23:51:54 +08:00
|
|
|
const binExistsRet = await ipcRenderer.invoke(
|
2025-11-14 02:58:09 +08:00
|
|
|
`${IPC_METHOD_BASE}.getIfAikariBinExists`
|
2025-06-07 23:51:54 +08:00
|
|
|
);
|
2025-11-16 18:35:53 +08:00
|
|
|
if (
|
|
|
|
|
(binExistsRet.success && binExistsRet.data.isExists) ||
|
|
|
|
|
lifecycleStatus.detached
|
|
|
|
|
) {
|
2025-06-07 23:51:54 +08:00
|
|
|
lifecycleStatus.installed = true;
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA__.aikariStats.installed = true;
|
2025-06-11 17:25:55 +08:00
|
|
|
ipcRenderer.invoke(
|
2025-11-14 02:58:09 +08:00
|
|
|
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
|
|
|
|
global.__HUGO_AURA__.aikariStats
|
2025-06-11 17:25:55 +08:00
|
|
|
);
|
2025-06-07 23:51:54 +08:00
|
|
|
} else {
|
|
|
|
|
lifecycleStatus.installed = false;
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA__.aikariStats.installed = false;
|
2025-06-11 17:25:55 +08:00
|
|
|
ipcRenderer.invoke(
|
2025-11-14 02:58:09 +08:00
|
|
|
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
|
|
|
|
global.__HUGO_AURA__.aikariStats
|
2025-06-11 17:25:55 +08:00
|
|
|
);
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-09 18:02:11 +08:00
|
|
|
"error",
|
2025-11-14 02:58:09 +08:00
|
|
|
"请下载 Aikari 内核以继续",
|
2025-06-09 18:02:11 +08:00
|
|
|
null,
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
3000
|
|
|
|
|
);
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
2025-06-07 23:51:54 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const isSvcInstalledRet = await ipcRenderer.invoke(
|
2025-11-14 02:58:09 +08:00
|
|
|
`${IPC_METHOD_BASE}.aikariLifecycleQuery`,
|
2025-06-07 23:51:54 +08:00
|
|
|
{ target: "isSvcInstalled" }
|
|
|
|
|
);
|
|
|
|
|
if (isSvcInstalledRet.success && isSvcInstalledRet.result) {
|
|
|
|
|
lifecycleStatus.svcInstalled = true;
|
|
|
|
|
} else {
|
|
|
|
|
lifecycleStatus.svcInstalled = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const isSvcRunningRet = await ipcRenderer.invoke(
|
2025-11-14 02:58:09 +08:00
|
|
|
`${IPC_METHOD_BASE}.aikariLifecycleQuery`,
|
2025-06-07 23:51:54 +08:00
|
|
|
{ target: "isSvcStart" }
|
|
|
|
|
);
|
|
|
|
|
if (isSvcRunningRet.success && isSvcRunningRet.result) {
|
|
|
|
|
lifecycleStatus.svcRunning = true;
|
|
|
|
|
} else {
|
|
|
|
|
lifecycleStatus.svcRunning = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (init) {
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
2025-06-07 23:51:54 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-06 02:05:04 +08:00
|
|
|
const updateOperationBtnStatus =
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus
|
2025-06-06 02:05:04 +08:00
|
|
|
.updateOperationBtnStatus;
|
|
|
|
|
updateOperationBtnStatus("Refresh", true);
|
|
|
|
|
const result = await ipcRenderer.invoke(
|
2025-11-14 02:58:09 +08:00
|
|
|
`${IPC_METHOD_BASE}.retryAikariConnect`
|
2025-06-06 02:05:04 +08:00
|
|
|
);
|
|
|
|
|
if (result.success && result.status === "Retrying") {
|
|
|
|
|
updateOperationBtnStatus("Refresh", true, "正在重连");
|
|
|
|
|
|
|
|
|
|
ipcRenderer.once(
|
|
|
|
|
`${IPC_METHOD_BASE}.post.updateRetryStatus`,
|
2025-06-07 23:51:54 +08:00
|
|
|
async (_evt, arg) => {
|
2025-06-06 02:05:04 +08:00
|
|
|
await global.__HUGO_AURA_GLOBAL__.utils.sleep(50);
|
|
|
|
|
updateOperationBtnStatus("Refresh", false, "刷新状态");
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-07 23:51:54 +08:00
|
|
|
arg.success ? "success" : "error",
|
|
|
|
|
arg.success ? "更新成功" : "连接失败",
|
|
|
|
|
null,
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
3000
|
|
|
|
|
);
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
2025-06-06 02:05:04 +08:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
} else if (result.success && result.status === "Already") {
|
|
|
|
|
updateOperationBtnStatus("Refresh", false, "刷新状态");
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
2025-06-09 18:02:11 +08:00
|
|
|
"success",
|
|
|
|
|
"更新成功",
|
|
|
|
|
null,
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
3000
|
|
|
|
|
);
|
2025-06-06 02:05:04 +08:00
|
|
|
}
|
|
|
|
|
},
|
2025-06-09 18:02:11 +08:00
|
|
|
|
2025-06-13 11:49:22 +08:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param {boolean} isShow
|
|
|
|
|
*/
|
|
|
|
|
switchPBarShowStatus: (isShow) => {
|
|
|
|
|
const operAreaEl = document.getElementsByClassName(
|
|
|
|
|
"acs-bc-psp-operations-container"
|
|
|
|
|
)[0];
|
|
|
|
|
const pBarAreaEl = document.getElementsByClassName(
|
|
|
|
|
"acs-bc-psp-download-progress-area"
|
|
|
|
|
)[0];
|
|
|
|
|
const pBarDescEl = document.getElementById("acsBcPspDownloadPbarDesc");
|
|
|
|
|
const pBarSelfEl = document.getElementById("acsBcPspDownloadPbarEl");
|
|
|
|
|
|
|
|
|
|
if (isShow) {
|
|
|
|
|
pBarAreaEl.classList.remove("acs-bc-psp-dl-pbar-hidden");
|
|
|
|
|
operAreaEl.classList.add("acs-bc-psp-oper-ctnr-hidden");
|
|
|
|
|
pBarDescEl.textContent = "等待中...";
|
|
|
|
|
pBarSelfEl.style["width"] = "0";
|
|
|
|
|
} else {
|
|
|
|
|
pBarAreaEl.classList.add("acs-bc-psp-dl-pbar-hidden");
|
|
|
|
|
operAreaEl.classList.remove("acs-bc-psp-oper-ctnr-hidden");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
updatePBarStatus: async (
|
|
|
|
|
progress = null,
|
|
|
|
|
desc = null,
|
|
|
|
|
type = null,
|
|
|
|
|
isCancelShown = null
|
|
|
|
|
) => {
|
|
|
|
|
const pBarDescEl = document.getElementById("acsBcPspDownloadPbarDesc");
|
|
|
|
|
const pBarSelfEl = document.getElementById("acsBcPspDownloadPbarEl");
|
|
|
|
|
const pBarBtnEl = document.getElementById(
|
|
|
|
|
"acsBcPspDownloadPbarCancelBtn"
|
|
|
|
|
);
|
|
|
|
|
if (progress) {
|
|
|
|
|
pBarSelfEl.style["width"] = `${progress}%`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type) {
|
|
|
|
|
pBarSelfEl.classList.remove("bg-success");
|
|
|
|
|
pBarSelfEl.classList.remove("bg-warning");
|
|
|
|
|
pBarSelfEl.classList.remove("bg-danger");
|
|
|
|
|
if (type !== "normal") {
|
|
|
|
|
pBarSelfEl.classList.add(`bg-${type}`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (desc) {
|
|
|
|
|
pBarDescEl.innerHTML = desc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isCancelShown !== null) {
|
|
|
|
|
if (isCancelShown) {
|
|
|
|
|
pBarBtnEl.classList.remove("hidden");
|
|
|
|
|
} else {
|
|
|
|
|
pBarBtnEl.classList.add("hidden");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2025-11-14 02:58:09 +08:00
|
|
|
downloadAikariBin: async (retrieveMode = false) => {
|
2025-06-09 18:02:11 +08:00
|
|
|
const GLOBAL_FUNCTIONS =
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus;
|
|
|
|
|
const CUR_CHANNEL = `${IPC_METHOD_BASE}.post.reportAikariInstallStep`;
|
2025-06-13 11:49:22 +08:00
|
|
|
|
|
|
|
|
if (!retrieveMode) {
|
2025-11-16 18:35:53 +08:00
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Install", true, "正在检查");
|
2025-06-13 11:49:22 +08:00
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Refresh", true);
|
2025-11-14 02:58:09 +08:00
|
|
|
await ipcRenderer.invoke(`${IPC_METHOD_BASE}.ensureAikariInstallDir`);
|
2025-06-13 11:49:22 +08:00
|
|
|
GLOBAL_FUNCTIONS.updateToast(
|
|
|
|
|
"info",
|
|
|
|
|
"准备开始下载...",
|
|
|
|
|
null,
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
2000
|
|
|
|
|
);
|
2025-11-16 18:35:53 +08:00
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Install", true);
|
2025-06-13 11:49:22 +08:00
|
|
|
} else {
|
|
|
|
|
GLOBAL_FUNCTIONS.updateToast(
|
|
|
|
|
"info",
|
|
|
|
|
"正在恢复下载状态",
|
|
|
|
|
null,
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
2000
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GLOBAL_FUNCTIONS.switchPBarShowStatus(true);
|
|
|
|
|
GLOBAL_FUNCTIONS.updatePBarStatus(0, "等待中...", "normal", false);
|
2025-06-09 18:02:11 +08:00
|
|
|
|
|
|
|
|
const callbackFn = (_evt, info) => {
|
|
|
|
|
switch (info.status) {
|
|
|
|
|
case "failed":
|
|
|
|
|
GLOBAL_FUNCTIONS.updateToast(
|
|
|
|
|
"error",
|
|
|
|
|
"下载失败",
|
|
|
|
|
`<p>${
|
|
|
|
|
info.message ? info.message : "检查日志以获取错误信息"
|
2025-06-12 19:54:30 +08:00
|
|
|
}</p><p>
|
|
|
|
|
${info.errorObj ? info.errorObj : ""}
|
|
|
|
|
</p>`,
|
2025-06-09 18:02:11 +08:00
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
5000
|
|
|
|
|
);
|
2025-06-13 11:49:22 +08:00
|
|
|
|
|
|
|
|
GLOBAL_FUNCTIONS.updatePBarStatus(
|
|
|
|
|
100,
|
|
|
|
|
"下载时发生错误",
|
|
|
|
|
"danger",
|
|
|
|
|
false
|
|
|
|
|
);
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
GLOBAL_FUNCTIONS.switchPBarShowStatus(false);
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
2025-06-09 18:02:11 +08:00
|
|
|
ipcRenderer.off(CUR_CHANNEL, callbackFn);
|
|
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Refresh", false);
|
2025-06-13 11:49:22 +08:00
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus(
|
2025-11-16 18:35:53 +08:00
|
|
|
"Install",
|
2025-06-13 11:49:22 +08:00
|
|
|
false,
|
2025-11-16 18:35:53 +08:00
|
|
|
"下载应用"
|
2025-06-13 11:49:22 +08:00
|
|
|
);
|
2025-06-09 18:02:11 +08:00
|
|
|
break;
|
|
|
|
|
case "done":
|
|
|
|
|
GLOBAL_FUNCTIONS.updateToast(
|
|
|
|
|
"success",
|
|
|
|
|
"下载成功",
|
|
|
|
|
null,
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
2500
|
|
|
|
|
);
|
2025-06-13 11:49:22 +08:00
|
|
|
|
|
|
|
|
GLOBAL_FUNCTIONS.updatePBarStatus(
|
|
|
|
|
100,
|
|
|
|
|
"下载成功",
|
|
|
|
|
"success",
|
|
|
|
|
false
|
|
|
|
|
);
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
GLOBAL_FUNCTIONS.switchPBarShowStatus(false);
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
2025-06-09 18:02:11 +08:00
|
|
|
ipcRenderer.off(CUR_CHANNEL, callbackFn);
|
|
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Refresh", false);
|
|
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus(
|
2025-11-16 18:35:53 +08:00
|
|
|
"Install",
|
2025-06-09 18:02:11 +08:00
|
|
|
true,
|
2025-11-16 18:35:53 +08:00
|
|
|
"下载应用"
|
2025-06-09 18:02:11 +08:00
|
|
|
);
|
|
|
|
|
lifecycleStatus.installed = true;
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA__.aikariStats.installed = true;
|
2025-06-11 17:25:55 +08:00
|
|
|
ipcRenderer.invoke(
|
2025-11-14 02:58:09 +08:00
|
|
|
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
|
|
|
|
global.__HUGO_AURA__.aikariStats
|
2025-06-11 17:25:55 +08:00
|
|
|
);
|
2025-06-09 18:02:11 +08:00
|
|
|
GLOBAL_FUNCTIONS.updateStatusContent();
|
|
|
|
|
break;
|
|
|
|
|
case "waiting":
|
2025-06-13 11:49:22 +08:00
|
|
|
GLOBAL_FUNCTIONS.updatePBarStatus(0, "正在连接", "normal");
|
|
|
|
|
if (
|
2025-11-14 02:58:09 +08:00
|
|
|
!global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus
|
2025-06-13 11:49:22 +08:00
|
|
|
.curDlTaskId ||
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus
|
2025-06-13 11:49:22 +08:00
|
|
|
.curDlTaskId !== info.id
|
|
|
|
|
) {
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus.curDlTaskId =
|
2025-06-13 11:49:22 +08:00
|
|
|
info.id;
|
|
|
|
|
}
|
2025-06-09 18:02:11 +08:00
|
|
|
break;
|
|
|
|
|
case "progressing":
|
2025-06-13 11:49:22 +08:00
|
|
|
const roundProgress = Math.round(info.progress);
|
|
|
|
|
GLOBAL_FUNCTIONS.updatePBarStatus(
|
|
|
|
|
roundProgress,
|
|
|
|
|
`正在下载中... ${roundProgress}% (${(
|
|
|
|
|
info.curBytes /
|
|
|
|
|
1024 /
|
|
|
|
|
1024
|
|
|
|
|
).toFixed(2)}MB / ${(info.totalBytes / 1024 / 1024).toFixed(
|
|
|
|
|
2
|
|
|
|
|
)}MB)`, // POWERED BY PRETTIER
|
|
|
|
|
"normal",
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
case "struggling":
|
|
|
|
|
GLOBAL_FUNCTIONS.updatePBarStatus(100, info.message, "warning");
|
|
|
|
|
break;
|
|
|
|
|
case "cancelled":
|
|
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Refresh", false);
|
2025-06-09 18:02:11 +08:00
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus(
|
2025-11-16 18:35:53 +08:00
|
|
|
"Install",
|
2025-06-13 11:49:22 +08:00
|
|
|
false,
|
2025-11-16 18:35:53 +08:00
|
|
|
"下载应用"
|
2025-06-09 18:02:11 +08:00
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ipcRenderer.on(CUR_CHANNEL, callbackFn);
|
|
|
|
|
|
2025-11-14 02:58:09 +08:00
|
|
|
ipcRenderer.invoke(`${IPC_METHOD_BASE}.downloadAndInstallAikari`, {
|
2025-06-09 18:02:11 +08:00
|
|
|
channel: "stable",
|
|
|
|
|
reportTo: "assistant",
|
|
|
|
|
});
|
|
|
|
|
},
|
2025-06-13 11:49:22 +08:00
|
|
|
|
|
|
|
|
cancelDownloadTask: async () => {
|
|
|
|
|
const taskId =
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus.curDlTaskId;
|
2025-06-13 11:49:22 +08:00
|
|
|
|
|
|
|
|
if (!taskId) {
|
|
|
|
|
GLOBAL_FUNCTIONS.updateToast(
|
|
|
|
|
"error",
|
|
|
|
|
"操作取消失败",
|
|
|
|
|
"<p>未能获取当前的下载任务 ID</p>",
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
3000
|
|
|
|
|
);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const result = await ipcRenderer.invoke(
|
|
|
|
|
"$aura.fs.dl.cancelDownloadTask",
|
|
|
|
|
{ targetTaskId: taskId }
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (result.success) {
|
|
|
|
|
GLOBAL_FUNCTIONS.updateToast(
|
|
|
|
|
"success",
|
|
|
|
|
"操作取消成功",
|
|
|
|
|
null,
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
2000
|
|
|
|
|
);
|
|
|
|
|
GLOBAL_FUNCTIONS.switchPBarShowStatus(false);
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
GLOBAL_FUNCTIONS.updateToast(
|
|
|
|
|
"error",
|
|
|
|
|
"操作取消失败",
|
|
|
|
|
`<p>错误代码: ${result.error}</p>`,
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
3000
|
|
|
|
|
);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
},
|
2025-06-06 02:05:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const GLOBAL_FUNCTIONS =
|
2025-11-14 02:58:09 +08:00
|
|
|
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus;
|
2025-06-06 02:05:04 +08:00
|
|
|
|
2025-05-25 22:40:12 +08:00
|
|
|
const {
|
2025-11-14 02:58:09 +08:00
|
|
|
updateAikariStatusFromLocal,
|
|
|
|
|
} = require(`${REQUIRE_BASE}/../../../composables/aikariConfigManager`);
|
2025-05-25 22:40:12 +08:00
|
|
|
|
2025-06-06 02:05:04 +08:00
|
|
|
const initBsTooltip = () => {
|
|
|
|
|
const tooltipTriggerList = document.querySelectorAll(
|
|
|
|
|
'[data-bs-toggle="tooltip"]'
|
|
|
|
|
);
|
|
|
|
|
const _tooltipList = [...tooltipTriggerList].map(
|
|
|
|
|
(tooltipTriggerEl) => new bootstrap.Tooltip(tooltipTriggerEl)
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2025-05-25 22:40:12 +08:00
|
|
|
const updateStatusEl = (
|
|
|
|
|
areaContainerId,
|
|
|
|
|
areaTextId,
|
|
|
|
|
target,
|
|
|
|
|
text = false
|
|
|
|
|
) => {
|
|
|
|
|
const areaContainerEl = document.getElementById(areaContainerId);
|
|
|
|
|
const areaContainerText = document.getElementById(areaTextId);
|
|
|
|
|
switch (target) {
|
|
|
|
|
case "PENDING":
|
|
|
|
|
areaContainerEl.className =
|
2025-11-14 02:58:09 +08:00
|
|
|
"acs-bc-aikari-status-page-status-area pending";
|
2025-05-25 22:40:12 +08:00
|
|
|
break;
|
|
|
|
|
case "SUCCESS":
|
|
|
|
|
areaContainerEl.className =
|
2025-11-14 02:58:09 +08:00
|
|
|
"acs-bc-aikari-status-page-status-area success";
|
2025-05-25 22:40:12 +08:00
|
|
|
break;
|
|
|
|
|
case "FAILED":
|
2025-11-16 18:35:53 +08:00
|
|
|
areaContainerEl.className =
|
|
|
|
|
"acs-bc-aikari-status-page-status-area failed";
|
2025-05-25 22:40:12 +08:00
|
|
|
break;
|
|
|
|
|
case "WARNING":
|
|
|
|
|
areaContainerEl.className =
|
2025-11-14 02:58:09 +08:00
|
|
|
"acs-bc-aikari-status-page-status-area warning";
|
2025-05-25 22:40:12 +08:00
|
|
|
break;
|
2025-06-07 23:51:54 +08:00
|
|
|
case "INFO":
|
2025-11-16 18:35:53 +08:00
|
|
|
areaContainerEl.className =
|
|
|
|
|
"acs-bc-aikari-status-page-status-area info";
|
2025-06-07 23:51:54 +08:00
|
|
|
break;
|
2025-05-25 22:40:12 +08:00
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
areaContainerText.textContent = text ? text : "";
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const onMounted = () => {
|
2025-06-06 02:05:04 +08:00
|
|
|
initBsTooltip();
|
2025-06-07 23:51:54 +08:00
|
|
|
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Refresh", false);
|
2025-11-14 02:58:09 +08:00
|
|
|
GLOBAL_FUNCTIONS.refreshAikariStatus(true);
|
2025-06-10 00:28:53 +08:00
|
|
|
|
|
|
|
|
const eventListener = () => {
|
2025-06-07 23:51:54 +08:00
|
|
|
GLOBAL_FUNCTIONS.updateStatusContent();
|
2025-06-10 00:28:53 +08:00
|
|
|
};
|
2025-11-14 02:58:09 +08:00
|
|
|
document.addEventListener("onAikariStatsUpdate", eventListener);
|
2025-06-10 00:28:53 +08:00
|
|
|
global.__HUGO_AURA_GLOBAL__.utils.createOnLeaveEvtListener(
|
2025-11-14 02:58:09 +08:00
|
|
|
"onAikariStatsUpdate",
|
2025-06-10 00:28:53 +08:00
|
|
|
eventListener
|
|
|
|
|
);
|
2025-05-25 22:40:12 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onMounted();
|
|
|
|
|
})();
|