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