mirror of
https://github.com/HugoAura/Seewo-HugoAura.git
synced 2026-06-20 15:04:27 +08:00
[🔄 Chore] Prepare for Aikari (1/2)
1. [/] 一些无意义的重命名工作 2. [*] 修改了 WebSocket 对接逻辑
This commit is contained in:
2
.github/workflows/pack.yml
vendored
2
.github/workflows/pack.yml
vendored
@@ -1,8 +1,6 @@
|
||||
name: Pack source code & Create CI/CD Release
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 5 * * *'
|
||||
push:
|
||||
branches: [dev, stable]
|
||||
pull_request:
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -15,6 +15,7 @@ autoConfiguration.json
|
||||
|
||||
# NPM Packages
|
||||
node_modules/
|
||||
package-lock.json
|
||||
|
||||
# OS Files
|
||||
desktop.ini
|
||||
|
||||
@@ -80,7 +80,7 @@ const buildIpcMain = (electron) => {
|
||||
const { applyDebugIpcHandler } = require("./ipcModules/debugIpcHandler");
|
||||
const { applyConfigIpcHandler } = require("./ipcModules/configIpcHandler");
|
||||
const { applyFsIpcHandler } = require("./ipcModules/fsIpcHandler");
|
||||
const { applyPlsIpcHandler } = require("./ipcModules/plsIpcHandler");
|
||||
const { applyAikariIpcHandler } = require("./ipcModules/aikariIpcHandler");
|
||||
|
||||
ipcMain.handle("$aura.base.restartApplication", async () => {
|
||||
app.relaunch();
|
||||
@@ -91,7 +91,7 @@ const buildIpcMain = (electron) => {
|
||||
applyDebugIpcHandler(ipcMain);
|
||||
applyConfigIpcHandler(ipcMain);
|
||||
applyFsIpcHandler(ipcMain);
|
||||
applyPlsIpcHandler(ipcMain);
|
||||
applyAikariIpcHandler(ipcMain);
|
||||
};
|
||||
|
||||
module.exports = { buildIpcMain };
|
||||
|
||||
229
src/aura/init/main/ipcModules/plsIpcHandler.js → src/aura/init/main/ipcModules/aikariIpcHandler.js
Executable file → Normal file
229
src/aura/init/main/ipcModules/plsIpcHandler.js → src/aura/init/main/ipcModules/aikariIpcHandler.js
Executable file → Normal file
@@ -68,7 +68,7 @@ const functions = {
|
||||
* @param {(arg: DownloadTask) => any} callbackFn
|
||||
* @param {string} binPath
|
||||
*/
|
||||
handlePLSDownload: async (channel, callbackFn, binPath) => {
|
||||
handleAikariDownload: async (channel, callbackFn, binPath) => {
|
||||
// TODO: Channel selection
|
||||
const apiInfo = global.__HUGO_AURA_API__;
|
||||
|
||||
@@ -78,7 +78,7 @@ const functions = {
|
||||
const reqPromise = new Promise((resolveHttpRequest) => {
|
||||
nodeHttps
|
||||
.get(
|
||||
`${apiDomain}${apiInfo.plsUpdate}?channel=${channel}`,
|
||||
`${apiDomain}${apiInfo.aikariUpdate}?channel=${channel}`,
|
||||
(rep) => {
|
||||
let dataChunk = "";
|
||||
rep.on("data", (chunk) => {
|
||||
@@ -167,12 +167,12 @@ const functions = {
|
||||
status: "failed",
|
||||
dlUrl: null,
|
||||
savePath: null,
|
||||
message: "未能获取 PLS 版本信息, 所有 API 域名均无法连接",
|
||||
message: "未能获取 Aikari 版本信息, 所有 API 域名均无法连接",
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
const plsVersionInfo = rawResInfo.data;
|
||||
const aikariVersionInfo = rawResInfo.data;
|
||||
|
||||
let deviceArch = process.env.PROCESSOR_ARCHITEW6432
|
||||
? process.env.PROCESSOR_ARCHITEW6432
|
||||
@@ -180,7 +180,7 @@ const functions = {
|
||||
// @ts-expect-error
|
||||
deviceArch = deviceArch.toLowerCase();
|
||||
|
||||
if (!Object.keys(plsVersionInfo.data.downloadUrl).includes(deviceArch)) {
|
||||
if (!Object.keys(aikariVersionInfo.data.downloadUrl).includes(deviceArch)) {
|
||||
callbackFn({
|
||||
id: "",
|
||||
progress: 0,
|
||||
@@ -193,13 +193,13 @@ const functions = {
|
||||
}
|
||||
|
||||
fsComposables.downloadFile(
|
||||
plsVersionInfo.data.downloadUrl[deviceArch],
|
||||
aikariVersionInfo.data.downloadUrl[deviceArch],
|
||||
binPath,
|
||||
(...args) => {
|
||||
if (args[0].status === "done") {
|
||||
if (global.__HUGO_AURA__.plsStats) {
|
||||
global.__HUGO_AURA__.plsStats.installed = true;
|
||||
global.__HUGO_AURA__.plsStats.status = "dead";
|
||||
if (global.__HUGO_AURA__.aikariStats) {
|
||||
global.__HUGO_AURA__.aikariStats.installed = true;
|
||||
global.__HUGO_AURA__.aikariStats.status = "dead";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,37 +213,43 @@ const functions = {
|
||||
*
|
||||
* @param {import("../../../types/main/electron").AuraIPCMain} ipcMain
|
||||
*/
|
||||
const applyPlsIpcHandler = (ipcMain) => {
|
||||
const methodBase = "$aura.pls";
|
||||
const applyAikariIpcHandler = (ipcMain) => {
|
||||
const methodBase = "$aura.aikari";
|
||||
|
||||
const PLS_INSTALL_DIR = path.join("C:\\Program Files", "HugoAura PLS", "bin");
|
||||
const PLS_BIN_PATH = path.join(PLS_INSTALL_DIR, "HugoAura-PLS.exe");
|
||||
const PLS_SVC_NAME = "HugoAuraPLS";
|
||||
const AIKARI_DEFAULT_INSTALL_DIR = path.join(
|
||||
"C:\\Program Files",
|
||||
"HugoAura Aikari"
|
||||
);
|
||||
const AIKARI_LAUNCHER_PATH = path.join(
|
||||
AIKARI_DEFAULT_INSTALL_DIR,
|
||||
"Aikari-Launcher.exe"
|
||||
);
|
||||
const AIKARI_SVC_NAME = "HugoAuraAikari";
|
||||
|
||||
const isPlsDetached = process.argv.includes("--pls-detach");
|
||||
const isAikariDetached = process.argv.includes("--aikari-detach");
|
||||
|
||||
global.__HUGO_AURA__.plsStats = {
|
||||
global.__HUGO_AURA__.aikariStats = {
|
||||
installed: false,
|
||||
launched: false,
|
||||
detached: isPlsDetached,
|
||||
detached: isAikariDetached,
|
||||
connected: false,
|
||||
version: "unknown",
|
||||
status: "dead",
|
||||
authToken: global.__HUGO_AURA_CONFIG__.plsToken,
|
||||
authToken: global.__HUGO_AURA_CONFIG__.aikariToken,
|
||||
};
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.getPlsBinExists`,
|
||||
`${methodBase}.getIfAikariBinExists`,
|
||||
/**
|
||||
*
|
||||
* @returns {{ success: boolean; data: { isExists: boolean }; error?: Error }}
|
||||
*/
|
||||
(_event, _arg) => {
|
||||
try {
|
||||
const result = fs.existsSync(PLS_BIN_PATH);
|
||||
const result = fs.existsSync(AIKARI_LAUNCHER_PATH);
|
||||
|
||||
if (global.__HUGO_AURA__.plsStats?.status === "notInstalled") {
|
||||
global.__HUGO_AURA__.plsStats.status = "dead";
|
||||
if (global.__HUGO_AURA__.aikariStats?.status === "notInstalled") {
|
||||
global.__HUGO_AURA__.aikariStats.status = "dead";
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -252,7 +258,7 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
};
|
||||
} catch (e) {
|
||||
// @ts-expect-error
|
||||
global.__HUGO_AURA__.plsStats.status = "notInstalled";
|
||||
global.__HUGO_AURA__.aikariStats.status = "notInstalled";
|
||||
return {
|
||||
success: false,
|
||||
data: { isExists: false },
|
||||
@@ -263,7 +269,7 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.ensurePlsInstallDir`,
|
||||
`${methodBase}.ensureAikariInstallDir`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _event
|
||||
@@ -271,24 +277,24 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
* @returns {{ success: boolean; data: { alreadyExists: boolean; createdDir: string; }; error?: Error }}
|
||||
*/
|
||||
(_event, _arg) => {
|
||||
const alreadyExists = fs.existsSync(PLS_INSTALL_DIR);
|
||||
const alreadyExists = fs.existsSync(AIKARI_DEFAULT_INSTALL_DIR);
|
||||
if (alreadyExists) {
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
alreadyExists: true,
|
||||
createdDir: PLS_INSTALL_DIR,
|
||||
createdDir: AIKARI_DEFAULT_INSTALL_DIR,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
fs.mkdirSync(PLS_INSTALL_DIR, { recursive: true });
|
||||
fs.mkdirSync(AIKARI_DEFAULT_INSTALL_DIR, { recursive: true });
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
alreadyExists: false,
|
||||
createdDir: PLS_INSTALL_DIR,
|
||||
createdDir: AIKARI_DEFAULT_INSTALL_DIR,
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
@@ -296,7 +302,7 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
success: false,
|
||||
data: {
|
||||
alreadyExists: false,
|
||||
createdDir: PLS_INSTALL_DIR,
|
||||
createdDir: AIKARI_DEFAULT_INSTALL_DIR,
|
||||
},
|
||||
error: error,
|
||||
};
|
||||
@@ -305,30 +311,30 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.getPlsStats`,
|
||||
`${methodBase}.getAikariStatus`,
|
||||
/**
|
||||
*
|
||||
* @returns {{ success: boolean; data: import("../../../types/shared/pls/status").PLSStatus | null | undefined; }}
|
||||
* @returns {{ success: boolean; data: import("../../../types/shared/aikari/status").AikariStatus | null | undefined; }}
|
||||
*/
|
||||
(_event, _arg) => {
|
||||
return {
|
||||
success: true,
|
||||
data: global.__HUGO_AURA__.plsStats,
|
||||
data: global.__HUGO_AURA__.aikariStats,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.updatePlsStats`,
|
||||
`${methodBase}.updateAikariStatus`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _event
|
||||
* @param {import("../../../types/shared/pls/status").PLSStatus} arg
|
||||
* @param {import("../../../types/shared/aikari/status").AikariStatus} arg
|
||||
* @returns
|
||||
*/
|
||||
(_event, arg) => {
|
||||
global.__HUGO_AURA__.plsStats = arg;
|
||||
ipcMain.send("assistant", `${methodBase}.post.onPlsStatsUpdate`, arg);
|
||||
global.__HUGO_AURA__.aikariStats = arg;
|
||||
ipcMain.send("assistant", `${methodBase}.post.onAikariStatsUpdate`, arg);
|
||||
return {
|
||||
success: true,
|
||||
};
|
||||
@@ -336,7 +342,7 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.getPlsSettings`,
|
||||
`${methodBase}.getAikariSettings`,
|
||||
/**
|
||||
*
|
||||
* @returns {{ success: boolean; data: Record<any, any> | null | undefined }}
|
||||
@@ -344,13 +350,13 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
(_event, _arg) => {
|
||||
return {
|
||||
success: true,
|
||||
data: global.__HUGO_AURA__.plsSettings,
|
||||
data: global.__HUGO_AURA__.aikariSettings,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.updatePlsSettings`,
|
||||
`${methodBase}.updateAikariSettings`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _event
|
||||
@@ -358,8 +364,12 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
* @returns
|
||||
*/
|
||||
(_event, arg) => {
|
||||
global.__HUGO_AURA__.plsSettings = arg;
|
||||
ipcMain.send("assistant", `${methodBase}.post.onPlsSettingsUpdate`, arg);
|
||||
global.__HUGO_AURA__.aikariSettings = arg;
|
||||
ipcMain.send(
|
||||
"assistant",
|
||||
`${methodBase}.post.onAikariSettingsUpdate`,
|
||||
arg
|
||||
);
|
||||
return {
|
||||
success: true,
|
||||
};
|
||||
@@ -367,7 +377,7 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.getPlsRules`,
|
||||
`${methodBase}.getAikariRules`,
|
||||
/**
|
||||
*
|
||||
* @returns {{ success: boolean; data: Record<any, any> | null | undefined }}
|
||||
@@ -375,13 +385,13 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
(_event, _arg) => {
|
||||
return {
|
||||
success: true,
|
||||
data: global.__HUGO_AURA__.plsRules,
|
||||
data: global.__HUGO_AURA__.aikariRules,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.updatePlsRules`,
|
||||
`${methodBase}.updateAikariRules`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _event
|
||||
@@ -389,8 +399,8 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
* @returns
|
||||
*/
|
||||
(_event, arg) => {
|
||||
global.__HUGO_AURA__.plsRules = arg;
|
||||
ipcMain.send("assistant", `${methodBase}.post.onPlsRulesUpdate`, arg);
|
||||
global.__HUGO_AURA__.aikariRules = arg;
|
||||
ipcMain.send("assistant", `${methodBase}.post.onAikariRulesUpdate`, arg);
|
||||
return {
|
||||
success: true,
|
||||
};
|
||||
@@ -402,7 +412,7 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainEvent} _event
|
||||
* @param {PLSResponse} arg
|
||||
* @param {AikariResponse} arg
|
||||
*/
|
||||
(_event, arg) => {
|
||||
ipcMain.send("assistant", `${methodBase}.ws.post.onNewMsgRecv`, arg);
|
||||
@@ -414,7 +424,7 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _event
|
||||
* @param {ClientPLSRequest} arg
|
||||
* @param {ClientAikariRequest} arg
|
||||
*/
|
||||
(_event, arg) => {
|
||||
ipcMain.send(
|
||||
@@ -426,17 +436,17 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.syncPlsConfig`,
|
||||
`${methodBase}.syncAikariConfig`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} event
|
||||
* @param {{ basic: Record<any, any>, rules: Record<any, any> }} arg
|
||||
*/
|
||||
(event, arg) => {
|
||||
global.__HUGO_AURA__.plsRules = arg.rules;
|
||||
global.__HUGO_AURA__.plsSettings = arg.basic;
|
||||
global.__HUGO_AURA__.aikariRules = arg.rules;
|
||||
global.__HUGO_AURA__.aikariSettings = arg.basic;
|
||||
|
||||
ipcMain.send("*", `${methodBase}.syncPlsConfig`, arg, event.sender);
|
||||
ipcMain.send("*", `${methodBase}.syncAikariConfig`, arg, event.sender);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
@@ -445,24 +455,27 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.plsLifecycleQuery`,
|
||||
`${methodBase}.aikariLifecycleQuery`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _event
|
||||
* @param {{ target: import("../../../types/shared/pls/status").PLSLifecycleType }} arg
|
||||
* @param {{ target: import("../../../types/shared/aikari/status").AikariLifecycleType }} arg
|
||||
* @returns {Promise<{ success: boolean, result: boolean }>}
|
||||
*/
|
||||
async (_event, arg) => {
|
||||
switch (arg.target) {
|
||||
case "isDetached":
|
||||
return { success: true, result: isPlsDetached };
|
||||
return { success: true, result: isAikariDetached };
|
||||
case "isSvcInstalled":
|
||||
return await functions.querySvcDetail(PLS_SVC_NAME, "SERVICE_NAME");
|
||||
return await functions.querySvcDetail(
|
||||
AIKARI_SVC_NAME,
|
||||
"SERVICE_NAME"
|
||||
);
|
||||
case "isSvcStart":
|
||||
return await functions.querySvcDetail(PLS_SVC_NAME, "RUNNING");
|
||||
return await functions.querySvcDetail(AIKARI_SVC_NAME, "RUNNING");
|
||||
default:
|
||||
console.warn(
|
||||
`[HugoAura / IPC / PLS] <plsLifecycleQuery> Invalid arg.target: ${arg.target}`
|
||||
`[HugoAura / IPC / Aikari] <AikariLifecycleQuery> Invalid arg.target: ${arg.target}`
|
||||
);
|
||||
return {
|
||||
success: false,
|
||||
@@ -473,98 +486,68 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.plsLifecycleControl`,
|
||||
`${methodBase}.aikariLifecycleControl`,
|
||||
/**
|
||||
*
|
||||
* @param {*} _event
|
||||
* @param {{ target: import("../../../types/shared/pls/status").PLSLifecycleControlType }} arg
|
||||
* @param {{ target: import("../../../types/shared/aikari/status").AikariLifecycleControlType }} arg
|
||||
* @returns {Promise<{ success: boolean, errorObj?: Error }>}
|
||||
*/
|
||||
async (_event, arg) => {
|
||||
const logHeader = "[HugoAura / IPC / PLS] <plsLifecycleControl>";
|
||||
const logHeader = "[HugoAura / IPC / Aikari] <AikariLifecycleControl>";
|
||||
|
||||
// TODO: Impl this
|
||||
switch (arg.target) {
|
||||
case "instSvc":
|
||||
return await functions.execCommand(
|
||||
logHeader,
|
||||
PLS_BIN_PATH,
|
||||
AIKARI_LAUNCHER_PATH,
|
||||
"--startup auto install"
|
||||
);
|
||||
case "rmSvc": {
|
||||
case "uninstSvc": {
|
||||
const result = await functions.execCommand(
|
||||
logHeader,
|
||||
PLS_BIN_PATH,
|
||||
AIKARI_LAUNCHER_PATH,
|
||||
"remove"
|
||||
);
|
||||
return result;
|
||||
}
|
||||
case "startSvc":
|
||||
return await functions.execCommand(logHeader, PLS_BIN_PATH, "start");
|
||||
return await functions.execCommand(
|
||||
logHeader,
|
||||
AIKARI_LAUNCHER_PATH,
|
||||
"start"
|
||||
);
|
||||
case "stopSvc": {
|
||||
const result = await functions.execCommand(
|
||||
logHeader,
|
||||
PLS_BIN_PATH,
|
||||
AIKARI_LAUNCHER_PATH,
|
||||
"stop"
|
||||
);
|
||||
if (result.success && global.__HUGO_AURA__.plsStats) {
|
||||
global.__HUGO_AURA__.plsStats.connected = false;
|
||||
global.__HUGO_AURA__.plsStats.launched = false;
|
||||
global.__HUGO_AURA__.plsStats.version = "unknown";
|
||||
global.__HUGO_AURA__.plsStats.status = "dead";
|
||||
if (result.success && global.__HUGO_AURA__.aikariStats) {
|
||||
global.__HUGO_AURA__.aikariStats.connected = false;
|
||||
global.__HUGO_AURA__.aikariStats.launched = false;
|
||||
global.__HUGO_AURA__.aikariStats.version = "unknown";
|
||||
global.__HUGO_AURA__.aikariStats.status = "dead";
|
||||
|
||||
ipcMain.send(
|
||||
"assistant",
|
||||
`${methodBase}.post.onPlsStatsUpdate`,
|
||||
global.__HUGO_AURA__.plsStats
|
||||
`${methodBase}.post.onAikariStatsUpdate`,
|
||||
global.__HUGO_AURA__.aikariStats
|
||||
);
|
||||
|
||||
ipcMain.send(
|
||||
"auraWsKeepAlive",
|
||||
`${methodBase}.post.plsStopped`,
|
||||
`${methodBase}.post.aikariStopped`,
|
||||
{}
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
case "rmBin":
|
||||
const unlinkPromise = new Promise((resolve) => {
|
||||
fs.unlink(PLS_BIN_PATH, (error) => {
|
||||
if (error) {
|
||||
resolve({
|
||||
success: false,
|
||||
errorObj: error,
|
||||
});
|
||||
console.error(
|
||||
`${logHeader} Failed to remove PLS bin, error:`,
|
||||
error
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
resolve({
|
||||
success: true,
|
||||
errorObj: null,
|
||||
});
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
const unlinkRet = await unlinkPromise;
|
||||
|
||||
if (unlinkRet.success && global.__HUGO_AURA__.plsStats) {
|
||||
global.__HUGO_AURA__.plsStats.connected = false;
|
||||
global.__HUGO_AURA__.plsStats.launched = false;
|
||||
global.__HUGO_AURA__.plsStats.installed = false;
|
||||
global.__HUGO_AURA__.plsStats.version = "unknown";
|
||||
|
||||
ipcMain.send(
|
||||
"assistant",
|
||||
`${methodBase}.post.onPlsStatsUpdate`,
|
||||
global.__HUGO_AURA__.plsStats
|
||||
);
|
||||
}
|
||||
|
||||
return unlinkRet;
|
||||
case "inst":
|
||||
// TODO: Impl Aikari INST
|
||||
case "uninst":
|
||||
// same
|
||||
default:
|
||||
return { success: false, errorObj: new Error("Method not found") };
|
||||
}
|
||||
@@ -572,7 +555,7 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.downloadPls`,
|
||||
`${methodBase}.downloadAndInstallAikari`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _evt
|
||||
@@ -582,22 +565,22 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
(_evt, arg) => {
|
||||
const channel = arg.channel ? arg.channel : "stable";
|
||||
const reportWin = arg.reportTo ? arg.reportTo : "assistant";
|
||||
functions.handlePLSDownload(
|
||||
functions.handleAikariDownload(
|
||||
channel,
|
||||
(status) => {
|
||||
ipcMain.send(
|
||||
reportWin,
|
||||
`${methodBase}.post.reportPlsDownloadStatus`,
|
||||
`${methodBase}.post.reportAikariInstallStep`,
|
||||
status
|
||||
);
|
||||
},
|
||||
PLS_BIN_PATH
|
||||
AIKARI_LAUNCHER_PATH
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.retryPlsConnect`,
|
||||
`${methodBase}.retryAikariConnect`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _event
|
||||
@@ -605,13 +588,17 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
* @returns {{ success: boolean, status: "Already" | "Retrying" }}
|
||||
*/
|
||||
(_event, arg) => {
|
||||
if (global.__HUGO_AURA__.plsStats?.connected) {
|
||||
if (global.__HUGO_AURA__.aikariStats?.connected) {
|
||||
return {
|
||||
success: true,
|
||||
status: "Already",
|
||||
};
|
||||
} else {
|
||||
ipcMain.send("auraWsKeepAlive", `${methodBase}.retryPlsConnect`, arg);
|
||||
ipcMain.send(
|
||||
"auraWsKeepAlive",
|
||||
`${methodBase}.retryAikariConnect`,
|
||||
arg
|
||||
);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
@@ -639,4 +626,4 @@ const applyPlsIpcHandler = (ipcMain) => {
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = { applyPlsIpcHandler };
|
||||
module.exports = { applyAikariIpcHandler };
|
||||
4
src/aura/types/render/global.d.ts
vendored
4
src/aura/types/render/global.d.ts
vendored
@@ -3,14 +3,14 @@ interface HugoAuraGlobal {
|
||||
}
|
||||
|
||||
interface AssistantHugoAuraGlobal extends HugoAuraGlobal {
|
||||
plsStatus: PLSStatus;
|
||||
plsStatus: AikariStatus;
|
||||
plsRules: Record<any, any>;
|
||||
plsSettings: Record<any, any>;
|
||||
}
|
||||
|
||||
interface AuraWSKeepAliveWindowHugoAuraGlobal extends HugoAuraGlobal {
|
||||
plsWs: WebSocket | null;
|
||||
plsStats: PLSStatus;
|
||||
plsStats: AikariStatus;
|
||||
}
|
||||
|
||||
type UIFunctionsObject = Record<string, any>;
|
||||
|
||||
17
src/aura/types/shared/pls/status.d.ts → src/aura/types/shared/aikari/status.d.ts
vendored
Executable file → Normal file
17
src/aura/types/shared/pls/status.d.ts → src/aura/types/shared/aikari/status.d.ts
vendored
Executable file → Normal file
@@ -1,28 +1,29 @@
|
||||
import { RendererProcessOnlyVal } from "../global";
|
||||
|
||||
type PLSStatusDesc =
|
||||
type AikariStatusDesc =
|
||||
| "dead"
|
||||
| "running"
|
||||
| "notReady"
|
||||
| "downloading"
|
||||
| "installing"
|
||||
| "notInstalled";
|
||||
|
||||
interface PLSStatus {
|
||||
interface AikariStatus {
|
||||
installed: boolean;
|
||||
detached: boolean;
|
||||
connected: boolean;
|
||||
launched: boolean;
|
||||
status: PLSStatusDesc;
|
||||
status: AikariStatusDesc;
|
||||
version: string;
|
||||
authToken: string;
|
||||
}
|
||||
|
||||
type PLSLifecycleType = "isDetached" | "isSvcInstalled" | "isSvcStart";
|
||||
type AikariLifecycleType = "isDetached" | "isSvcInstalled" | "isSvcStart";
|
||||
|
||||
type PLSLifecycleControlType =
|
||||
type AikariLifecycleControlType =
|
||||
| "instSvc"
|
||||
| "rmSvc"
|
||||
| "uninstSvc"
|
||||
| "startSvc"
|
||||
| "stopSvc"
|
||||
| "rmBin"
|
||||
| "dlBin";
|
||||
| "uninst"
|
||||
| "inst";
|
||||
7
src/aura/types/shared/pls/websocket.d.ts → src/aura/types/shared/aikari/websocket.d.ts
vendored
Executable file → Normal file
7
src/aura/types/shared/pls/websocket.d.ts → src/aura/types/shared/aikari/websocket.d.ts
vendored
Executable file → Normal file
@@ -1,17 +1,18 @@
|
||||
interface ClientPLSRequest {
|
||||
interface ClientAikariRequest {
|
||||
method: string;
|
||||
data: Record<any, any>;
|
||||
eventId: string;
|
||||
module: string;
|
||||
}
|
||||
|
||||
interface PLSResponse {
|
||||
interface AikariResponse {
|
||||
success: boolean;
|
||||
code: number;
|
||||
data: Record<any, any>;
|
||||
eventId: string;
|
||||
}
|
||||
|
||||
interface PLSPush {
|
||||
interface AikariPush {
|
||||
success: boolean;
|
||||
type: string;
|
||||
data: Record<any, any>;
|
||||
12
src/aura/types/shared/global.d.ts
vendored
12
src/aura/types/shared/global.d.ts
vendored
@@ -3,7 +3,7 @@ import type EventBus from "../../utils/eventBus";
|
||||
import { HookedWindowsMap, UIHooksMap, WindowHooksMap } from "../main/core";
|
||||
import { UIHooksObject } from "../render/uiHook";
|
||||
import ConfigManager from "../../init/shared/configManager";
|
||||
import { PLSStatus } from "./pls/status";
|
||||
import { AikariStatus } from "./aikari/status";
|
||||
|
||||
type MainProcessOnlyVal<T> = T;
|
||||
type RendererProcessOnlyVal<T> = T;
|
||||
@@ -15,10 +15,10 @@ interface GlobalHugoAuraInfo {
|
||||
hookedWindows?: MainProcessOnlyVal<HookedWindowsMap>;
|
||||
ipcInit?: MainProcessOnlyVal<boolean>;
|
||||
auraDir: MainProcessOnlyVal<string>;
|
||||
plsRules?: Record<any, any> | null;
|
||||
plsSettings?: Record<any, any> | null;
|
||||
plsStats?: PLSStatus | null;
|
||||
plsWs?: RendererProcessOnlyVal<WebSocket>;
|
||||
aikariRules?: Record<any, any> | null;
|
||||
aikariSettings?: Record<any, any> | null;
|
||||
aikariStats?: AikariStatus | null;
|
||||
aikariWs?: RendererProcessOnlyVal<WebSocket>;
|
||||
uiHooks?: MainProcessOnlyVal<UIHooksMap>;
|
||||
windowHooks?: MainProcessOnlyVal<WindowHooksMap>;
|
||||
version: RendererProcessOnlyVal<string>;
|
||||
@@ -26,7 +26,7 @@ interface GlobalHugoAuraInfo {
|
||||
|
||||
interface GlobalHugoAuraApiInfo {
|
||||
domains: string[];
|
||||
plsUpdate: string;
|
||||
aikariUpdate: string;
|
||||
auraUpdate: string;
|
||||
}
|
||||
|
||||
|
||||
80
src/aura/ui/aikari/onConnectedSeq.js
Normal file
80
src/aura/ui/aikari/onConnectedSeq.js
Normal file
@@ -0,0 +1,80 @@
|
||||
// @ts-check
|
||||
|
||||
const { genRandomHex } = require("../../utils/crypto");
|
||||
|
||||
const IPC_METHOD_BASE = "$aura.aikari";
|
||||
|
||||
/** @type {Map<string, any>} */
|
||||
const wsGetCallbacks = new Map();
|
||||
|
||||
const actions = {
|
||||
getAikariVersion: async (originalAikariStates, wsObj) => {
|
||||
const eventId = genRandomHex();
|
||||
wsObj.send(
|
||||
JSON.stringify({
|
||||
module: "launcher",
|
||||
eventId: eventId,
|
||||
method: "basic.props.getVersion",
|
||||
data: {},
|
||||
})
|
||||
);
|
||||
const promise = new Promise((resolve) => {
|
||||
wsGetCallbacks.set(eventId, resolve);
|
||||
});
|
||||
const data = await promise;
|
||||
if (data.success) {
|
||||
originalAikariStates.version = data.data.version;
|
||||
console.debug(
|
||||
"[HugoAura / UI / Aikari OCMS] Updated Aikari version info: " +
|
||||
data.data.version
|
||||
);
|
||||
}
|
||||
},
|
||||
getAikariLauncherConfig: async (wsObj) => {
|
||||
const eventId = genRandomHex();
|
||||
wsObj.send(
|
||||
JSON.stringify({
|
||||
module: "launcher",
|
||||
eventId,
|
||||
method: "config.actions.getConfig",
|
||||
data: {},
|
||||
})
|
||||
);
|
||||
const promise = new Promise((resolve) => {
|
||||
wsGetCallbacks.set(eventId, resolve);
|
||||
});
|
||||
const data = await promise;
|
||||
if (data.success) {
|
||||
console.debug(
|
||||
"[HugoAura / UI / Aikari OCMS] Received Aikari launcher config: ",
|
||||
data
|
||||
);
|
||||
return data.data;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const onAikariConnectedMsgSeq = async ({ curAikariStates, wsObj }) => {
|
||||
const updatedAikariStates = { ...curAikariStates };
|
||||
const onMsgRecvListener = (data) => {
|
||||
if (wsGetCallbacks.has(data.detail.eventId)) {
|
||||
wsGetCallbacks.get(data.detail.eventId)(data.detail);
|
||||
}
|
||||
};
|
||||
document.addEventListener("onAikariMessageRecv", onMsgRecvListener);
|
||||
// Get Aikari Version
|
||||
await actions.getAikariVersion(updatedAikariStates, wsObj);
|
||||
const aikariLauncherConfig = await actions.getAikariLauncherConfig(wsObj);
|
||||
if (aikariLauncherConfig) {
|
||||
global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updateAikariSettings`,
|
||||
aikariLauncherConfig
|
||||
);
|
||||
}
|
||||
|
||||
return updatedAikariStates;
|
||||
};
|
||||
|
||||
module.exports = { onAikariConnectedMsgSeq };
|
||||
2
src/aura/ui/pls/pushHandler.js → src/aura/ui/aikari/pushHandler.js
Executable file → Normal file
2
src/aura/ui/pls/pushHandler.js → src/aura/ui/aikari/pushHandler.js
Executable file → Normal file
@@ -7,7 +7,7 @@ const { configRouteHandler } = require(`${REQUIRE_BASE}/routes/config`);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {PLSPush} parsedWsMsg
|
||||
* @param {AikariPush} parsedWsMsg
|
||||
* @returns
|
||||
*/
|
||||
const pushMsgHandler = (parsedWsMsg) => {
|
||||
49
src/aura/ui/aikari/routes/basic.js
Normal file
49
src/aura/ui/aikari/routes/basic.js
Normal file
@@ -0,0 +1,49 @@
|
||||
// @ts-check
|
||||
|
||||
const IPC_METHOD_BASE = "$aura.aikari";
|
||||
|
||||
// TODO: REFACTOR
|
||||
/**
|
||||
*
|
||||
* @param {AikariPush} parsedWsMsg
|
||||
* @returns
|
||||
*/
|
||||
const basicRouteHandler = (parsedWsMsg) => {
|
||||
const target = parsedWsMsg.type.split(".").slice(-1)[0];
|
||||
switch (target) {
|
||||
case "pushPlsInfo":
|
||||
if (global.__HUGO_AURA__.aikariStats) {
|
||||
global.__HUGO_AURA__.aikariStats.status = parsedWsMsg.data.status;
|
||||
global.__HUGO_AURA__.aikariStats.version = parsedWsMsg.data.version;
|
||||
}
|
||||
|
||||
global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
||||
global.__HUGO_AURA__.aikariStats
|
||||
);
|
||||
|
||||
console.debug(
|
||||
"[HugoAura / UI / Aikari Routes / DEBUG] Updated aikariStats basic info:",
|
||||
global.__HUGO_AURA__.aikariStats
|
||||
);
|
||||
break;
|
||||
|
||||
case "plsNotReadyError":
|
||||
if (global.__HUGO_AURA__.aikariStats) {
|
||||
global.__HUGO_AURA__.aikariStats.launched = true;
|
||||
global.__HUGO_AURA__.aikariStats.connected = false;
|
||||
global.__HUGO_AURA__.aikariStats.status = "notReady";
|
||||
}
|
||||
|
||||
global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
||||
global.__HUGO_AURA__.aikariStats
|
||||
);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = { basicRouteHandler };
|
||||
8
src/aura/ui/pls/routes/config.js → src/aura/ui/aikari/routes/config.js
Executable file → Normal file
8
src/aura/ui/pls/routes/config.js → src/aura/ui/aikari/routes/config.js
Executable file → Normal file
@@ -1,10 +1,10 @@
|
||||
// @ts-check
|
||||
|
||||
const IPC_METHOD_BASE = "$aura.pls";
|
||||
const IPC_METHOD_BASE = "$aura.aikari";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {PLSPush} parsedWsMsg
|
||||
* @param {AikariPush} parsedWsMsg
|
||||
* @returns
|
||||
*/
|
||||
const configRouteHandler = (parsedWsMsg) => {
|
||||
@@ -12,13 +12,13 @@ const configRouteHandler = (parsedWsMsg) => {
|
||||
switch (target) {
|
||||
case "pushBasicConfig":
|
||||
global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updatePlsSettings`,
|
||||
`${IPC_METHOD_BASE}.updateAikariSettings`,
|
||||
parsedWsMsg.data
|
||||
);
|
||||
break;
|
||||
case "pushRuleSettings":
|
||||
global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updatePlsRules`,
|
||||
`${IPC_METHOD_BASE}.updateAikariRules`,
|
||||
parsedWsMsg.data
|
||||
);
|
||||
break;
|
||||
83
src/aura/ui/composables/aikariConfigManager.js
Normal file
83
src/aura/ui/composables/aikariConfigManager.js
Normal file
@@ -0,0 +1,83 @@
|
||||
// @ts-check
|
||||
|
||||
const __SCOPE = "assistant / rendererCommon";
|
||||
|
||||
const IPC_METHOD_BASE = "$aura.aikari";
|
||||
|
||||
const updateAikariStatusFromLocal = async () => {
|
||||
const aikariStatus = (
|
||||
await global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.getAikariStatus`)
|
||||
).data;
|
||||
global.__HUGO_AURA__.aikariStats = aikariStatus;
|
||||
return aikariStatus;
|
||||
};
|
||||
|
||||
const updateAikariSettingsFromLocal = async () => {
|
||||
const aikariSettings = (
|
||||
await global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.getAikariSettings`)
|
||||
).data;
|
||||
global.__HUGO_AURA__.aikariSettings = aikariSettings;
|
||||
return aikariSettings;
|
||||
};
|
||||
|
||||
const updateAikariRulesFromLocal = async () => {
|
||||
const aikariRules = (
|
||||
await global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.getAikariRules`)
|
||||
).data;
|
||||
global.__HUGO_AURA__.aikariRules = aikariRules;
|
||||
return aikariRules;
|
||||
};
|
||||
|
||||
const { genRandomHex } = require("../../utils/crypto");
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} configKey
|
||||
* @param {any} configValue
|
||||
*/
|
||||
const updateAikariConfigToRemote = async (configKey, configValue) => {
|
||||
const configLevels = configKey.split(".");
|
||||
|
||||
const aikariConfigUpdateEvent = new CustomEvent("onAikariConfigUpdate", {
|
||||
detail: {
|
||||
path: configLevels,
|
||||
value: configValue,
|
||||
},
|
||||
});
|
||||
document.dispatchEvent(aikariConfigUpdateEvent);
|
||||
const settingsEntries = document.getElementsByClassName(
|
||||
"aura-settings-entry"
|
||||
);
|
||||
if (settingsEntries.length > 0) {
|
||||
Array.from(settingsEntries).forEach((entry) => {
|
||||
entry.dispatchEvent(aikariConfigUpdateEvent);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {ClientAikariRequest}
|
||||
*/
|
||||
/*
|
||||
const data = {
|
||||
method: "config.action.updateConfig",
|
||||
data: {
|
||||
key: configKey,
|
||||
value: configValue,
|
||||
},
|
||||
eventId: genRandomHex(), // 不用 crypto, 因为会带来不必要的性能开销
|
||||
};*/
|
||||
// TODO: Impl this ↑
|
||||
|
||||
// global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.ws.sendWsMessage`, data);
|
||||
global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.syncAikariConfig`, {
|
||||
basic: global.__HUGO_AURA__.aikariSettings,
|
||||
rules: global.__HUGO_AURA__.aikariRules,
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
updateAikariRulesFromLocal,
|
||||
updateAikariStatusFromLocal,
|
||||
updateAikariSettingsFromLocal,
|
||||
updateAikariConfigToRemote,
|
||||
};
|
||||
@@ -1,81 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
const __SCOPE = "assistant / rendererCommon";
|
||||
|
||||
const IPC_METHOD_BASE = "$aura.pls";
|
||||
|
||||
const updatePlsStatusFromLocal = async () => {
|
||||
const plsStatus = (
|
||||
await global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.getPlsStats`)
|
||||
).data;
|
||||
global.__HUGO_AURA__.plsStats = plsStatus;
|
||||
return plsStatus;
|
||||
};
|
||||
|
||||
const updatePlsSettingsFromLocal = async () => {
|
||||
const plsSettings = (
|
||||
await global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.getPlsSettings`)
|
||||
).data;
|
||||
global.__HUGO_AURA__.plsSettings = plsSettings;
|
||||
return plsSettings;
|
||||
};
|
||||
|
||||
const updatePlsRulesFromLocal = async () => {
|
||||
const plsRules = (
|
||||
await global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.getPlsRules`)
|
||||
).data;
|
||||
global.__HUGO_AURA__.plsRules = plsRules;
|
||||
return plsRules;
|
||||
};
|
||||
|
||||
const { genRandomHex } = require("../../utils/crypto");
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} configKey
|
||||
* @param {any} configValue
|
||||
*/
|
||||
const updatePlsConfigToRemote = async (configKey, configValue) => {
|
||||
const configLevels = configKey.split(".");
|
||||
|
||||
const plsConfigUpdateEvent = new CustomEvent("onPLSConfigUpdate", {
|
||||
detail: {
|
||||
path: configLevels,
|
||||
value: configValue,
|
||||
},
|
||||
});
|
||||
document.dispatchEvent(plsConfigUpdateEvent);
|
||||
const settingsEntries = document.getElementsByClassName(
|
||||
"aura-settings-entry"
|
||||
);
|
||||
if (settingsEntries.length > 0) {
|
||||
Array.from(settingsEntries).forEach((entry) => {
|
||||
entry.dispatchEvent(plsConfigUpdateEvent);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {ClientPLSRequest}
|
||||
*/
|
||||
const data = {
|
||||
method: "config.action.updateConfig",
|
||||
data: {
|
||||
key: configKey,
|
||||
value: configValue,
|
||||
},
|
||||
eventId: genRandomHex(), // 不用 crypto, 因为会带来不必要的性能开销
|
||||
};
|
||||
|
||||
global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.ws.sendWsMessage`, data);
|
||||
global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.syncPlsConfig`, {
|
||||
basic: global.__HUGO_AURA__.plsSettings,
|
||||
rules: global.__HUGO_AURA__.plsRules,
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
updatePlsRulesFromLocal,
|
||||
updatePlsStatusFromLocal,
|
||||
updatePlsSettingsFromLocal,
|
||||
updatePlsConfigToRemote,
|
||||
};
|
||||
@@ -18,12 +18,12 @@ const showRelaunchToast = () => {
|
||||
if (!toastBs.isShown()) toastBs.show();
|
||||
};
|
||||
|
||||
const showRelaunchPLSToast = () => {
|
||||
const toast = document.getElementById("relaunchPlsNotifyToast");
|
||||
const showRelaunchAikariToast = () => {
|
||||
const toast = document.getElementById("relaunchAikariNotifyToast");
|
||||
const toastBs = bootstrap.Toast.getOrCreateInstance(toast);
|
||||
|
||||
if (global.__HUGO_AURA__.plsStats.detached) {
|
||||
const relaunchBtn = document.getElementById("plsRelaunchBtn");
|
||||
if (global.__HUGO_AURA__.aikariStats.detached) {
|
||||
const relaunchBtn = document.getElementById("aikariRelaunchBtn");
|
||||
relaunchBtn.disabled = true;
|
||||
relaunchBtn.textContent = "分离模式下无法执行";
|
||||
}
|
||||
@@ -37,12 +37,6 @@ const showToast = (entry) => {
|
||||
} else if (entry.restart) {
|
||||
showRelaunchToast();
|
||||
}
|
||||
|
||||
/*
|
||||
else if (entry.restartPLS) {
|
||||
showRelaunchPLSToast();
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
const setDisableStatus = (el, isDisable, hint = null) => {
|
||||
@@ -225,29 +219,29 @@ const renderNormalSettingsItem = (entry, formEl) => {
|
||||
powerIcon.setAttribute("data-bs-title", "需要重启 Electron 进程");
|
||||
entryTitle.appendChild(powerIcon);
|
||||
}
|
||||
if (entry.PLSRequired) {
|
||||
const plsIcon = document.createElement("i");
|
||||
plsIcon.classList.add(
|
||||
if (entry.AikariRequired) {
|
||||
const aikariIcon = document.createElement("i");
|
||||
aikariIcon.classList.add(
|
||||
"layui-icon",
|
||||
"layui-icon-component",
|
||||
"aura-settings-entry-property-icon"
|
||||
);
|
||||
plsIcon.setAttribute("data-bs-toggle", "tooltip");
|
||||
plsIcon.setAttribute("data-bs-placement", "top");
|
||||
plsIcon.setAttribute("data-bs-title", "需要 PLS 支持");
|
||||
entryTitle.appendChild(plsIcon);
|
||||
aikariIcon.setAttribute("data-bs-toggle", "tooltip");
|
||||
aikariIcon.setAttribute("data-bs-placement", "top");
|
||||
aikariIcon.setAttribute("data-bs-title", "需要 Aikari 支持");
|
||||
entryTitle.appendChild(aikariIcon);
|
||||
}
|
||||
if (entry.restartPLS) {
|
||||
const plsIcon = document.createElement("i");
|
||||
plsIcon.classList.add(
|
||||
if (entry.restartAikari) {
|
||||
const aikariIcon = document.createElement("i");
|
||||
aikariIcon.classList.add(
|
||||
"layui-icon",
|
||||
"layui-icon-logout",
|
||||
"aura-settings-entry-property-icon"
|
||||
);
|
||||
plsIcon.setAttribute("data-bs-toggle", "tooltip");
|
||||
plsIcon.setAttribute("data-bs-placement", "top");
|
||||
plsIcon.setAttribute("data-bs-title", "需要重启 PLS 进程");
|
||||
entryTitle.appendChild(plsIcon);
|
||||
aikariIcon.setAttribute("data-bs-toggle", "tooltip");
|
||||
aikariIcon.setAttribute("data-bs-placement", "top");
|
||||
aikariIcon.setAttribute("data-bs-title", "需要重启 Aikari 进程");
|
||||
entryTitle.appendChild(aikariIcon);
|
||||
}
|
||||
if (entry.reload) {
|
||||
const reloadIcon = document.createElement("i");
|
||||
@@ -308,27 +302,27 @@ const renderNormalSettingsItem = (entry, formEl) => {
|
||||
insertOrRemoveEl(entryOperationArea, targetEl, true);
|
||||
}
|
||||
};
|
||||
const channel = entry.PLSRequired
|
||||
? "onPLSConfigUpdate"
|
||||
const channel = entry.AikariRequired
|
||||
? "onAikariConfigUpdate"
|
||||
: "onHugoAuraConfigUpdate";
|
||||
entryContainerEl.addEventListener(channel, evtListener);
|
||||
// createOnLeaveEvtListener(channel, evtListener);
|
||||
}
|
||||
|
||||
if (entry.PLSRequired) {
|
||||
if (!global.__HUGO_AURA__.plsStats.connected) {
|
||||
setDisableStatus(entryOperationArea, true, "连接至 PLS 以继续");
|
||||
if (entry.AikariRequired) {
|
||||
if (!global.__HUGO_AURA__.aikariStats.connected) {
|
||||
setDisableStatus(entryOperationArea, true, "连接至 Aikari 以继续");
|
||||
}
|
||||
|
||||
const evtListener = (event) => {
|
||||
if (event.detail.connected) {
|
||||
setDisableStatus(entryOperationArea, false);
|
||||
} else {
|
||||
setDisableStatus(entryOperationArea, true, "连接至 PLS 以继续");
|
||||
setDisableStatus(entryOperationArea, true, "连接至 Aikari 以继续");
|
||||
}
|
||||
};
|
||||
entryContainerEl.addEventListener("onPLSStatsUpdate", evtListener);
|
||||
// createOnLeaveEvtListener("onPLSStatsUpdate", evtListener);
|
||||
entryContainerEl.addEventListener("onAikariStatsUpdate", evtListener);
|
||||
// createOnLeaveEvtListener("onAikariStatsUpdate", evtListener);
|
||||
}
|
||||
entryContainerEl.appendChild(entryOperationArea);
|
||||
const isShow = entry.auraIf();
|
||||
@@ -360,8 +354,8 @@ const renderNormalSettingsItem = (entry, formEl) => {
|
||||
updateDisableStatus();
|
||||
}
|
||||
};
|
||||
const channel = entry.PLSRequired
|
||||
? "onPLSConfigUpdate"
|
||||
const channel = entry.AikariRequired
|
||||
? "onAikariConfigUpdate"
|
||||
: "onHugoAuraConfigUpdate";
|
||||
entryContainerEl.addEventListener(channel, evtListener);
|
||||
// createOnLeaveEvtListener(channel, evtListener);
|
||||
@@ -403,7 +397,7 @@ const renderPreviewItem = (entry, formEl) => {
|
||||
};
|
||||
|
||||
document.addEventListener(
|
||||
eventChannel === "pls" ? "onPLSConfigUpdate" : "onHugoAuraConfigUpdate",
|
||||
eventChannel === "pls" ? "onAikariConfigUpdate" : "onHugoAuraConfigUpdate",
|
||||
eventListener
|
||||
);
|
||||
createOnLeaveEvtListener(eventListener); // Clean up
|
||||
|
||||
@@ -41,13 +41,13 @@ const def = {
|
||||
selectorMode: "appendChild",
|
||||
pageCSS: "ui/pages/configSubPages/behaviourCtrl/behaviourCtrl.css",
|
||||
childs: {
|
||||
PlsStatus: {
|
||||
AikariStatus: {
|
||||
active: false,
|
||||
pageURI: "ui/pages/configSubPages/behaviourCtrl/plsStatus.html",
|
||||
pageScript: "ui/pages/configSubPages/behaviourCtrl/plsStatus.js",
|
||||
pageURI: "ui/pages/configSubPages/behaviourCtrl/aikariStatus.html",
|
||||
pageScript: "ui/pages/configSubPages/behaviourCtrl/aikariStatus.js",
|
||||
pageSelector: "#status-subpage",
|
||||
selectorMode: "appendChild",
|
||||
pageCSS: "ui/pages/configSubPages/behaviourCtrl/plsStatus.css",
|
||||
pageCSS: "ui/pages/configSubPages/behaviourCtrl/aikariStatus.css",
|
||||
},
|
||||
DeviceSecurity: {
|
||||
childs: {
|
||||
@@ -86,7 +86,7 @@ const def = {
|
||||
],
|
||||
globalJS: [
|
||||
"ui/js/global.js",
|
||||
"ui/js/plsListener.js",
|
||||
"ui/js/aikariListener.js",
|
||||
"ui/bootstrap/bootstrap.bundle.min.js",
|
||||
],
|
||||
onLoaded: `
|
||||
|
||||
372
src/aura/ui/js/aikariConnectionManager.js
Normal file
372
src/aura/ui/js/aikariConnectionManager.js
Normal file
@@ -0,0 +1,372 @@
|
||||
// @ts-check
|
||||
(() => {
|
||||
if (!global.__HUGO_AURA__)
|
||||
global.__HUGO_AURA__ = {
|
||||
configInit: true,
|
||||
auraDir: "",
|
||||
version: "",
|
||||
};
|
||||
|
||||
if (!global.__HUGO_AURA__.aikariStats)
|
||||
global.__HUGO_AURA__.aikariStats = {
|
||||
installed: false,
|
||||
detached: false,
|
||||
connected: false,
|
||||
launched: false,
|
||||
status: "dead",
|
||||
version: "unknown",
|
||||
authToken: "",
|
||||
};
|
||||
|
||||
const IPC_METHOD_BASE = "$aura.aikari";
|
||||
const REQUIRE_BASE = "../../..";
|
||||
const __SCOPE = "auraWsKeepAlive";
|
||||
|
||||
const AIKARI_RPC_CONFIG_REG_PATH = "Aikari\\RPC";
|
||||
|
||||
const { pushMsgHandler } = require(`${REQUIRE_BASE}/aikari/pushHandler`);
|
||||
const {
|
||||
onAikariConnectedMsgSeq,
|
||||
} = require(`${REQUIRE_BASE}/aikari/onConnectedSeq`);
|
||||
const RegistryManager = require(`${REQUIRE_BASE}/../init/shared/registryManager`);
|
||||
|
||||
const registryManager = new RegistryManager();
|
||||
|
||||
/** @type {number} */
|
||||
let failedCounter = 0;
|
||||
/** @type {boolean} */
|
||||
let isErrorOccurred = false;
|
||||
|
||||
/** @type {number} */
|
||||
let plsPort = 22077;
|
||||
/** @type {"wss" | "ws"} */
|
||||
let plsProtocol = "wss";
|
||||
|
||||
/** @type {boolean} */
|
||||
let isRetrying = false;
|
||||
|
||||
/** @type {any} */
|
||||
let curSendListener = null;
|
||||
let curSendGetListener = null;
|
||||
|
||||
const sendRetryStatusToMain = (/** @type {Boolean} */ status) => {
|
||||
global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.post.updateRetryStatus`, {
|
||||
success: status,
|
||||
});
|
||||
};
|
||||
|
||||
const clearReqSendIpcListener = () => {
|
||||
if (curSendListener) {
|
||||
global.ipcRenderer.off(
|
||||
`${IPC_METHOD_BASE}.ws.post.onReqSendMsg`,
|
||||
curSendListener
|
||||
);
|
||||
curSendListener = null;
|
||||
}
|
||||
};
|
||||
|
||||
const clearSendGetIpcListener = () => {
|
||||
if (curSendGetListener) {
|
||||
global.ipcRenderer.off(
|
||||
`${IPC_METHOD_BASE}.ws.post.onSendGetMsg`,
|
||||
curSendListener
|
||||
);
|
||||
curSendGetListener = null;
|
||||
}
|
||||
};
|
||||
|
||||
const startConnAikariProc = async (updatedAikariStats) => {
|
||||
const authTokenRet = await registryManager.readRegKey(
|
||||
AIKARI_RPC_CONFIG_REG_PATH,
|
||||
"authToken",
|
||||
true
|
||||
);
|
||||
if (authTokenRet.success) {
|
||||
updatedAikariStats.authToken = authTokenRet.data;
|
||||
// @ts-expect-error
|
||||
global.__HUGO_AURA__.aikariStats.authToken = authTokenRet.data;
|
||||
} else {
|
||||
sendRetryStatusToMain(false);
|
||||
return;
|
||||
}
|
||||
const portRet = await registryManager.readRegKey(
|
||||
AIKARI_RPC_CONFIG_REG_PATH,
|
||||
"wsPort",
|
||||
true
|
||||
);
|
||||
if (portRet.success) {
|
||||
try {
|
||||
plsPort = Number(portRet.data);
|
||||
} catch {
|
||||
console.warn(
|
||||
`[HugoAura / UI / Aikari Conn Manager] Invalid Aikari port: ${portRet.data}`
|
||||
);
|
||||
}
|
||||
}
|
||||
// TODO: wsHost
|
||||
createAikariConnection(updatedAikariStats.authToken, connectionResultCallback);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} authToken
|
||||
* @param {any} callback
|
||||
* @returns
|
||||
*/
|
||||
const createAikariConnection = (authToken, callback) => {
|
||||
if (failedCounter >= 3) {
|
||||
console.error(
|
||||
`[HugoAura / UI / Aikari Conn Manager / ERROR] Failed connecting to PLS WebSocket server, please check the status of PLS process.`
|
||||
);
|
||||
sendRetryStatusToMain(false);
|
||||
return;
|
||||
}
|
||||
|
||||
/** @type {WebSocket} */
|
||||
const aikariWs = new WebSocket(
|
||||
`${plsProtocol}://aikari.hugoaura.local:${plsPort}/?auth=${authToken}`
|
||||
);
|
||||
|
||||
aikariWs.onopen = () => {
|
||||
callback(true, aikariWs);
|
||||
};
|
||||
|
||||
aikariWs.onerror = () => {
|
||||
isErrorOccurred = true;
|
||||
failedCounter += 1;
|
||||
callback(false, aikariWs);
|
||||
};
|
||||
|
||||
aikariWs.onclose = () => {
|
||||
clearReqSendIpcListener();
|
||||
if (global.__HUGO_AURA__.aikariStats) {
|
||||
if (global.__HUGO_AURA__.aikariStats.status === "notReady") {
|
||||
if (isRetrying) {
|
||||
sendRetryStatusToMain(false);
|
||||
return;
|
||||
}
|
||||
console.warn(
|
||||
"[HugoAura / UI / Aikari Conn Manager / WARN] Aikari not ready, try again after 10s..."
|
||||
);
|
||||
isRetrying = true;
|
||||
setTimeout(async () => {
|
||||
isRetrying = false;
|
||||
startConnAikariProc(global.__HUGO_AURA__.aikariStats);
|
||||
}, 10000);
|
||||
sendRetryStatusToMain(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (global.__HUGO_AURA__.aikariStats.launched === false) {
|
||||
console.warn(
|
||||
"[HugoAura / UI / Aikari Conn Manager / WARN] Aikari stopped, closing WebSocket connection."
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
console.error(
|
||||
"[HugoAura / UI / Aikari Conn Manager / ERROR] WebSocket connection closed."
|
||||
);
|
||||
if (isErrorOccurred) return;
|
||||
failedCounter += 1;
|
||||
callback(false, aikariWs);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {WebSocket} wsObj
|
||||
*/
|
||||
const registerSendReqListener = (wsObj) => {
|
||||
clearReqSendIpcListener();
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcRendererEvent} _evt
|
||||
* @param {any} arg
|
||||
*/
|
||||
curSendListener = (_evt, arg) => {
|
||||
wsObj.send(JSON.stringify(arg));
|
||||
};
|
||||
global.ipcRenderer.on(
|
||||
`${IPC_METHOD_BASE}.ws.post.onReqSendMsg`,
|
||||
curSendListener
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {boolean} result
|
||||
* @param {WebSocket} wsObj
|
||||
* @returns
|
||||
*/
|
||||
const connectionResultCallback = async (result, wsObj) => {
|
||||
if (!global.__HUGO_AURA__.aikariStats) return; // 😅 typescript
|
||||
|
||||
global.__HUGO_AURA__.aikariStats.launched = result;
|
||||
global.__HUGO_AURA__.aikariStats.connected = result;
|
||||
global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
||||
global.__HUGO_AURA__.aikariStats
|
||||
);
|
||||
if (!result) {
|
||||
console.error(
|
||||
`[HugoAura / UI / Aikari Conn Manager / ERROR] Failed connecting to Aikari WebSocket server, retrying ...`
|
||||
);
|
||||
createAikariConnection(
|
||||
global.__HUGO_AURA__.aikariStats.authToken,
|
||||
connectionResultCallback
|
||||
);
|
||||
return;
|
||||
}
|
||||
wsObj.onmessage = aikariPushHandler;
|
||||
|
||||
registerSendReqListener(wsObj);
|
||||
|
||||
global.__HUGO_AURA__.aikariWs = wsObj;
|
||||
|
||||
global.__HUGO_AURA__.aikariStats = await onAikariConnectedMsgSeq({
|
||||
curAikariStates: global.__HUGO_AURA__.aikariStats,
|
||||
wsObj,
|
||||
});
|
||||
global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
||||
global.__HUGO_AURA__.aikariStats
|
||||
);
|
||||
|
||||
sendRetryStatusToMain(true);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {MessageEvent} event
|
||||
*/
|
||||
const aikariPushHandler = (event) => {
|
||||
try {
|
||||
/** @type {Record<any, any>} */
|
||||
const parsedEvent = JSON.parse(event.data);
|
||||
console.debug(
|
||||
"[HugoAura / UI / Aikari Conn Manager / DEBUG] Received new server message: "
|
||||
);
|
||||
if (!parsedEvent.eventId || parsedEvent.eventId === "N/A") {
|
||||
// Push
|
||||
pushMsgHandler(parsedEvent);
|
||||
} else {
|
||||
// Not push
|
||||
global.ipcRenderer.send(
|
||||
`${IPC_METHOD_BASE}.ws.broadcastMessageRecv`,
|
||||
parsedEvent
|
||||
);
|
||||
|
||||
const msgRecvEvent = new CustomEvent("onAikariMessageRecv", {
|
||||
detail: parsedEvent,
|
||||
});
|
||||
document.dispatchEvent(msgRecvEvent);
|
||||
}
|
||||
} catch {
|
||||
console.error(
|
||||
"[HugoAura / UI / Aikari Conn Manager / ERROR] Failed to resolve server message: ",
|
||||
event.data
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const initAikariWebSocketConnection = async () => {
|
||||
if (!global.__HUGO_AURA__.aikariStats) return;
|
||||
|
||||
if (isRetrying) {
|
||||
sendRetryStatusToMain(false);
|
||||
return;
|
||||
}
|
||||
|
||||
failedCounter = 0;
|
||||
isErrorOccurred = false;
|
||||
|
||||
const curPlsStats = await global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.getAikariStatus`
|
||||
);
|
||||
let updatedAikariStats = {};
|
||||
if (
|
||||
(curPlsStats === null || !curPlsStats.success) &&
|
||||
curPlsStats.status !== "downloading" &&
|
||||
curPlsStats.status !== "installing"
|
||||
) {
|
||||
updatedAikariStats = {
|
||||
installed: false,
|
||||
launched: false,
|
||||
detached: false,
|
||||
connected: false,
|
||||
version: "unknown",
|
||||
status: "dead",
|
||||
authToken: "",
|
||||
};
|
||||
} else {
|
||||
updatedAikariStats = curPlsStats.data;
|
||||
}
|
||||
|
||||
const isAikariBinExists = (
|
||||
await global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.getIfAikariBinExists`)
|
||||
).data.isExists;
|
||||
updatedAikariStats.installed = isAikariBinExists;
|
||||
// @ts-expect-error
|
||||
global.__HUGO_AURA__.aikariStats = updatedAikariStats;
|
||||
console.debug(
|
||||
"[HugoAura / UI / Aikari Conn Manager / DEBUG] Updated early aikariStats:",
|
||||
global.__HUGO_AURA__.aikariStats
|
||||
);
|
||||
|
||||
global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
||||
updatedAikariStats
|
||||
);
|
||||
|
||||
/*
|
||||
if (updatedPlsStats.detached && updatedPlsStats.installed) {
|
||||
*/
|
||||
if (updatedAikariStats.installed || updatedAikariStats.detached) {
|
||||
await startConnAikariProc(updatedAikariStats);
|
||||
} else {
|
||||
sendRetryStatusToMain(false);
|
||||
}
|
||||
|
||||
/*
|
||||
global.ipcRenderer.on(`${IPC_METHOD_BASE}.post.onPlsLaunched`, (_event) => {
|
||||
setTimeout(() => {
|
||||
startConnPls();
|
||||
}, 5000);
|
||||
});
|
||||
*/
|
||||
};
|
||||
|
||||
const onSetup = () => {
|
||||
if (!global.ipcRenderer) {
|
||||
// @ts-ignore
|
||||
global.ipcRenderer = require("electron").ipcRenderer;
|
||||
}
|
||||
|
||||
initAikariWebSocketConnection();
|
||||
|
||||
global.ipcRenderer.on(
|
||||
`${IPC_METHOD_BASE}.retryAikariConnect`,
|
||||
(_evt, _arg) => {
|
||||
if (!global.__HUGO_AURA__.aikariStats) return;
|
||||
if (global.__HUGO_AURA__.aikariStats.connected) return;
|
||||
initAikariWebSocketConnection();
|
||||
}
|
||||
);
|
||||
|
||||
global.ipcRenderer.on(
|
||||
`${IPC_METHOD_BASE}.post.aikariStopped`,
|
||||
(_evt, _arg) => {
|
||||
if (!global.__HUGO_AURA__.aikariStats) return;
|
||||
global.__HUGO_AURA__.aikariStats.launched = false;
|
||||
global.__HUGO_AURA__.aikariStats.connected = false;
|
||||
global.__HUGO_AURA__.aikariStats.version = "unknown";
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
setTimeout(() => {
|
||||
onSetup();
|
||||
}, 1500);
|
||||
})();
|
||||
28
src/aura/ui/js/plsListener.js → src/aura/ui/js/aikariListener.js
Executable file → Normal file
28
src/aura/ui/js/plsListener.js → src/aura/ui/js/aikariListener.js
Executable file → Normal file
@@ -1,21 +1,21 @@
|
||||
(() => {
|
||||
const IPC_METHOD_BASE = "$aura.pls";
|
||||
const IPC_METHOD_BASE = "$aura.aikari";
|
||||
const REQUIRE_BASE = "../../aura/ui";
|
||||
const __SCOPE = "assistant";
|
||||
const {
|
||||
updatePlsStatusFromLocal,
|
||||
} = require(`${REQUIRE_BASE}/composables/plsConfigManager`);
|
||||
updateAikariStatusFromLocal,
|
||||
} = require(`${REQUIRE_BASE}/composables/aikariConfigManager`);
|
||||
|
||||
const setupListeners = () => {
|
||||
if (!global.ipcRenderer)
|
||||
global.ipcRenderer = require("electron").ipcRenderer;
|
||||
|
||||
ipcRenderer.on(
|
||||
`${IPC_METHOD_BASE}.post.onPlsStatsUpdate`,
|
||||
`${IPC_METHOD_BASE}.post.onAikariStatsUpdate`,
|
||||
(_event, arg) => {
|
||||
global.__HUGO_AURA__.plsStats = arg;
|
||||
global.__HUGO_AURA__.aikariStats = arg;
|
||||
|
||||
const event = new CustomEvent("onPLSStatsUpdate", {
|
||||
const event = new CustomEvent("onAikariStatsUpdate", {
|
||||
detail: {
|
||||
connected: arg.connected,
|
||||
},
|
||||
@@ -35,11 +35,11 @@
|
||||
);
|
||||
|
||||
ipcRenderer.on(
|
||||
`${IPC_METHOD_BASE}.post.onPlsSettingsUpdate`,
|
||||
`${IPC_METHOD_BASE}.post.onAikariSettingsUpdate`,
|
||||
(_event, arg) => {
|
||||
global.__HUGO_AURA__.plsSettings = arg;
|
||||
global.__HUGO_AURA__.aikariSettings = arg;
|
||||
|
||||
const event = new CustomEvent("onPLSConfigUpdate", {
|
||||
const event = new CustomEvent("onAikariConfigUpdate", {
|
||||
detail: {
|
||||
path: ["root", "settings"],
|
||||
value: arg,
|
||||
@@ -60,11 +60,11 @@
|
||||
);
|
||||
|
||||
ipcRenderer.on(
|
||||
`${IPC_METHOD_BASE}.post.onPlsRulesUpdate`,
|
||||
`${IPC_METHOD_BASE}.post.onAikariRulesUpdate`,
|
||||
(_event, arg) => {
|
||||
global.__HUGO_AURA__.plsRules = arg;
|
||||
global.__HUGO_AURA__.aikariRules = arg;
|
||||
|
||||
const event = new CustomEvent("onPLSConfigUpdate", {
|
||||
const event = new CustomEvent("onAikariConfigUpdate", {
|
||||
detail: {
|
||||
path: ["root", "ruleSettings"],
|
||||
value: arg,
|
||||
@@ -87,7 +87,7 @@
|
||||
ipcRenderer.on(
|
||||
`${IPC_METHOD_BASE}.post.updateRetryStatus`,
|
||||
(_event, arg) => {
|
||||
const event = new CustomEvent("onPLSStatsUpdate", {
|
||||
const event = new CustomEvent("onAikariStatsUpdate", {
|
||||
detail: {
|
||||
connected: arg.success,
|
||||
},
|
||||
@@ -107,6 +107,6 @@
|
||||
);
|
||||
};
|
||||
|
||||
updatePlsStatusFromLocal();
|
||||
updateAikariStatusFromLocal();
|
||||
setupListeners();
|
||||
})();
|
||||
@@ -1,357 +0,0 @@
|
||||
// @ts-check
|
||||
(() => {
|
||||
if (!global.__HUGO_AURA__)
|
||||
global.__HUGO_AURA__ = {
|
||||
configInit: true,
|
||||
auraDir: "",
|
||||
version: "",
|
||||
};
|
||||
|
||||
if (!global.__HUGO_AURA__.plsStats)
|
||||
global.__HUGO_AURA__.plsStats = {
|
||||
installed: false,
|
||||
detached: false,
|
||||
connected: false,
|
||||
launched: false,
|
||||
status: "dead",
|
||||
version: "unknown",
|
||||
authToken: "",
|
||||
};
|
||||
|
||||
const IPC_METHOD_BASE = "$aura.pls";
|
||||
const REQUIRE_BASE = "../../..";
|
||||
const __SCOPE = "auraWsKeepAlive";
|
||||
|
||||
const PLS_REG_PATH = "ProxyLayerServices";
|
||||
|
||||
const { pushMsgHandler } = require(`${REQUIRE_BASE}/pls/pushHandler`);
|
||||
const RegistryManager = require(`${REQUIRE_BASE}/../init/shared/registryManager`);
|
||||
|
||||
const registryManager = new RegistryManager();
|
||||
|
||||
/** @type {number} */
|
||||
let failedCounter = 0;
|
||||
/** @type {boolean} */
|
||||
let isErrorOccurred = false;
|
||||
|
||||
/** @type {number} */
|
||||
let plsPort = 22077;
|
||||
/** @type {"wss" | "ws"} */
|
||||
let plsProtocol = "wss";
|
||||
|
||||
/** @type {boolean} */
|
||||
let isRetrying = false;
|
||||
|
||||
/** @type {any} */
|
||||
let curSendListener = null;
|
||||
|
||||
const sendRetryStatusToMain = (/** @type {Boolean} */ status) => {
|
||||
global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.post.updateRetryStatus`, {
|
||||
success: status,
|
||||
});
|
||||
};
|
||||
|
||||
const calcFullAuthToken = (/** @type {string} */ authToken) => {
|
||||
const conjToken = authToken + "AuraXAuth 0xFFFFFF NeverEnds";
|
||||
const crypto = require("crypto");
|
||||
return crypto.createHash("sha512").update(conjToken).digest("hex");
|
||||
};
|
||||
|
||||
const clearIpcListener = () => {
|
||||
if (curSendListener) {
|
||||
global.ipcRenderer.off(
|
||||
`${IPC_METHOD_BASE}.ws.post.onReqSendMsg`,
|
||||
curSendListener
|
||||
);
|
||||
curSendListener = null;
|
||||
}
|
||||
};
|
||||
|
||||
const startConnPlsProc = async (updatedPlsStats) => {
|
||||
const authTokenRet = await registryManager.readRegKey(
|
||||
PLS_REG_PATH,
|
||||
"AuthToken",
|
||||
true
|
||||
);
|
||||
if (authTokenRet.success) {
|
||||
updatedPlsStats.authToken = authTokenRet.data;
|
||||
// @ts-expect-error
|
||||
global.__HUGO_AURA__.plsStats.authToken = authTokenRet.data;
|
||||
} else {
|
||||
sendRetryStatusToMain(false);
|
||||
return;
|
||||
}
|
||||
const portRet = await registryManager.readRegKey(
|
||||
PLS_REG_PATH,
|
||||
"WsPort",
|
||||
true
|
||||
);
|
||||
if (portRet.success) {
|
||||
try {
|
||||
plsPort = Number(portRet.data);
|
||||
} catch {
|
||||
console.warn(
|
||||
`[HugoAura / UI / PLS Manager] Invalid PLS port: ${portRet.data}`
|
||||
);
|
||||
}
|
||||
}
|
||||
const protoRet = await registryManager.readRegKey(
|
||||
PLS_REG_PATH,
|
||||
"Protocol",
|
||||
true
|
||||
);
|
||||
if (protoRet.success) {
|
||||
plsProtocol = protoRet.data;
|
||||
}
|
||||
createPlsConnection(updatedPlsStats.authToken, connectionResultCallback);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} authToken
|
||||
* @param {any} callback
|
||||
* @returns
|
||||
*/
|
||||
const createPlsConnection = (authToken, callback) => {
|
||||
if (failedCounter >= 3) {
|
||||
console.error(
|
||||
`[HugoAura / UI / PLS Manager / ERROR] Failed connecting to PLS WebSocket server, please check the status of PLS process.`
|
||||
);
|
||||
sendRetryStatusToMain(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const fullAuthToken = calcFullAuthToken(authToken);
|
||||
|
||||
/** @type {WebSocket} */
|
||||
const plsWs = new WebSocket(
|
||||
`${plsProtocol}://pls.hugoaura.local:${plsPort}/?auth=${fullAuthToken}`
|
||||
);
|
||||
|
||||
plsWs.onopen = () => {
|
||||
callback(true, plsWs);
|
||||
};
|
||||
|
||||
plsWs.onerror = () => {
|
||||
isErrorOccurred = true;
|
||||
failedCounter += 1;
|
||||
callback(false, plsWs);
|
||||
};
|
||||
|
||||
plsWs.onclose = () => {
|
||||
clearIpcListener();
|
||||
if (global.__HUGO_AURA__.plsStats) {
|
||||
if (global.__HUGO_AURA__.plsStats.status === "notReady") {
|
||||
if (isRetrying) {
|
||||
sendRetryStatusToMain(false);
|
||||
return;
|
||||
}
|
||||
console.warn(
|
||||
"[HugoAura / UI / PLS Manager / WARN] PLS not ready, try again after 10s..."
|
||||
);
|
||||
isRetrying = true;
|
||||
setTimeout(async () => {
|
||||
isRetrying = false;
|
||||
startConnPlsProc(global.__HUGO_AURA__.plsStats);
|
||||
}, 10000);
|
||||
sendRetryStatusToMain(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (global.__HUGO_AURA__.plsStats.launched === false) {
|
||||
console.warn(
|
||||
"[HugoAura / UI / PLS Manager / WARN] PLS stopped, closing WebSocket connection."
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
console.error(
|
||||
"[HugoAura / UI / PLS Manager / ERROR] WebSocket connection closed."
|
||||
);
|
||||
if (isErrorOccurred) return;
|
||||
failedCounter += 1;
|
||||
callback(false, plsWs);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {WebSocket} wsObj
|
||||
*/
|
||||
const registerSendReqListener = (wsObj) => {
|
||||
clearIpcListener();
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcRendererEvent} _evt
|
||||
* @param {any} arg
|
||||
*/
|
||||
curSendListener = (_evt, arg) => {
|
||||
wsObj.send(JSON.stringify(arg));
|
||||
};
|
||||
global.ipcRenderer.on(
|
||||
`${IPC_METHOD_BASE}.ws.post.onReqSendMsg`,
|
||||
curSendListener
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {boolean} result
|
||||
* @param {WebSocket} wsObj
|
||||
* @returns
|
||||
*/
|
||||
const connectionResultCallback = (result, wsObj) => {
|
||||
if (!global.__HUGO_AURA__.plsStats) return; // 😅 typescript
|
||||
|
||||
global.__HUGO_AURA__.plsStats.launched = result;
|
||||
global.__HUGO_AURA__.plsStats.connected = result;
|
||||
global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updatePlsStats`,
|
||||
global.__HUGO_AURA__.plsStats
|
||||
);
|
||||
if (!result) {
|
||||
console.error(
|
||||
`[HugoAura / UI / PLS Manager / ERROR] Failed connecting to PLS WebSocket server, retrying ...`
|
||||
);
|
||||
createPlsConnection(
|
||||
global.__HUGO_AURA__.plsStats.authToken,
|
||||
connectionResultCallback
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
sendRetryStatusToMain(true);
|
||||
|
||||
global.__HUGO_AURA__.plsWs = wsObj;
|
||||
registerSendReqListener(wsObj);
|
||||
wsObj.onmessage = plsPushHandler;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {MessageEvent} event
|
||||
*/
|
||||
const plsPushHandler = (event) => {
|
||||
try {
|
||||
/** @type {Record<any, any>} */
|
||||
const parsedEvent = JSON.parse(event.data);
|
||||
console.debug(
|
||||
"[HugoAura / UI / PLS Manager / DEBUG] Received new server message: "
|
||||
);
|
||||
if (!parsedEvent.eventId) {
|
||||
// Push
|
||||
pushMsgHandler(parsedEvent);
|
||||
} else {
|
||||
// Not push
|
||||
global.ipcRenderer.send(
|
||||
`${IPC_METHOD_BASE}.ws.broadcastMessageRecv`,
|
||||
parsedEvent
|
||||
);
|
||||
}
|
||||
} catch {
|
||||
console.error(
|
||||
"[HugoAura / UI / PLS Manager / ERROR] Failed to resolve server message: ",
|
||||
event.data
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const initPlsConnection = async () => {
|
||||
if (!global.__HUGO_AURA__.plsStats) return;
|
||||
|
||||
if (isRetrying) {
|
||||
sendRetryStatusToMain(false);
|
||||
return;
|
||||
}
|
||||
|
||||
failedCounter = 0;
|
||||
isErrorOccurred = false;
|
||||
|
||||
const curPlsStats = await global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.getPlsStats`
|
||||
);
|
||||
let updatedPlsStats = {};
|
||||
if (
|
||||
(curPlsStats === null || !curPlsStats.success) &&
|
||||
curPlsStats.status !== "downloading"
|
||||
) {
|
||||
updatedPlsStats = {
|
||||
installed: false,
|
||||
launched: false,
|
||||
detached: false,
|
||||
connected: false,
|
||||
version: "unknown",
|
||||
status: "dead",
|
||||
authToken: "66ccff0d000721114514191981023333",
|
||||
};
|
||||
} else {
|
||||
updatedPlsStats = curPlsStats.data;
|
||||
}
|
||||
|
||||
const isPlsFolderExists = (
|
||||
await global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.getPlsBinExists`)
|
||||
).data.isExists;
|
||||
updatedPlsStats.installed = isPlsFolderExists;
|
||||
// @ts-expect-error
|
||||
global.__HUGO_AURA__.plsStats = updatedPlsStats;
|
||||
console.debug(
|
||||
"[HugoAura / UI / PLS Manager / DEBUG] Updated early plsStats:",
|
||||
global.__HUGO_AURA__.plsStats
|
||||
);
|
||||
|
||||
global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updatePlsStats`,
|
||||
updatedPlsStats
|
||||
);
|
||||
|
||||
/*
|
||||
if (updatedPlsStats.detached && updatedPlsStats.installed) {
|
||||
*/
|
||||
if (updatedPlsStats.installed) {
|
||||
await startConnPlsProc(updatedPlsStats);
|
||||
} else {
|
||||
sendRetryStatusToMain(false);
|
||||
}
|
||||
|
||||
/*
|
||||
global.ipcRenderer.on(`${IPC_METHOD_BASE}.post.onPlsLaunched`, (_event) => {
|
||||
setTimeout(() => {
|
||||
startConnPls();
|
||||
}, 5000);
|
||||
});
|
||||
*/
|
||||
};
|
||||
|
||||
const onSetup = () => {
|
||||
if (!global.ipcRenderer) {
|
||||
// @ts-ignore
|
||||
global.ipcRenderer = require("electron").ipcRenderer;
|
||||
}
|
||||
|
||||
initPlsConnection();
|
||||
|
||||
global.ipcRenderer.on(
|
||||
`${IPC_METHOD_BASE}.retryPlsConnect`,
|
||||
(_evt, _arg) => {
|
||||
if (!global.__HUGO_AURA__.plsStats) return;
|
||||
if (global.__HUGO_AURA__.plsStats.connected) return;
|
||||
initPlsConnection();
|
||||
}
|
||||
);
|
||||
|
||||
global.ipcRenderer.on(
|
||||
`${IPC_METHOD_BASE}.post.plsStopped`,
|
||||
(_evt, _arg) => {
|
||||
if (!global.__HUGO_AURA__.plsStats) return;
|
||||
global.__HUGO_AURA__.plsStats.launched = false;
|
||||
global.__HUGO_AURA__.plsStats.connected = false;
|
||||
global.__HUGO_AURA__.plsStats.version = "unknown";
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
setTimeout(() => {
|
||||
onSetup();
|
||||
}, 1500);
|
||||
})();
|
||||
@@ -293,14 +293,14 @@
|
||||
|
||||
<div class="toast-container position-fixed bottom-0 end-0 p-3">
|
||||
<div
|
||||
id="relaunchPlsNotifyToast"
|
||||
id="relaunchAikariNotifyToast"
|
||||
class="toast acp-toast-emerg"
|
||||
aria-atomic="true"
|
||||
data-bs-autohide="false"
|
||||
>
|
||||
<div class="toast-header">
|
||||
<i class="layui-icon layui-icon-tips"></i>
|
||||
<strong class="me-auto">重启 PLS 进程以应用设置</strong>
|
||||
<strong class="me-auto">重启 Aikari 进程以应用设置</strong>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-close"
|
||||
@@ -308,13 +308,13 @@
|
||||
></button>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
<p>请重启 PLS 进程以应用修改的设置</p>
|
||||
<p>请重启 Aikari 进程以应用修改的设置</p>
|
||||
<p>已修改的配置将自动保存</p>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary btn-sm"
|
||||
id="plsRelaunchBtn"
|
||||
onclick="ipcRenderer.invoke('$aura.pls.relaunchPls')"
|
||||
id="aikariRelaunchBtn"
|
||||
onclick="ipcRenderer.invoke('$aura.aikari.relaunchPls')"
|
||||
>
|
||||
重启进程
|
||||
</button>
|
||||
|
||||
@@ -106,7 +106,7 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
||||
if (!side) {
|
||||
setTimeout(() => {
|
||||
global.__HUGO_AURA_LOADER__[
|
||||
"Aura.UI.Assistant.Config.BehaviourCtrl.PlsStatus"
|
||||
"Aura.UI.Assistant.Config.BehaviourCtrl.AikariStatus"
|
||||
].active = false;
|
||||
}, 500);
|
||||
}
|
||||
|
||||
52
src/aura/ui/pages/configSubPages/behaviourCtrl/plsStatus.css → src/aura/ui/pages/configSubPages/behaviourCtrl/aikariStatus.css
Executable file → Normal file
52
src/aura/ui/pages/configSubPages/behaviourCtrl/plsStatus.css → src/aura/ui/pages/configSubPages/behaviourCtrl/aikariStatus.css
Executable file → Normal file
@@ -1,15 +1,15 @@
|
||||
.acs-behaviour-control-pls-status-page {
|
||||
.acs-behaviour-control-aikari-status-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.acs-behaviour-control-pls-status-page p {
|
||||
.acs-behaviour-control-aikari-status-page p {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-pls-description {
|
||||
.acs-bc-aikari-status-page-aikari-description {
|
||||
margin-top: 0.5rem;
|
||||
max-width: 80%;
|
||||
opacity: 0.35;
|
||||
@@ -17,11 +17,11 @@
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-main-logo {
|
||||
max-width: 11%;
|
||||
.acs-bc-aikari-status-page-main-logo {
|
||||
max-width: 15%;
|
||||
opacity: 0.45;
|
||||
margin-top: 1.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.acs-bc-psp-operations-container {
|
||||
@@ -133,7 +133,7 @@
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-el {
|
||||
.acs-bc-aikari-status-page-status-el {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 40%;
|
||||
@@ -141,17 +141,17 @@
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-el div {
|
||||
.acs-bc-aikari-status-page-status-el div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-area {
|
||||
.acs-bc-aikari-status-page-status-area {
|
||||
flex-grow: 1;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-area-circle {
|
||||
.acs-bc-aikari-status-page-status-area-circle {
|
||||
height: 10px;
|
||||
width: 10px;
|
||||
border-radius: 100%;
|
||||
@@ -159,48 +159,48 @@
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-area.pending
|
||||
.acs-bc-pls-status-page-status-area-circle {
|
||||
.acs-bc-aikari-status-page-status-area.pending
|
||||
.acs-bc-aikari-status-page-status-area-circle {
|
||||
background-color: rgba(0, 0, 0, 0.375);
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-area.pending p {
|
||||
.acs-bc-aikari-status-page-status-area.pending p {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-area.success
|
||||
.acs-bc-pls-status-page-status-area-circle {
|
||||
.acs-bc-aikari-status-page-status-area.success
|
||||
.acs-bc-aikari-status-page-status-area-circle {
|
||||
background-color: rgb(0, 175, 38);
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-area.success p {
|
||||
.acs-bc-aikari-status-page-status-area.success p {
|
||||
color: rgb(0, 150, 33);
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-area.failed
|
||||
.acs-bc-pls-status-page-status-area-circle {
|
||||
.acs-bc-aikari-status-page-status-area.failed
|
||||
.acs-bc-aikari-status-page-status-area-circle {
|
||||
background-color: rgb(175, 0, 0);
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-area.failed p {
|
||||
.acs-bc-aikari-status-page-status-area.failed p {
|
||||
color: rgb(175, 0, 0);
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-area.warning
|
||||
.acs-bc-pls-status-page-status-area-circle {
|
||||
.acs-bc-aikari-status-page-status-area.warning
|
||||
.acs-bc-aikari-status-page-status-area-circle {
|
||||
background-color: rgb(212, 127, 0);
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-area.warning p {
|
||||
.acs-bc-aikari-status-page-status-area.warning p {
|
||||
color: rgb(212, 127, 0);
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-area.info
|
||||
.acs-bc-pls-status-page-status-area-circle {
|
||||
.acs-bc-aikari-status-page-status-area.info
|
||||
.acs-bc-aikari-status-page-status-area-circle {
|
||||
background-color: #3d78ff;
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-area.info p {
|
||||
.acs-bc-aikari-status-page-status-area.info p {
|
||||
color: #3d78ff;
|
||||
}
|
||||
|
||||
41
src/aura/ui/pages/configSubPages/behaviourCtrl/plsStatus.html → src/aura/ui/pages/configSubPages/behaviourCtrl/aikariStatus.html
Executable file → Normal file
41
src/aura/ui/pages/configSubPages/behaviourCtrl/plsStatus.html → src/aura/ui/pages/configSubPages/behaviourCtrl/aikariStatus.html
Executable file → Normal file
@@ -1,12 +1,11 @@
|
||||
<div class="acs-behaviour-control-pls-status-page">
|
||||
<p class="acs-bc-pls-status-page-pls-description">
|
||||
HugoAura ProxyLayerServices (Aura-PLS) 是基于 Python + MITMProxy
|
||||
实现的代理服务, 用于解密并修改希沃基础服务 (SeewoCore) 的 MQTT 数据包,
|
||||
实现行为监控、伪造上报等功能
|
||||
<div class="acs-behaviour-control-aikari-status-page">
|
||||
<p class="acs-bc-aikari-status-page-aikari-description">
|
||||
HugoAura Aikari 是基于 C++ 实现的 HugoAura 特权访问服务, 集成篡改 MQTT
|
||||
数据包、冰点穿透增强等功能, 实现行为监控、伪造上报
|
||||
</p>
|
||||
<img
|
||||
src="../../aura/ui/static/aura_pls.png"
|
||||
class="acs-bc-pls-status-page-main-logo"
|
||||
src="../../aura/ui/static/aikari_color_reversed.png"
|
||||
class="acs-bc-aikari-status-page-main-logo"
|
||||
/>
|
||||
|
||||
<div class="acs-bc-psp-operations-container">
|
||||
@@ -155,61 +154,61 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-pls-status-page-status-el">
|
||||
<div class="acs-bc-aikari-status-page-status-el">
|
||||
<p>安装状态</p>
|
||||
<div
|
||||
class="acs-bc-pls-status-page-status-area pending"
|
||||
class="acs-bc-aikari-status-page-status-area pending"
|
||||
id="acs-bc-psp-installStatus-container"
|
||||
>
|
||||
<span class="acs-bc-pls-status-page-status-area-circle"></span>
|
||||
<span class="acs-bc-aikari-status-page-status-area-circle"></span>
|
||||
<p id="acs-bc-psp-installStatus-text">未安装</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-pls-status-page-status-el">
|
||||
<div class="acs-bc-aikari-status-page-status-el">
|
||||
<p>启动状态</p>
|
||||
<div
|
||||
class="acs-bc-pls-status-page-status-area pending"
|
||||
class="acs-bc-aikari-status-page-status-area pending"
|
||||
id="acs-bc-psp-launchStatus-container"
|
||||
>
|
||||
<span class="acs-bc-pls-status-page-status-area-circle"></span>
|
||||
<span class="acs-bc-aikari-status-page-status-area-circle"></span>
|
||||
<p id="acs-bc-psp-launchStatus-text">未启动</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-pls-status-page-status-el">
|
||||
<div class="acs-bc-aikari-status-page-status-el">
|
||||
<p>连接状态</p>
|
||||
<div
|
||||
class="acs-bc-pls-status-page-status-area pending"
|
||||
class="acs-bc-aikari-status-page-status-area pending"
|
||||
id="acs-bc-psp-connStatus-container"
|
||||
>
|
||||
<span class="acs-bc-pls-status-page-status-area-circle"></span>
|
||||
<span class="acs-bc-aikari-status-page-status-area-circle"></span>
|
||||
<p id="acs-bc-psp-connStatus-text">已断开</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-pls-status-page-status-el" style="border-bottom: none">
|
||||
<div class="acs-bc-aikari-status-page-status-el" style="border-bottom: none">
|
||||
<p>版本</p>
|
||||
<div class="acs-bc-pls-status-page-status-area">
|
||||
<div class="acs-bc-aikari-status-page-status-area">
|
||||
<p id="acs-bc-psp-version-text">不可用</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toast-container position-fixed bottom-0 end-0 p-3">
|
||||
<div
|
||||
id="plsStatusNotifyToast"
|
||||
id="aikariStatusNotifyToast"
|
||||
class="acs-bc-psp-toast toast"
|
||||
data-bs-autohide="false"
|
||||
>
|
||||
<div class="toast-header">
|
||||
<strong class="me-auto" id="plsStatusNotifyToastTitle"></strong>
|
||||
<strong class="me-auto" id="aikariStatusNotifyToastTitle"></strong>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-close"
|
||||
data-bs-dismiss="toast"
|
||||
></button>
|
||||
</div>
|
||||
<div class="toast-body" id="plsStatusNotifyToastBody"></div>
|
||||
<div class="toast-body" id="aikariStatusNotifyToastBody"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
262
src/aura/ui/pages/configSubPages/behaviourCtrl/plsStatus.js → src/aura/ui/pages/configSubPages/behaviourCtrl/aikariStatus.js
Executable file → Normal file
262
src/aura/ui/pages/configSubPages/behaviourCtrl/plsStatus.js → src/aura/ui/pages/configSubPages/behaviourCtrl/aikariStatus.js
Executable file → Normal file
@@ -6,7 +6,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
|
||||
(() => {
|
||||
const REQUIRE_BASE = "../../aura/ui/pages/configSubPages/behaviourCtrl";
|
||||
const IPC_METHOD_BASE = "$aura.pls";
|
||||
const IPC_METHOD_BASE = "$aura.aikari";
|
||||
|
||||
const lifecycleStatus = {
|
||||
installed: false,
|
||||
@@ -15,12 +15,12 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
svcRunning: false,
|
||||
};
|
||||
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.plsStatus = {
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus = {
|
||||
toastAutoHideTimeout: null,
|
||||
curDlTaskId: null,
|
||||
};
|
||||
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus = {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus = {
|
||||
updateToast: async (
|
||||
variant,
|
||||
title,
|
||||
@@ -29,17 +29,17 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
autoHide = true,
|
||||
hideAfter = 3000
|
||||
) => {
|
||||
const toastRootEl = document.getElementById("plsStatusNotifyToast");
|
||||
const toastRootEl = document.getElementById("aikariStatusNotifyToast");
|
||||
const toastHeaderEl = document.getElementById(
|
||||
"plsStatusNotifyToastTitle"
|
||||
"aikariStatusNotifyToastTitle"
|
||||
);
|
||||
const toastBodyEl = document.getElementById("plsStatusNotifyToastBody");
|
||||
const toastBodyEl = document.getElementById("aikariStatusNotifyToastBody");
|
||||
|
||||
const bsToastIns = bootstrap.Toast.getOrCreateInstance(toastRootEl);
|
||||
if (bsToastIns.isShown) {
|
||||
bsToastIns.hide();
|
||||
const timeout =
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.plsStatus
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus
|
||||
.toastAutoHideTimeout;
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
@@ -60,7 +60,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
|
||||
bsToastIns.show();
|
||||
if (autoHide && hideAfter) {
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.plsStatus.toastAutoHideTimeout =
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus.toastAutoHideTimeout =
|
||||
setTimeout(() => {
|
||||
bsToastIns.hide();
|
||||
}, hideAfter);
|
||||
@@ -85,7 +85,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
switch (btnName) {
|
||||
case "Refresh":
|
||||
btnEl.onclick = () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"warning",
|
||||
"正在更新",
|
||||
null,
|
||||
@@ -93,12 +93,12 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
false,
|
||||
null
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.refreshPlsStatus();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.refreshAikariStatus();
|
||||
};
|
||||
break;
|
||||
case "Download":
|
||||
btnEl.onclick = async () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.downloadPLSBin();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.downloadAndInstallAikariBin();
|
||||
};
|
||||
break;
|
||||
|
||||
@@ -106,11 +106,11 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
// 如果后续要引入错误视觉反馈, 合并到单个 fn 反而会增加实现复杂度
|
||||
case "Install":
|
||||
btnEl.onclick = async () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateOperationBtnStatus(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateOperationBtnStatus(
|
||||
"Install",
|
||||
true
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"info",
|
||||
"正在请求安装",
|
||||
null,
|
||||
@@ -119,12 +119,12 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
null
|
||||
);
|
||||
const ret = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.plsLifecycleControl`,
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
||||
{ target: "instSvc" }
|
||||
);
|
||||
if (ret.success) {
|
||||
lifecycleStatus.svcInstalled = true;
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"success",
|
||||
"服务安装成功",
|
||||
null,
|
||||
@@ -133,7 +133,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
2000
|
||||
);
|
||||
} else {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"error",
|
||||
"服务安装失败",
|
||||
`<p>${ret.errorObj}</p>`,
|
||||
@@ -142,17 +142,17 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
null
|
||||
);
|
||||
}
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
};
|
||||
break;
|
||||
case "Uninstall":
|
||||
if (btnContent === "删除内核") {
|
||||
btnEl.onclick = async () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateOperationBtnStatus(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateOperationBtnStatus(
|
||||
"Uninstall",
|
||||
true
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"warning",
|
||||
"正在删除内核",
|
||||
null,
|
||||
@@ -161,20 +161,20 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
null
|
||||
);
|
||||
const ret = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.plsLifecycleControl`,
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
||||
{ target: "rmBin" }
|
||||
);
|
||||
if (ret.success) {
|
||||
lifecycleStatus.installed = false;
|
||||
lifecycleStatus.svcInstalled = false;
|
||||
global.__HUGO_AURA__.plsStats.installed = false;
|
||||
global.__HUGO_AURA__.plsStats.connected = false;
|
||||
global.__HUGO_AURA__.plsStats.launched = false;
|
||||
global.__HUGO_AURA__.aikariStats.installed = false;
|
||||
global.__HUGO_AURA__.aikariStats.connected = false;
|
||||
global.__HUGO_AURA__.aikariStats.launched = false;
|
||||
ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updatePlsStats`,
|
||||
global.__HUGO_AURA__.plsStats
|
||||
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
||||
global.__HUGO_AURA__.aikariStats
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"success",
|
||||
"内核已删除",
|
||||
null,
|
||||
@@ -183,7 +183,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
2000
|
||||
);
|
||||
} else {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"error",
|
||||
"内核删除失败",
|
||||
`<p>
|
||||
@@ -194,15 +194,15 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
null
|
||||
);
|
||||
}
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
};
|
||||
} else {
|
||||
btnEl.onclick = async () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateOperationBtnStatus(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateOperationBtnStatus(
|
||||
"Uninstall",
|
||||
true
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"info",
|
||||
lifecycleStatus.svcRunning
|
||||
? "正在停止服务并卸载"
|
||||
@@ -214,11 +214,11 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
);
|
||||
if (lifecycleStatus.svcRunning) {
|
||||
const stopRet = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.plsLifecycleControl`,
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
||||
{ target: "stopSvc" }
|
||||
);
|
||||
if (!stopRet.success) {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"error",
|
||||
"服务卸载失败: 无法停止服务",
|
||||
`<p>${
|
||||
@@ -227,7 +227,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
: "检查日志以获取详细信息"
|
||||
}</p>
|
||||
<p>
|
||||
您可以尝试手动停止 PLS 服务
|
||||
您可以尝试手动停止 Aikari 服务
|
||||
</p>`,
|
||||
true,
|
||||
false,
|
||||
@@ -238,12 +238,12 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
}
|
||||
}
|
||||
const ret = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.plsLifecycleControl`,
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
||||
{ target: "rmSvc" }
|
||||
);
|
||||
if (ret.success) {
|
||||
lifecycleStatus.svcInstalled = false;
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"success",
|
||||
"服务卸载成功",
|
||||
null,
|
||||
@@ -252,7 +252,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
2000
|
||||
);
|
||||
} else {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"error",
|
||||
"服务卸载失败",
|
||||
"<p>检查日志以获取详细信息</p>",
|
||||
@@ -261,18 +261,18 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
null
|
||||
);
|
||||
}
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
};
|
||||
}
|
||||
|
||||
break;
|
||||
case "Start":
|
||||
btnEl.onclick = async () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateOperationBtnStatus(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateOperationBtnStatus(
|
||||
"Start",
|
||||
true
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"info",
|
||||
"正在请求启动",
|
||||
null,
|
||||
@@ -281,29 +281,29 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
null
|
||||
);
|
||||
const ret = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.plsLifecycleControl`,
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
||||
{ target: "startSvc" }
|
||||
);
|
||||
if (ret.success) {
|
||||
lifecycleStatus.svcRunning = true;
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"success",
|
||||
"PLS 已启动",
|
||||
"Aikari 已启动",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
2000
|
||||
);
|
||||
await global.__HUGO_AURA_GLOBAL__.utils.sleep(100);
|
||||
await ipcRenderer.invoke(`${IPC_METHOD_BASE}.retryPlsConnect`);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
await ipcRenderer.invoke(`${IPC_METHOD_BASE}.retryAikariConnect`);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
} else {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"error",
|
||||
"PLS 启动失败",
|
||||
"<p>检查 PLS 日志目录以获取详细信息</p>",
|
||||
"Aikari 启动失败",
|
||||
"<p>检查 Aikari 日志目录以获取详细信息</p>",
|
||||
true,
|
||||
false,
|
||||
null
|
||||
@@ -313,11 +313,11 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
break;
|
||||
case "Stop":
|
||||
btnEl.onclick = async () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateOperationBtnStatus(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateOperationBtnStatus(
|
||||
"Stop",
|
||||
true
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"info",
|
||||
"正在请求停止",
|
||||
null,
|
||||
@@ -326,33 +326,33 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
null
|
||||
);
|
||||
const ret = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.plsLifecycleControl`,
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
||||
{ target: "stopSvc" }
|
||||
);
|
||||
if (ret.success) {
|
||||
lifecycleStatus.svcRunning = false;
|
||||
global.__HUGO_AURA__.plsStats.launched = false;
|
||||
global.__HUGO_AURA__.plsStats.version = "unknown";
|
||||
global.__HUGO_AURA__.plsStats.status = "dead";
|
||||
global.__HUGO_AURA__.aikariStats.launched = false;
|
||||
global.__HUGO_AURA__.aikariStats.version = "unknown";
|
||||
global.__HUGO_AURA__.aikariStats.status = "dead";
|
||||
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"success",
|
||||
"PLS 已停止",
|
||||
"Aikari 已停止",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
2000
|
||||
);
|
||||
} else {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"error",
|
||||
"PLS 停止失败",
|
||||
"Aikari 停止失败",
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
null
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
}
|
||||
};
|
||||
break;
|
||||
@@ -364,10 +364,10 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
},
|
||||
|
||||
updateStatusContent: async () => {
|
||||
const curPlsStats = await updatePlsStatusFromLocal();
|
||||
const curAikariStats = await updateAikariStatusFromLocal();
|
||||
|
||||
if (curPlsStats.status === "downloading") {
|
||||
GLOBAL_FUNCTIONS.downloadPLSBin(true);
|
||||
if (curAikariStats.status === "downloading") {
|
||||
GLOBAL_FUNCTIONS.downloadAndInstallAikariBin(true);
|
||||
}
|
||||
|
||||
const acIdInst = "acs-bc-psp-installStatus-container";
|
||||
@@ -411,9 +411,9 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", true);
|
||||
} else if (lifecycleStatus.svcInstalled && lifecycleStatus.installed) {
|
||||
switch (lifecycleStatus.svcRunning || curPlsStats.launched) {
|
||||
switch (lifecycleStatus.svcRunning || curAikariStats.launched) {
|
||||
case true:
|
||||
if (curPlsStats.status !== "notReady") {
|
||||
if (curAikariStats.status !== "notReady") {
|
||||
updateStatusEl(acIdLaunch, atIdLaunch, "SUCCESS", "已启动");
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", false);
|
||||
@@ -433,12 +433,12 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
|
||||
const acIdConn = "acs-bc-psp-connStatus-container";
|
||||
const atIdConn = "acs-bc-psp-connStatus-text";
|
||||
switch (curPlsStats.connected) {
|
||||
switch (curAikariStats.connected) {
|
||||
case true:
|
||||
updateStatusEl(acIdConn, atIdConn, "SUCCESS", "已连接");
|
||||
break;
|
||||
case false:
|
||||
if (curPlsStats.status !== "notReady") {
|
||||
if (curAikariStats.status !== "notReady") {
|
||||
updateStatusEl(acIdConn, atIdConn, "FAILED", "连接失败");
|
||||
} else {
|
||||
updateStatusEl(acIdConn, atIdConn, "PENDING", "等待启动");
|
||||
@@ -447,45 +447,16 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
}
|
||||
|
||||
const versionTextEl = document.getElementById("acs-bc-psp-version-text");
|
||||
if (curPlsStats.version && curPlsStats.version !== "unknown") {
|
||||
versionTextEl.textContent = "v" + curPlsStats.version;
|
||||
if (curAikariStats.version && curAikariStats.version !== "unknown") {
|
||||
versionTextEl.textContent = curAikariStats.version;
|
||||
} else {
|
||||
versionTextEl.textContent = "不可用"
|
||||
}
|
||||
},
|
||||
|
||||
refreshPlsStatus: async (init = false) => {
|
||||
const binExistsRet = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.getPlsBinExists`
|
||||
);
|
||||
if (binExistsRet.success && binExistsRet.data.isExists) {
|
||||
lifecycleStatus.installed = true;
|
||||
global.__HUGO_AURA__.plsStats.installed = true;
|
||||
ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updatePlsStats`,
|
||||
global.__HUGO_AURA__.plsStats
|
||||
);
|
||||
} else {
|
||||
lifecycleStatus.installed = false;
|
||||
global.__HUGO_AURA__.plsStats.installed = false;
|
||||
ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updatePlsStats`,
|
||||
global.__HUGO_AURA__.plsStats
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"error",
|
||||
"请下载 PLS 内核以继续",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
3000
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
return;
|
||||
}
|
||||
|
||||
refreshAikariStatus: async (init = false) => {
|
||||
const isDetachedRet = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.plsLifecycleQuery`,
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleQuery`,
|
||||
{ target: "isDetached" }
|
||||
);
|
||||
if (isDetachedRet.success && isDetachedRet.result) {
|
||||
@@ -494,8 +465,37 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
lifecycleStatus.detached = false;
|
||||
}
|
||||
|
||||
const binExistsRet = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.getIfAikariBinExists`
|
||||
);
|
||||
if ((binExistsRet.success && binExistsRet.data.isExists) || lifecycleStatus.detached) {
|
||||
lifecycleStatus.installed = true;
|
||||
global.__HUGO_AURA__.aikariStats.installed = true;
|
||||
ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
||||
global.__HUGO_AURA__.aikariStats
|
||||
);
|
||||
} else {
|
||||
lifecycleStatus.installed = false;
|
||||
global.__HUGO_AURA__.aikariStats.installed = false;
|
||||
ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
||||
global.__HUGO_AURA__.aikariStats
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"error",
|
||||
"请下载 Aikari 内核以继续",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
3000
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
return;
|
||||
}
|
||||
|
||||
const isSvcInstalledRet = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.plsLifecycleQuery`,
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleQuery`,
|
||||
{ target: "isSvcInstalled" }
|
||||
);
|
||||
if (isSvcInstalledRet.success && isSvcInstalledRet.result) {
|
||||
@@ -505,7 +505,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
}
|
||||
|
||||
const isSvcRunningRet = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.plsLifecycleQuery`,
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleQuery`,
|
||||
{ target: "isSvcStart" }
|
||||
);
|
||||
if (isSvcRunningRet.success && isSvcRunningRet.result) {
|
||||
@@ -515,16 +515,16 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
}
|
||||
|
||||
if (init) {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
return;
|
||||
}
|
||||
|
||||
const updateOperationBtnStatus =
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus
|
||||
.updateOperationBtnStatus;
|
||||
updateOperationBtnStatus("Refresh", true);
|
||||
const result = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.retryPlsConnect`
|
||||
`${IPC_METHOD_BASE}.retryAikariConnect`
|
||||
);
|
||||
if (result.success && result.status === "Retrying") {
|
||||
updateOperationBtnStatus("Refresh", true, "正在重连");
|
||||
@@ -534,7 +534,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
async (_evt, arg) => {
|
||||
await global.__HUGO_AURA_GLOBAL__.utils.sleep(50);
|
||||
updateOperationBtnStatus("Refresh", false, "刷新状态");
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
arg.success ? "success" : "error",
|
||||
arg.success ? "更新成功" : "连接失败",
|
||||
null,
|
||||
@@ -542,12 +542,12 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
true,
|
||||
3000
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
}
|
||||
);
|
||||
} else if (result.success && result.status === "Already") {
|
||||
updateOperationBtnStatus("Refresh", false, "刷新状态");
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"success",
|
||||
"更新成功",
|
||||
null,
|
||||
@@ -622,15 +622,15 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
}
|
||||
},
|
||||
|
||||
downloadPLSBin: async (retrieveMode = false) => {
|
||||
downloadAikariBin: async (retrieveMode = false) => {
|
||||
const GLOBAL_FUNCTIONS =
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus;
|
||||
const CUR_CHANNEL = `${IPC_METHOD_BASE}.post.reportPlsDownloadStatus`;
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus;
|
||||
const CUR_CHANNEL = `${IPC_METHOD_BASE}.post.reportAikariInstallStep`;
|
||||
|
||||
if (!retrieveMode) {
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Download", true, "正在检查");
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Refresh", true);
|
||||
await ipcRenderer.invoke(`${IPC_METHOD_BASE}.ensurePlsInstallDir`);
|
||||
await ipcRenderer.invoke(`${IPC_METHOD_BASE}.ensureAikariInstallDir`);
|
||||
GLOBAL_FUNCTIONS.updateToast(
|
||||
"info",
|
||||
"准备开始下载...",
|
||||
@@ -716,22 +716,22 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
"下载内核"
|
||||
);
|
||||
lifecycleStatus.installed = true;
|
||||
global.__HUGO_AURA__.plsStats.installed = true;
|
||||
global.__HUGO_AURA__.aikariStats.installed = true;
|
||||
ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updatePlsStats`,
|
||||
global.__HUGO_AURA__.plsStats
|
||||
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
||||
global.__HUGO_AURA__.aikariStats
|
||||
);
|
||||
GLOBAL_FUNCTIONS.updateStatusContent();
|
||||
break;
|
||||
case "waiting":
|
||||
GLOBAL_FUNCTIONS.updatePBarStatus(0, "正在连接", "normal");
|
||||
if (
|
||||
!global.__HUGO_AURA_UI_REACTIVES__.subConfig.plsStatus
|
||||
!global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus
|
||||
.curDlTaskId ||
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.plsStatus
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus
|
||||
.curDlTaskId !== info.id
|
||||
) {
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.plsStatus.curDlTaskId =
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus.curDlTaskId =
|
||||
info.id;
|
||||
}
|
||||
break;
|
||||
@@ -766,7 +766,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
|
||||
ipcRenderer.on(CUR_CHANNEL, callbackFn);
|
||||
|
||||
ipcRenderer.invoke(`${IPC_METHOD_BASE}.downloadPls`, {
|
||||
ipcRenderer.invoke(`${IPC_METHOD_BASE}.downloadAndInstallAikari`, {
|
||||
channel: "stable",
|
||||
reportTo: "assistant",
|
||||
});
|
||||
@@ -774,7 +774,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
|
||||
cancelDownloadTask: async () => {
|
||||
const taskId =
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.plsStatus.curDlTaskId;
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus.curDlTaskId;
|
||||
|
||||
if (!taskId) {
|
||||
GLOBAL_FUNCTIONS.updateToast(
|
||||
@@ -819,11 +819,11 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
};
|
||||
|
||||
const GLOBAL_FUNCTIONS =
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus;
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus;
|
||||
|
||||
const {
|
||||
updatePlsStatusFromLocal,
|
||||
} = require(`${REQUIRE_BASE}/../../../composables/plsConfigManager`);
|
||||
updateAikariStatusFromLocal,
|
||||
} = require(`${REQUIRE_BASE}/../../../composables/aikariConfigManager`);
|
||||
|
||||
const initBsTooltip = () => {
|
||||
const tooltipTriggerList = document.querySelectorAll(
|
||||
@@ -845,21 +845,21 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
switch (target) {
|
||||
case "PENDING":
|
||||
areaContainerEl.className =
|
||||
"acs-bc-pls-status-page-status-area pending";
|
||||
"acs-bc-aikari-status-page-status-area pending";
|
||||
break;
|
||||
case "SUCCESS":
|
||||
areaContainerEl.className =
|
||||
"acs-bc-pls-status-page-status-area success";
|
||||
"acs-bc-aikari-status-page-status-area success";
|
||||
break;
|
||||
case "FAILED":
|
||||
areaContainerEl.className = "acs-bc-pls-status-page-status-area failed";
|
||||
areaContainerEl.className = "acs-bc-aikari-status-page-status-area failed";
|
||||
break;
|
||||
case "WARNING":
|
||||
areaContainerEl.className =
|
||||
"acs-bc-pls-status-page-status-area warning";
|
||||
"acs-bc-aikari-status-page-status-area warning";
|
||||
break;
|
||||
case "INFO":
|
||||
areaContainerEl.className = "acs-bc-pls-status-page-status-area info";
|
||||
areaContainerEl.className = "acs-bc-aikari-status-page-status-area info";
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
@@ -871,14 +871,14 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
const onMounted = () => {
|
||||
initBsTooltip();
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Refresh", false);
|
||||
GLOBAL_FUNCTIONS.refreshPlsStatus(true);
|
||||
GLOBAL_FUNCTIONS.refreshAikariStatus(true);
|
||||
|
||||
const eventListener = () => {
|
||||
GLOBAL_FUNCTIONS.updateStatusContent();
|
||||
};
|
||||
document.addEventListener("onPLSStatsUpdate", eventListener);
|
||||
document.addEventListener("onAikariStatsUpdate", eventListener);
|
||||
global.__HUGO_AURA_GLOBAL__.utils.createOnLeaveEvtListener(
|
||||
"onPLSStatsUpdate",
|
||||
"onAikariStatsUpdate",
|
||||
eventListener
|
||||
);
|
||||
};
|
||||
@@ -10,13 +10,13 @@
|
||||
const { deviceSecuritySettings } = require(`${REQUIRE_BASE}/deviceSecurity`);
|
||||
|
||||
const {
|
||||
updatePlsSettingsFromLocal,
|
||||
updatePlsRulesFromLocal,
|
||||
} = require(`${REQUIRE_BASE}/../../../../composables/plsConfigManager`);
|
||||
updateAikariSettingsFromLocal,
|
||||
updateAikariRulesFromLocal,
|
||||
} = require(`${REQUIRE_BASE}/../../../../composables/aikariConfigManager`);
|
||||
|
||||
const initStatusPage = () => {
|
||||
global.__HUGO_AURA_LOADER__[
|
||||
"Aura.UI.Assistant.Config.BehaviourCtrl.PlsStatus"
|
||||
"Aura.UI.Assistant.Config.BehaviourCtrl.AikariStatus"
|
||||
].active = true;
|
||||
};
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
};
|
||||
|
||||
const renderSubPages = async () => {
|
||||
await updatePlsSettingsFromLocal();
|
||||
await updatePlsRulesFromLocal();
|
||||
await updateAikariSettingsFromLocal();
|
||||
await updateAikariRulesFromLocal();
|
||||
|
||||
initBasicSettingsPage();
|
||||
initDeviceSecuritySettingsPage();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const REQUIRE_BASE = ".";
|
||||
|
||||
const {
|
||||
updatePlsConfigToRemote,
|
||||
} = require(`${REQUIRE_BASE}/../../../../composables/plsConfigManager`);
|
||||
updateAikariConfigToRemote,
|
||||
} = require(`${REQUIRE_BASE}/../../../../composables/aikariConfigManager`);
|
||||
|
||||
const reusableChkFn = {
|
||||
checkRelativePath: () => {
|
||||
@@ -42,8 +42,8 @@ const basicSettings = [
|
||||
reactiveVal: ["root.settings"],
|
||||
restart: false,
|
||||
reload: false,
|
||||
PLSRequired: true,
|
||||
restartPLS: false,
|
||||
AikariRequired: true,
|
||||
restartAikari: false,
|
||||
warning: true,
|
||||
warningContent: "PLS 仍会在默认端口被占用时, 自动随机端口重试",
|
||||
associateVal: null,
|
||||
@@ -51,8 +51,8 @@ const basicSettings = [
|
||||
defaultValue: "",
|
||||
placeHolder: "输入端口号 (10000 ~ 65535)",
|
||||
valueGetter: () => {
|
||||
if (!global.__HUGO_AURA__.plsSettings) return "";
|
||||
return global.__HUGO_AURA__.plsSettings.wsPort;
|
||||
if (!global.__HUGO_AURA__.aikariSettings) return "";
|
||||
return global.__HUGO_AURA__.aikariSettings.wsPort;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
if (newVal === "" || !newVal)
|
||||
@@ -63,8 +63,8 @@ const basicSettings = [
|
||||
return { valid: false, hint: "请输入合法的端口号 (10000 ~ 65535)" };
|
||||
}
|
||||
|
||||
global.__HUGO_AURA__.plsSettings.wsPort = numberNewVal;
|
||||
updatePlsConfigToRemote("wsPort", numberNewVal);
|
||||
global.__HUGO_AURA__.aikariSettings.wsPort = numberNewVal;
|
||||
updateAikariConfigToRemote("wsPort", numberNewVal);
|
||||
return { valid: true };
|
||||
},
|
||||
},
|
||||
@@ -79,8 +79,8 @@ const basicSettings = [
|
||||
reactiveVal: ["root.settings"],
|
||||
restart: false,
|
||||
reload: false,
|
||||
PLSRequired: true,
|
||||
restartPLS: true,
|
||||
AikariRequired: true,
|
||||
restartAikari: true,
|
||||
tip: true,
|
||||
tipTitle:
|
||||
'路径相对于 "%PROGRAMDATA%\\HugoAura\\Aura-PLS\\", 使用 "/" 作为路径符',
|
||||
@@ -89,8 +89,8 @@ const basicSettings = [
|
||||
defaultValue: "",
|
||||
placeHolder: "输入相对路径, 例如: config/vme50/cert.crt",
|
||||
valueGetter: () => {
|
||||
if (!global.__HUGO_AURA__.plsSettings) return "";
|
||||
return global.__HUGO_AURA__.plsSettings.certPath;
|
||||
if (!global.__HUGO_AURA__.aikariSettings) return "";
|
||||
return global.__HUGO_AURA__.aikariSettings.certPath;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
const validate = reusableChkFn.checkRelativePath();
|
||||
@@ -98,8 +98,8 @@ const basicSettings = [
|
||||
return validate;
|
||||
}
|
||||
|
||||
global.__HUGO_AURA__.plsSettings.certPath = newVal;
|
||||
updatePlsConfigToRemote("certPath", newVal);
|
||||
global.__HUGO_AURA__.aikariSettings.certPath = newVal;
|
||||
updateAikariConfigToRemote("certPath", newVal);
|
||||
return { valid: true };
|
||||
},
|
||||
},
|
||||
@@ -114,8 +114,8 @@ const basicSettings = [
|
||||
reactiveVal: ["root.settings"],
|
||||
restart: false,
|
||||
reload: false,
|
||||
PLSRequired: true,
|
||||
restartPLS: true,
|
||||
AikariRequired: true,
|
||||
restartAikari: true,
|
||||
tip: true,
|
||||
tipTitle:
|
||||
'路径相对于 "%PROGRAMDATA%\\HugoAura\\Aura-PLS\\", 使用 "/" 作为路径符',
|
||||
@@ -126,8 +126,8 @@ const basicSettings = [
|
||||
defaultValue: "",
|
||||
placeHolder: "输入相对路径, 例如: config/vme50/cert.key",
|
||||
valueGetter: () => {
|
||||
if (!global.__HUGO_AURA__.plsSettings) return "";
|
||||
return global.__HUGO_AURA__.plsSettings.keyPath;
|
||||
if (!global.__HUGO_AURA__.aikariSettings) return "";
|
||||
return global.__HUGO_AURA__.aikariSettings.keyPath;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
const validate = reusableChkFn.checkRelativePath();
|
||||
@@ -135,8 +135,8 @@ const basicSettings = [
|
||||
return validate;
|
||||
}
|
||||
|
||||
global.__HUGO_AURA__.plsSettings.keyPath = newVal;
|
||||
updatePlsConfigToRemote("keyPath", newVal);
|
||||
global.__HUGO_AURA__.aikariSettings.keyPath = newVal;
|
||||
updateAikariConfigToRemote("keyPath", newVal);
|
||||
return { valid: true };
|
||||
},
|
||||
},
|
||||
@@ -150,20 +150,20 @@ const basicSettings = [
|
||||
reactiveVal: ["root.settings"],
|
||||
restart: false,
|
||||
reload: false,
|
||||
PLSRequired: true,
|
||||
restartPLS: true,
|
||||
AikariRequired: true,
|
||||
restartAikari: true,
|
||||
associateVal: null,
|
||||
auraIf: () => true,
|
||||
defaultValue: false,
|
||||
valueGetter: () => {
|
||||
if (!global.__HUGO_AURA__.plsSettings) return "";
|
||||
return global.__HUGO_AURA__.plsSettings.regenCert;
|
||||
if (!global.__HUGO_AURA__.aikariSettings) return "";
|
||||
return global.__HUGO_AURA__.aikariSettings.regenCert;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
if (typeof newVal !== "boolean") return false;
|
||||
|
||||
global.__HUGO_AURA__.plsSettings.regenCert = newVal;
|
||||
updatePlsConfigToRemote("regenCert", newVal);
|
||||
global.__HUGO_AURA__.aikariSettings.regenCert = newVal;
|
||||
updateAikariConfigToRemote("regenCert", newVal);
|
||||
return true;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const REQUIRE_BASE = ".";
|
||||
|
||||
const {
|
||||
updatePlsConfigToRemote,
|
||||
} = require(`${REQUIRE_BASE}/../../../../composables/plsConfigManager`);
|
||||
updateAikariConfigToRemote,
|
||||
} = require(`${REQUIRE_BASE}/../../../../composables/aikariConfigManager`);
|
||||
|
||||
const composables = {};
|
||||
|
||||
@@ -21,23 +21,23 @@ const deviceSecuritySettings = [
|
||||
reactiveVal: ["root.ruleSettings"],
|
||||
restart: false,
|
||||
reload: false,
|
||||
PLSRequired: true,
|
||||
restartPLS: false,
|
||||
AikariRequired: true,
|
||||
restartAikari: false,
|
||||
associateVal: null,
|
||||
auraIf: () => true,
|
||||
defaultValue: false,
|
||||
valueGetter: () => {
|
||||
if (!global.__HUGO_AURA__.plsRules) return "";
|
||||
return global.__HUGO_AURA__.plsRules.client.security.uploadFreezeInfo
|
||||
if (!global.__HUGO_AURA__.aikariRules) return "";
|
||||
return global.__HUGO_AURA__.aikariRules.client.security.uploadFreezeInfo
|
||||
.enable;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
if (typeof newVal !== "boolean") return;
|
||||
if (!global.__HUGO_AURA__.plsRules) return;
|
||||
if (!global.__HUGO_AURA__.aikariRules) return;
|
||||
|
||||
global.__HUGO_AURA__.plsRules.client.security.uploadFreezeInfo.enable =
|
||||
global.__HUGO_AURA__.aikariRules.client.security.uploadFreezeInfo.enable =
|
||||
newVal;
|
||||
updatePlsConfigToRemote(
|
||||
updateAikariConfigToRemote(
|
||||
"ruleSettings.client.security.uploadFreezeInfo.enable",
|
||||
newVal
|
||||
);
|
||||
@@ -53,30 +53,30 @@ const deviceSecuritySettings = [
|
||||
"选择一种篡改模式, 选中的磁盘范围会<b>被上报</b>为冻结 (不是实际行为)",
|
||||
restart: false,
|
||||
reload: false,
|
||||
PLSRequired: true,
|
||||
restartPLS: false,
|
||||
AikariRequired: true,
|
||||
restartAikari: false,
|
||||
reactive: true,
|
||||
reactiveVal: ["root.ruleSettings"],
|
||||
associateVal: ["ruleSettings.client.security.uploadFreezeInfo.enable"],
|
||||
auraIf: () => {
|
||||
if (!global.__HUGO_AURA__.plsRules) return true;
|
||||
if (!global.__HUGO_AURA__.aikariRules) return true;
|
||||
|
||||
return global.__HUGO_AURA__.plsRules.client.security.uploadFreezeInfo
|
||||
return global.__HUGO_AURA__.aikariRules.client.security.uploadFreezeInfo
|
||||
.enable;
|
||||
},
|
||||
defaultValue: "allFreeze",
|
||||
templates: ["allFreeze", "systemOnly", "exceptSecondDisk"],
|
||||
templateLabels: ["全部冻结", "仅系统盘", "第二磁盘除外"],
|
||||
valueGetter: () => {
|
||||
if (!global.__HUGO_AURA__.plsRules) return;
|
||||
if (!global.__HUGO_AURA__.aikariRules) return;
|
||||
|
||||
return global.__HUGO_AURA__.plsRules.client.security.uploadFreezeInfo
|
||||
return global.__HUGO_AURA__.aikariRules.client.security.uploadFreezeInfo
|
||||
.rewriteMode;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
global.__HUGO_AURA__.plsRules.client.security.uploadFreezeInfo.rewriteMode =
|
||||
global.__HUGO_AURA__.aikariRules.client.security.uploadFreezeInfo.rewriteMode =
|
||||
newVal;
|
||||
updatePlsConfigToRemote(
|
||||
updateAikariConfigToRemote(
|
||||
"ruleSettings.client.security.uploadFreezeInfo.rewriteMode",
|
||||
newVal
|
||||
);
|
||||
|
||||
@@ -148,9 +148,10 @@
|
||||
)[0];
|
||||
|
||||
const eventListener = (_event) => {
|
||||
if (!global.__HUGO_AURA__.plsRules) return;
|
||||
// if (!global.__HUGO_AURA__.plsRules) return;
|
||||
composables.getAndUpdateDiskInfo(
|
||||
global.__HUGO_AURA__.plsRules.client.security.uploadFreezeInfo
|
||||
// global.__HUGO_AURA__.plsRules.client.security.uploadFreezeInfo
|
||||
{ enable: false }
|
||||
);
|
||||
};
|
||||
rootEl.addEventListener("onAssociateValueUpdated", eventListener);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<script>
|
||||
let global = window;
|
||||
</script>
|
||||
<script src="../../../js/plsConnectionManager.js"></script>
|
||||
<script src="../../../js/aikariConnectionManager.js"></script>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
const IPC_METHOD_BASE = "$aura.pls";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {PLSPush} parsedWsMsg
|
||||
* @returns
|
||||
*/
|
||||
const basicRouteHandler = (parsedWsMsg) => {
|
||||
const target = parsedWsMsg.type.split(".").slice(-1)[0];
|
||||
switch (target) {
|
||||
case "pushPlsInfo":
|
||||
if (global.__HUGO_AURA__.plsStats) {
|
||||
global.__HUGO_AURA__.plsStats.status = parsedWsMsg.data.status;
|
||||
global.__HUGO_AURA__.plsStats.version = parsedWsMsg.data.version;
|
||||
}
|
||||
|
||||
global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updatePlsStats`,
|
||||
global.__HUGO_AURA__.plsStats
|
||||
);
|
||||
|
||||
console.debug(
|
||||
"[HugoAura / UI / PLS Routes / DEBUG] Updated plsStats basic info:",
|
||||
global.__HUGO_AURA__.plsStats
|
||||
);
|
||||
break;
|
||||
|
||||
case "plsNotReadyError":
|
||||
if (global.__HUGO_AURA__.plsStats) {
|
||||
global.__HUGO_AURA__.plsStats.launched = true;
|
||||
global.__HUGO_AURA__.plsStats.connected = false;
|
||||
global.__HUGO_AURA__.plsStats.status = "notReady";
|
||||
}
|
||||
|
||||
global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updatePlsStats`,
|
||||
global.__HUGO_AURA__.plsStats
|
||||
);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = { basicRouteHandler };
|
||||
BIN
src/aura/ui/static/aikari_color_reversed.png
Normal file
BIN
src/aura/ui/static/aikari_color_reversed.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB |
@@ -27,7 +27,7 @@ if (!global.__HUGO_AURA_API__) {
|
||||
"https://api-aura-projekts.minorice.moe",
|
||||
"https://api.aura.vim.moe",
|
||||
],
|
||||
plsUpdate: "/api/getPLSLatestVersion",
|
||||
aikariUpdate: "/api/getPLSLatestVersion",
|
||||
auraUpdate: "/api/getAuraLatestVersion",
|
||||
};
|
||||
global.__HUGO_AURA_API__ = __HUGO_AURA_API__;
|
||||
|
||||
Reference in New Issue
Block a user