mirror of
https://github.com/HugoAura/Seewo-HugoAura.git
synced 2026-06-20 23:14:28 +08:00
Compare commits
1 Commits
v0.2.0-rc1
...
vAutoBuild
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef0e39dd8c |
3
.github/ISSUE_TEMPLATE/bugReport.yml
vendored
3
.github/ISSUE_TEMPLATE/bugReport.yml
vendored
@@ -54,11 +54,10 @@ body:
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: 日志 / Logs
|
||||
description: 请前往 `偏好设置` - `调试选项` 打开日志文件夹
|
||||
description: 请前往 `用户文件夹/Documents/HugoAura/logs` 取得日志
|
||||
placeholder: |
|
||||
[LOG] Logger initialized. Log file: C:\...
|
||||
[LOG] [HugoAura / Loaded] Aura is loaded!
|
||||
render: bash
|
||||
validations:
|
||||
required: false
|
||||
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/other.yml
vendored
2
.github/ISSUE_TEMPLATE/other.yml
vendored
@@ -16,5 +16,5 @@ body:
|
||||
attributes:
|
||||
label: 提交前请确认 / Confirm before submit
|
||||
options:
|
||||
- label: 请勿利用此 Issue 类型进行闲聊 / 灌水, 如需闲聊, 可移步至 HugoAura 社区 (forum.aurax.cc)
|
||||
- label: 请勿利用此 Issue 类型进行灌水 / 闲聊, 如果您有相关需求, 可留意后续 HugoAura 的论坛 / 用户讨论群开放情况
|
||||
required: true
|
||||
|
||||
130
.github/workflows/pack.yml
vendored
130
.github/workflows/pack.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Pack source code & Create CI/CD Release
|
||||
name: Patch ASAR & Pack source code
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -11,68 +11,156 @@ permissions: write-all
|
||||
|
||||
jobs:
|
||||
pack:
|
||||
name: Pack
|
||||
name: Patch & Pack
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Setup Node.JS 20 LTS
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "20"
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y p7zip-full wget
|
||||
npm install -g asar
|
||||
|
||||
- name: Checkout repository code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: "./HugoAura-Code"
|
||||
|
||||
- name: Create aura.zip
|
||||
- name: Download SeewoServiceSetup
|
||||
run: |
|
||||
echo "[DEBUG] Working DIR:"
|
||||
pwd
|
||||
|
||||
wget -nv -O "SeewoService.exe" "https://e.seewo.com/download/file?code=SeewoServiceSetup"
|
||||
echo "[DEBUG] Listing downloaded file"
|
||||
ls -la SeewoService*
|
||||
|
||||
- name: Extract SeewoServiceSetup as zip
|
||||
run: |
|
||||
mkdir -p SeewoServiceSource
|
||||
7z x "SeewoService.exe" -o"./SeewoServiceSource/" -y
|
||||
|
||||
echo "[DEBUG] Listing extracted files"
|
||||
ls -la SeewoServiceSource/
|
||||
|
||||
- name: Extract ASAR file
|
||||
run: |
|
||||
cd SeewoServiceSource
|
||||
SEEWO_DIR=$(find . -name "SeewoService_*" -type d | head -1)
|
||||
echo "[INFO] Found SeewoService directory: $SEEWO_DIR"
|
||||
|
||||
cd "$SEEWO_DIR/SeewoServiceAssistant/resources/"
|
||||
|
||||
asar extract ./app.asar ./app-unpacked
|
||||
|
||||
- name: Move app-unpacked and clean SSASource
|
||||
run: |
|
||||
mkdir -p SSARes
|
||||
|
||||
cd SeewoServiceSource
|
||||
SEEWO_DIR=$(find . -name "SeewoService_*" -type d | head -1)
|
||||
mv "$SEEWO_DIR/SeewoServiceAssistant/resources/app-unpacked" "../SSARes/"
|
||||
|
||||
cd ..
|
||||
rm -rf SeewoServiceSource
|
||||
rm -rf *.exe
|
||||
echo "[DEBUG] Listing Working DIR"
|
||||
ls -la
|
||||
|
||||
- name: Patch main.js
|
||||
run: |
|
||||
cd SSARes/app-unpacked
|
||||
|
||||
### cp main.js main.js.bak
|
||||
|
||||
cat > patch_main.js << 'EOF'
|
||||
const fs = require('fs');
|
||||
|
||||
let content = fs.readFileSync('main.js', 'utf8');
|
||||
|
||||
content = 'const hook = require("./hook.js");\n' + content;
|
||||
|
||||
content = content.replace(/n\.m=e/, ';const zeron = require("./zeron.js");n = zeron(n);n.m=e');
|
||||
|
||||
content = content.replace(/let f=new s\(Object\.assign\(\{\},\{transparent:!0,/, ';hook({ central: n, windowName: this.wname, config: c });let f=new s(Object.assign({},{transparent:!0,');
|
||||
|
||||
content = content.replace(/c\.canOpenDevTool/, 'c.canOpenDevTool,preload: __dirname + "\\\\preload.js"');
|
||||
|
||||
fs.writeFileSync('main.js', content);
|
||||
|
||||
console.log('[SUCCESS] main.js has been modified successfully');
|
||||
EOF
|
||||
|
||||
echo "[DEBUG] Running patch_main.js"
|
||||
node ./patch_main.js
|
||||
|
||||
rm -rf patch_main.js
|
||||
|
||||
- name: Copy HugoAura core files
|
||||
run: |
|
||||
cp -r HugoAura-Code/src/core/* SSARes/app-unpacked/
|
||||
|
||||
echo "[DEBUG] Listing files under <Working DIR>/SSARes/app-unpacked/"
|
||||
ls -la SSARes/app-unpacked/
|
||||
|
||||
- name: Create artifacts DIR and re-pack ASAR
|
||||
run: |
|
||||
echo "[DEBUG] Creating artifacts directory"
|
||||
mkdir -p Artifacts
|
||||
cd ./HugoAura-Code/src/aura
|
||||
|
||||
asar pack SSARes/app-unpacked Artifacts/app-patched.asar
|
||||
|
||||
- name: Create aura.zip
|
||||
run: |
|
||||
cd HugoAura-Code/src/aura
|
||||
zip -r ../../../Artifacts/aura.zip .
|
||||
cd ../core
|
||||
zip -r ../../../Artifacts/core.zip .
|
||||
cd ../../..
|
||||
|
||||
echo "[DEBUG] Files in <Working DIR>/Artifacts directory:"
|
||||
ls -la Artifacts/
|
||||
|
||||
- name: Get commit hash & build time
|
||||
- name: Get short commit hash
|
||||
run: |
|
||||
cd ./HugoAura-Code
|
||||
SHORT_HASH=$(git rev-parse --short=7 HEAD)
|
||||
FULL_HASH=$(git rev-parse HEAD)
|
||||
echo "SHORT_HASH=$SHORT_HASH" >> $GITHUB_ENV
|
||||
echo "FULL_HASH=$FULL_HASH" >> $GITHUB_ENV
|
||||
echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV
|
||||
|
||||
- name: Create release content
|
||||
run: |
|
||||
cat > rel_msg.txt << 'EOF'
|
||||
cat > rel_msg.txt << EOF
|
||||
## 这是 HugoAura 的 CI 自动构建版本
|
||||
|
||||
### 版本类型: 🔁 自动构建版
|
||||
|
||||
### 版本号: `vAutoBuild-${{ env.SHORT_HASH }}`
|
||||
|
||||
### 对应 Commit: [`${{ env.SHORT_HASH }}`](https://github.com/HugoAura/Seewo-HugoAura/commit/${{ env.FULL_HASH }})
|
||||
### 对应 Commit: [`${{ env.SHORT_HASH }}`](https://github.com/HugoAura/Seewo-HugoAura/commit/${{ env.GITHUB_SHA }})
|
||||
|
||||
---
|
||||
|
||||
### ⚠ 注意: CI 自动构建版本可能不稳定 / 存在较多 Bug, 更新时请留意
|
||||
|
||||
#### 🕘 构建时间: ${{ env.BUILDTIME }}
|
||||
**🕘 构建时间: ${{ env.BUILDTIME }}**
|
||||
EOF
|
||||
|
||||
- name: Upload patched ASAR
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: asar-patched
|
||||
path: Artifacts/app-patched.asar
|
||||
|
||||
- name: Upload aura.zip
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: aura-code
|
||||
path: Artifacts/aura.zip
|
||||
|
||||
- name: Upload core.zip
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: aura-core
|
||||
path: Artifacts/core.zip
|
||||
|
||||
- name: Upload release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
@@ -82,6 +170,6 @@ jobs:
|
||||
prerelease: true
|
||||
generate_release_notes: false
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
files: |
|
||||
file: |
|
||||
Artifacts/app-patched.asar
|
||||
Artifacts/aura.zip
|
||||
Artifacts/core.zip
|
||||
|
||||
26
.github/workflows/trigger-install-upd.yml
vendored
26
.github/workflows/trigger-install-upd.yml
vendored
@@ -1,26 +0,0 @@
|
||||
name: Trigger Aura Install static JSON update
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
trigger-dispatch:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: github.event.release.tag_name != 'vAutoBuild'
|
||||
|
||||
steps:
|
||||
- name: Trigger repository dispatch
|
||||
uses: peter-evans/repository-dispatch@v3
|
||||
with:
|
||||
token: ${{ secrets.AURA_INSTALL_REPO_PAT }}
|
||||
repository: HugoAura/HugoAura-Install
|
||||
event-type: hugoaura_rel
|
||||
client-payload: |
|
||||
{
|
||||
"tag_name": "${{ github.event.release.tag_name }}",
|
||||
"release_name": "${{ github.event.release.name }}",
|
||||
"release_url": "${{ github.event.release.html_url }}",
|
||||
"repository": "${{ github.repository }}"
|
||||
}
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -15,7 +15,6 @@ autoConfiguration.json
|
||||
|
||||
# NPM Packages
|
||||
node_modules/
|
||||
package-lock.json
|
||||
|
||||
# OS Files
|
||||
desktop.ini
|
||||
@@ -23,6 +22,3 @@ desktop.ini
|
||||
|
||||
# Editor Files
|
||||
.vscode/
|
||||
|
||||
# Misc
|
||||
*.bak
|
||||
|
||||
20
README.md
20
README.md
@@ -3,16 +3,16 @@
|
||||
<h1 align="center">HugoAura</h1>
|
||||
<h4 align="center">下一代希沃管家注入式修改方案</h4>
|
||||
<div align="center">
|
||||
<a href="https://github.com/HugoAura/HugoAura">首页</a> · <a href="https://hugo.aurax.cc/about">关于 (WIP)</a> · <a href="https://docs.aurax.cc/HugoAura-Main/">文档 (WIP)</a> · <a href="https://github.com/HugoAura/HugoAura/issues">反馈</a> · <a href="https://forum.aurax.cc/">社区</a>
|
||||
<a href="https://github.com/HugoAura/HugoAura">首页</a> · <a href="https://hugoaura.org/about">关于</a> · <a href="https://github.com/HugoAura/HugoAura/wiki">文档</a> · <a href="https://github.com/HugoAura/HugoAura/issues">反馈</a>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
> [!TIP]
|
||||
> 在[此处](https://github.com/HugoAura/HugoAura/wiki)查看 HugoAura 的安装教程
|
||||
> HugoAura 的首个预览版已发布! [查看安装教程](https://github.com/HugoAura/HugoAura/wiki)
|
||||
|
||||
> [!IMPORTANT]
|
||||
> 已经过测试的希沃管家版本: v1.5.5.3878
|
||||
> 已经过测试的希沃管家版本: v1.5.4.3824
|
||||
|
||||

|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
- [x] 修改希沃管家密码认证组件 (自定义密码 / 解除密码 / 重设认证方式 / ...)
|
||||
- [x] 阻止希沃管家前端 Audit 上报行为
|
||||
- [x] 屏蔽屏幕锁 / 自定义屏幕锁行为
|
||||
- [x] Aura 代理层服务 (篡改上报数据 / 欺骗冰冻状态)
|
||||
- [ ] Aura 代理层服务 (篡改上报数据 / 欺骗冰冻状态)
|
||||
- [ ] 窥屏提醒
|
||||
- [ ] 插件功能
|
||||
|
||||
@@ -55,18 +55,6 @@
|
||||
|
||||
请参阅 [Wiki](https://github.com/HugoAura/HugoAura/wiki) 以了解安装流程。
|
||||
|
||||
## 🤖 AIGC 声明
|
||||
|
||||

|
||||
|
||||
## 📦 贡献准则
|
||||
|
||||

|
||||
|
||||
## 🎉 鸣谢
|
||||
|
||||

|
||||
|
||||
## ❗ 免责声明
|
||||
|
||||
本项目仅用于研究或教育目的, 请勿将本项目用于可能违反当地法律、侵犯著作权或其他软件 EULA 的用途。若将本项目用于非法用途, 一切后果由使用者承担。开发者不承担此类行为带来的任何后果或责任。
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "HugoAura",
|
||||
"version": "0.2.0-rc1",
|
||||
"version": "0.1.1-pre-IV",
|
||||
"description": "Aura for SeewoHugo",
|
||||
"main": "app.asar/main.js",
|
||||
"dependencies": {},
|
||||
|
||||
@@ -77,10 +77,9 @@ const buildIpcMain = (electron) => {
|
||||
};
|
||||
|
||||
const { applyBaseIpcHandler } = require("./ipcModules/baseIpcHandler");
|
||||
const { applyDebugIpcHandler } = require("./ipcModules/debugIpcHandler");
|
||||
const { applyConfigIpcHandler } = require("./ipcModules/configIpcHandler");
|
||||
const { applyFsIpcHandler } = require("./ipcModules/fsIpcHandler");
|
||||
const { applyAikariIpcHandler } = require("./ipcModules/aikariIpcHandler");
|
||||
const { applyPlsIpcHandler } = require("./ipcModules/plsIpcHandler");
|
||||
|
||||
ipcMain.handle("$aura.base.restartApplication", async () => {
|
||||
app.relaunch();
|
||||
@@ -88,10 +87,9 @@ const buildIpcMain = (electron) => {
|
||||
});
|
||||
|
||||
applyBaseIpcHandler(ipcMain);
|
||||
applyDebugIpcHandler(ipcMain);
|
||||
applyConfigIpcHandler(ipcMain);
|
||||
applyFsIpcHandler(ipcMain);
|
||||
applyAikariIpcHandler(ipcMain);
|
||||
applyPlsIpcHandler(ipcMain);
|
||||
};
|
||||
|
||||
module.exports = { buildIpcMain };
|
||||
|
||||
@@ -1,73 +1,59 @@
|
||||
// @ts-check
|
||||
|
||||
const { BrowserWindow } = require("electron");
|
||||
|
||||
const composables = {
|
||||
getBrowserWindowInstance: (windowKey) => {
|
||||
if (!global.__HUGO_AURA__.hookedWindows) return null;
|
||||
const hookedWindowIns = global.__HUGO_AURA__.hookedWindows.get(windowKey);
|
||||
if (!hookedWindowIns) return undefined;
|
||||
const browserWindowIns = BrowserWindow.fromWebContents(
|
||||
hookedWindowIns.webContents
|
||||
);
|
||||
return browserWindowIns;
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMain} ipcMain
|
||||
*/
|
||||
const applyBaseIpcHandler = (ipcMain) => {
|
||||
const methodBase = "$aura.base";
|
||||
|
||||
ipcMain.on(
|
||||
`${methodBase}.minimizeWindow`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainEvent} _event
|
||||
* @param {{ targetWindowKey: string }} arg
|
||||
*/
|
||||
(_event, arg) => {
|
||||
const browserWindowIns = composables.getBrowserWindowInstance(
|
||||
arg.targetWindowKey
|
||||
);
|
||||
if (!browserWindowIns) return;
|
||||
|
||||
browserWindowIns.minimize();
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.on(
|
||||
`${methodBase}.closeWindow`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainEvent} _event
|
||||
* @param {{ targetWindowKey: string }} arg
|
||||
*/
|
||||
(_event, arg) => {
|
||||
const browserWindowIns = composables.getBrowserWindowInstance(
|
||||
arg.targetWindowKey
|
||||
);
|
||||
if (!browserWindowIns) return;
|
||||
|
||||
browserWindowIns.close();
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.handle(`${methodBase}.getAuraDirAsync`, (_evt, _arg) => {
|
||||
return {
|
||||
success: true,
|
||||
data: global.__HUGO_AURA__.auraDir,
|
||||
};
|
||||
});
|
||||
|
||||
ipcMain.on(`${methodBase}.getAuraDirSync`, (event, _arg) => {
|
||||
event.returnValue = {
|
||||
success: true,
|
||||
data: global.__HUGO_AURA__.auraDir,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = { applyBaseIpcHandler };
|
||||
// @ts-check
|
||||
|
||||
const { BrowserWindow } = require("electron");
|
||||
|
||||
const composables = {
|
||||
getBrowserWindowInstance: (windowKey) => {
|
||||
if (!global.__HUGO_AURA__.hookedWindows) return null;
|
||||
const hookedWindowIns = global.__HUGO_AURA__.hookedWindows.get(windowKey);
|
||||
if (!hookedWindowIns) return undefined;
|
||||
const browserWindowIns = BrowserWindow.fromWebContents(
|
||||
hookedWindowIns.webContents
|
||||
);
|
||||
return browserWindowIns;
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMain} ipcMain
|
||||
*/
|
||||
const applyBaseIpcHandler = (ipcMain) => {
|
||||
const methodBase = "$aura.base";
|
||||
|
||||
ipcMain.on(
|
||||
`${methodBase}.minimizeWindow`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainEvent} _event
|
||||
* @param {{ targetWindowKey: string }} arg
|
||||
*/
|
||||
(_event, arg) => {
|
||||
const browserWindowIns = composables.getBrowserWindowInstance(
|
||||
arg.targetWindowKey
|
||||
);
|
||||
if (!browserWindowIns) return;
|
||||
|
||||
browserWindowIns.minimize();
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.on(
|
||||
`${methodBase}.closeWindow`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainEvent} _event
|
||||
* @param {{ targetWindowKey: string }} arg
|
||||
*/
|
||||
(_event, arg) => {
|
||||
const browserWindowIns = composables.getBrowserWindowInstance(
|
||||
arg.targetWindowKey
|
||||
);
|
||||
if (!browserWindowIns) return;
|
||||
|
||||
browserWindowIns.close();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = { applyBaseIpcHandler };
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
const __SCOPE = "main";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMain} ipcMain
|
||||
*/
|
||||
const applyDebugIpcHandler = (ipcMain) => {
|
||||
const methodBase = "$aura.debug";
|
||||
};
|
||||
|
||||
module.exports = { applyDebugIpcHandler };
|
||||
340
src/aura/init/main/ipcModules/aikariIpcHandler.js → src/aura/init/main/ipcModules/plsIpcHandler.js
Normal file → Executable file
340
src/aura/init/main/ipcModules/aikariIpcHandler.js → src/aura/init/main/ipcModules/plsIpcHandler.js
Normal file → Executable file
@@ -68,7 +68,7 @@ const functions = {
|
||||
* @param {(arg: DownloadTask) => any} callbackFn
|
||||
* @param {string} binPath
|
||||
*/
|
||||
handleAikariDlAndInstall: async (channel, callbackFn, binPath) => {
|
||||
handlePLSDownload: async (channel, callbackFn, binPath) => {
|
||||
// TODO: Channel selection
|
||||
const apiInfo = global.__HUGO_AURA_API__;
|
||||
|
||||
@@ -78,7 +78,7 @@ const functions = {
|
||||
const reqPromise = new Promise((resolveHttpRequest) => {
|
||||
nodeHttps
|
||||
.get(
|
||||
`${apiDomain}${apiInfo.aikariUpdate}?channel=${channel}`,
|
||||
`${apiDomain}${apiInfo.plsUpdate}?channel=${channel}`,
|
||||
(rep) => {
|
||||
let dataChunk = "";
|
||||
rep.on("data", (chunk) => {
|
||||
@@ -167,13 +167,12 @@ const functions = {
|
||||
status: "failed",
|
||||
dlUrl: null,
|
||||
savePath: null,
|
||||
message:
|
||||
"未能获取 Aikari 版本信息, 所有 API 域名均无法连接, 建议前往 GitHub 下载安装包并自行安装",
|
||||
message: "未能获取 PLS 版本信息, 所有 API 域名均无法连接",
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
const aikariVersionInfo = rawResInfo.data;
|
||||
const plsVersionInfo = rawResInfo.data;
|
||||
|
||||
let deviceArch = process.env.PROCESSOR_ARCHITEW6432
|
||||
? process.env.PROCESSOR_ARCHITEW6432
|
||||
@@ -181,92 +180,32 @@ const functions = {
|
||||
// @ts-expect-error
|
||||
deviceArch = deviceArch.toLowerCase();
|
||||
|
||||
if (!Object.keys(aikariVersionInfo.data.downloadUrl).includes(deviceArch)) {
|
||||
if (!Object.keys(plsVersionInfo.data.downloadUrl).includes(deviceArch)) {
|
||||
callbackFn({
|
||||
id: "",
|
||||
progress: 0,
|
||||
status: "failed",
|
||||
dlUrl: null,
|
||||
savePath: null,
|
||||
message: `不支持的处理器架构, 检测到的架构: "${deviceArch}"`,
|
||||
message: `处理器架构识别失败, 检测到的架构: ${deviceArch}`,
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
const downloadFilePromise = new Promise((resolve) => {
|
||||
fsComposables.downloadFile(
|
||||
aikariVersionInfo.data.downloadUrl[deviceArch],
|
||||
binPath,
|
||||
(...args) => {
|
||||
if (args[0].status === "done") {
|
||||
resolve(true);
|
||||
} else if (args[0].status === "failed") {
|
||||
resolve(false);
|
||||
fsComposables.downloadFile(
|
||||
plsVersionInfo.data.downloadUrl[deviceArch],
|
||||
binPath,
|
||||
(...args) => {
|
||||
if (args[0].status === "done") {
|
||||
if (global.__HUGO_AURA__.plsStats) {
|
||||
global.__HUGO_AURA__.plsStats.installed = true;
|
||||
global.__HUGO_AURA__.plsStats.status = "dead";
|
||||
}
|
||||
|
||||
callbackFn(...args);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
const dlResult = await downloadFilePromise;
|
||||
|
||||
if (dlResult) {
|
||||
callbackFn({
|
||||
id: "INSTALL_STAGE",
|
||||
progress: 5,
|
||||
status: "waiting",
|
||||
dlUrl: null,
|
||||
savePath: null,
|
||||
message: "准备运行 Aikari 安装程序...",
|
||||
});
|
||||
|
||||
const runInstPromise = new Promise((resolve) => {
|
||||
exec(
|
||||
`"${binPath}" /VERYSILENT /SUPPRESSMSGBOXES /LOG="${binPath}\\..\\Aikari-Install.log"`,
|
||||
(err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.error(
|
||||
`[HugoAura / Main / Aikari IPC Handler / Install Aikari] Error running installer: ${stderr}`
|
||||
);
|
||||
resolve({ success: false });
|
||||
}
|
||||
resolve({ success: true });
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
callbackFn({
|
||||
id: "INSTALL_STAGE",
|
||||
progress: 15,
|
||||
status: "progressing",
|
||||
dlUrl: null,
|
||||
savePath: null,
|
||||
message: "正在安装 Aikari...",
|
||||
});
|
||||
|
||||
const instResult = await runInstPromise;
|
||||
|
||||
callbackFn({
|
||||
id: "INSTALL_STAGE",
|
||||
progress: 100,
|
||||
status: instResult.success ? "done" : "failed",
|
||||
dlUrl: null,
|
||||
savePath: null,
|
||||
message: instResult.success
|
||||
? "Aikari 安装成功"
|
||||
: "安装失败, 请检查 %TEMP%/Aikari-Install-Temp 下的安装日志",
|
||||
});
|
||||
|
||||
if (instResult.success) {
|
||||
if (global.__HUGO_AURA__.aikariStats) {
|
||||
global.__HUGO_AURA__.aikariStats.installed = true;
|
||||
global.__HUGO_AURA__.aikariStats.status = "dead";
|
||||
}
|
||||
callbackFn(...args);
|
||||
}
|
||||
|
||||
fs.unlinkSync(binPath);
|
||||
}
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -274,57 +213,37 @@ const functions = {
|
||||
*
|
||||
* @param {import("../../../types/main/electron").AuraIPCMain} ipcMain
|
||||
*/
|
||||
const applyAikariIpcHandler = (ipcMain) => {
|
||||
const methodBase = "$aura.aikari";
|
||||
const applyPlsIpcHandler = (ipcMain) => {
|
||||
const methodBase = "$aura.pls";
|
||||
|
||||
const AIKARI_DEFAULT_INSTALL_DIR = path.join(
|
||||
"C:\\Program Files",
|
||||
"HugoAura",
|
||||
"Aikari"
|
||||
);
|
||||
const AIKARI_LAUNCHER_PATH = path.join(
|
||||
AIKARI_DEFAULT_INSTALL_DIR,
|
||||
"Aikari-Launcher.exe"
|
||||
);
|
||||
const AIKARI_UNINSTALLER_PATH = path.join(
|
||||
AIKARI_DEFAULT_INSTALL_DIR,
|
||||
"unins000.exe"
|
||||
);
|
||||
const AIKARI_SVC_NAME = "HugoAuraAikari";
|
||||
const PLS_INSTALL_DIR = path.join("C:\\Program Files", "HugoAura PLS", "bin");
|
||||
const PLS_BIN_PATH = path.join(PLS_INSTALL_DIR, "HugoAura-PLS.exe");
|
||||
const PLS_SVC_NAME = "HugoAuraPLS";
|
||||
|
||||
const AIKARI_TEMP_DL_DIR = path.join(
|
||||
require("os").tmpdir(),
|
||||
"Aikari-Install-Temp"
|
||||
);
|
||||
const AIKARI_TEMP_INSTALLER_FILENAME = path.join(
|
||||
AIKARI_TEMP_DL_DIR,
|
||||
"Aikari-Installer.exe"
|
||||
);
|
||||
const isPlsDetached = process.argv.includes("--pls-detach");
|
||||
|
||||
const isAikariDetached = process.argv.includes("--aikari-detach");
|
||||
|
||||
global.__HUGO_AURA__.aikariStats = {
|
||||
global.__HUGO_AURA__.plsStats = {
|
||||
installed: false,
|
||||
launched: false,
|
||||
detached: isAikariDetached,
|
||||
detached: isPlsDetached,
|
||||
connected: false,
|
||||
version: "unknown",
|
||||
version: "未知",
|
||||
status: "dead",
|
||||
authToken: global.__HUGO_AURA_CONFIG__.aikariToken,
|
||||
authToken: global.__HUGO_AURA_CONFIG__.plsToken,
|
||||
};
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.getIfAikariBinExists`,
|
||||
`${methodBase}.getPlsBinExists`,
|
||||
/**
|
||||
*
|
||||
* @returns {{ success: boolean; data: { isExists: boolean }; error?: Error }}
|
||||
*/
|
||||
(_event, _arg) => {
|
||||
try {
|
||||
const result = fs.existsSync(AIKARI_LAUNCHER_PATH);
|
||||
const result = fs.existsSync(PLS_BIN_PATH);
|
||||
|
||||
if (global.__HUGO_AURA__.aikariStats?.status === "notInstalled") {
|
||||
global.__HUGO_AURA__.aikariStats.status = "dead";
|
||||
if (global.__HUGO_AURA__.plsStats?.status === "notInstalled") {
|
||||
global.__HUGO_AURA__.plsStats.status = "dead";
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -333,7 +252,7 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
};
|
||||
} catch (e) {
|
||||
// @ts-expect-error
|
||||
global.__HUGO_AURA__.aikariStats.status = "notInstalled";
|
||||
global.__HUGO_AURA__.plsStats.status = "notInstalled";
|
||||
return {
|
||||
success: false,
|
||||
data: { isExists: false },
|
||||
@@ -344,7 +263,7 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.ensureAikariInstallDir`,
|
||||
`${methodBase}.ensurePlsInstallDir`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _event
|
||||
@@ -352,24 +271,24 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
* @returns {{ success: boolean; data: { alreadyExists: boolean; createdDir: string; }; error?: Error }}
|
||||
*/
|
||||
(_event, _arg) => {
|
||||
const alreadyExists = fs.existsSync(AIKARI_DEFAULT_INSTALL_DIR);
|
||||
const alreadyExists = fs.existsSync(PLS_INSTALL_DIR);
|
||||
if (alreadyExists) {
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
alreadyExists: true,
|
||||
createdDir: AIKARI_DEFAULT_INSTALL_DIR,
|
||||
createdDir: PLS_INSTALL_DIR,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
fs.mkdirSync(AIKARI_DEFAULT_INSTALL_DIR, { recursive: true });
|
||||
fs.mkdirSync(PLS_INSTALL_DIR, { recursive: true });
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
alreadyExists: false,
|
||||
createdDir: AIKARI_DEFAULT_INSTALL_DIR,
|
||||
createdDir: PLS_INSTALL_DIR,
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
@@ -377,7 +296,7 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
success: false,
|
||||
data: {
|
||||
alreadyExists: false,
|
||||
createdDir: AIKARI_DEFAULT_INSTALL_DIR,
|
||||
createdDir: PLS_INSTALL_DIR,
|
||||
},
|
||||
error: error,
|
||||
};
|
||||
@@ -386,30 +305,30 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.getAikariStatus`,
|
||||
`${methodBase}.getPlsStats`,
|
||||
/**
|
||||
*
|
||||
* @returns {{ success: boolean; data: import("../../../types/shared/aikari/status").AikariStatus | null | undefined; }}
|
||||
* @returns {{ success: boolean; data: import("../../../types/shared/pls/status").PLSStatus | null | undefined; }}
|
||||
*/
|
||||
(_event, _arg) => {
|
||||
return {
|
||||
success: true,
|
||||
data: global.__HUGO_AURA__.aikariStats,
|
||||
data: global.__HUGO_AURA__.plsStats,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.updateAikariStatus`,
|
||||
`${methodBase}.updatePlsStats`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _event
|
||||
* @param {import("../../../types/shared/aikari/status").AikariStatus} arg
|
||||
* @param {import("../../../types/shared/pls/status").PLSStatus} arg
|
||||
* @returns
|
||||
*/
|
||||
(_event, arg) => {
|
||||
global.__HUGO_AURA__.aikariStats = arg;
|
||||
ipcMain.send("assistant", `${methodBase}.post.onAikariStatsUpdate`, arg);
|
||||
global.__HUGO_AURA__.plsStats = arg;
|
||||
ipcMain.send("assistant", `${methodBase}.post.onPlsStatsUpdate`, arg);
|
||||
return {
|
||||
success: true,
|
||||
};
|
||||
@@ -417,7 +336,7 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.getAikariSettings`,
|
||||
`${methodBase}.getPlsSettings`,
|
||||
/**
|
||||
*
|
||||
* @returns {{ success: boolean; data: Record<any, any> | null | undefined }}
|
||||
@@ -425,13 +344,13 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
(_event, _arg) => {
|
||||
return {
|
||||
success: true,
|
||||
data: global.__HUGO_AURA__.aikariSettings,
|
||||
data: global.__HUGO_AURA__.plsSettings,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.updateAikariSettings`,
|
||||
`${methodBase}.updatePlsSettings`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _event
|
||||
@@ -439,12 +358,8 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
* @returns
|
||||
*/
|
||||
(_event, arg) => {
|
||||
global.__HUGO_AURA__.aikariSettings = arg;
|
||||
ipcMain.send(
|
||||
"assistant",
|
||||
`${methodBase}.post.onAikariSettingsUpdate`,
|
||||
arg
|
||||
);
|
||||
global.__HUGO_AURA__.plsSettings = arg;
|
||||
ipcMain.send("assistant", `${methodBase}.post.onPlsSettingsUpdate`, arg);
|
||||
return {
|
||||
success: true,
|
||||
};
|
||||
@@ -452,7 +367,7 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.getAikariRules`,
|
||||
`${methodBase}.getPlsRules`,
|
||||
/**
|
||||
*
|
||||
* @returns {{ success: boolean; data: Record<any, any> | null | undefined }}
|
||||
@@ -460,13 +375,13 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
(_event, _arg) => {
|
||||
return {
|
||||
success: true,
|
||||
data: global.__HUGO_AURA__.aikariRules,
|
||||
data: global.__HUGO_AURA__.plsRules,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.updateAikariRules`,
|
||||
`${methodBase}.updatePlsRules`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _event
|
||||
@@ -474,8 +389,8 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
* @returns
|
||||
*/
|
||||
(_event, arg) => {
|
||||
global.__HUGO_AURA__.aikariRules = arg;
|
||||
ipcMain.send("assistant", `${methodBase}.post.onAikariRulesUpdate`, arg);
|
||||
global.__HUGO_AURA__.plsRules = arg;
|
||||
ipcMain.send("assistant", `${methodBase}.post.onPlsRulesUpdate`, arg);
|
||||
return {
|
||||
success: true,
|
||||
};
|
||||
@@ -487,7 +402,7 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainEvent} _event
|
||||
* @param {AikariResponse} arg
|
||||
* @param {PLSResponse} arg
|
||||
*/
|
||||
(_event, arg) => {
|
||||
ipcMain.send("assistant", `${methodBase}.ws.post.onNewMsgRecv`, arg);
|
||||
@@ -499,11 +414,11 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _event
|
||||
* @param {ClientAikariRequest} arg
|
||||
* @param {ClientPLSRequest} arg
|
||||
*/
|
||||
(_event, arg) => {
|
||||
ipcMain.send(
|
||||
"auraWsKeepAlive",
|
||||
"desktopAssistant",
|
||||
`${methodBase}.ws.post.onReqSendMsg`,
|
||||
arg
|
||||
);
|
||||
@@ -511,17 +426,17 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.syncAikariConfig`,
|
||||
`${methodBase}.syncPlsConfig`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} event
|
||||
* @param {{ basic: Record<any, any>, rules: Record<any, any> }} arg
|
||||
*/
|
||||
(event, arg) => {
|
||||
global.__HUGO_AURA__.aikariRules = arg.rules;
|
||||
global.__HUGO_AURA__.aikariSettings = arg.basic;
|
||||
global.__HUGO_AURA__.plsRules = arg.rules;
|
||||
global.__HUGO_AURA__.plsSettings = arg.basic;
|
||||
|
||||
ipcMain.send("*", `${methodBase}.syncAikariConfig`, arg, event.sender);
|
||||
ipcMain.send("*", `${methodBase}.syncPlsConfig`, arg, event.sender);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
@@ -530,27 +445,24 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.aikariLifecycleQuery`,
|
||||
`${methodBase}.plsLifecycleQuery`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _event
|
||||
* @param {{ target: import("../../../types/shared/aikari/status").AikariLifecycleType }} arg
|
||||
* @param {{ target: import("../../../types/shared/pls/status").PLSLifecycleType }} arg
|
||||
* @returns {Promise<{ success: boolean, result: boolean }>}
|
||||
*/
|
||||
async (_event, arg) => {
|
||||
switch (arg.target) {
|
||||
case "isDetached":
|
||||
return { success: true, result: isAikariDetached };
|
||||
return { success: true, result: isPlsDetached };
|
||||
case "isSvcInstalled":
|
||||
return await functions.querySvcDetail(
|
||||
AIKARI_SVC_NAME,
|
||||
"SERVICE_NAME"
|
||||
);
|
||||
return await functions.querySvcDetail(PLS_SVC_NAME, "SERVICE_NAME");
|
||||
case "isSvcStart":
|
||||
return await functions.querySvcDetail(AIKARI_SVC_NAME, "RUNNING");
|
||||
return await functions.querySvcDetail(PLS_SVC_NAME, "RUNNING");
|
||||
default:
|
||||
console.warn(
|
||||
`[HugoAura / IPC / Aikari] <AikariLifecycleQuery> Invalid arg.target: ${arg.target}`
|
||||
`[HugoAura / IPC / PLS] <plsLifecycleQuery> Invalid arg.target: ${arg.target}`
|
||||
);
|
||||
return {
|
||||
success: false,
|
||||
@@ -561,72 +473,55 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.aikariLifecycleControl`,
|
||||
`${methodBase}.plsLifecycleControl`,
|
||||
/**
|
||||
*
|
||||
* @param {*} _event
|
||||
* @param {{ target: import("../../../types/shared/aikari/status").AikariLifecycleControlType }} arg
|
||||
* @param {{ target: import("../../../types/shared/pls/status").PLSLifecycleControlType }} arg
|
||||
* @returns {Promise<{ success: boolean, errorObj?: Error }>}
|
||||
*/
|
||||
async (_event, arg) => {
|
||||
const logHeader = "[HugoAura / IPC / Aikari] <AikariLifecycleControl>";
|
||||
const logHeader = "[HugoAura / IPC / PLS] <plsLifecycleControl>";
|
||||
|
||||
// TODO: Impl this
|
||||
switch (arg.target) {
|
||||
case "instSvc":
|
||||
return await functions.execCommand(
|
||||
logHeader,
|
||||
AIKARI_LAUNCHER_PATH,
|
||||
"--service install"
|
||||
PLS_BIN_PATH,
|
||||
"--startup auto install"
|
||||
);
|
||||
case "uninstSvc": {
|
||||
const result = await functions.execCommand(
|
||||
logHeader,
|
||||
AIKARI_LAUNCHER_PATH,
|
||||
"--service uninstall"
|
||||
);
|
||||
return result;
|
||||
}
|
||||
case "rmSvc":
|
||||
return await functions.execCommand(logHeader, PLS_BIN_PATH, "remove");
|
||||
case "startSvc":
|
||||
return await functions.execCommand(
|
||||
logHeader,
|
||||
"sc.exe",
|
||||
`start ${AIKARI_SVC_NAME}`
|
||||
);
|
||||
case "stopSvc": {
|
||||
const result = await functions.execCommand(
|
||||
logHeader,
|
||||
"sc.exe",
|
||||
`stop ${AIKARI_SVC_NAME}`
|
||||
);
|
||||
if (result.success && global.__HUGO_AURA__.aikariStats) {
|
||||
global.__HUGO_AURA__.aikariStats.connected = false;
|
||||
global.__HUGO_AURA__.aikariStats.launched = false;
|
||||
global.__HUGO_AURA__.aikariStats.version = "unknown";
|
||||
global.__HUGO_AURA__.aikariStats.status = "dead";
|
||||
return await functions.execCommand(logHeader, PLS_BIN_PATH, "start");
|
||||
case "stopSvc":
|
||||
return await functions.execCommand(logHeader, PLS_BIN_PATH, "stop");
|
||||
case "rmBin":
|
||||
const unlinkPromise = new Promise((resolve) => {
|
||||
fs.unlink(PLS_BIN_PATH, (error) => {
|
||||
if (error) {
|
||||
resolve({
|
||||
success: false,
|
||||
errorObj: error,
|
||||
});
|
||||
console.error(
|
||||
`${logHeader} Failed to remove PLS bin, error:`,
|
||||
error
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
ipcMain.send(
|
||||
"assistant",
|
||||
`${methodBase}.post.onAikariStatsUpdate`,
|
||||
global.__HUGO_AURA__.aikariStats
|
||||
);
|
||||
resolve({
|
||||
success: true,
|
||||
errorObj: null,
|
||||
});
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.send(
|
||||
"auraWsKeepAlive",
|
||||
`${methodBase}.post.aikariStopped`,
|
||||
{}
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
case "inst":
|
||||
// TODO: Impl Aikari INST
|
||||
case "uninst":
|
||||
return await functions.execCommand(
|
||||
logHeader,
|
||||
AIKARI_UNINSTALLER_PATH,
|
||||
""
|
||||
);
|
||||
const unlinkRet = await unlinkPromise;
|
||||
|
||||
return unlinkRet;
|
||||
default:
|
||||
return { success: false, errorObj: new Error("Method not found") };
|
||||
}
|
||||
@@ -634,41 +529,32 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.downloadAndInstallAikari`,
|
||||
`${methodBase}.downloadPls`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _evt
|
||||
* @param {{channel?: "stable" | "alpha", reportTo?: import("../../../types/main/core").WindowName}} arg
|
||||
* @returns {Promise<void>}
|
||||
* @returns {void}
|
||||
*/
|
||||
async (_evt, arg) => {
|
||||
if (fs.existsSync(AIKARI_TEMP_DL_DIR)) {
|
||||
try {
|
||||
fs.unlinkSync(AIKARI_TEMP_DL_DIR);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
} else {
|
||||
fs.mkdirSync(AIKARI_TEMP_DL_DIR);
|
||||
}
|
||||
(_evt, arg) => {
|
||||
const channel = arg.channel ? arg.channel : "stable";
|
||||
const reportWin = arg.reportTo ? arg.reportTo : "assistant";
|
||||
functions.handleAikariDlAndInstall(
|
||||
functions.handlePLSDownload(
|
||||
channel,
|
||||
(status) => {
|
||||
ipcMain.send(
|
||||
reportWin,
|
||||
`${methodBase}.post.reportAikariInstallStep`,
|
||||
`${methodBase}.post.reportPlsDownloadStatus`,
|
||||
status
|
||||
);
|
||||
},
|
||||
AIKARI_TEMP_INSTALLER_FILENAME
|
||||
PLS_BIN_PATH
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.retryAikariConnect`,
|
||||
`${methodBase}.retryPlsConnect`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _event
|
||||
@@ -676,17 +562,13 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
* @returns {{ success: boolean, status: "Already" | "Retrying" }}
|
||||
*/
|
||||
(_event, arg) => {
|
||||
if (global.__HUGO_AURA__.aikariStats?.connected) {
|
||||
if (global.__HUGO_AURA__.plsStats?.connected) {
|
||||
return {
|
||||
success: true,
|
||||
status: "Already",
|
||||
};
|
||||
} else {
|
||||
ipcMain.send(
|
||||
"auraWsKeepAlive",
|
||||
`${methodBase}.retryAikariConnect`,
|
||||
arg
|
||||
);
|
||||
ipcMain.send("desktopAssistant", `${methodBase}.retryPlsConnect`, arg);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
@@ -714,4 +596,4 @@ const applyAikariIpcHandler = (ipcMain) => {
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = { applyAikariIpcHandler };
|
||||
module.exports = { applyPlsIpcHandler };
|
||||
@@ -8,10 +8,7 @@ const util = require("util");
|
||||
* @param {import("../aura/types/main/core").WindowName} windowName
|
||||
*/
|
||||
const initLogger = (windowName) => {
|
||||
const logDir = path.join(global.__HUGO_AURA__.auraDir, "logs");
|
||||
|
||||
global.__HUGO_AURA__.logDir = logDir;
|
||||
|
||||
const logDir = path.join(os.homedir(), "Documents", "HugoAura", "logs");
|
||||
if (!fs.existsSync(logDir)) {
|
||||
fs.mkdirSync(logDir, { recursive: true });
|
||||
}
|
||||
@@ -67,22 +64,25 @@ const initLogger = (windowName) => {
|
||||
console.error("[CRITICAL] UNCAUGHT EXCEPTION:", err);
|
||||
});
|
||||
|
||||
console.log("[HugoAura / Logger] Logger initialized. Log file:", logFile);
|
||||
console.log(
|
||||
"[HugoAura / Logger] Logger initialized. Log file:",
|
||||
logFile
|
||||
);
|
||||
};
|
||||
|
||||
const cleanupOldLogs = (logDir) => {
|
||||
try {
|
||||
const files = fs.readdirSync(logDir);
|
||||
const now = new Date();
|
||||
const daysAgo = new Date(now.getTime() - 15 * 24 * 60 * 60 * 1000);
|
||||
const sevenDaysAgo = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000);
|
||||
|
||||
files.forEach((file) => {
|
||||
if (file.endsWith(".log")) {
|
||||
const filePath = path.join(logDir, file);
|
||||
const stats = fs.statSync(filePath);
|
||||
|
||||
// 如果文件创建时间超过两周, 则删除
|
||||
if (stats.birthtime < daysAgo) {
|
||||
// 如果文件创建时间超过 30 天, 则删除
|
||||
if (stats.birthtime < sevenDaysAgo) {
|
||||
fs.unlinkSync(filePath);
|
||||
console.log(
|
||||
`[HugoAura / Logger / Cleanup] Cleaned log file: ${file}`
|
||||
@@ -91,10 +91,7 @@ const cleanupOldLogs = (logDir) => {
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"[HugoAura / Logger / Cleanup] Unexpected error occurred cleaning log file:",
|
||||
error
|
||||
);
|
||||
console.error("[HugoAura / Logger / Cleanup] Unexpected error occurred cleaning log file:", error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class WindowHooksManager {
|
||||
|
||||
const hooksPath = path.join(__dirname, "../../../aura/mainProcess/hooks");
|
||||
|
||||
/** @type {import("../../types/main/core").UIHooksMap} */
|
||||
/** @type {import("../../types/main/core").HooksMap} */
|
||||
const hooks = new Map();
|
||||
|
||||
try {
|
||||
@@ -55,9 +55,6 @@ class WindowHooksManager {
|
||||
browserWindowInstance
|
||||
) {
|
||||
const stripWindowName = windowName.split("_")[0];
|
||||
|
||||
if (!global.__HUGO_AURA__.windowHooks) return;
|
||||
|
||||
if (!global.__HUGO_AURA__.windowHooks.has(stripWindowName)) {
|
||||
console.log(
|
||||
`[HugoAura / Init / WDH] Window ${windowName} has no corresponding main process hooks, ignoring...`
|
||||
|
||||
@@ -168,8 +168,8 @@
|
||||
observers.set(moduleKey, observer);
|
||||
};
|
||||
|
||||
const loadResources = async (resources, type, moduleKey) => {
|
||||
if (!resources) return [];
|
||||
const loadResources = async (resources, type, moduleKey, isRevive) => {
|
||||
if (!resources || isRevive) return [];
|
||||
|
||||
const resourceArray = Array.isArray(resources) ? resources : [resources];
|
||||
const loadedResources = [];
|
||||
@@ -232,11 +232,12 @@
|
||||
const resources = new Set();
|
||||
moduleResources.set(moduleKey, resources);
|
||||
|
||||
if (config.pageCSS && !isRevive) {
|
||||
if (config.pageCSS) {
|
||||
const cssResources = await loadResources(
|
||||
config.pageCSS,
|
||||
"css",
|
||||
moduleKey
|
||||
moduleKey,
|
||||
isRevive
|
||||
);
|
||||
cssResources.forEach((resource) => resources.add(resource));
|
||||
}
|
||||
@@ -249,22 +250,16 @@
|
||||
insertElement(target, container, config.selectorMode);
|
||||
monitorParent(moduleKey, target, container, config.selectorMode);
|
||||
|
||||
if (config.pageScript && !isRevive) {
|
||||
if (config.pageScript) {
|
||||
const jsResources = await loadResources(
|
||||
config.pageScript,
|
||||
"js",
|
||||
moduleKey
|
||||
moduleKey,
|
||||
isRevive
|
||||
);
|
||||
jsResources.forEach((resource) => resources.add(resource));
|
||||
}
|
||||
|
||||
if (isRevive) {
|
||||
const onReviveEvent = new CustomEvent(
|
||||
`onLoaderElRevive:${moduleKey}`
|
||||
);
|
||||
document.dispatchEvent(onReviveEvent);
|
||||
}
|
||||
|
||||
const observer = new MutationObserver(() => {
|
||||
if (
|
||||
!document.contains(container) &&
|
||||
|
||||
@@ -69,7 +69,7 @@ const deepMerge = (target, source) => {
|
||||
|
||||
class ConfigManager {
|
||||
constructor() {
|
||||
this.configDir = global.__HUGO_AURA__.auraDir;
|
||||
this.configDir = path.join(os.homedir(), "Documents", "HugoAura");
|
||||
this.configPath = path.join(this.configDir, "config.json");
|
||||
this.encConfigPath = path.join(this.configDir, ".cache_2eafc8d0.dat"); // (雾
|
||||
/* ↑ 不使用 .tmp 扩展名, 不然容易真被清理了 */
|
||||
@@ -78,10 +78,10 @@ class ConfigManager {
|
||||
this.isConfigReadFailed = false;
|
||||
this.side = "unknown";
|
||||
|
||||
if (fs.existsSync(this.encConfigPath)) {
|
||||
this.useEncConfig = true;
|
||||
} else {
|
||||
if (fs.existsSync(this.configPath)) {
|
||||
this.useEncConfig = false;
|
||||
} else {
|
||||
this.useEncConfig = true;
|
||||
}
|
||||
|
||||
if (global.__HUGO_AURA_EVENT_BUS__) {
|
||||
@@ -95,38 +95,6 @@ class ConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
migrateOldConfigFile() {
|
||||
if (this.configDir === path.join(os.homedir(), "Documents", "HugoAura")) {
|
||||
return;
|
||||
}
|
||||
|
||||
const oldConfigPath = path.join(
|
||||
os.homedir(),
|
||||
"Documents",
|
||||
"HugoAura",
|
||||
"config.json"
|
||||
);
|
||||
const oldEncConfigPath = path.join(
|
||||
os.homedir(),
|
||||
"Documents",
|
||||
"HugoAura",
|
||||
".cache_2eafc8d0.dat"
|
||||
);
|
||||
|
||||
if (fs.existsSync(oldConfigPath)) {
|
||||
fs.copyFileSync(oldConfigPath, this.configPath);
|
||||
fs.unlinkSync(oldConfigPath);
|
||||
} else if (fs.existsSync(oldEncConfigPath)) {
|
||||
fs.copyFileSync(oldEncConfigPath, this.encConfigPath);
|
||||
fs.unlinkSync(oldEncConfigPath);
|
||||
this.useEncConfig = true;
|
||||
}
|
||||
|
||||
console.log(
|
||||
`[HugoAura / Config] Moved old config file to ${this.configDir}`
|
||||
);
|
||||
}
|
||||
|
||||
getHugoAuraConfigPath() {
|
||||
return path.dirname(
|
||||
this.useEncConfig ? this.encConfigPath : this.configPath
|
||||
|
||||
@@ -26,23 +26,11 @@
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
"ssa": {
|
||||
"ux": {
|
||||
"easiAssistant": {
|
||||
"autoHide": false,
|
||||
"notDisplay": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"auraSettings": {
|
||||
"settingsPasswordEnabled": false,
|
||||
"settingsPasswordWithSalt": "32703D292460CC9A3B867494D6AD9A8E4A3ADF0FAA4D6867BC4D412CC3927D02E47C6D0B1763BB53E57B2241C6193433561CDA09D7C48CA03983072B876F0965",
|
||||
"encryptConfig": false,
|
||||
"appearance": {
|
||||
"appBar": {
|
||||
"actionBtnsOnRight": false
|
||||
}
|
||||
},
|
||||
"appearance": {},
|
||||
"uiAccessMethod": {
|
||||
"showEntryIcon": true,
|
||||
"fallbackAccessMethods": {
|
||||
|
||||
@@ -6,12 +6,7 @@ const { exec, execSync } = require("child_process");
|
||||
|
||||
const LOG_PREFIX = "[HugoAura / Init / Reg";
|
||||
const LOG_PREFIX_FUNC = "[HugoAura / Reg";
|
||||
const AURA_REGISTRY_PATH = [
|
||||
"HKEY_USERS",
|
||||
".DEFAULT",
|
||||
"SOFTWARE",
|
||||
"HugoAura",
|
||||
].join("\\");
|
||||
const AURA_REGISTRY_PATH = ["HKEY_USERS", ".DEFAULT", "SOFTWARE", "HugoAura"].join("\\");
|
||||
|
||||
class RegistryManager {
|
||||
/**
|
||||
@@ -346,27 +341,19 @@ class RegistryManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} keyPath
|
||||
* @param {string} relativePath
|
||||
* @param {string} keyName
|
||||
* @param {boolean | undefined} silent
|
||||
* @param {boolean} absolute
|
||||
* @param {any} regex
|
||||
* @returns {Promise<{ success: boolean, data: string | null, error: Error | null }>}
|
||||
*/
|
||||
async readRegKey(
|
||||
keyPath,
|
||||
keyName,
|
||||
silent = false,
|
||||
absolute = false,
|
||||
regex = null
|
||||
) {
|
||||
async readRegKey(relativePath, keyName, silent = false) {
|
||||
try {
|
||||
const { stdout } = await new Promise((resolve, reject) => {
|
||||
exec(
|
||||
[
|
||||
"reg",
|
||||
"query",
|
||||
absolute ? keyPath : [AURA_REGISTRY_PATH, keyPath].join("\\"),
|
||||
[AURA_REGISTRY_PATH, relativePath].join("\\"),
|
||||
"/v",
|
||||
`\"${keyName}\"`,
|
||||
].join(" "),
|
||||
@@ -380,12 +367,12 @@ class RegistryManager {
|
||||
|
||||
if (!silent) {
|
||||
console.debug(
|
||||
`${LOG_PREFIX_FUNC} / SUCCESS] Successfully read reg key ${keyPath}/${keyName}, stdout:`,
|
||||
`${LOG_PREFIX_FUNC} / SUCCESS] Successfully read reg key ${relativePath}/${keyName}, stdout:`,
|
||||
stdout
|
||||
);
|
||||
}
|
||||
|
||||
const match = regex ? stdout.match(regex) : stdout.match(/REG_SZ\s+(.+)/);
|
||||
const match = stdout.match(/REG_SZ\s+(.+)/);
|
||||
|
||||
if (!match) {
|
||||
console.warn(`${LOG_PREFIX} / WARN] Data not found in stdout`);
|
||||
@@ -403,7 +390,10 @@ class RegistryManager {
|
||||
error: null,
|
||||
};
|
||||
} catch (e) {
|
||||
console.error(`${LOG_PREFIX} / ERROR] Failed to read reg key, error:`, e);
|
||||
console.error(
|
||||
`${LOG_PREFIX} / ERROR] Failed to read reg key, error:`,
|
||||
e
|
||||
);
|
||||
return {
|
||||
success: false,
|
||||
data: null,
|
||||
@@ -413,26 +403,18 @@ class RegistryManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} keyPath
|
||||
* @param {string} relativePath
|
||||
* @param {string} keyName
|
||||
* @param {boolean | undefined} silent
|
||||
* @param {boolean} absolute
|
||||
* @param {any} regex
|
||||
* @returns {{ success: boolean, data: string | null, error: Error | null }}
|
||||
*/
|
||||
readRegKeySync(
|
||||
keyPath,
|
||||
keyName,
|
||||
silent = false,
|
||||
absolute = false,
|
||||
regex = null
|
||||
) {
|
||||
readRegKeySync(relativePath, keyName, silent = false) {
|
||||
try {
|
||||
const readResult = execSync(
|
||||
[
|
||||
"reg",
|
||||
"query",
|
||||
absolute ? keyPath : [AURA_REGISTRY_PATH, keyPath].join("\\"),
|
||||
[AURA_REGISTRY_PATH, relativePath].join("\\"),
|
||||
"/v",
|
||||
`\"${keyName}\"`,
|
||||
].join(" "),
|
||||
@@ -442,13 +424,11 @@ class RegistryManager {
|
||||
if (readResult) {
|
||||
if (!silent) {
|
||||
console.debug(
|
||||
`${LOG_PREFIX_FUNC} / SUCCESS] Successfully read reg key ${keyPath}/${keyName}, stdout:`,
|
||||
`${LOG_PREFIX_FUNC} / SUCCESS] Successfully read reg key ${relativePath}/${keyName}, stdout:`,
|
||||
readResult
|
||||
);
|
||||
}
|
||||
const match = regex
|
||||
? readResult.match(regex)
|
||||
: readResult.match(/REG_SZ\s+(.+)/);
|
||||
const match = readResult.match(/REG_SZ\s+(.+)/);
|
||||
|
||||
if (!match) {
|
||||
console.warn(`${LOG_PREFIX} / WARN] Data not found in stdout`);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const buildClass = (n) => {
|
||||
// >>> BEGIN OF SEEWO HUGO ORIGINAL CODE <<< //
|
||||
const s = n(239),
|
||||
const s = n(237),
|
||||
o = n(7);
|
||||
class WebSocketManager {
|
||||
constructor(e, t) {
|
||||
|
||||
10
src/aura/jsRewrite/vendor/passwordValidation.js
vendored
10
src/aura/jsRewrite/vendor/passwordValidation.js
vendored
@@ -46,8 +46,8 @@ const newFunction = function (e, t, b) {
|
||||
_ = b(14),
|
||||
M = b(44),
|
||||
g = b(22),
|
||||
w = (b(433), b(7)),
|
||||
D = b(15),
|
||||
w = (b(432), b(7)),
|
||||
D = b(17),
|
||||
T = b.n(D),
|
||||
j = b(10),
|
||||
E = b.n(j),
|
||||
@@ -56,7 +56,7 @@ const newFunction = function (e, t, b) {
|
||||
z = b(19),
|
||||
Y = b(78),
|
||||
L = b.n(Y);
|
||||
b(445);
|
||||
b(444);
|
||||
var x,
|
||||
k = 2,
|
||||
S = 0,
|
||||
@@ -178,7 +178,7 @@ const newFunction = function (e, t, b) {
|
||||
value: s,
|
||||
size: n.width || null,
|
||||
})
|
||||
: v.a.createElement("img", { src: b(448) })
|
||||
: v.a.createElement("img", { src: b(447) })
|
||||
),
|
||||
d !== C &&
|
||||
d !== O &&
|
||||
@@ -386,8 +386,8 @@ const newFunction = function (e, t, b) {
|
||||
} else {
|
||||
originalFunc();
|
||||
}
|
||||
// ### EOR ### //
|
||||
break;
|
||||
// ### EOR ### //
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
16
src/aura/jsRewrite/vendor/screenLock.js
vendored
16
src/aura/jsRewrite/vendor/screenLock.js
vendored
@@ -30,12 +30,12 @@ const newFunction = function (e, t, n) {
|
||||
p = n.n(h),
|
||||
_ = n(41),
|
||||
M = n.n(_),
|
||||
g = (n(814), n(7)),
|
||||
g = (n(808), n(7)),
|
||||
b = n(9),
|
||||
y = n(8),
|
||||
v = n.n(y),
|
||||
w =
|
||||
(n(816),
|
||||
(n(810),
|
||||
{
|
||||
"./numberKeyboard.less": {
|
||||
"ps-icon": "numberKeyboard__ps-icon__1KO_WOCz",
|
||||
@@ -530,7 +530,7 @@ const newFunction = function (e, t, n) {
|
||||
password: "password",
|
||||
},
|
||||
G = n(19);
|
||||
n(818);
|
||||
n(812);
|
||||
function W(e) {
|
||||
var t = e.canvasRender,
|
||||
n = void 0 === t || t,
|
||||
@@ -589,12 +589,12 @@ const newFunction = function (e, t, n) {
|
||||
)
|
||||
);
|
||||
}
|
||||
n(821);
|
||||
n(815);
|
||||
var J = n(64),
|
||||
V = n(20);
|
||||
var q,
|
||||
Z,
|
||||
X = n(17);
|
||||
X = n(16);
|
||||
function K(r) {
|
||||
var a = (function () {
|
||||
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
|
||||
@@ -805,7 +805,7 @@ const newFunction = function (e, t, n) {
|
||||
);
|
||||
})(h.PureComponent))
|
||||
) || Z,
|
||||
oe = (n(823), n(137).a);
|
||||
oe = (n(817), n(137).a);
|
||||
function se(t, e) {
|
||||
var n = Object.keys(t);
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
@@ -913,7 +913,6 @@ const newFunction = function (e, t, n) {
|
||||
});
|
||||
}),
|
||||
(o.checkPasswordCorrect = function () {
|
||||
// ### BOR ### //
|
||||
const originalAuthFailed = () => {
|
||||
o.failCount++,
|
||||
o.passwordCheckFail(),
|
||||
@@ -956,7 +955,6 @@ const newFunction = function (e, t, n) {
|
||||
o.state.inputPassword.join("") === o.password
|
||||
? (o.props.onActivationCorrect(), (o.failCount = 0))
|
||||
: customAuthFailed();
|
||||
// ### EOR ### //
|
||||
}),
|
||||
(o.insertHtml = function () {
|
||||
return p.a.createElement(
|
||||
@@ -1004,7 +1002,7 @@ const newFunction = function (e, t, n) {
|
||||
n
|
||||
);
|
||||
})(I),
|
||||
me = (n(825), n(38));
|
||||
me = (n(819), n(38));
|
||||
function fe(r) {
|
||||
var a = (function () {
|
||||
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
|
||||
|
||||
6
src/aura/types/render/global.d.ts
vendored
6
src/aura/types/render/global.d.ts
vendored
@@ -3,14 +3,14 @@ interface HugoAuraGlobal {
|
||||
}
|
||||
|
||||
interface AssistantHugoAuraGlobal extends HugoAuraGlobal {
|
||||
plsStatus: AikariStatus;
|
||||
plsStatus: PLSStatus;
|
||||
plsRules: Record<any, any>;
|
||||
plsSettings: Record<any, any>;
|
||||
}
|
||||
|
||||
interface AuraWSKeepAliveWindowHugoAuraGlobal extends HugoAuraGlobal {
|
||||
interface DesktopAssistantHugoAuraGlobal extends HugoAuraGlobal {
|
||||
plsWs: WebSocket | null;
|
||||
plsStats: AikariStatus;
|
||||
plsStats: PLSStatus;
|
||||
}
|
||||
|
||||
type UIFunctionsObject = Record<string, any>;
|
||||
|
||||
13
src/aura/types/shared/global.d.ts
vendored
13
src/aura/types/shared/global.d.ts
vendored
@@ -3,7 +3,7 @@ import type EventBus from "../../utils/eventBus";
|
||||
import { HookedWindowsMap, UIHooksMap, WindowHooksMap } from "../main/core";
|
||||
import { UIHooksObject } from "../render/uiHook";
|
||||
import ConfigManager from "../../init/shared/configManager";
|
||||
import { AikariStatus } from "./aikari/status";
|
||||
import { PLSStatus } from "./pls/status";
|
||||
|
||||
type MainProcessOnlyVal<T> = T;
|
||||
type RendererProcessOnlyVal<T> = T;
|
||||
@@ -14,11 +14,10 @@ interface GlobalHugoAuraInfo {
|
||||
fsTasks?: MainProcessOnlyVal<FSTasks>;
|
||||
hookedWindows?: MainProcessOnlyVal<HookedWindowsMap>;
|
||||
ipcInit?: MainProcessOnlyVal<boolean>;
|
||||
auraDir: MainProcessOnlyVal<string>;
|
||||
aikariRules?: Record<any, any> | null;
|
||||
aikariSettings?: Record<any, any> | null;
|
||||
aikariStats?: AikariStatus | null;
|
||||
aikariWs?: RendererProcessOnlyVal<WebSocket>;
|
||||
plsRules?: Record<any, any> | null;
|
||||
plsSettings?: Record<any, any> | null;
|
||||
plsStats?: PLSStatus | null;
|
||||
plsWs?: RendererProcessOnlyVal<WebSocket>;
|
||||
uiHooks?: MainProcessOnlyVal<UIHooksMap>;
|
||||
windowHooks?: MainProcessOnlyVal<WindowHooksMap>;
|
||||
version: RendererProcessOnlyVal<string>;
|
||||
@@ -26,7 +25,7 @@ interface GlobalHugoAuraInfo {
|
||||
|
||||
interface GlobalHugoAuraApiInfo {
|
||||
domains: string[];
|
||||
aikariUpdate: string;
|
||||
plsUpdate: string;
|
||||
auraUpdate: string;
|
||||
}
|
||||
|
||||
|
||||
17
src/aura/types/shared/aikari/status.d.ts → src/aura/types/shared/pls/status.d.ts
vendored
Normal file → Executable file
17
src/aura/types/shared/aikari/status.d.ts → src/aura/types/shared/pls/status.d.ts
vendored
Normal file → Executable file
@@ -1,29 +1,28 @@
|
||||
import { RendererProcessOnlyVal } from "../global";
|
||||
|
||||
type AikariStatusDesc =
|
||||
type PLSStatusDesc =
|
||||
| "dead"
|
||||
| "running"
|
||||
| "notReady"
|
||||
| "downloading"
|
||||
| "installing"
|
||||
| "notInstalled";
|
||||
|
||||
interface AikariStatus {
|
||||
interface PLSStatus {
|
||||
installed: boolean;
|
||||
detached: boolean;
|
||||
connected: boolean;
|
||||
launched: boolean;
|
||||
status: AikariStatusDesc;
|
||||
status: PLSStatusDesc;
|
||||
version: string;
|
||||
authToken: string;
|
||||
}
|
||||
|
||||
type AikariLifecycleType = "isDetached" | "isSvcInstalled" | "isSvcStart";
|
||||
type PLSLifecycleType = "isDetached" | "isSvcInstalled" | "isSvcStart";
|
||||
|
||||
type AikariLifecycleControlType =
|
||||
type PLSLifecycleControlType =
|
||||
| "instSvc"
|
||||
| "uninstSvc"
|
||||
| "rmSvc"
|
||||
| "startSvc"
|
||||
| "stopSvc"
|
||||
| "uninst"
|
||||
| "inst";
|
||||
| "rmBin"
|
||||
| "dlBin";
|
||||
7
src/aura/types/shared/aikari/websocket.d.ts → src/aura/types/shared/pls/websocket.d.ts
vendored
Normal file → Executable file
7
src/aura/types/shared/aikari/websocket.d.ts → src/aura/types/shared/pls/websocket.d.ts
vendored
Normal file → Executable file
@@ -1,18 +1,17 @@
|
||||
interface ClientAikariRequest {
|
||||
interface ClientPLSRequest {
|
||||
method: string;
|
||||
data: Record<any, any>;
|
||||
eventId: string;
|
||||
module: string;
|
||||
}
|
||||
|
||||
interface AikariResponse {
|
||||
interface PLSResponse {
|
||||
success: boolean;
|
||||
code: number;
|
||||
data: Record<any, any>;
|
||||
eventId: string;
|
||||
}
|
||||
|
||||
interface AikariPush {
|
||||
interface PLSPush {
|
||||
success: boolean;
|
||||
type: string;
|
||||
data: Record<any, any>;
|
||||
@@ -1,112 +0,0 @@
|
||||
// @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;
|
||||
}
|
||||
},
|
||||
getAikariPLSRules: async (wsObj) => {
|
||||
const eventId = genRandomHex();
|
||||
wsObj.send(
|
||||
JSON.stringify({
|
||||
module: "pls",
|
||||
eventId,
|
||||
method: "config.rules.getConfig",
|
||||
})
|
||||
);
|
||||
const promise = new Promise((resolve) => {
|
||||
wsGetCallbacks.set(eventId, resolve);
|
||||
});
|
||||
const data = await promise;
|
||||
if (data.success) {
|
||||
console.debug(
|
||||
"[HugoAura / UI / Aikari OCMS] Received Aikari PLS rules: ",
|
||||
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);
|
||||
// Get Aikari Launcher Config
|
||||
const aikariLauncherConfig = await actions.getAikariLauncherConfig(wsObj);
|
||||
if (aikariLauncherConfig) {
|
||||
global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updateAikariSettings`,
|
||||
aikariLauncherConfig
|
||||
);
|
||||
}
|
||||
// Get Aikari PLS Rules
|
||||
const aikariPLSRules = await actions.getAikariPLSRules(wsObj);
|
||||
if (aikariPLSRules) {
|
||||
global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updateAikariRules`,
|
||||
aikariPLSRules
|
||||
);
|
||||
}
|
||||
|
||||
return updatedAikariStates;
|
||||
};
|
||||
|
||||
module.exports = { onAikariConnectedMsgSeq };
|
||||
@@ -1,49 +0,0 @@
|
||||
// @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 };
|
||||
@@ -1,136 +0,0 @@
|
||||
// @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,
|
||||
module = "launcher",
|
||||
writeToDisk = true
|
||||
) => {
|
||||
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.actions.updateConfig",
|
||||
data: {
|
||||
key: configKey,
|
||||
value: configValue,
|
||||
write: writeToDisk,
|
||||
},
|
||||
eventId: genRandomHex(), // 不用 crypto, 因为会带来不必要的性能开销
|
||||
module: module,
|
||||
};
|
||||
|
||||
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,
|
||||
});
|
||||
};
|
||||
|
||||
// [!] Will be deprecated
|
||||
const updateAikariPLSRulesToRemote = async (
|
||||
configKey,
|
||||
configValue,
|
||||
affiliated,
|
||||
writeToDisk = true
|
||||
) => {
|
||||
const configLevels = configKey.split(".");
|
||||
|
||||
const aikariRuleConfigUpdateEvent = new CustomEvent("onAikariConfigUpdate", {
|
||||
detail: {
|
||||
path: configLevels,
|
||||
value: configValue,
|
||||
},
|
||||
});
|
||||
document.dispatchEvent(aikariRuleConfigUpdateEvent);
|
||||
const settingsEntries = document.getElementsByClassName(
|
||||
"aura-settings-entry"
|
||||
);
|
||||
if (settingsEntries.length > 0) {
|
||||
Array.from(settingsEntries).forEach((entry) => {
|
||||
entry.dispatchEvent(aikariRuleConfigUpdateEvent);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {ClientAikariRequest}
|
||||
*/
|
||||
const data = {
|
||||
method: "config.rules.updateConfig",
|
||||
data: {
|
||||
key: configKey,
|
||||
value: configValue,
|
||||
write: writeToDisk,
|
||||
affiliated,
|
||||
},
|
||||
eventId: genRandomHex(),
|
||||
module: "pls",
|
||||
};
|
||||
|
||||
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,
|
||||
updateAikariPLSRulesToRemote,
|
||||
};
|
||||
81
src/aura/ui/composables/plsConfigManager.js
Executable file
81
src/aura/ui/composables/plsConfigManager.js
Executable file
@@ -0,0 +1,81 @@
|
||||
// @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,
|
||||
};
|
||||
@@ -1,28 +0,0 @@
|
||||
const childProc = require("child_process");
|
||||
|
||||
const fileSystemRawCmds = {
|
||||
getDiskCaptions: async () => {
|
||||
const waitForCmd = new Promise((resolve) => {
|
||||
childProc.exec("fsutil fsinfo drives", (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.error(
|
||||
`[HugoAura / UI / Composables / Raw CMD / FS] Failed to exec fsutil getCaption: ${error}`
|
||||
);
|
||||
resolve([]);
|
||||
}
|
||||
const finResult = [];
|
||||
stdout
|
||||
.trim()
|
||||
.split(": ")[1]
|
||||
.split(":\\")
|
||||
.forEach((line) => {
|
||||
if (line !== "") finResult.push(line.trim() + ":");
|
||||
});
|
||||
resolve(finResult);
|
||||
});
|
||||
});
|
||||
return waitForCmd;
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = fileSystemRawCmds;
|
||||
@@ -18,12 +18,12 @@ const showRelaunchToast = () => {
|
||||
if (!toastBs.isShown()) toastBs.show();
|
||||
};
|
||||
|
||||
const showRelaunchAikariToast = () => {
|
||||
const toast = document.getElementById("relaunchAikariNotifyToast");
|
||||
const showRelaunchPLSToast = () => {
|
||||
const toast = document.getElementById("relaunchPlsNotifyToast");
|
||||
const toastBs = bootstrap.Toast.getOrCreateInstance(toast);
|
||||
|
||||
if (global.__HUGO_AURA__.aikariStats.detached) {
|
||||
const relaunchBtn = document.getElementById("aikariRelaunchBtn");
|
||||
if (global.__HUGO_AURA__.plsStats.detached) {
|
||||
const relaunchBtn = document.getElementById("plsRelaunchBtn");
|
||||
relaunchBtn.disabled = true;
|
||||
relaunchBtn.textContent = "分离模式下无法执行";
|
||||
}
|
||||
@@ -37,6 +37,12 @@ const showToast = (entry) => {
|
||||
} else if (entry.restart) {
|
||||
showRelaunchToast();
|
||||
}
|
||||
|
||||
/*
|
||||
else if (entry.restartPLS) {
|
||||
showRelaunchPLSToast();
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
const setDisableStatus = (el, isDisable, hint = null) => {
|
||||
@@ -50,9 +56,9 @@ const setDisableStatus = (el, isDisable, hint = null) => {
|
||||
tooltipIns.enable();
|
||||
}
|
||||
} else {
|
||||
el.removeAttribute("data-bs-toggle");
|
||||
el.removeAttribute("data-bs-placement");
|
||||
el.removeAttribute("data-bs-title");
|
||||
el.setAttribute("data-bs-toggle", "tooltip");
|
||||
el.setAttribute("data-bs-placement", "top");
|
||||
el.setAttribute("data-bs-title", "None");
|
||||
el.classList.remove("ase-operation-area-disabled");
|
||||
const tooltipIns = bootstrap.Tooltip.getInstance(el);
|
||||
if (tooltipIns) {
|
||||
@@ -100,18 +106,7 @@ const renderInputArea = (entry, operationArea, descriptionArea) => {
|
||||
case "radio": {
|
||||
const elValue = entry.valueGetter();
|
||||
const elArr = [];
|
||||
let targetTemplatesArr = [];
|
||||
let targetTemplateLablesArr = [];
|
||||
targetTemplatesArr =
|
||||
typeof entry.templates === "function"
|
||||
? entry.templates()
|
||||
: entry.templates;
|
||||
targetTemplateLablesArr =
|
||||
typeof entry.templateLabels === "function"
|
||||
? entry.templateLabels()
|
||||
: entry.templateLabels;
|
||||
|
||||
for (const template of targetTemplatesArr) {
|
||||
for (const template of entry.templates) {
|
||||
const inlineContainerEl = document.createElement("div");
|
||||
inlineContainerEl.classList.add("form-check", "form-check-inline");
|
||||
const radioEl = document.createElement("input");
|
||||
@@ -119,7 +114,7 @@ const renderInputArea = (entry, operationArea, descriptionArea) => {
|
||||
radioEl.classList.add("form-check-input");
|
||||
radioEl.type = "radio";
|
||||
radioEl.name = `${entry.id}Radios`;
|
||||
radioEl.id = `${entry.id}Radio${targetTemplatesArr.indexOf(template)}`;
|
||||
radioEl.id = `${entry.id}Radio${entry.templates.indexOf(template)}`;
|
||||
radioEl.checked = template === elValue ? true : false;
|
||||
radioEl.addEventListener("change", async (event) => {
|
||||
if (event.target.checked) {
|
||||
@@ -137,53 +132,7 @@ const renderInputArea = (entry, operationArea, descriptionArea) => {
|
||||
labelEl.classList.add("form-check-label");
|
||||
labelEl.setAttribute("for", radioEl.id);
|
||||
labelEl.textContent =
|
||||
targetTemplateLablesArr[targetTemplatesArr.indexOf(template)];
|
||||
inlineContainerEl.appendChild(labelEl);
|
||||
elArr.push(inlineContainerEl);
|
||||
}
|
||||
return elArr;
|
||||
}
|
||||
case "checkbox": {
|
||||
const elValue = entry.valueGetter();
|
||||
const elArr = [];
|
||||
let targetTemplatesArr = [];
|
||||
let targetTemplateLablesArr = [];
|
||||
targetTemplatesArr =
|
||||
typeof entry.templates === "function"
|
||||
? entry.templates()
|
||||
: entry.templates;
|
||||
targetTemplateLablesArr =
|
||||
typeof entry.templateLabels === "function"
|
||||
? entry.templateLabels()
|
||||
: entry.templateLabels;
|
||||
|
||||
for (const templateName of targetTemplatesArr) {
|
||||
const inlineContainerEl = document.createElement("div");
|
||||
inlineContainerEl.classList.add("form-check", "form-check-inline");
|
||||
const chkBoxEl = document.createElement("input");
|
||||
chkBoxEl.value = templateName;
|
||||
chkBoxEl.classList.add("form-check-input");
|
||||
chkBoxEl.type = "checkbox";
|
||||
chkBoxEl.name = `${entry.id}Checkbox`;
|
||||
chkBoxEl.id = `${entry.id}Checkbox${targetTemplatesArr.indexOf(
|
||||
templateName
|
||||
)}`;
|
||||
chkBoxEl.checked = elValue.includes(templateName) ? true : false;
|
||||
chkBoxEl.addEventListener("change", async (event) => {
|
||||
showToast(entry);
|
||||
await entry.callbackFn(
|
||||
event.target.value,
|
||||
chkBoxEl,
|
||||
operationArea,
|
||||
descriptionArea
|
||||
);
|
||||
});
|
||||
inlineContainerEl.appendChild(chkBoxEl);
|
||||
const labelEl = document.createElement("label");
|
||||
labelEl.classList.add("form-check-label");
|
||||
labelEl.setAttribute("for", chkBoxEl.id);
|
||||
labelEl.textContent =
|
||||
targetTemplateLablesArr[targetTemplatesArr.indexOf(templateName)];
|
||||
entry.templateLabels[entry.templates.indexOf(template)];
|
||||
inlineContainerEl.appendChild(labelEl);
|
||||
elArr.push(inlineContainerEl);
|
||||
}
|
||||
@@ -196,10 +145,9 @@ const renderInputArea = (entry, operationArea, descriptionArea) => {
|
||||
inputEl.value = entry.valueGetter();
|
||||
inputEl.placeholder = entry.placeHolder;
|
||||
inputEl.id = entry.id;
|
||||
|
||||
const handleSubmit = async (event = null) => {
|
||||
inputEl.addEventListener("change", async (event) => {
|
||||
const result = await entry.callbackFn(
|
||||
event ? event.target.value : inputEl.value,
|
||||
event.target.value,
|
||||
inputEl,
|
||||
operationArea,
|
||||
descriptionArea
|
||||
@@ -218,37 +166,10 @@ const renderInputArea = (entry, operationArea, descriptionArea) => {
|
||||
descriptionArea.textContent = result.hint;
|
||||
descriptionArea.classList.add("ase-desc-error-hint");
|
||||
}
|
||||
};
|
||||
|
||||
inputEl.addEventListener("change", async (event) => {
|
||||
await handleSubmit(event);
|
||||
});
|
||||
|
||||
inputEl.onsubmit = async (evt) => {
|
||||
evt.preventDefault();
|
||||
await handleSubmit();
|
||||
};
|
||||
|
||||
operationArea.classList.add("ase-operation-area-expanded");
|
||||
return inputEl;
|
||||
}
|
||||
case "button": {
|
||||
const btnEl = document.createElement("button");
|
||||
btnEl.type = "button";
|
||||
btnEl.classList.add("btn");
|
||||
switch (entry.style) {
|
||||
case "outline":
|
||||
default:
|
||||
btnEl.classList.add("btn-outline-primary");
|
||||
break;
|
||||
}
|
||||
btnEl.innerHTML = entry.buttonContent;
|
||||
btnEl.onclick = entry.callbackFn;
|
||||
(async () => {
|
||||
descriptionArea.innerHTML = await entry.valueGetter();
|
||||
})();
|
||||
return btnEl;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -276,29 +197,29 @@ const renderNormalSettingsItem = (entry, formEl) => {
|
||||
powerIcon.setAttribute("data-bs-title", "需要重启 Electron 进程");
|
||||
entryTitle.appendChild(powerIcon);
|
||||
}
|
||||
if (entry.aikariRequired) {
|
||||
const aikariIcon = document.createElement("i");
|
||||
aikariIcon.classList.add(
|
||||
if (entry.PLSRequired) {
|
||||
const plsIcon = document.createElement("i");
|
||||
plsIcon.classList.add(
|
||||
"layui-icon",
|
||||
"layui-icon-component",
|
||||
"aura-settings-entry-property-icon"
|
||||
);
|
||||
aikariIcon.setAttribute("data-bs-toggle", "tooltip");
|
||||
aikariIcon.setAttribute("data-bs-placement", "top");
|
||||
aikariIcon.setAttribute("data-bs-title", "需要 Aikari 支持");
|
||||
entryTitle.appendChild(aikariIcon);
|
||||
plsIcon.setAttribute("data-bs-toggle", "tooltip");
|
||||
plsIcon.setAttribute("data-bs-placement", "top");
|
||||
plsIcon.setAttribute("data-bs-title", "需要 PLS 支持");
|
||||
entryTitle.appendChild(plsIcon);
|
||||
}
|
||||
if (entry.restartAikari) {
|
||||
const aikariIcon = document.createElement("i");
|
||||
aikariIcon.classList.add(
|
||||
if (entry.restartPLS) {
|
||||
const plsIcon = document.createElement("i");
|
||||
plsIcon.classList.add(
|
||||
"layui-icon",
|
||||
"layui-icon-logout",
|
||||
"aura-settings-entry-property-icon"
|
||||
);
|
||||
aikariIcon.setAttribute("data-bs-toggle", "tooltip");
|
||||
aikariIcon.setAttribute("data-bs-placement", "top");
|
||||
aikariIcon.setAttribute("data-bs-title", "需要重启 Aikari 进程");
|
||||
entryTitle.appendChild(aikariIcon);
|
||||
plsIcon.setAttribute("data-bs-toggle", "tooltip");
|
||||
plsIcon.setAttribute("data-bs-placement", "top");
|
||||
plsIcon.setAttribute("data-bs-title", "需要重启 PLS 进程");
|
||||
entryTitle.appendChild(plsIcon);
|
||||
}
|
||||
if (entry.reload) {
|
||||
const reloadIcon = document.createElement("i");
|
||||
@@ -359,14 +280,33 @@ const renderNormalSettingsItem = (entry, formEl) => {
|
||||
insertOrRemoveEl(entryOperationArea, targetEl, true);
|
||||
}
|
||||
};
|
||||
const channel = entry.aikariRequired
|
||||
? "onAikariConfigUpdate"
|
||||
const channel = entry.PLSRequired
|
||||
? "onPLSConfigUpdate"
|
||||
: "onHugoAuraConfigUpdate";
|
||||
entryContainerEl.addEventListener(channel, evtListener);
|
||||
// createOnLeaveEvtListener(channel, evtListener);
|
||||
}
|
||||
|
||||
const updateDisableStatus = (entry) => {
|
||||
if (entry.PLSRequired) {
|
||||
if (!global.__HUGO_AURA__.plsStats.connected) {
|
||||
setDisableStatus(entryOperationArea, true, "连接至 PLS 以继续");
|
||||
}
|
||||
|
||||
const evtListener = (event) => {
|
||||
if (event.detail.connected) {
|
||||
setDisableStatus(entryOperationArea, false);
|
||||
} else {
|
||||
setDisableStatus(entryOperationArea, true, "连接至 PLS 以继续");
|
||||
}
|
||||
};
|
||||
entryContainerEl.addEventListener("onPLSStatsUpdate", evtListener);
|
||||
// createOnLeaveEvtListener("onPLSStatsUpdate", evtListener);
|
||||
}
|
||||
entryContainerEl.appendChild(entryOperationArea);
|
||||
const isShow = entry.auraIf();
|
||||
if (!isShow) entryContainerEl.classList.add("aura-settings-entry-hidden");
|
||||
|
||||
const updateDisableStatus = () => {
|
||||
const isDisabledRet = entry.auraDisable();
|
||||
setDisableStatus(
|
||||
entryOperationArea,
|
||||
@@ -376,32 +316,9 @@ const renderNormalSettingsItem = (entry, formEl) => {
|
||||
};
|
||||
|
||||
if (entry.auraDisable) {
|
||||
updateDisableStatus(entry);
|
||||
updateDisableStatus();
|
||||
}
|
||||
|
||||
if (entry.aikariRequired) {
|
||||
if (!global.__HUGO_AURA__.aikariStats.connected) {
|
||||
setDisableStatus(entryOperationArea, true, "连接至 Aikari 以继续");
|
||||
}
|
||||
|
||||
const evtListener = (event) => {
|
||||
if (event.detail.connected) {
|
||||
try {
|
||||
updateDisableStatus(entry);
|
||||
} catch {
|
||||
setDisableStatus(entryOperationArea, false);
|
||||
}
|
||||
} else {
|
||||
setDisableStatus(entryOperationArea, true, "连接至 Aikari 以继续");
|
||||
}
|
||||
};
|
||||
entryContainerEl.addEventListener("onAikariStatsUpdate", evtListener);
|
||||
// createOnLeaveEvtListener("onAikariStatsUpdate", evtListener);
|
||||
}
|
||||
entryContainerEl.appendChild(entryOperationArea);
|
||||
const isShow = entry.auraIf();
|
||||
if (!isShow) entryContainerEl.classList.add("aura-settings-entry-hidden");
|
||||
|
||||
if (entry.associateVal) {
|
||||
const evtListener = (event) => {
|
||||
if (!entry.associateVal.includes(event.detail.path.join("."))) return;
|
||||
@@ -412,11 +329,11 @@ const renderNormalSettingsItem = (entry, formEl) => {
|
||||
: cls.add("aura-settings-entry-hidden");
|
||||
|
||||
if (entry.auraDisable) {
|
||||
updateDisableStatus(entry);
|
||||
updateDisableStatus();
|
||||
}
|
||||
};
|
||||
const channel = entry.aikariRequired
|
||||
? "onAikariConfigUpdate"
|
||||
const channel = entry.PLSRequired
|
||||
? "onPLSConfigUpdate"
|
||||
: "onHugoAuraConfigUpdate";
|
||||
entryContainerEl.addEventListener(channel, evtListener);
|
||||
// createOnLeaveEvtListener(channel, evtListener);
|
||||
@@ -458,9 +375,7 @@ const renderPreviewItem = (entry, formEl) => {
|
||||
};
|
||||
|
||||
document.addEventListener(
|
||||
eventChannel === "aikari"
|
||||
? "onAikariConfigUpdate"
|
||||
: "onHugoAuraConfigUpdate",
|
||||
eventChannel === "pls" ? "onPLSConfigUpdate" : "onHugoAuraConfigUpdate",
|
||||
eventListener
|
||||
);
|
||||
createOnLeaveEvtListener(eventListener); // Clean up
|
||||
|
||||
@@ -41,13 +41,13 @@ const def = {
|
||||
selectorMode: "appendChild",
|
||||
pageCSS: "ui/pages/configSubPages/behaviourCtrl/behaviourCtrl.css",
|
||||
childs: {
|
||||
AikariStatus: {
|
||||
PlsStatus: {
|
||||
active: false,
|
||||
pageURI: "ui/pages/configSubPages/behaviourCtrl/aikariStatus.html",
|
||||
pageScript: "ui/pages/configSubPages/behaviourCtrl/aikariStatus.js",
|
||||
pageURI: "ui/pages/configSubPages/behaviourCtrl/plsStatus.html",
|
||||
pageScript: "ui/pages/configSubPages/behaviourCtrl/plsStatus.js",
|
||||
pageSelector: "#status-subpage",
|
||||
selectorMode: "appendChild",
|
||||
pageCSS: "ui/pages/configSubPages/behaviourCtrl/aikariStatus.css",
|
||||
pageCSS: "ui/pages/configSubPages/behaviourCtrl/plsStatus.css",
|
||||
},
|
||||
DeviceSecurity: {
|
||||
childs: {
|
||||
@@ -86,7 +86,7 @@ const def = {
|
||||
],
|
||||
globalJS: [
|
||||
"ui/js/global.js",
|
||||
"ui/js/aikariListener.js",
|
||||
"ui/js/plsListener.js",
|
||||
"ui/bootstrap/bootstrap.bundle.min.js",
|
||||
],
|
||||
onLoaded: `
|
||||
|
||||
2
src/aura/ui/hookDefinitions/desktopAssistant.js
Normal file → Executable file
2
src/aura/ui/hookDefinitions/desktopAssistant.js
Normal file → Executable file
@@ -6,7 +6,7 @@
|
||||
const def = {
|
||||
targets: {},
|
||||
globalStyles: ["ui/css/global.css"],
|
||||
globalJS: ["ui/js/global.js", "ui/js/pageGlobal/desktopAssistant.js"],
|
||||
globalJS: ["ui/js/global.js", "ui/js/plsConnectionManager.js"],
|
||||
onLoaded: `
|
||||
console.log('[HugoAura / UI / Hooks / Desktop Assistant] Page loaded.');
|
||||
`,
|
||||
|
||||
@@ -1,372 +0,0 @@
|
||||
// @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);
|
||||
})();
|
||||
@@ -6,11 +6,9 @@
|
||||
let tooltipTriggerCache = null;
|
||||
const refreshBsTooltip = (selector = '[data-bs-toggle="tooltip"]') => {
|
||||
if (tooltipTriggerCache) {
|
||||
[...tooltipTriggerCache].map((el) => {
|
||||
if (bootstrap.Tooltip.getInstance(el)) {
|
||||
bootstrap.Tooltip.getInstance(el).disable();
|
||||
}
|
||||
});
|
||||
[...tooltipTriggerCache].map((el) =>
|
||||
bootstrap.Tooltip.getInstance(el).disable()
|
||||
);
|
||||
}
|
||||
|
||||
const tooltipTriggerList = document.querySelectorAll(selector);
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
(() => {
|
||||
const applyHideSettings = () => {
|
||||
if (global.__HUGO_AURA_CONFIG__.ssa.ux.easiAssistant.autoHide) {
|
||||
const minimizeBtnEl = document.getElementsByClassName(
|
||||
"index__button2__2mhwC3oY"
|
||||
)[0].children[0];
|
||||
// @ts-expect-error
|
||||
minimizeBtnEl.click();
|
||||
} else if (global.__HUGO_AURA_CONFIG__.ssa.ux.easiAssistant.notDisplay) {
|
||||
const rootEl = document.getElementById("root");
|
||||
// @ts-expect-error
|
||||
rootEl.style["display"] = "none";
|
||||
}
|
||||
};
|
||||
|
||||
const onMounted = () => {
|
||||
applyHideSettings();
|
||||
};
|
||||
|
||||
onMounted();
|
||||
})();
|
||||
334
src/aura/ui/js/plsConnectionManager.js
Executable file
334
src/aura/ui/js/plsConnectionManager.js
Executable file
@@ -0,0 +1,334 @@
|
||||
// @ts-check
|
||||
(() => {
|
||||
if (!global.__HUGO_AURA__.plsStats)
|
||||
global.__HUGO_AURA__.plsStats = {
|
||||
installed: false,
|
||||
detached: false,
|
||||
connected: false,
|
||||
launched: false,
|
||||
status: "dead",
|
||||
version: "未知",
|
||||
authToken: "",
|
||||
};
|
||||
|
||||
const IPC_METHOD_BASE = "$aura.pls";
|
||||
const REQUIRE_BASE = "../../aura/ui";
|
||||
const __SCOPE = "desktopAssistant";
|
||||
|
||||
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 trustToken = window._ACCEPT_DATA.getData("deviceId");
|
||||
const conjToken = authToken + "AuraXAuth" + trustToken + "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;
|
||||
}
|
||||
}
|
||||
|
||||
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: "未知",
|
||||
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").global.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();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
setTimeout(() => {
|
||||
onSetup();
|
||||
}, 1500);
|
||||
})();
|
||||
28
src/aura/ui/js/aikariListener.js → src/aura/ui/js/plsListener.js
Normal file → Executable file
28
src/aura/ui/js/aikariListener.js → src/aura/ui/js/plsListener.js
Normal file → Executable file
@@ -1,21 +1,21 @@
|
||||
(() => {
|
||||
const IPC_METHOD_BASE = "$aura.aikari";
|
||||
const IPC_METHOD_BASE = "$aura.pls";
|
||||
const REQUIRE_BASE = "../../aura/ui";
|
||||
const __SCOPE = "assistant";
|
||||
const {
|
||||
updateAikariStatusFromLocal,
|
||||
} = require(`${REQUIRE_BASE}/composables/aikariConfigManager`);
|
||||
updatePlsStatusFromLocal,
|
||||
} = require(`${REQUIRE_BASE}/composables/plsConfigManager`);
|
||||
|
||||
const setupListeners = () => {
|
||||
if (!global.ipcRenderer)
|
||||
global.ipcRenderer = require("electron").ipcRenderer;
|
||||
|
||||
ipcRenderer.on(
|
||||
`${IPC_METHOD_BASE}.post.onAikariStatsUpdate`,
|
||||
`${IPC_METHOD_BASE}.post.onPlsStatsUpdate`,
|
||||
(_event, arg) => {
|
||||
global.__HUGO_AURA__.aikariStats = arg;
|
||||
global.__HUGO_AURA__.plsStats = arg;
|
||||
|
||||
const event = new CustomEvent("onAikariStatsUpdate", {
|
||||
const event = new CustomEvent("onPLSStatsUpdate", {
|
||||
detail: {
|
||||
connected: arg.connected,
|
||||
},
|
||||
@@ -35,11 +35,11 @@
|
||||
);
|
||||
|
||||
ipcRenderer.on(
|
||||
`${IPC_METHOD_BASE}.post.onAikariSettingsUpdate`,
|
||||
`${IPC_METHOD_BASE}.post.onPlsSettingsUpdate`,
|
||||
(_event, arg) => {
|
||||
global.__HUGO_AURA__.aikariSettings = arg;
|
||||
global.__HUGO_AURA__.plsSettings = arg;
|
||||
|
||||
const event = new CustomEvent("onAikariConfigUpdate", {
|
||||
const event = new CustomEvent("onPLSConfigUpdate", {
|
||||
detail: {
|
||||
path: ["root", "settings"],
|
||||
value: arg,
|
||||
@@ -60,11 +60,11 @@
|
||||
);
|
||||
|
||||
ipcRenderer.on(
|
||||
`${IPC_METHOD_BASE}.post.onAikariRulesUpdate`,
|
||||
`${IPC_METHOD_BASE}.post.onPlsRulesUpdate`,
|
||||
(_event, arg) => {
|
||||
global.__HUGO_AURA__.aikariRules = arg;
|
||||
global.__HUGO_AURA__.plsRules = arg;
|
||||
|
||||
const event = new CustomEvent("onAikariConfigUpdate", {
|
||||
const event = new CustomEvent("onPLSConfigUpdate", {
|
||||
detail: {
|
||||
path: ["root", "ruleSettings"],
|
||||
value: arg,
|
||||
@@ -87,7 +87,7 @@
|
||||
ipcRenderer.on(
|
||||
`${IPC_METHOD_BASE}.post.updateRetryStatus`,
|
||||
(_event, arg) => {
|
||||
const event = new CustomEvent("onAikariStatsUpdate", {
|
||||
const event = new CustomEvent("onPLSStatsUpdate", {
|
||||
detail: {
|
||||
connected: arg.success,
|
||||
},
|
||||
@@ -107,6 +107,6 @@
|
||||
);
|
||||
};
|
||||
|
||||
updateAikariStatusFromLocal();
|
||||
updatePlsStatusFromLocal();
|
||||
setupListeners();
|
||||
})();
|
||||
@@ -13,27 +13,18 @@
|
||||
<!-- Chevron Left Icon -->
|
||||
</div>
|
||||
<p>雨光之环</p>
|
||||
<div
|
||||
class="aura-config-page-app-bar-hr-vertical"
|
||||
id="auraConfigPageAppBarVerticalHr"
|
||||
></div>
|
||||
<div class="aura-config-page-app-bar-spacer space-none"></div>
|
||||
<div class="aura-config-page-app-bar-hr-vertical"></div>
|
||||
<div
|
||||
onclick="global.__HUGO_AURA_UI_FUNCTIONS__.config.handleNavHome()"
|
||||
style="
|
||||
-webkit-app-region: no-drag;
|
||||
z-index: 2000;
|
||||
margin-left: 6px;
|
||||
margin-right: 0.5rem;
|
||||
"
|
||||
style="-webkit-app-region: no-drag; z-index: 2000; margin-left: 6px"
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="22"
|
||||
height="22"
|
||||
width="21"
|
||||
height="21"
|
||||
viewBox="0 0 24 24"
|
||||
class="iconfont"
|
||||
style="margin-top: -1.35px"
|
||||
style="margin-top: -1.5px"
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
@@ -145,8 +136,8 @@
|
||||
<div class="aura-config-page-operation-body">
|
||||
<img src="../../aura/ui/static/config/no_limitations.svg" />
|
||||
<div>
|
||||
<p class="config-operation-title">行为改写</p>
|
||||
<p class="config-operation-description">覆写密码、禁用能力</p>
|
||||
<p class="config-operation-title">限制解除</p>
|
||||
<p class="config-operation-description">禁用密码、关闭功能</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -158,7 +149,7 @@
|
||||
<div class="aura-config-page-operation-body">
|
||||
<img src="../../aura/ui/static/config/behaviour_mon.svg" />
|
||||
<div>
|
||||
<p class="config-operation-title">操作管控</p>
|
||||
<p class="config-operation-title">行为管控</p>
|
||||
<p class="config-operation-description">窥屏提醒、数据欺骗</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -293,14 +284,14 @@
|
||||
|
||||
<div class="toast-container position-fixed bottom-0 end-0 p-3">
|
||||
<div
|
||||
id="relaunchAikariNotifyToast"
|
||||
id="relaunchPlsNotifyToast"
|
||||
class="toast acp-toast-emerg"
|
||||
aria-atomic="true"
|
||||
data-bs-autohide="false"
|
||||
>
|
||||
<div class="toast-header">
|
||||
<i class="layui-icon layui-icon-tips"></i>
|
||||
<strong class="me-auto">重启 Aikari 进程以应用设置</strong>
|
||||
<strong class="me-auto">重启 PLS 进程以应用设置</strong>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-close"
|
||||
@@ -308,13 +299,13 @@
|
||||
></button>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
<p>请重启 Aikari 进程以应用修改的设置</p>
|
||||
<p>请重启 PLS 进程以应用修改的设置</p>
|
||||
<p>已修改的配置将自动保存</p>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary btn-sm"
|
||||
id="aikariRelaunchBtn"
|
||||
onclick="ipcRenderer.invoke('$aura.aikari.relaunchPls')"
|
||||
id="plsRelaunchBtn"
|
||||
onclick="ipcRenderer.invoke('$aura.pls.relaunchPls')"
|
||||
>
|
||||
重启进程
|
||||
</button>
|
||||
|
||||
@@ -106,7 +106,7 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
||||
if (!side) {
|
||||
setTimeout(() => {
|
||||
global.__HUGO_AURA_LOADER__[
|
||||
"Aura.UI.Assistant.Config.BehaviourCtrl.AikariStatus"
|
||||
"Aura.UI.Assistant.Config.BehaviourCtrl.PlsStatus"
|
||||
].active = false;
|
||||
}, 500);
|
||||
}
|
||||
@@ -235,11 +235,6 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
||||
inputEl.value = "";
|
||||
inputEl.classList.remove("invalid");
|
||||
inputEl.classList.remove("is-invalid");
|
||||
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.config.resetAuthDialogInputElOnSubmit(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.config.verifyAuthPassword
|
||||
);
|
||||
|
||||
acpDialogConfirmBtnEl.onclick = (_evt) => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.config.verifyAuthPassword();
|
||||
};
|
||||
@@ -248,16 +243,6 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
||||
};
|
||||
},
|
||||
|
||||
resetAuthDialogInputElOnSubmit: (func) => {
|
||||
const inputEl = document.getElementById("acp-auth-user-input");
|
||||
inputEl.onsubmit = (evt) => evt.preventDefault();
|
||||
inputEl.onkeydown = (event) => {
|
||||
if (event.key === "Enter") {
|
||||
func();
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
handleACSNShow: async () => {
|
||||
const acsnRootEl = document.getElementsByClassName(
|
||||
"acp-config-status-notify"
|
||||
@@ -309,27 +294,6 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
||||
// TODO: Error handling
|
||||
}
|
||||
},
|
||||
|
||||
initCustomUIProps: async (refresh = false) => {
|
||||
const verticalHrEl = document.getElementById(
|
||||
"auraConfigPageAppBarVerticalHr"
|
||||
);
|
||||
const spacerElArr = document.getElementsByClassName(
|
||||
"aura-config-page-app-bar-spacer"
|
||||
);
|
||||
if (
|
||||
global.__HUGO_AURA_CONFIG__.auraSettings.appearance.appBar
|
||||
.actionBtnsOnRight
|
||||
) {
|
||||
verticalHrEl.classList.add("hidden");
|
||||
spacerElArr[0].classList.remove("space-none");
|
||||
spacerElArr[1].classList.add("space-none");
|
||||
} else if (refresh) {
|
||||
verticalHrEl.classList.remove("hidden");
|
||||
spacerElArr[0].classList.add("space-none");
|
||||
spacerElArr[1].classList.remove("space-none");
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
(() => {
|
||||
@@ -374,8 +338,7 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
||||
let timeout = 0;
|
||||
Array.from(operationElArr).forEach((el) => {
|
||||
setTimeout(() => {
|
||||
el.classList.remove("operation-el-hidden");
|
||||
el.classList.add("operation-el-show");
|
||||
el.className = "operation-el-show aura-config-page-operation-el";
|
||||
}, timeout);
|
||||
timeout += 150;
|
||||
});
|
||||
@@ -401,9 +364,6 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
||||
"aura-config-page-header-area"
|
||||
)[0];
|
||||
acsDialogAreaEl.style = "";
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.config.resetAuthDialogInputElOnSubmit(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.config.verifyAuthPassword
|
||||
);
|
||||
await window.__HUGO_AURA_GLOBAL__.utils.sleep(500);
|
||||
acsDialogAreaEl.classList.remove("acp-ada-hidden");
|
||||
acpAppBarEl.classList.add("color-reverse");
|
||||
@@ -431,7 +391,6 @@ global.__HUGO_AURA_UI_FUNCTIONS__.config = {
|
||||
};
|
||||
|
||||
const onMounted = () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.config.initCustomUIProps();
|
||||
applyVersionInfo();
|
||||
|
||||
showAnimation();
|
||||
|
||||
@@ -58,10 +58,6 @@
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.aura-config-page-app-bar-spacer.space-none {
|
||||
flex-grow: 0;
|
||||
}
|
||||
|
||||
.aura-config-page-app-bar-hr-vertical {
|
||||
position: relative;
|
||||
margin-left: 8px;
|
||||
@@ -70,7 +66,3 @@
|
||||
height: 12px;
|
||||
transition: background 0.5s;
|
||||
}
|
||||
|
||||
.aura-config-page-app-bar-hr-vertical.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -36,13 +36,13 @@
|
||||
class="nav-link"
|
||||
id="security-config-tab"
|
||||
data-bs-toggle="pill"
|
||||
data-bs-target="#device-info-post-config-subpage"
|
||||
data-bs-target="#security-config-subpage"
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-controls="device-info-post-config-subpage"
|
||||
aria-controls="security-config-subpage"
|
||||
aria-selected="false"
|
||||
>
|
||||
信息上报
|
||||
设备安全
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -61,7 +61,7 @@
|
||||
></div>
|
||||
<div
|
||||
class="tab-pane fade"
|
||||
id="device-info-post-config-subpage"
|
||||
id="security-config-subpage"
|
||||
role="tabpanel"
|
||||
aria-labelledby="security-config-tab"
|
||||
></div>
|
||||
|
||||
@@ -7,58 +7,45 @@
|
||||
} = require(`${REQUIRE_BASE}/../../../../composables/settingsRenderer`);
|
||||
|
||||
const { basicSettings } = require(`${REQUIRE_BASE}/basic`);
|
||||
const { deviceInfoPostSettings } = require(`${REQUIRE_BASE}/deviceInfoPost`);
|
||||
const { deviceSecuritySettings } = require(`${REQUIRE_BASE}/deviceSecurity`);
|
||||
|
||||
const {
|
||||
updateAikariSettingsFromLocal,
|
||||
updateAikariRulesFromLocal,
|
||||
} = require(`${REQUIRE_BASE}/../../../../composables/aikariConfigManager`);
|
||||
|
||||
const fileSystemRawCmds = require(`${REQUIRE_BASE}/../../../../composables/rawCmdExec/fs`);
|
||||
updatePlsSettingsFromLocal,
|
||||
updatePlsRulesFromLocal,
|
||||
} = require(`${REQUIRE_BASE}/../../../../composables/plsConfigManager`);
|
||||
|
||||
const initStatusPage = () => {
|
||||
global.__HUGO_AURA_LOADER__[
|
||||
"Aura.UI.Assistant.Config.BehaviourCtrl.AikariStatus"
|
||||
"Aura.UI.Assistant.Config.BehaviourCtrl.PlsStatus"
|
||||
].active = true;
|
||||
};
|
||||
|
||||
const preInitUIReactives = async () => {
|
||||
if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig = {};
|
||||
if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig.behaviourCtrlShared)
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.behaviourCtrlShared = {};
|
||||
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.behaviourCtrlShared.diskCaptions =
|
||||
await fileSystemRawCmds.getDiskCaptions();
|
||||
};
|
||||
|
||||
const initBasicSettingsPage = () => {
|
||||
const basicSubPageEl = document.getElementById("basic-config-subpage");
|
||||
settingsRenderer(basicSubPageEl, basicSettings);
|
||||
};
|
||||
|
||||
const initDeviceInfoPostSettingsPage = () => {
|
||||
const deviceInfoPostSubPageEl = document.getElementById(
|
||||
"device-info-post-config-subpage"
|
||||
const initDeviceSecuritySettingsPage = () => {
|
||||
const deviceSecuritySubPageEl = document.getElementById(
|
||||
"security-config-subpage"
|
||||
);
|
||||
settingsRenderer(deviceInfoPostSubPageEl, deviceInfoPostSettings);
|
||||
settingsRenderer(deviceSecuritySubPageEl, deviceSecuritySettings);
|
||||
};
|
||||
|
||||
const renderSubPages = async () => {
|
||||
await updateAikariSettingsFromLocal();
|
||||
await updateAikariRulesFromLocal();
|
||||
await updatePlsSettingsFromLocal();
|
||||
await updatePlsRulesFromLocal();
|
||||
|
||||
initBasicSettingsPage();
|
||||
initDeviceInfoPostSettingsPage();
|
||||
initDeviceSecuritySettingsPage();
|
||||
};
|
||||
|
||||
const onMounted = () => {
|
||||
const rootEl = document.getElementById("acs-behaviour-control-el");
|
||||
preInitUIReactives();
|
||||
initStatusPage();
|
||||
setTimeout(() => {
|
||||
rootEl.classList.remove("acs-behaviour-control-hidden");
|
||||
renderSubPages();
|
||||
renderSubPages(); // 如果立即渲染子页面, 此时 plsRules 还未初始化, 会导致子页面 auraIf 失效
|
||||
}, 500);
|
||||
};
|
||||
|
||||
|
||||
52
src/aura/ui/pages/configSubPages/behaviourCtrl/aikariStatus.css → src/aura/ui/pages/configSubPages/behaviourCtrl/plsStatus.css
Normal file → Executable file
52
src/aura/ui/pages/configSubPages/behaviourCtrl/aikariStatus.css → src/aura/ui/pages/configSubPages/behaviourCtrl/plsStatus.css
Normal file → Executable file
@@ -1,15 +1,15 @@
|
||||
.acs-behaviour-control-aikari-status-page {
|
||||
.acs-behaviour-control-pls-status-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.acs-behaviour-control-aikari-status-page p {
|
||||
.acs-behaviour-control-pls-status-page p {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
.acs-bc-aikari-status-page-aikari-description {
|
||||
.acs-bc-pls-status-page-pls-description {
|
||||
margin-top: 0.5rem;
|
||||
max-width: 80%;
|
||||
opacity: 0.35;
|
||||
@@ -17,11 +17,11 @@
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.acs-bc-aikari-status-page-main-logo {
|
||||
max-width: 15%;
|
||||
.acs-bc-pls-status-page-main-logo {
|
||||
max-width: 11%;
|
||||
opacity: 0.45;
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
margin-top: 1.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.acs-bc-psp-operations-container {
|
||||
@@ -133,7 +133,7 @@
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
.acs-bc-aikari-status-page-status-el {
|
||||
.acs-bc-pls-status-page-status-el {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 40%;
|
||||
@@ -141,17 +141,17 @@
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.acs-bc-aikari-status-page-status-el div {
|
||||
.acs-bc-pls-status-page-status-el div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.acs-bc-aikari-status-page-status-area {
|
||||
.acs-bc-pls-status-page-status-area {
|
||||
flex-grow: 1;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.acs-bc-aikari-status-page-status-area-circle {
|
||||
.acs-bc-pls-status-page-status-area-circle {
|
||||
height: 10px;
|
||||
width: 10px;
|
||||
border-radius: 100%;
|
||||
@@ -159,48 +159,48 @@
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.acs-bc-aikari-status-page-status-area.pending
|
||||
.acs-bc-aikari-status-page-status-area-circle {
|
||||
.acs-bc-pls-status-page-status-area.pending
|
||||
.acs-bc-pls-status-page-status-area-circle {
|
||||
background-color: rgba(0, 0, 0, 0.375);
|
||||
}
|
||||
|
||||
.acs-bc-aikari-status-page-status-area.pending p {
|
||||
.acs-bc-pls-status-page-status-area.pending p {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.acs-bc-aikari-status-page-status-area.success
|
||||
.acs-bc-aikari-status-page-status-area-circle {
|
||||
.acs-bc-pls-status-page-status-area.success
|
||||
.acs-bc-pls-status-page-status-area-circle {
|
||||
background-color: rgb(0, 175, 38);
|
||||
}
|
||||
|
||||
.acs-bc-aikari-status-page-status-area.success p {
|
||||
.acs-bc-pls-status-page-status-area.success p {
|
||||
color: rgb(0, 150, 33);
|
||||
}
|
||||
|
||||
.acs-bc-aikari-status-page-status-area.failed
|
||||
.acs-bc-aikari-status-page-status-area-circle {
|
||||
.acs-bc-pls-status-page-status-area.failed
|
||||
.acs-bc-pls-status-page-status-area-circle {
|
||||
background-color: rgb(175, 0, 0);
|
||||
}
|
||||
|
||||
.acs-bc-aikari-status-page-status-area.failed p {
|
||||
.acs-bc-pls-status-page-status-area.failed p {
|
||||
color: rgb(175, 0, 0);
|
||||
}
|
||||
|
||||
.acs-bc-aikari-status-page-status-area.warning
|
||||
.acs-bc-aikari-status-page-status-area-circle {
|
||||
.acs-bc-pls-status-page-status-area.warning
|
||||
.acs-bc-pls-status-page-status-area-circle {
|
||||
background-color: rgb(212, 127, 0);
|
||||
}
|
||||
|
||||
.acs-bc-aikari-status-page-status-area.warning p {
|
||||
.acs-bc-pls-status-page-status-area.warning p {
|
||||
color: rgb(212, 127, 0);
|
||||
}
|
||||
|
||||
.acs-bc-aikari-status-page-status-area.info
|
||||
.acs-bc-aikari-status-page-status-area-circle {
|
||||
.acs-bc-pls-status-page-status-area.info
|
||||
.acs-bc-pls-status-page-status-area-circle {
|
||||
background-color: #3d78ff;
|
||||
}
|
||||
|
||||
.acs-bc-aikari-status-page-status-area.info p {
|
||||
.acs-bc-pls-status-page-status-area.info p {
|
||||
color: #3d78ff;
|
||||
}
|
||||
|
||||
49
src/aura/ui/pages/configSubPages/behaviourCtrl/aikariStatus.html → src/aura/ui/pages/configSubPages/behaviourCtrl/plsStatus.html
Normal file → Executable file
49
src/aura/ui/pages/configSubPages/behaviourCtrl/aikariStatus.html → src/aura/ui/pages/configSubPages/behaviourCtrl/plsStatus.html
Normal file → Executable file
@@ -1,11 +1,12 @@
|
||||
<div class="acs-behaviour-control-aikari-status-page">
|
||||
<p class="acs-bc-aikari-status-page-aikari-description">
|
||||
HugoAura Aikari 是基于 C++ 实现的 HugoAura 特权访问服务, 集成篡改 MQTT
|
||||
数据包、冰点穿透增强等功能, 实现行为监控、伪造上报
|
||||
<div class="acs-behaviour-control-pls-status-page">
|
||||
<p class="acs-bc-pls-status-page-pls-description">
|
||||
HugoAura ProxyLayerServices (Aura-PLS) 是基于 Python + MITMProxy
|
||||
实现的代理服务, 用于解密并修改希沃基础服务 (SeewoCore) 的 MQTT 数据包,
|
||||
实现行为监控、伪造上报等功能
|
||||
</p>
|
||||
<img
|
||||
src="../../aura/ui/static/aikari_color_reversed.png"
|
||||
class="acs-bc-aikari-status-page-main-logo"
|
||||
src="../../aura/ui/static/aura_pls.png"
|
||||
class="acs-bc-pls-status-page-main-logo"
|
||||
/>
|
||||
|
||||
<div class="acs-bc-psp-operations-container">
|
||||
@@ -27,7 +28,7 @@
|
||||
<div
|
||||
class="acs-bc-psp-operation-btn"
|
||||
aura-disabled="true"
|
||||
id="acsBcPsp-operBtn-Install"
|
||||
id="acsBcPsp-operBtn-Download"
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
@@ -44,10 +45,10 @@
|
||||
d="M17 26.17V14h-2v12.17l-2.59-2.58L11 25l5 5l5-5l-1.41-1.41z"
|
||||
/>
|
||||
</svg>
|
||||
<p>下载应用</p>
|
||||
<p>下载内核</p>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-psp-operation-btn" id="acsBcPsp-operBtn-InstallSvc">
|
||||
<div class="acs-bc-psp-operation-btn" id="acsBcPsp-operBtn-Install">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="32"
|
||||
@@ -72,7 +73,7 @@
|
||||
|
||||
<div
|
||||
class="acs-bc-psp-operation-btn acs-bc-psp-o-btn-dangerous"
|
||||
id="acsBcPsp-operBtn-UninstallSvc"
|
||||
id="acsBcPsp-operBtn-Uninstall"
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
@@ -154,61 +155,61 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-aikari-status-page-status-el">
|
||||
<div class="acs-bc-pls-status-page-status-el">
|
||||
<p>安装状态</p>
|
||||
<div
|
||||
class="acs-bc-aikari-status-page-status-area pending"
|
||||
class="acs-bc-pls-status-page-status-area pending"
|
||||
id="acs-bc-psp-installStatus-container"
|
||||
>
|
||||
<span class="acs-bc-aikari-status-page-status-area-circle"></span>
|
||||
<span class="acs-bc-pls-status-page-status-area-circle"></span>
|
||||
<p id="acs-bc-psp-installStatus-text">未安装</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-aikari-status-page-status-el">
|
||||
<div class="acs-bc-pls-status-page-status-el">
|
||||
<p>启动状态</p>
|
||||
<div
|
||||
class="acs-bc-aikari-status-page-status-area pending"
|
||||
class="acs-bc-pls-status-page-status-area pending"
|
||||
id="acs-bc-psp-launchStatus-container"
|
||||
>
|
||||
<span class="acs-bc-aikari-status-page-status-area-circle"></span>
|
||||
<span class="acs-bc-pls-status-page-status-area-circle"></span>
|
||||
<p id="acs-bc-psp-launchStatus-text">未启动</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-aikari-status-page-status-el">
|
||||
<div class="acs-bc-pls-status-page-status-el">
|
||||
<p>连接状态</p>
|
||||
<div
|
||||
class="acs-bc-aikari-status-page-status-area pending"
|
||||
class="acs-bc-pls-status-page-status-area pending"
|
||||
id="acs-bc-psp-connStatus-container"
|
||||
>
|
||||
<span class="acs-bc-aikari-status-page-status-area-circle"></span>
|
||||
<span class="acs-bc-pls-status-page-status-area-circle"></span>
|
||||
<p id="acs-bc-psp-connStatus-text">已断开</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-aikari-status-page-status-el" style="border-bottom: none">
|
||||
<div class="acs-bc-pls-status-page-status-el" style="border-bottom: none">
|
||||
<p>版本</p>
|
||||
<div class="acs-bc-aikari-status-page-status-area">
|
||||
<div class="acs-bc-pls-status-page-status-area">
|
||||
<p id="acs-bc-psp-version-text">不可用</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toast-container position-fixed bottom-0 end-0 p-3">
|
||||
<div
|
||||
id="aikariStatusNotifyToast"
|
||||
id="plsStatusNotifyToast"
|
||||
class="acs-bc-psp-toast toast"
|
||||
data-bs-autohide="false"
|
||||
>
|
||||
<div class="toast-header">
|
||||
<strong class="me-auto" id="aikariStatusNotifyToastTitle"></strong>
|
||||
<strong class="me-auto" id="plsStatusNotifyToastTitle"></strong>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-close"
|
||||
data-bs-dismiss="toast"
|
||||
></button>
|
||||
</div>
|
||||
<div class="toast-body" id="aikariStatusNotifyToastBody"></div>
|
||||
<div class="toast-body" id="plsStatusNotifyToastBody"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
581
src/aura/ui/pages/configSubPages/behaviourCtrl/aikariStatus.js → src/aura/ui/pages/configSubPages/behaviourCtrl/plsStatus.js
Normal file → Executable file
581
src/aura/ui/pages/configSubPages/behaviourCtrl/aikariStatus.js → src/aura/ui/pages/configSubPages/behaviourCtrl/plsStatus.js
Normal file → Executable file
@@ -6,7 +6,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
|
||||
(() => {
|
||||
const REQUIRE_BASE = "../../aura/ui/pages/configSubPages/behaviourCtrl";
|
||||
const IPC_METHOD_BASE = "$aura.aikari";
|
||||
const IPC_METHOD_BASE = "$aura.pls";
|
||||
|
||||
const lifecycleStatus = {
|
||||
installed: false,
|
||||
@@ -15,12 +15,12 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
svcRunning: false,
|
||||
};
|
||||
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus = {
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.plsStatus = {
|
||||
toastAutoHideTimeout: null,
|
||||
curDlTaskId: null,
|
||||
};
|
||||
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus = {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus = {
|
||||
updateToast: async (
|
||||
variant,
|
||||
title,
|
||||
@@ -29,19 +29,17 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
autoHide = true,
|
||||
hideAfter = 3000
|
||||
) => {
|
||||
const toastRootEl = document.getElementById("aikariStatusNotifyToast");
|
||||
const toastRootEl = document.getElementById("plsStatusNotifyToast");
|
||||
const toastHeaderEl = document.getElementById(
|
||||
"aikariStatusNotifyToastTitle"
|
||||
);
|
||||
const toastBodyEl = document.getElementById(
|
||||
"aikariStatusNotifyToastBody"
|
||||
"plsStatusNotifyToastTitle"
|
||||
);
|
||||
const toastBodyEl = document.getElementById("plsStatusNotifyToastBody");
|
||||
|
||||
const bsToastIns = bootstrap.Toast.getOrCreateInstance(toastRootEl);
|
||||
if (bsToastIns.isShown) {
|
||||
bsToastIns.hide();
|
||||
const timeout =
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.plsStatus
|
||||
.toastAutoHideTimeout;
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
@@ -62,7 +60,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
|
||||
bsToastIns.show();
|
||||
if (autoHide && hideAfter) {
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus.toastAutoHideTimeout =
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.plsStatus.toastAutoHideTimeout =
|
||||
setTimeout(() => {
|
||||
bsToastIns.hide();
|
||||
}, hideAfter);
|
||||
@@ -87,7 +85,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
switch (btnName) {
|
||||
case "Refresh":
|
||||
btnEl.onclick = () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"warning",
|
||||
"正在更新",
|
||||
null,
|
||||
@@ -95,24 +93,24 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
false,
|
||||
null
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.refreshAikariStatus();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.refreshPlsStatus();
|
||||
};
|
||||
break;
|
||||
case "Install":
|
||||
case "Download":
|
||||
btnEl.onclick = async () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.downloadAndInstallAikariBin();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.downloadPLSBin();
|
||||
};
|
||||
break;
|
||||
|
||||
// ↓ 这边的确可以把这些全都合并到一个可复用 fn 里去, 但没必要
|
||||
// 如果后续要引入错误视觉反馈, 合并到单个 fn 反而会增加实现复杂度
|
||||
case "InstallSvc":
|
||||
case "Install":
|
||||
btnEl.onclick = async () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateOperationBtnStatus(
|
||||
"InstallSvc",
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateOperationBtnStatus(
|
||||
"Install",
|
||||
true
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"info",
|
||||
"正在请求安装",
|
||||
null,
|
||||
@@ -121,12 +119,12 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
null
|
||||
);
|
||||
const ret = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
||||
`${IPC_METHOD_BASE}.plsLifecycleControl`,
|
||||
{ target: "instSvc" }
|
||||
);
|
||||
if (ret.success) {
|
||||
lifecycleStatus.svcInstalled = true;
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"success",
|
||||
"服务安装成功",
|
||||
null,
|
||||
@@ -135,7 +133,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
2000
|
||||
);
|
||||
} else {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"error",
|
||||
"服务安装失败",
|
||||
`<p>${ret.errorObj}</p>`,
|
||||
@@ -144,52 +142,50 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
null
|
||||
);
|
||||
}
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
};
|
||||
break;
|
||||
case "UninstallSvc":
|
||||
if (btnContent === "卸载应用") {
|
||||
case "Uninstall":
|
||||
if (btnContent === "删除内核") {
|
||||
btnEl.onclick = async () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateOperationBtnStatus(
|
||||
"UninstallSvc",
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateOperationBtnStatus(
|
||||
"Uninstall",
|
||||
true
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"warning",
|
||||
"正在卸载 Aikari",
|
||||
`<p>
|
||||
请在弹出窗口中完成操作
|
||||
</p>`,
|
||||
"正在删除内核",
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
null
|
||||
);
|
||||
const ret = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
||||
{ target: "uninst" }
|
||||
`${IPC_METHOD_BASE}.plsLifecycleControl`,
|
||||
{ target: "rmBin" }
|
||||
);
|
||||
if (ret.success) {
|
||||
lifecycleStatus.installed = false;
|
||||
lifecycleStatus.svcInstalled = false;
|
||||
global.__HUGO_AURA__.aikariStats.installed = false;
|
||||
global.__HUGO_AURA__.aikariStats.connected = false;
|
||||
global.__HUGO_AURA__.aikariStats.launched = false;
|
||||
global.__HUGO_AURA__.plsStats.installed = false;
|
||||
global.__HUGO_AURA__.plsStats.connected = false;
|
||||
global.__HUGO_AURA__.plsStats.launched = false;
|
||||
ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
||||
global.__HUGO_AURA__.aikariStats
|
||||
`${IPC_METHOD_BASE}.updatePlsStats`,
|
||||
global.__HUGO_AURA__.plsStats
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"success",
|
||||
"Aikari 已完成卸载",
|
||||
"内核已删除",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
2000
|
||||
);
|
||||
} else {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"error",
|
||||
"Aikari 卸载失败",
|
||||
"内核删除失败",
|
||||
`<p>
|
||||
${ret.errorObj ? ret.errorObj : "检查日志以获取详细信息"}
|
||||
</p>`,
|
||||
@@ -198,15 +194,15 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
null
|
||||
);
|
||||
}
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
};
|
||||
} else {
|
||||
btnEl.onclick = async () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateOperationBtnStatus(
|
||||
"UninstallSvc",
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateOperationBtnStatus(
|
||||
"Uninstall",
|
||||
true
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"info",
|
||||
lifecycleStatus.svcRunning
|
||||
? "正在停止服务并卸载"
|
||||
@@ -218,11 +214,11 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
);
|
||||
if (lifecycleStatus.svcRunning) {
|
||||
const stopRet = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
||||
`${IPC_METHOD_BASE}.plsLifecycleControl`,
|
||||
{ target: "stopSvc" }
|
||||
);
|
||||
if (!stopRet.success) {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"error",
|
||||
"服务卸载失败: 无法停止服务",
|
||||
`<p>${
|
||||
@@ -231,7 +227,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
: "检查日志以获取详细信息"
|
||||
}</p>
|
||||
<p>
|
||||
您可以尝试手动停止 Aikari 服务
|
||||
您可以尝试手动停止 PLS 服务
|
||||
</p>`,
|
||||
true,
|
||||
false,
|
||||
@@ -242,19 +238,12 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
}
|
||||
}
|
||||
const ret = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
||||
{ target: "uninstSvc" }
|
||||
`${IPC_METHOD_BASE}.plsLifecycleControl`,
|
||||
{ target: "rmSvc" }
|
||||
);
|
||||
if (ret.success) {
|
||||
lifecycleStatus.svcRunning = false;
|
||||
lifecycleStatus.svcInstalled = false;
|
||||
global.__HUGO_AURA__.aikariStats.connected = false;
|
||||
global.__HUGO_AURA__.aikariStats.launched = false;
|
||||
ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
||||
global.__HUGO_AURA__.aikariStats
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"success",
|
||||
"服务卸载成功",
|
||||
null,
|
||||
@@ -263,7 +252,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
2000
|
||||
);
|
||||
} else {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"error",
|
||||
"服务卸载失败",
|
||||
"<p>检查日志以获取详细信息</p>",
|
||||
@@ -272,18 +261,18 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
null
|
||||
);
|
||||
}
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
};
|
||||
}
|
||||
|
||||
break;
|
||||
case "Start":
|
||||
btnEl.onclick = async () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateOperationBtnStatus(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateOperationBtnStatus(
|
||||
"Start",
|
||||
true
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"info",
|
||||
"正在请求启动",
|
||||
null,
|
||||
@@ -291,36 +280,30 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
false,
|
||||
null
|
||||
);
|
||||
const isHostNotInit =
|
||||
await global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.showWarnToastIfHostsNotInitialized();
|
||||
const ret = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
||||
`${IPC_METHOD_BASE}.plsLifecycleControl`,
|
||||
{ target: "startSvc" }
|
||||
);
|
||||
if (ret.success) {
|
||||
lifecycleStatus.svcRunning = true;
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
if (!isHostNotInit) {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"success",
|
||||
"Aikari 已启动",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
2000
|
||||
);
|
||||
}
|
||||
await global.__HUGO_AURA_GLOBAL__.utils.sleep(100);
|
||||
await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.retryAikariConnect`
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"success",
|
||||
"PLS 已启动",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
2000
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
await global.__HUGO_AURA_GLOBAL__.utils.sleep(100);
|
||||
await ipcRenderer.invoke(`${IPC_METHOD_BASE}.retryPlsConnect`);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
} else {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"error",
|
||||
"Aikari 启动失败",
|
||||
"<p>检查 Aikari 日志目录以获取详细信息</p>",
|
||||
"PLS 启动失败",
|
||||
"<p>检查 PLS 日志目录以获取详细信息</p>",
|
||||
true,
|
||||
false,
|
||||
null
|
||||
@@ -330,11 +313,11 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
break;
|
||||
case "Stop":
|
||||
btnEl.onclick = async () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateOperationBtnStatus(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateOperationBtnStatus(
|
||||
"Stop",
|
||||
true
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"info",
|
||||
"正在请求停止",
|
||||
null,
|
||||
@@ -343,33 +326,29 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
null
|
||||
);
|
||||
const ret = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleControl`,
|
||||
`${IPC_METHOD_BASE}.plsLifecycleControl`,
|
||||
{ target: "stopSvc" }
|
||||
);
|
||||
if (ret.success) {
|
||||
lifecycleStatus.svcRunning = false;
|
||||
global.__HUGO_AURA__.aikariStats.launched = false;
|
||||
global.__HUGO_AURA__.aikariStats.version = "unknown";
|
||||
global.__HUGO_AURA__.aikariStats.status = "dead";
|
||||
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"success",
|
||||
"Aikari 已停止",
|
||||
"PLS 已停止",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
2000
|
||||
);
|
||||
} else {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"error",
|
||||
"Aikari 停止失败",
|
||||
"PLS 停止失败",
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
null
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
}
|
||||
};
|
||||
break;
|
||||
@@ -381,10 +360,10 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
},
|
||||
|
||||
updateStatusContent: async () => {
|
||||
const curAikariStats = await updateAikariStatusFromLocal();
|
||||
const curPlsStats = await updatePlsStatusFromLocal();
|
||||
|
||||
if (curAikariStats.status === "downloading") {
|
||||
GLOBAL_FUNCTIONS.downloadAndInstallAikariBin(true);
|
||||
if (curPlsStats.status === "downloading") {
|
||||
GLOBAL_FUNCTIONS.downloadPLSBin(true);
|
||||
}
|
||||
|
||||
const acIdInst = "acs-bc-psp-installStatus-container";
|
||||
@@ -392,30 +371,20 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
switch (lifecycleStatus.installed) {
|
||||
case true:
|
||||
if (!lifecycleStatus.svcInstalled) {
|
||||
updateStatusEl(
|
||||
acIdInst,
|
||||
atIdInst,
|
||||
"WARNING",
|
||||
"应用已安装, 服务未安装"
|
||||
);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("InstallSvc", false);
|
||||
updateStatusEl(acIdInst, atIdInst, "WARNING", "已下载, 服务未安装");
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Install", false);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus(
|
||||
"UninstallSvc",
|
||||
"Uninstall",
|
||||
false,
|
||||
"卸载应用"
|
||||
"删除内核"
|
||||
);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", true);
|
||||
} else {
|
||||
updateStatusEl(
|
||||
acIdInst,
|
||||
atIdInst,
|
||||
"SUCCESS",
|
||||
"应用已安装, 服务已安装"
|
||||
);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("InstallSvc", true);
|
||||
updateStatusEl(acIdInst, atIdInst, "SUCCESS", "已安装");
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Install", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus(
|
||||
"UninstallSvc",
|
||||
"Uninstall",
|
||||
false,
|
||||
"卸载服务"
|
||||
);
|
||||
@@ -423,9 +392,9 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
break;
|
||||
case false:
|
||||
updateStatusEl(acIdInst, atIdInst, "PENDING", "未下载");
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Install", false);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("InstallSvc", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("UninstallSvc", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Download", false);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Install", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Uninstall", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", true);
|
||||
}
|
||||
@@ -438,9 +407,9 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", true);
|
||||
} else if (lifecycleStatus.svcInstalled && lifecycleStatus.installed) {
|
||||
switch (lifecycleStatus.svcRunning || curAikariStats.launched) {
|
||||
switch (lifecycleStatus.svcRunning || curPlsStats.launched) {
|
||||
case true:
|
||||
if (curAikariStats.status !== "notReady") {
|
||||
if (curPlsStats.status !== "notReady") {
|
||||
updateStatusEl(acIdLaunch, atIdLaunch, "SUCCESS", "已启动");
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", false);
|
||||
@@ -460,12 +429,12 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
|
||||
const acIdConn = "acs-bc-psp-connStatus-container";
|
||||
const atIdConn = "acs-bc-psp-connStatus-text";
|
||||
switch (curAikariStats.connected) {
|
||||
switch (curPlsStats.connected) {
|
||||
case true:
|
||||
updateStatusEl(acIdConn, atIdConn, "SUCCESS", "已连接");
|
||||
break;
|
||||
case false:
|
||||
if (curAikariStats.status !== "notReady") {
|
||||
if (curPlsStats.status !== "notReady") {
|
||||
updateStatusEl(acIdConn, atIdConn, "FAILED", "连接失败");
|
||||
} else {
|
||||
updateStatusEl(acIdConn, atIdConn, "PENDING", "等待启动");
|
||||
@@ -473,41 +442,46 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
break;
|
||||
}
|
||||
|
||||
const versionTextEl = document.getElementById("acs-bc-psp-version-text");
|
||||
if (curAikariStats.version && curAikariStats.version !== "unknown") {
|
||||
versionTextEl.textContent = curAikariStats.version;
|
||||
if (curPlsStats.version && curPlsStats.version !== "未知") {
|
||||
const versionTextEl = document.getElementById(
|
||||
"acs-bc-psp-version-text"
|
||||
);
|
||||
versionTextEl.textContent = "v" + curPlsStats.version;
|
||||
}
|
||||
},
|
||||
|
||||
refreshPlsStatus: async (init = false) => {
|
||||
const binExistsRet = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.getPlsBinExists`
|
||||
);
|
||||
if (binExistsRet.success && binExistsRet.data.isExists) {
|
||||
lifecycleStatus.installed = true;
|
||||
global.__HUGO_AURA__.plsStats.installed = true;
|
||||
ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updatePlsStats`,
|
||||
global.__HUGO_AURA__.plsStats
|
||||
);
|
||||
} else {
|
||||
versionTextEl.textContent = "不可用";
|
||||
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;
|
||||
}
|
||||
},
|
||||
|
||||
showWarnToastIfHostsNotInitialized: async () => {
|
||||
const dnsModule = require("dns");
|
||||
const lookupPromise = new Promise((resolve) => {
|
||||
dnsModule.lookup("iot-broker-mis.seewo.com", (err, result) => {
|
||||
resolve(err ? err : result);
|
||||
});
|
||||
});
|
||||
const result = await lookupPromise;
|
||||
if (result) {
|
||||
if (!result.startsWith("127.")) {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"error",
|
||||
"警告: 页面即将刷新",
|
||||
`<p>您似乎是首次运行 Aikari, 基于 Aikari PLS 模块的实现原理, 我们需要修改 Hosts 文件并重启 SeewoCore 进程以开始拦截流量。</p>
|
||||
<p>重启 SeewoCore 进程会导致管家前端页面<b>在重启完成后自动发生刷新</b>, 因此稍后请留意此变更。</p>`,
|
||||
true,
|
||||
false,
|
||||
null
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
refreshAikariStatus: async (init = false) => {
|
||||
const isDetachedRet = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleQuery`,
|
||||
`${IPC_METHOD_BASE}.plsLifecycleQuery`,
|
||||
{ target: "isDetached" }
|
||||
);
|
||||
if (isDetachedRet.success && isDetachedRet.result) {
|
||||
@@ -516,40 +490,8 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
lifecycleStatus.detached = false;
|
||||
}
|
||||
|
||||
const binExistsRet = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.getIfAikariBinExists`
|
||||
);
|
||||
if (
|
||||
(binExistsRet.success && binExistsRet.data.isExists) ||
|
||||
lifecycleStatus.detached
|
||||
) {
|
||||
lifecycleStatus.installed = true;
|
||||
global.__HUGO_AURA__.aikariStats.installed = true;
|
||||
ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
||||
global.__HUGO_AURA__.aikariStats
|
||||
);
|
||||
} else {
|
||||
lifecycleStatus.installed = false;
|
||||
global.__HUGO_AURA__.aikariStats.installed = false;
|
||||
ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
||||
global.__HUGO_AURA__.aikariStats
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
"error",
|
||||
"请下载 Aikari 内核以继续",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
3000
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
return;
|
||||
}
|
||||
|
||||
const isSvcInstalledRet = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleQuery`,
|
||||
`${IPC_METHOD_BASE}.plsLifecycleQuery`,
|
||||
{ target: "isSvcInstalled" }
|
||||
);
|
||||
if (isSvcInstalledRet.success && isSvcInstalledRet.result) {
|
||||
@@ -559,7 +501,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
}
|
||||
|
||||
const isSvcRunningRet = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.aikariLifecycleQuery`,
|
||||
`${IPC_METHOD_BASE}.plsLifecycleQuery`,
|
||||
{ target: "isSvcStart" }
|
||||
);
|
||||
if (isSvcRunningRet.success && isSvcRunningRet.result) {
|
||||
@@ -569,16 +511,16 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
}
|
||||
|
||||
if (init) {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
return;
|
||||
}
|
||||
|
||||
const updateOperationBtnStatus =
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus
|
||||
.updateOperationBtnStatus;
|
||||
updateOperationBtnStatus("Refresh", true);
|
||||
const result = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.retryAikariConnect`
|
||||
`${IPC_METHOD_BASE}.retryPlsConnect`
|
||||
);
|
||||
if (result.success && result.status === "Retrying") {
|
||||
updateOperationBtnStatus("Refresh", true, "正在重连");
|
||||
@@ -588,7 +530,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
async (_evt, arg) => {
|
||||
await global.__HUGO_AURA_GLOBAL__.utils.sleep(50);
|
||||
updateOperationBtnStatus("Refresh", false, "刷新状态");
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
arg.success ? "success" : "error",
|
||||
arg.success ? "更新成功" : "连接失败",
|
||||
null,
|
||||
@@ -596,12 +538,12 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
true,
|
||||
3000
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
}
|
||||
);
|
||||
} else if (result.success && result.status === "Already") {
|
||||
updateOperationBtnStatus("Refresh", false, "刷新状态");
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus.updateToast(
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"success",
|
||||
"更新成功",
|
||||
null,
|
||||
@@ -676,15 +618,15 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
}
|
||||
},
|
||||
|
||||
downloadAndInstallAikariBin: async (retrieveMode = false) => {
|
||||
downloadPLSBin: async (retrieveMode = false) => {
|
||||
const GLOBAL_FUNCTIONS =
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus;
|
||||
const CUR_CHANNEL = `${IPC_METHOD_BASE}.post.reportAikariInstallStep`;
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus;
|
||||
const CUR_CHANNEL = `${IPC_METHOD_BASE}.post.reportPlsDownloadStatus`;
|
||||
|
||||
if (!retrieveMode) {
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Install", true, "正在检查");
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Download", true, "正在检查");
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Refresh", true);
|
||||
await ipcRenderer.invoke(`${IPC_METHOD_BASE}.ensureAikariInstallDir`);
|
||||
await ipcRenderer.invoke(`${IPC_METHOD_BASE}.ensurePlsInstallDir`);
|
||||
GLOBAL_FUNCTIONS.updateToast(
|
||||
"info",
|
||||
"准备开始下载...",
|
||||
@@ -693,7 +635,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
true,
|
||||
2000
|
||||
);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Install", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Download", true);
|
||||
} else {
|
||||
GLOBAL_FUNCTIONS.updateToast(
|
||||
"info",
|
||||
@@ -711,50 +653,25 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
const callbackFn = (_evt, info) => {
|
||||
switch (info.status) {
|
||||
case "failed":
|
||||
if (info.id !== "INSTALL_STAGE") {
|
||||
GLOBAL_FUNCTIONS.updateToast(
|
||||
"error",
|
||||
"下载失败",
|
||||
`<p>${
|
||||
info.message ? info.message : "检查日志以获取错误信息"
|
||||
}</p><p>
|
||||
${info.errorObj ? info.errorObj : ""}
|
||||
</p>`,
|
||||
true,
|
||||
true,
|
||||
5000
|
||||
);
|
||||
|
||||
GLOBAL_FUNCTIONS.updatePBarStatus(
|
||||
100,
|
||||
"下载时发生错误",
|
||||
"danger",
|
||||
false
|
||||
);
|
||||
} else {
|
||||
GLOBAL_FUNCTIONS.updateToast(
|
||||
"error",
|
||||
"安装失败",
|
||||
`<p>${
|
||||
info.message
|
||||
? info.message
|
||||
: "检查 HugoAura 日志或安装器日志 (%TEMP%/Aikari-Install-Temp) 以获取错误信息"
|
||||
}</p><p>
|
||||
${info.errorObj ? info.errorObj : ""}
|
||||
</p>`,
|
||||
true,
|
||||
true,
|
||||
15000
|
||||
);
|
||||
|
||||
GLOBAL_FUNCTIONS.updatePBarStatus(
|
||||
100,
|
||||
`发生错误: ${info.message}`,
|
||||
"danger",
|
||||
false
|
||||
);
|
||||
}
|
||||
GLOBAL_FUNCTIONS.updateToast(
|
||||
"error",
|
||||
"下载失败",
|
||||
`<p>${
|
||||
info.message ? info.message : "检查日志以获取错误信息"
|
||||
}</p><p>
|
||||
${info.errorObj ? info.errorObj : ""}
|
||||
</p>`,
|
||||
true,
|
||||
true,
|
||||
5000
|
||||
);
|
||||
|
||||
GLOBAL_FUNCTIONS.updatePBarStatus(
|
||||
100,
|
||||
"下载时发生错误",
|
||||
"danger",
|
||||
false
|
||||
);
|
||||
setTimeout(() => {
|
||||
GLOBAL_FUNCTIONS.switchPBarShowStatus(false);
|
||||
}, 1000);
|
||||
@@ -762,108 +679,72 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
ipcRenderer.off(CUR_CHANNEL, callbackFn);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Refresh", false);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus(
|
||||
"Install",
|
||||
"Download",
|
||||
false,
|
||||
"下载应用"
|
||||
"下载内核"
|
||||
);
|
||||
break;
|
||||
case "done":
|
||||
if (info.id !== "INSTALL_STAGE") {
|
||||
GLOBAL_FUNCTIONS.updateToast(
|
||||
"success",
|
||||
"下载成功",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
2500
|
||||
);
|
||||
|
||||
GLOBAL_FUNCTIONS.updatePBarStatus(
|
||||
100,
|
||||
"下载成功",
|
||||
"success",
|
||||
false
|
||||
);
|
||||
break;
|
||||
} else {
|
||||
GLOBAL_FUNCTIONS.updateToast(
|
||||
"success",
|
||||
"安装成功",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
2500
|
||||
);
|
||||
|
||||
GLOBAL_FUNCTIONS.updatePBarStatus(
|
||||
100,
|
||||
"Aikari 安装成功",
|
||||
"success",
|
||||
false
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
GLOBAL_FUNCTIONS.switchPBarShowStatus(false);
|
||||
}, 1000);
|
||||
|
||||
ipcRenderer.off(CUR_CHANNEL, callbackFn);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Refresh", false);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus(
|
||||
"Install",
|
||||
true,
|
||||
"下载应用"
|
||||
);
|
||||
lifecycleStatus.installed = true;
|
||||
global.__HUGO_AURA__.aikariStats.installed = true;
|
||||
setTimeout(() => {
|
||||
ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updateAikariStatus`,
|
||||
global.__HUGO_AURA__.aikariStats
|
||||
);
|
||||
GLOBAL_FUNCTIONS.updateStatusContent();
|
||||
}, 500);
|
||||
break;
|
||||
}
|
||||
case "waiting":
|
||||
GLOBAL_FUNCTIONS.updatePBarStatus(
|
||||
0,
|
||||
info.message ? info.message : "正在连接",
|
||||
"normal"
|
||||
GLOBAL_FUNCTIONS.updateToast(
|
||||
"success",
|
||||
"下载成功",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
2500
|
||||
);
|
||||
|
||||
GLOBAL_FUNCTIONS.updatePBarStatus(
|
||||
100,
|
||||
"下载成功",
|
||||
"success",
|
||||
false
|
||||
);
|
||||
setTimeout(() => {
|
||||
GLOBAL_FUNCTIONS.switchPBarShowStatus(false);
|
||||
}, 1000);
|
||||
|
||||
ipcRenderer.off(CUR_CHANNEL, callbackFn);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Refresh", false);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus(
|
||||
"Download",
|
||||
true,
|
||||
"下载内核"
|
||||
);
|
||||
lifecycleStatus.installed = true;
|
||||
global.__HUGO_AURA__.plsStats.installed = true;
|
||||
ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updatePlsStats`,
|
||||
global.__HUGO_AURA__.plsStats
|
||||
);
|
||||
GLOBAL_FUNCTIONS.updateStatusContent();
|
||||
break;
|
||||
case "waiting":
|
||||
GLOBAL_FUNCTIONS.updatePBarStatus(0, "正在连接", "normal");
|
||||
if (
|
||||
(!global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus
|
||||
!global.__HUGO_AURA_UI_REACTIVES__.subConfig.plsStatus
|
||||
.curDlTaskId ||
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus
|
||||
.curDlTaskId !== info.id) &&
|
||||
info.id !== "INSTALL_STAGE"
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.plsStatus
|
||||
.curDlTaskId !== info.id
|
||||
) {
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus.curDlTaskId =
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.plsStatus.curDlTaskId =
|
||||
info.id;
|
||||
}
|
||||
break;
|
||||
case "progressing":
|
||||
if (info.id !== "INSTALL_STAGE") {
|
||||
const roundProgress = Math.round(info.progress);
|
||||
GLOBAL_FUNCTIONS.updatePBarStatus(
|
||||
roundProgress,
|
||||
`正在下载中... ${roundProgress}% (${(
|
||||
info.curBytes /
|
||||
1024 /
|
||||
1024
|
||||
).toFixed(2)}MB / ${(info.totalBytes / 1024 / 1024).toFixed(
|
||||
2
|
||||
)}MB)`, // POWERED BY PRETTIER
|
||||
"normal",
|
||||
true
|
||||
);
|
||||
} else {
|
||||
GLOBAL_FUNCTIONS.updatePBarStatus(
|
||||
info.progress,
|
||||
`正在安装 Aikari...`,
|
||||
"normal",
|
||||
false
|
||||
);
|
||||
}
|
||||
const roundProgress = Math.round(info.progress);
|
||||
GLOBAL_FUNCTIONS.updatePBarStatus(
|
||||
roundProgress,
|
||||
`正在下载中... ${roundProgress}% (${(
|
||||
info.curBytes /
|
||||
1024 /
|
||||
1024
|
||||
).toFixed(2)}MB / ${(info.totalBytes / 1024 / 1024).toFixed(
|
||||
2
|
||||
)}MB)`, // POWERED BY PRETTIER
|
||||
"normal",
|
||||
true
|
||||
);
|
||||
break;
|
||||
case "struggling":
|
||||
GLOBAL_FUNCTIONS.updatePBarStatus(100, info.message, "warning");
|
||||
@@ -871,9 +752,9 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
case "cancelled":
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Refresh", false);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus(
|
||||
"Install",
|
||||
"Download",
|
||||
false,
|
||||
"下载应用"
|
||||
"下载内核"
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -881,7 +762,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
|
||||
ipcRenderer.on(CUR_CHANNEL, callbackFn);
|
||||
|
||||
ipcRenderer.invoke(`${IPC_METHOD_BASE}.downloadAndInstallAikari`, {
|
||||
ipcRenderer.invoke(`${IPC_METHOD_BASE}.downloadPls`, {
|
||||
channel: "stable",
|
||||
reportTo: "assistant",
|
||||
});
|
||||
@@ -889,7 +770,7 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
|
||||
cancelDownloadTask: async () => {
|
||||
const taskId =
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.aikariStatus.curDlTaskId;
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.plsStatus.curDlTaskId;
|
||||
|
||||
if (!taskId) {
|
||||
GLOBAL_FUNCTIONS.updateToast(
|
||||
@@ -934,11 +815,11 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
};
|
||||
|
||||
const GLOBAL_FUNCTIONS =
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.aikariStatus;
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus;
|
||||
|
||||
const {
|
||||
updateAikariStatusFromLocal,
|
||||
} = require(`${REQUIRE_BASE}/../../../composables/aikariConfigManager`);
|
||||
updatePlsStatusFromLocal,
|
||||
} = require(`${REQUIRE_BASE}/../../../composables/plsConfigManager`);
|
||||
|
||||
const initBsTooltip = () => {
|
||||
const tooltipTriggerList = document.querySelectorAll(
|
||||
@@ -960,23 +841,21 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
switch (target) {
|
||||
case "PENDING":
|
||||
areaContainerEl.className =
|
||||
"acs-bc-aikari-status-page-status-area pending";
|
||||
"acs-bc-pls-status-page-status-area pending";
|
||||
break;
|
||||
case "SUCCESS":
|
||||
areaContainerEl.className =
|
||||
"acs-bc-aikari-status-page-status-area success";
|
||||
"acs-bc-pls-status-page-status-area success";
|
||||
break;
|
||||
case "FAILED":
|
||||
areaContainerEl.className =
|
||||
"acs-bc-aikari-status-page-status-area failed";
|
||||
areaContainerEl.className = "acs-bc-pls-status-page-status-area failed";
|
||||
break;
|
||||
case "WARNING":
|
||||
areaContainerEl.className =
|
||||
"acs-bc-aikari-status-page-status-area warning";
|
||||
"acs-bc-pls-status-page-status-area warning";
|
||||
break;
|
||||
case "INFO":
|
||||
areaContainerEl.className =
|
||||
"acs-bc-aikari-status-page-status-area info";
|
||||
areaContainerEl.className = "acs-bc-pls-status-page-status-area info";
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
@@ -988,14 +867,14 @@ if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
const onMounted = () => {
|
||||
initBsTooltip();
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Refresh", false);
|
||||
GLOBAL_FUNCTIONS.refreshAikariStatus(true);
|
||||
GLOBAL_FUNCTIONS.refreshPlsStatus(true);
|
||||
|
||||
const eventListener = () => {
|
||||
GLOBAL_FUNCTIONS.updateStatusContent();
|
||||
};
|
||||
document.addEventListener("onAikariStatsUpdate", eventListener);
|
||||
document.addEventListener("onPLSStatsUpdate", eventListener);
|
||||
global.__HUGO_AURA_GLOBAL__.utils.createOnLeaveEvtListener(
|
||||
"onAikariStatsUpdate",
|
||||
"onPLSStatsUpdate",
|
||||
eventListener
|
||||
);
|
||||
};
|
||||
@@ -1,8 +1,30 @@
|
||||
const REQUIRE_BASE = ".";
|
||||
|
||||
const {
|
||||
updateAikariConfigToRemote,
|
||||
} = require(`${REQUIRE_BASE}/../../../../composables/aikariConfigManager`);
|
||||
updatePlsConfigToRemote,
|
||||
} = require(`${REQUIRE_BASE}/../../../../composables/plsConfigManager`);
|
||||
|
||||
const reusableChkFn = {
|
||||
checkRelativePath: () => {
|
||||
if (newVal === "" || !newVal)
|
||||
return { valid: false, hint: "请输入证书路径" };
|
||||
|
||||
if (newVal.includes(":/") || newVal.includes(":\\")) {
|
||||
return { valid: false, hint: "请输入相对路径, 而非绝对路径" };
|
||||
}
|
||||
|
||||
if (newVal.includes("\\")) {
|
||||
return {
|
||||
valid: false,
|
||||
hint: '请输入正确的路径, 使用 "/" 作为路径符',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
valid: true,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
const basicSettings = [
|
||||
{
|
||||
@@ -11,70 +33,137 @@ const basicSettings = [
|
||||
child: [
|
||||
{
|
||||
index: 0,
|
||||
id: "aikarWsPreferPort",
|
||||
id: "plsListenPort",
|
||||
type: "input",
|
||||
subType: "number",
|
||||
name: "Aikari WS 默认监听端口",
|
||||
description: "Aikari WebSocket 服务器默认监听的端口",
|
||||
name: "PLS WS 默认监听端口",
|
||||
description: "PLS 的 WebSocket 服务器将默认监听指定的端口",
|
||||
reactive: true,
|
||||
reactiveVal: ["root.settings"],
|
||||
restart: false,
|
||||
reload: false,
|
||||
aikariRequired: true,
|
||||
restartAikari: false,
|
||||
PLSRequired: true,
|
||||
restartPLS: false,
|
||||
warning: true,
|
||||
warningContent: "Aikari 仍会在默认端口被占用时, 自动随机端口重试",
|
||||
warningContent: "PLS 仍会在默认端口被占用时, 自动随机端口重试",
|
||||
associateVal: null,
|
||||
auraIf: () => true,
|
||||
defaultValue: "",
|
||||
placeHolder: "输入端口号 (10000 ~ 65535)",
|
||||
valueGetter: () => {
|
||||
if (!global.__HUGO_AURA__.aikariSettings) return "";
|
||||
return global.__HUGO_AURA__.aikariSettings.wsPreferPort;
|
||||
if (!global.__HUGO_AURA__.plsSettings) return "";
|
||||
return global.__HUGO_AURA__.plsSettings.wsPort;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
if (newVal === "" || !newVal)
|
||||
return { valid: false, hint: "请输入端口号" };
|
||||
|
||||
const numberNewVal = Number(newVal);
|
||||
if (
|
||||
numberNewVal === NaN ||
|
||||
!(10000 <= numberNewVal) ||
|
||||
!(newVal <= 65535)
|
||||
) {
|
||||
if (numberNewVal === NaN || !(10000 <= numberNewVal) || !(newVal <= 65535)) {
|
||||
return { valid: false, hint: "请输入合法的端口号 (10000 ~ 65535)" };
|
||||
}
|
||||
|
||||
global.__HUGO_AURA__.aikariSettings.wsPreferPort = numberNewVal;
|
||||
updateAikariConfigToRemote("wsPreferPort", numberNewVal);
|
||||
global.__HUGO_AURA__.plsSettings.wsPort = numberNewVal;
|
||||
updatePlsConfigToRemote("wsPort", numberNewVal);
|
||||
return { valid: true };
|
||||
},
|
||||
},
|
||||
{
|
||||
index: 1,
|
||||
id: "aikariForceRegenWsTlsCert",
|
||||
type: "switch",
|
||||
name: "重新生成 WS TLS 证书",
|
||||
description: "Aikari 将在下次启动时重新生成用于 WebSocket 的 TLS 证书",
|
||||
id: "plsCertPath",
|
||||
type: "input",
|
||||
subType: "text",
|
||||
name: "WSS TLS 证书相对路径",
|
||||
description: "PLS 将使用指定路径下的证书启动 WSS 服务器",
|
||||
reactive: true,
|
||||
reactiveVal: ["root.settings"],
|
||||
restart: false,
|
||||
reload: false,
|
||||
aikariRequired: true,
|
||||
restartAikari: true,
|
||||
PLSRequired: true,
|
||||
restartPLS: true,
|
||||
tip: true,
|
||||
tipTitle:
|
||||
'路径相对于 "%PROGRAMDATA%\\HugoAura\\Aura-PLS\\", 使用 "/" 作为路径符',
|
||||
associateVal: null,
|
||||
auraIf: () => true,
|
||||
defaultValue: "",
|
||||
placeHolder: "输入相对路径, 例如: config/vme50/cert.crt",
|
||||
valueGetter: () => {
|
||||
if (!global.__HUGO_AURA__.plsSettings) return "";
|
||||
return global.__HUGO_AURA__.plsSettings.certPath;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
const validate = reusableChkFn.checkRelativePath();
|
||||
if (!validate.valid) {
|
||||
return validate;
|
||||
}
|
||||
|
||||
global.__HUGO_AURA__.plsSettings.certPath = newVal;
|
||||
updatePlsConfigToRemote("certPath", newVal);
|
||||
return { valid: true };
|
||||
},
|
||||
},
|
||||
{
|
||||
index: 2,
|
||||
id: "plsCertPath",
|
||||
type: "input",
|
||||
subType: "text",
|
||||
name: "WSS TLS 证书私钥相对路径",
|
||||
description: "PLS 将使用指定路径下的私钥启动 WSS 服务器",
|
||||
reactive: true,
|
||||
reactiveVal: ["root.settings"],
|
||||
restart: false,
|
||||
reload: false,
|
||||
PLSRequired: true,
|
||||
restartPLS: true,
|
||||
tip: true,
|
||||
tipTitle:
|
||||
'路径相对于 "%PROGRAMDATA%\\HugoAura\\Aura-PLS\\", 使用 "/" 作为路径符',
|
||||
warning: true,
|
||||
warningContent: "请使用 PEM 格式的密钥",
|
||||
associateVal: null,
|
||||
auraIf: () => true,
|
||||
defaultValue: "",
|
||||
placeHolder: "输入相对路径, 例如: config/vme50/cert.key",
|
||||
valueGetter: () => {
|
||||
if (!global.__HUGO_AURA__.plsSettings) return "";
|
||||
return global.__HUGO_AURA__.plsSettings.keyPath;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
const validate = reusableChkFn.checkRelativePath();
|
||||
if (!validate.valid) {
|
||||
return validate;
|
||||
}
|
||||
|
||||
global.__HUGO_AURA__.plsSettings.keyPath = newVal;
|
||||
updatePlsConfigToRemote("keyPath", newVal);
|
||||
return { valid: true };
|
||||
},
|
||||
},
|
||||
{
|
||||
index: 3,
|
||||
id: "plsRegenCertAftRelaunch",
|
||||
type: "switch",
|
||||
name: "重新生成 TLS 证书",
|
||||
description: "PLS 将在下次启动时重新生成 TLS 证书",
|
||||
reactive: true,
|
||||
reactiveVal: ["root.settings"],
|
||||
restart: false,
|
||||
reload: false,
|
||||
PLSRequired: true,
|
||||
restartPLS: true,
|
||||
associateVal: null,
|
||||
auraIf: () => true,
|
||||
defaultValue: false,
|
||||
valueGetter: () => {
|
||||
if (!global.__HUGO_AURA__.aikariSettings) return "";
|
||||
return global.__HUGO_AURA__.aikariSettings.tls.regenWsCertNextLaunch;
|
||||
if (!global.__HUGO_AURA__.plsSettings) return "";
|
||||
return global.__HUGO_AURA__.plsSettings.regenCert;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
if (typeof newVal !== "boolean") return false;
|
||||
|
||||
global.__HUGO_AURA__.aikariSettings.tls.regenWsCertNextLaunch =
|
||||
newVal;
|
||||
updateAikariConfigToRemote("tls.regenWsCertNextLaunch", newVal);
|
||||
global.__HUGO_AURA__.plsSettings.regenCert = newVal;
|
||||
updatePlsConfigToRemote("regenCert", newVal);
|
||||
return true;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,259 +0,0 @@
|
||||
// [!] Will be deprecated
|
||||
|
||||
const REQUIRE_BASE = ".";
|
||||
|
||||
const {
|
||||
updateAikariPLSRulesToRemote,
|
||||
} = require(`${REQUIRE_BASE}/../../../../composables/aikariConfigManager`);
|
||||
|
||||
const composables = {};
|
||||
|
||||
const deviceInfoPostSettings = [
|
||||
{
|
||||
id: 0,
|
||||
categoryName: "冰点管理",
|
||||
child: [
|
||||
{
|
||||
index: 0,
|
||||
id: "enableFreezeInfoReportOverride",
|
||||
type: "switch",
|
||||
name: "启用冰冻状态篡改",
|
||||
description: "篡改上报的冰冻数据, 可自定义集控端显示的状态",
|
||||
reactive: true,
|
||||
reactiveVal: ["root.ruleSettings"],
|
||||
restart: false,
|
||||
reload: false,
|
||||
aikariRequired: true,
|
||||
restartAikari: false,
|
||||
associateVal: null,
|
||||
auraIf: () => true,
|
||||
defaultValue: false,
|
||||
valueGetter: () => {
|
||||
if (!global.__HUGO_AURA__.aikariRules) return "";
|
||||
return global.__HUGO_AURA__.aikariRules.ssaFeatures.securityPolicies
|
||||
.freezeManagement.freezeDiskInfoPost.enabled;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
if (typeof newVal !== "boolean") return;
|
||||
if (!global.__HUGO_AURA__.aikariRules) return;
|
||||
|
||||
global.__HUGO_AURA__.aikariRules.ssaFeatures.securityPolicies.freezeManagement.freezeDiskInfoPost.enabled =
|
||||
newVal;
|
||||
updateAikariPLSRulesToRemote(
|
||||
"ssaFeatures.securityPolicies.freezeManagement.freezeDiskInfoPost.enabled",
|
||||
newVal,
|
||||
"ssaFeatures.securityPolicies.freezeManagement.freezeDiskInfoPost"
|
||||
);
|
||||
return true;
|
||||
},
|
||||
},
|
||||
{
|
||||
index: 1,
|
||||
id: "freezeInfoReportFrozenDisks",
|
||||
type: "checkbox",
|
||||
name: "被冻结的磁盘",
|
||||
description: "选中的磁盘会<b>被上报</b>为冻结 (不是实际行为)",
|
||||
restart: false,
|
||||
reload: false,
|
||||
aikariRequired: true,
|
||||
restartAikari: false,
|
||||
warning: true,
|
||||
warningContent:
|
||||
"如果可选的磁盘盘符与下方预览不一致, 则多出的盘符可能为 DVD 驱动器 / 软盘 / 可移动磁盘, 忽略即可",
|
||||
reactive: true,
|
||||
reactiveVal: ["root.ruleSettings"],
|
||||
associateVal: [
|
||||
"ssaFeatures.securityPolicies.freezeManagement.freezeDiskInfoPost.enabled",
|
||||
],
|
||||
auraIf: () => true,
|
||||
auraDisable: () => {
|
||||
if (!global.__HUGO_AURA__.aikariRules) return { value: true };
|
||||
if (
|
||||
!global.__HUGO_AURA_UI_REACTIVES__.subConfig.behaviourCtrlShared
|
||||
.diskCaptions
|
||||
)
|
||||
return {
|
||||
value: true,
|
||||
tooltip: "发生错误, 请上报至 HugoAura GitHub Issues",
|
||||
};
|
||||
if (
|
||||
!global.__HUGO_AURA_UI_REACTIVES__.subConfig.behaviourCtrlShared
|
||||
.diskCaptions.length === 0
|
||||
)
|
||||
return {
|
||||
value: true,
|
||||
tooltip: "发生错误, 请上报至 HugoAura GitHub Issues",
|
||||
};
|
||||
|
||||
return {
|
||||
value:
|
||||
!global.__HUGO_AURA__.aikariRules.ssaFeatures.securityPolicies
|
||||
.freezeManagement.freezeDiskInfoPost.enabled,
|
||||
tooltip: "启用冰冻状态篡改以继续",
|
||||
};
|
||||
},
|
||||
defaultValue: [],
|
||||
templates: () => {
|
||||
try {
|
||||
if (
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.behaviourCtrlShared
|
||||
.diskCaptions.length === 0
|
||||
) {
|
||||
return ["error"];
|
||||
} else {
|
||||
return global.__HUGO_AURA_UI_REACTIVES__.subConfig.behaviourCtrlShared.diskCaptions.map(
|
||||
(element) => {
|
||||
return element.toLowerCase().replace(/:/g, "");
|
||||
}
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return ["error"];
|
||||
}
|
||||
},
|
||||
templateLabels: () => {
|
||||
try {
|
||||
if (
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.behaviourCtrlShared
|
||||
.diskCaptions.length === 0
|
||||
) {
|
||||
return ["获取盘符时发生错误, 请上报至 GitHub Issues"];
|
||||
} else {
|
||||
return global.__HUGO_AURA_UI_REACTIVES__.subConfig.behaviourCtrlShared.diskCaptions.map(
|
||||
(element) => {
|
||||
return element.replace(/:/g, " 盘");
|
||||
}
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return ["发生未知错误"];
|
||||
}
|
||||
},
|
||||
valueGetter: () => {
|
||||
if (!global.__HUGO_AURA__.aikariRules) return [];
|
||||
|
||||
return global.__HUGO_AURA__.aikariRules.ssaFeatures.securityPolicies
|
||||
.freezeManagement.freezeDiskInfoPost.frozenDisks;
|
||||
},
|
||||
callbackFn: (affectedData, affectedEl) => {
|
||||
const targetArr =
|
||||
global.__HUGO_AURA__.aikariRules.ssaFeatures.securityPolicies
|
||||
.freezeManagement.freezeDiskInfoPost.frozenDisks;
|
||||
if (affectedEl.checked) {
|
||||
targetArr.push(affectedData);
|
||||
} else {
|
||||
targetArr.splice(targetArr.indexOf(affectedData), 1);
|
||||
}
|
||||
updateAikariPLSRulesToRemote(
|
||||
"ssaFeatures.securityPolicies.freezeManagement.freezeDiskInfoPost.frozenDisks",
|
||||
targetArr,
|
||||
"ssaFeatures.securityPolicies.freezeManagement.freezeDiskInfoPost"
|
||||
);
|
||||
return true;
|
||||
},
|
||||
},
|
||||
{
|
||||
index: 2,
|
||||
id: "freezeInfoReportOverridePreview",
|
||||
type: "preview",
|
||||
loaderTarget:
|
||||
"Aura.UI.Assistant.Config.BehaviourCtrl.DeviceSecurity.FreezeOverridePreview",
|
||||
associateVal: [
|
||||
"ssaFeatures.securityPolicies.freezeManagement.freezeDiskInfoPost.frozenDisks",
|
||||
],
|
||||
listenerType: "aikari",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
categoryName: "软件信息",
|
||||
child: [
|
||||
{
|
||||
index: 0,
|
||||
id: "enableSoftwareReportPostOverride",
|
||||
type: "switch",
|
||||
name: "启用软件信息上报覆写",
|
||||
description:
|
||||
'覆写上报的软件信息, 可自定义集控端 "设备管控" - <设备名> - "软件列表" 下的信息显示',
|
||||
reactive: true,
|
||||
reactiveVal: ["root.ruleSettings"],
|
||||
restart: false,
|
||||
reload: false,
|
||||
aikariRequired: true,
|
||||
restartAikari: false,
|
||||
warning: true,
|
||||
warningContent: '此功能与 "弹窗拦截" 等无关',
|
||||
associateVal: null,
|
||||
auraIf: () => true,
|
||||
defaultValue: false,
|
||||
valueGetter: () => {
|
||||
if (!global.__HUGO_AURA__.aikariRules) return false;
|
||||
return global.__HUGO_AURA__.aikariRules.deviceInfo.software
|
||||
.softwareReportPost.enabled;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
if (typeof newVal !== "boolean") return;
|
||||
if (!global.__HUGO_AURA__.aikariRules) return;
|
||||
|
||||
global.__HUGO_AURA__.aikariRules.deviceInfo.software.softwareReportPost.enabled =
|
||||
newVal;
|
||||
updateAikariPLSRulesToRemote(
|
||||
"deviceInfo.software.softwareReportPost.enabled",
|
||||
newVal,
|
||||
"deviceInfo.software.softwareReportPost"
|
||||
);
|
||||
return true;
|
||||
},
|
||||
},
|
||||
{
|
||||
index: 1,
|
||||
id: "enableSoftwareReportPostSetAsEmpty",
|
||||
type: "switch",
|
||||
name: "清空软件上报列表",
|
||||
description: "将上报列表置空, 集控端将无法看到任何已安装应用",
|
||||
reactive: true,
|
||||
reactiveVal: ["root.ruleSettings"],
|
||||
restart: false,
|
||||
reload: false,
|
||||
aikariRequired: true,
|
||||
restartAikari: false,
|
||||
associateVal: ["deviceInfo.software.softwareReportPost.enabled"],
|
||||
auraIf: () => true,
|
||||
auraDisable: () => {
|
||||
if (!global.__HUGO_AURA__.aikariRules) return { value: true };
|
||||
|
||||
return {
|
||||
value:
|
||||
!global.__HUGO_AURA__.aikariRules.deviceInfo.software
|
||||
.softwareReportPost.enabled,
|
||||
tooltip: "启用软件信息上报覆写以继续",
|
||||
};
|
||||
},
|
||||
defaultValue: true,
|
||||
valueGetter: () => {
|
||||
if (!global.__HUGO_AURA__.aikariRules) return true;
|
||||
return global.__HUGO_AURA__.aikariRules.deviceInfo.software
|
||||
.softwareReportPost.setAsEmpty;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
if (typeof newVal !== "boolean") return;
|
||||
if (!global.__HUGO_AURA__.aikariRules) return;
|
||||
|
||||
global.__HUGO_AURA__.aikariRules.deviceInfo.software.softwareReportPost.setAsEmpty =
|
||||
newVal;
|
||||
updateAikariPLSRulesToRemote(
|
||||
"deviceInfo.software.softwareReportPost.setAsEmpty",
|
||||
newVal,
|
||||
"deviceInfo.software.softwareReportPost"
|
||||
);
|
||||
return true;
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
module.exports = { deviceInfoPostSettings };
|
||||
99
src/aura/ui/pages/configSubPages/behaviourCtrl/settings/deviceSecurity.js
Executable file
99
src/aura/ui/pages/configSubPages/behaviourCtrl/settings/deviceSecurity.js
Executable file
@@ -0,0 +1,99 @@
|
||||
const REQUIRE_BASE = ".";
|
||||
|
||||
const {
|
||||
updatePlsConfigToRemote,
|
||||
} = require(`${REQUIRE_BASE}/../../../../composables/plsConfigManager`);
|
||||
|
||||
const composables = {};
|
||||
|
||||
const deviceSecuritySettings = [
|
||||
{
|
||||
id: 0,
|
||||
categoryName: "冰点管理",
|
||||
child: [
|
||||
{
|
||||
index: 0,
|
||||
id: "enableFreezeInfoReportOverride",
|
||||
type: "switch",
|
||||
name: "启用冰冻状态篡改",
|
||||
description: "篡改上报的冰冻数据, 可自定义集控端显示的状态",
|
||||
reactive: true,
|
||||
reactiveVal: ["root.ruleSettings"],
|
||||
restart: false,
|
||||
reload: false,
|
||||
PLSRequired: true,
|
||||
restartPLS: false,
|
||||
associateVal: null,
|
||||
auraIf: () => true,
|
||||
defaultValue: false,
|
||||
valueGetter: () => {
|
||||
if (!global.__HUGO_AURA__.plsRules) return "";
|
||||
return global.__HUGO_AURA__.plsRules.client.security.uploadFreezeInfo
|
||||
.enable;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
if (typeof newVal !== "boolean") return;
|
||||
if (!global.__HUGO_AURA__.plsRules) return;
|
||||
|
||||
global.__HUGO_AURA__.plsRules.client.security.uploadFreezeInfo.enable =
|
||||
newVal;
|
||||
updatePlsConfigToRemote(
|
||||
"ruleSettings.client.security.uploadFreezeInfo.enable",
|
||||
newVal
|
||||
);
|
||||
return true;
|
||||
},
|
||||
},
|
||||
{
|
||||
index: 1,
|
||||
id: "freezeInfoReportOverrideType",
|
||||
type: "radio",
|
||||
name: "篡改模式",
|
||||
description:
|
||||
"选择一种篡改模式, 选中的磁盘范围会<b>被上报</b>为冻结 (不是实际行为)",
|
||||
restart: false,
|
||||
reload: false,
|
||||
PLSRequired: true,
|
||||
restartPLS: false,
|
||||
reactive: true,
|
||||
reactiveVal: ["root.ruleSettings"],
|
||||
associateVal: ["ruleSettings.client.security.uploadFreezeInfo.enable"],
|
||||
auraIf: () => {
|
||||
if (!global.__HUGO_AURA__.plsRules) return true;
|
||||
|
||||
return global.__HUGO_AURA__.plsRules.client.security.uploadFreezeInfo
|
||||
.enable;
|
||||
},
|
||||
defaultValue: "allFreeze",
|
||||
templates: ["allFreeze", "systemOnly", "exceptSecondDisk"],
|
||||
templateLabels: ["全部冻结", "仅系统盘", "第二磁盘除外"],
|
||||
valueGetter: () => {
|
||||
if (!global.__HUGO_AURA__.plsRules) return;
|
||||
|
||||
return global.__HUGO_AURA__.plsRules.client.security.uploadFreezeInfo
|
||||
.rewriteMode;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
global.__HUGO_AURA__.plsRules.client.security.uploadFreezeInfo.rewriteMode =
|
||||
newVal;
|
||||
updatePlsConfigToRemote(
|
||||
"ruleSettings.client.security.uploadFreezeInfo.rewriteMode",
|
||||
newVal
|
||||
);
|
||||
return true;
|
||||
},
|
||||
},
|
||||
{
|
||||
index: 2,
|
||||
id: "freezeInfoReportOverridePreview",
|
||||
type: "preview",
|
||||
loaderTarget:
|
||||
"Aura.UI.Assistant.Config.BehaviourCtrl.DeviceSecurity.FreezeOverridePreview",
|
||||
associateVal: ["ruleSettings.client.security.uploadFreezeInfo"],
|
||||
listenerType: "pls",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
module.exports = { deviceSecuritySettings };
|
||||
@@ -36,8 +36,8 @@
|
||||
resolve({
|
||||
success: true,
|
||||
data: null,
|
||||
status: response.status,
|
||||
});
|
||||
status: response.status
|
||||
})
|
||||
}
|
||||
|
||||
const parsedData = await response.json();
|
||||
@@ -84,7 +84,7 @@
|
||||
|
||||
const diskElTemplate = document.createElement("p");
|
||||
diskElTemplate.classList.add("acs-bc-dsc-fop-disk-el");
|
||||
if (!curConfig.enabled) {
|
||||
if (!curConfig.enable) {
|
||||
for (const disk of curDisks) {
|
||||
const curDiskEl = diskElTemplate.cloneNode();
|
||||
if (disk.status !== 0) {
|
||||
@@ -95,16 +95,44 @@
|
||||
diskContainerEl.appendChild(curDiskEl);
|
||||
}
|
||||
} else {
|
||||
let idx = 0;
|
||||
for (const disk of curDisks) {
|
||||
const curDiskEl = diskElTemplate.cloneNode();
|
||||
if (curConfig.frozenDisks.includes(disk.name.toLowerCase())) {
|
||||
// @ts-expect-error
|
||||
curDiskEl.classList.add("active");
|
||||
}
|
||||
curDiskEl.textContent = `${disk.name.toUpperCase()} 盘`;
|
||||
diskContainerEl.appendChild(curDiskEl);
|
||||
idx += 1;
|
||||
switch (curConfig.rewriteMode) {
|
||||
case "allFreeze":
|
||||
{
|
||||
for (const disk of curDisks) {
|
||||
const curDiskEl = diskElTemplate.cloneNode();
|
||||
// @ts-expect-error
|
||||
curDiskEl.classList.add("active");
|
||||
curDiskEl.textContent = `${disk.name.toUpperCase()} 盘`;
|
||||
diskContainerEl.appendChild(curDiskEl);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "systemOnly":
|
||||
{
|
||||
let idx = 0;
|
||||
for (const disk of curDisks) {
|
||||
const curDiskEl = diskElTemplate.cloneNode();
|
||||
// @ts-expect-error
|
||||
if (idx === 0) curDiskEl.classList.add("active");
|
||||
curDiskEl.textContent = `${disk.name.toUpperCase()} 盘`;
|
||||
diskContainerEl.appendChild(curDiskEl);
|
||||
idx += 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "exceptSecondDisk":
|
||||
{
|
||||
let idx = 0;
|
||||
for (const disk of curDisks) {
|
||||
const curDiskEl = diskElTemplate.cloneNode();
|
||||
// @ts-expect-error
|
||||
if (idx === 0) curDiskEl.classList.add("active");
|
||||
curDiskEl.textContent = `${disk.name.toUpperCase()} 盘`;
|
||||
diskContainerEl.appendChild(curDiskEl);
|
||||
idx += 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,10 +148,9 @@
|
||||
)[0];
|
||||
|
||||
const eventListener = (_event) => {
|
||||
if (!global.__HUGO_AURA__.aikariRules) return;
|
||||
if (!global.__HUGO_AURA__.plsRules) return;
|
||||
composables.getAndUpdateDiskInfo(
|
||||
global.__HUGO_AURA__.aikariRules.ssaFeatures.securityPolicies
|
||||
.freezeManagement.freezeDiskInfoPost
|
||||
global.__HUGO_AURA__.plsRules.client.security.uploadFreezeInfo
|
||||
);
|
||||
};
|
||||
rootEl.addEventListener("onAssociateValueUpdated", eventListener);
|
||||
|
||||
@@ -31,20 +31,6 @@
|
||||
上报屏蔽
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button
|
||||
class="nav-link"
|
||||
id="appearance-ctl-tab"
|
||||
data-bs-toggle="pill"
|
||||
data-bs-target="#appearance-ctl-subpage"
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-controls="appearance-ctl-subpage"
|
||||
aria-selected="false"
|
||||
>
|
||||
外观与体验
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div
|
||||
@@ -59,11 +45,5 @@
|
||||
role="tabpanel"
|
||||
aria-labelledby="disable-audit-tab"
|
||||
></div>
|
||||
<div
|
||||
class="tab-pane fade"
|
||||
id="appearance-ctl-subpage"
|
||||
role="tabpanel"
|
||||
aria-labelledby="appearance-ctl-tab"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
} = require("../../aura/ui/composables/settingsRenderer");
|
||||
const { authSettings } = require(`${pathBase}/auth`);
|
||||
const { banAuditSettings } = require(`${pathBase}/audit`);
|
||||
const { uxAndAppearanceSettings } = require(`${pathBase}/uxAppearance`);
|
||||
|
||||
const initAuthSubPage = () => {
|
||||
const authSubPageEl = document.getElementById("auth-subpage");
|
||||
@@ -19,17 +18,9 @@
|
||||
settingsRenderer(banAuditSubPageEl, banAuditSettings);
|
||||
};
|
||||
|
||||
const initUxAndAppearanceSubPage = () => {
|
||||
const uxAndAppearancePageEl = document.getElementById(
|
||||
"appearance-ctl-subpage"
|
||||
);
|
||||
settingsRenderer(uxAndAppearancePageEl, uxAndAppearanceSettings);
|
||||
};
|
||||
|
||||
const onMounted = () => {
|
||||
initAuthSubPage();
|
||||
initBanAuditSubPage();
|
||||
initUxAndAppearanceSubPage();
|
||||
|
||||
const rootEl = document.getElementById("acs-disable-limit-root-el");
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
const uxAndAppearanceSettings = [
|
||||
{
|
||||
id: 0,
|
||||
categoryName: "管家助手",
|
||||
child: [
|
||||
{
|
||||
index: 0,
|
||||
id: "autoHideEasiAssistant",
|
||||
type: "switch",
|
||||
name: "自动最小化管家助手",
|
||||
description: "管家启动后, 自动将桌面右下角管家助手最小化至 Fab 形态",
|
||||
restart: true,
|
||||
reload: false,
|
||||
associateVal: ["ssa.ux.easiAssistant.notDisplay"],
|
||||
auraIf: () => true,
|
||||
defaultValue: false,
|
||||
auraDisable: () => {
|
||||
if (global.__HUGO_AURA_CONFIG__.ssa.ux.easiAssistant.notDisplay) {
|
||||
return { value: true, tooltip: '禁用 "隐藏管家助手" 以继续' };
|
||||
} else {
|
||||
return { value: false };
|
||||
}
|
||||
},
|
||||
valueGetter: () => {
|
||||
return global.__HUGO_AURA_CONFIG__.ssa.ux.easiAssistant.autoHide;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
if (typeof newVal !== "boolean") return;
|
||||
global.__HUGO_AURA_CONFIG__.ssa.ux.easiAssistant.autoHide = newVal;
|
||||
},
|
||||
},
|
||||
{
|
||||
index: 1,
|
||||
id: "notDisplayEasiAssistant",
|
||||
type: "switch",
|
||||
name: "隐藏管家助手",
|
||||
description: "管家启动后, 管家助手窗口将不再显示",
|
||||
restart: true,
|
||||
reload: false,
|
||||
associateVal: ["ssa.ux.easiAssistant.autoHide"],
|
||||
auraIf: () => true,
|
||||
defaultValue: false,
|
||||
auraDisable: () => {
|
||||
if (global.__HUGO_AURA_CONFIG__.ssa.ux.easiAssistant.autoHide) {
|
||||
return { value: true, tooltip: '禁用 "自动最小化管家助手" 以继续' };
|
||||
} else {
|
||||
return { value: false };
|
||||
}
|
||||
},
|
||||
valueGetter: () => {
|
||||
return global.__HUGO_AURA_CONFIG__.ssa.ux.easiAssistant.notDisplay;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
if (typeof newVal !== "boolean") return;
|
||||
global.__HUGO_AURA_CONFIG__.ssa.ux.easiAssistant.notDisplay = newVal;
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
module.exports = { uxAndAppearanceSettings };
|
||||
@@ -17,20 +17,6 @@
|
||||
Aura 设置
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button
|
||||
class="nav-link"
|
||||
id="debug-subpage-tab"
|
||||
data-bs-toggle="pill"
|
||||
data-bs-target="#debug-subpage"
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-controls="debug-subpage"
|
||||
aria-selected="false"
|
||||
>
|
||||
调试选项
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button
|
||||
class="nav-link"
|
||||
@@ -40,7 +26,7 @@
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-controls="about-subpage"
|
||||
aria-selected="false"
|
||||
aria-selected="true"
|
||||
>
|
||||
关于项目
|
||||
</button>
|
||||
@@ -53,12 +39,6 @@
|
||||
role="tabpanel"
|
||||
aria-labelledby="aura-subpage-tab"
|
||||
></div>
|
||||
<div
|
||||
class="tab-pane fade"
|
||||
id="debug-subpage"
|
||||
role="tabpanel"
|
||||
aria-labelledby="debug-subpage-tab"
|
||||
></div>
|
||||
<div
|
||||
class="tab-pane fade"
|
||||
id="about-subpage"
|
||||
|
||||
@@ -5,21 +5,13 @@
|
||||
settingsRenderer,
|
||||
} = require("../../aura/ui/composables/settingsRenderer");
|
||||
const { auraSettings } = require(`${pathBase}/aura`);
|
||||
const { debugSettings } = require(`${pathBase}/debug`);
|
||||
|
||||
const initAuraSubPage = () => {
|
||||
const auraSettingsSubPageEl = document.getElementById("aura-subpage");
|
||||
settingsRenderer(auraSettingsSubPageEl, auraSettings);
|
||||
};
|
||||
|
||||
const initDebugSubPage = () => {
|
||||
const debugSubPageEl = document.getElementById("debug-subpage");
|
||||
settingsRenderer(debugSubPageEl, debugSettings);
|
||||
};
|
||||
|
||||
const onMounted = () => {
|
||||
initAuraSubPage();
|
||||
initDebugSubPage();
|
||||
|
||||
const rootEl = document.getElementById("acs-preferences-root-el");
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -142,10 +142,6 @@ const functions = {
|
||||
}
|
||||
};
|
||||
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.config.resetAuthDialogInputElOnSubmit(
|
||||
verifyPassword
|
||||
);
|
||||
|
||||
// @ts-expect-error
|
||||
acpDialogConfirmBtnEl.onclick = verifyPassword;
|
||||
// @ts-expect-error
|
||||
@@ -445,35 +441,6 @@ const auraSettings = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
categoryName: "外观",
|
||||
child: [
|
||||
{
|
||||
index: 0,
|
||||
id: "actionBtnsOnRight",
|
||||
type: "switch",
|
||||
name: "顶栏操作类按钮右置",
|
||||
description: "启用后, 顶栏的<b>返回首页按钮</b>将靠右放置",
|
||||
restart: false,
|
||||
reload: false,
|
||||
auraIf: () => {
|
||||
return true;
|
||||
},
|
||||
defaultValue: false,
|
||||
valueGetter: () => {
|
||||
return global.__HUGO_AURA_CONFIG__.auraSettings.appearance.appBar
|
||||
.actionBtnsOnRight;
|
||||
},
|
||||
callbackFn: async (newVal) => {
|
||||
if (typeof newVal !== "boolean") return;
|
||||
global.__HUGO_AURA_CONFIG__.auraSettings.appearance.appBar.actionBtnsOnRight =
|
||||
newVal;
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.config.initCustomUIProps(true);
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
module.exports = { auraSettings };
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
const IPC_METHOD_BASE = "$aura.debug";
|
||||
|
||||
const path = require("path");
|
||||
|
||||
const debugSettings = [
|
||||
{
|
||||
id: 0,
|
||||
categoryName: "日志与输出",
|
||||
child: [
|
||||
{
|
||||
index: 0,
|
||||
id: "openHugoAuraLogDir",
|
||||
type: "button",
|
||||
style: "outline",
|
||||
name: "HugoAura 日志目录",
|
||||
description: "",
|
||||
restart: false,
|
||||
reload: false,
|
||||
associateVal: null,
|
||||
auraIf: () => true,
|
||||
buttonContent: "打开",
|
||||
valueGetter: async () => {
|
||||
if (
|
||||
global.__HUGO_AURA__.auraDir &&
|
||||
global.__HUGO_AURA__.auraDir !== ""
|
||||
) {
|
||||
return (
|
||||
"目录位置: " + path.join(global.__HUGO_AURA__.auraDir, "logs")
|
||||
);
|
||||
} else {
|
||||
return "未能获取日志目录位置";
|
||||
}
|
||||
},
|
||||
callbackFn: async (event) => {
|
||||
const childProc = require("child_process");
|
||||
childProc.spawn(`explorer.exe`, [
|
||||
`${path.join(global.__HUGO_AURA__.auraDir, "logs")}`,
|
||||
]);
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
module.exports = { debugSettings };
|
||||
@@ -7,7 +7,7 @@
|
||||
transition: opacity 0.25s;
|
||||
}
|
||||
|
||||
#root.aura-header-icon-hidden .aura-header-icon {
|
||||
.aura-header-icon.aura-header-icon-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,19 +9,15 @@ global.__HUGO_AURA_UI_FUNCTIONS__.headerIcon = {
|
||||
let clickCounter = 0;
|
||||
let clickTimeout = null;
|
||||
|
||||
const onMounted = (revive = false) => {
|
||||
if (
|
||||
!global.__HUGO_AURA_CONFIG__.auraSettings.uiAccessMethod.showEntryIcon &&
|
||||
!revive
|
||||
) {
|
||||
const rootEl = document.getElementById("root");
|
||||
rootEl.classList.add("aura-header-icon-hidden");
|
||||
const onMounted = () => {
|
||||
if (!global.__HUGO_AURA_CONFIG__.auraSettings.uiAccessMethod.showEntryIcon) {
|
||||
const iconEl = document.getElementsByClassName("aura-header-icon")[0];
|
||||
iconEl.classList.add("aura-header-icon-hidden");
|
||||
}
|
||||
|
||||
if (
|
||||
global.__HUGO_AURA_CONFIG__.auraSettings.uiAccessMethod
|
||||
.fallbackAccessMethods.hotkey &&
|
||||
!revive
|
||||
.fallbackAccessMethods.hotkey
|
||||
) {
|
||||
document.addEventListener("keydown", (event) => {
|
||||
if (event.ctrlKey && event.shiftKey && event.key === "A") {
|
||||
@@ -55,11 +51,4 @@ global.__HUGO_AURA_UI_FUNCTIONS__.headerIcon = {
|
||||
};
|
||||
|
||||
onMounted();
|
||||
|
||||
document.addEventListener(
|
||||
"onLoaderElRevive:Aura.UI.Assistant.HeaderEntry",
|
||||
() => {
|
||||
onMounted(true);
|
||||
}
|
||||
);
|
||||
})();
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Aura WebSocket KeepAlive Window</title>
|
||||
<style>
|
||||
:root {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
let global = window;
|
||||
</script>
|
||||
<script src="../../../js/aikariConnectionManager.js"></script>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
2
src/aura/ui/aikari/pushHandler.js → src/aura/ui/pls/pushHandler.js
Normal file → Executable file
2
src/aura/ui/aikari/pushHandler.js → src/aura/ui/pls/pushHandler.js
Normal file → Executable file
@@ -7,7 +7,7 @@ const { configRouteHandler } = require(`${REQUIRE_BASE}/routes/config`);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {AikariPush} parsedWsMsg
|
||||
* @param {PLSPush} parsedWsMsg
|
||||
* @returns
|
||||
*/
|
||||
const pushMsgHandler = (parsedWsMsg) => {
|
||||
48
src/aura/ui/pls/routes/basic.js
Executable file
48
src/aura/ui/pls/routes/basic.js
Executable file
@@ -0,0 +1,48 @@
|
||||
// @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 };
|
||||
8
src/aura/ui/aikari/routes/config.js → src/aura/ui/pls/routes/config.js
Normal file → Executable file
8
src/aura/ui/aikari/routes/config.js → src/aura/ui/pls/routes/config.js
Normal file → Executable file
@@ -1,10 +1,10 @@
|
||||
// @ts-check
|
||||
|
||||
const IPC_METHOD_BASE = "$aura.aikari";
|
||||
const IPC_METHOD_BASE = "$aura.pls";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {AikariPush} parsedWsMsg
|
||||
* @param {PLSPush} parsedWsMsg
|
||||
* @returns
|
||||
*/
|
||||
const configRouteHandler = (parsedWsMsg) => {
|
||||
@@ -12,13 +12,13 @@ const configRouteHandler = (parsedWsMsg) => {
|
||||
switch (target) {
|
||||
case "pushBasicConfig":
|
||||
global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updateAikariSettings`,
|
||||
`${IPC_METHOD_BASE}.updatePlsSettings`,
|
||||
parsedWsMsg.data
|
||||
);
|
||||
break;
|
||||
case "pushRuleSettings":
|
||||
global.ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.updateAikariRules`,
|
||||
`${IPC_METHOD_BASE}.updatePlsRules`,
|
||||
parsedWsMsg.data
|
||||
);
|
||||
break;
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 39 KiB |
BIN
src/aura/ui/static/aura_pls.png
Executable file
BIN
src/aura/ui/static/aura_pls.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
@@ -1,40 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
/**
|
||||
* @param {Electron} electron
|
||||
*/
|
||||
const createWsWindow = (electron) => {
|
||||
const path = require("path");
|
||||
const { BrowserWindow } = electron;
|
||||
const window = new BrowserWindow({
|
||||
width: 0,
|
||||
height: 0,
|
||||
frame: false,
|
||||
skipTaskbar: true,
|
||||
transparent: true,
|
||||
alwaysOnTop: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
devTools: true,
|
||||
},
|
||||
});
|
||||
|
||||
window.setIgnoreMouseEvents(true);
|
||||
window.minimize();
|
||||
window.loadFile(
|
||||
path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
"ui",
|
||||
"pages",
|
||||
"windows",
|
||||
"auraWsKeepAlive",
|
||||
"index.html"
|
||||
)
|
||||
);
|
||||
|
||||
return window;
|
||||
};
|
||||
|
||||
module.exports = { createWsWindow };
|
||||
@@ -6,7 +6,6 @@ if (!global.__HUGO_AURA__) {
|
||||
configInit: false,
|
||||
central: () => {},
|
||||
ipcInit: false,
|
||||
auraDir: "",
|
||||
plsStats: null,
|
||||
plsSettings: null,
|
||||
plsRules: null,
|
||||
@@ -25,9 +24,9 @@ if (!global.__HUGO_AURA_API__) {
|
||||
"https://api-aura.asaka.site",
|
||||
"https://api.hugoaura.dpdns.org",
|
||||
"https://api-aura-projekts.minorice.moe",
|
||||
"https://api.aura.vim.moe",
|
||||
"https://api.aura.vim.moe"
|
||||
],
|
||||
aikariUpdate: "/api/getAikariLatestVersion",
|
||||
plsUpdate: "/api/getPLSLatestVersion",
|
||||
auraUpdate: "/api/getAuraLatestVersion",
|
||||
};
|
||||
global.__HUGO_AURA_API__ = __HUGO_AURA_API__;
|
||||
@@ -37,46 +36,15 @@ if (!global.__HUGO_AURA_CONFIG__) {
|
||||
global.__HUGO_AURA_CONFIG__ = {};
|
||||
}
|
||||
|
||||
const path = require("path");
|
||||
const os = require("os");
|
||||
|
||||
const MainProcessHooksManager = require("../aura/init/main/windowHooksManager");
|
||||
const RendererHooksManager = require("../aura/init/rendererHook/uiHooksManager");
|
||||
const EventBus = require("../aura/utils/eventBus");
|
||||
const NetworkHook = require("../aura/init/rendererHook/networkHook");
|
||||
const ConfigManager = require("../aura/init/shared/configManager");
|
||||
const RegistryManager = require("../aura/init/shared/registryManager");
|
||||
const { buildIpcMain } = require("../aura/init/main/ipcHandler");
|
||||
const plsUtils = require("../aura/utils/pls");
|
||||
|
||||
const { initLogger } = require("../aura/init/main/logger");
|
||||
|
||||
const getUserDocumentsDirPath = () => {
|
||||
const registryManager = new RegistryManager();
|
||||
const pathInfo = registryManager.readRegKeySync(
|
||||
'"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders"',
|
||||
"Personal",
|
||||
false,
|
||||
true,
|
||||
/REG_EXPAND_SZ\s+(.+)/
|
||||
);
|
||||
if (pathInfo.success && pathInfo.data) {
|
||||
const resolvedPath = pathInfo.data.replace(
|
||||
/%([^%]+)%/g,
|
||||
(match, varName) => {
|
||||
return process.env[varName] || match;
|
||||
}
|
||||
);
|
||||
|
||||
return resolvedPath;
|
||||
} else {
|
||||
console.error(
|
||||
"[HugoAura / Init / Logger] Failed to get the path of documents dir, using default val."
|
||||
);
|
||||
return path.join(os.homedir(), "Documents");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../aura/types/main/core").LauncherArgs} param0
|
||||
@@ -98,11 +66,6 @@ const launcher = ({ central, windowName, config }) => {
|
||||
app.exit(0);
|
||||
};
|
||||
|
||||
global.__HUGO_AURA__.auraDir = path.join(
|
||||
getUserDocumentsDirPath(),
|
||||
"HugoAura"
|
||||
);
|
||||
|
||||
// >>> Init Logger <<< //
|
||||
initLogger(windowName);
|
||||
|
||||
@@ -116,7 +79,6 @@ const launcher = ({ central, windowName, config }) => {
|
||||
// >>> Init Config <<< //
|
||||
const configManager = new ConfigManager();
|
||||
configManager.side = "main";
|
||||
configManager.migrateOldConfigFile();
|
||||
configManager.ensureConfigExists();
|
||||
const loadedConfig = configManager.loadConfig();
|
||||
if (!global.__HUGO_AURA__.configInit) global.__HUGO_AURA__.configInit = true;
|
||||
@@ -150,13 +112,6 @@ const launcher = ({ central, windowName, config }) => {
|
||||
config.canOpenDevTool = true;
|
||||
}
|
||||
|
||||
// >>> Create WebSocket KeepAlive Window <<< //
|
||||
if (!global.__HUGO_AURA__.hookedWindows?.has("auraWsKeepAlive")) {
|
||||
const wsKaWin = plsUtils.createWsWindow(electron);
|
||||
// @ts-expect-error
|
||||
global.__HUGO_AURA__.hookedWindows.set("auraWsKeepAlive", wsKaWin);
|
||||
}
|
||||
|
||||
// >>> Listeners <<< //
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
// @ts-check
|
||||
|
||||
const __AURA_VERSION__ = "0.2.0-rc1";
|
||||
const __AURA_VERSION__ = "0.1.1-pre-IV";
|
||||
|
||||
(() => {
|
||||
if (require.main) return; // 如果只是导入 Aura Version, 不运行闭包逻辑
|
||||
|
||||
const auraDir = require("electron").ipcRenderer.sendSync(
|
||||
"$aura.base.getAuraDirSync"
|
||||
);
|
||||
|
||||
// >>> Init Global Vars <<< //
|
||||
if (!global.__HUGO_AURA__) {
|
||||
global.__HUGO_AURA__ = {
|
||||
auraDir: auraDir.data,
|
||||
configInit: true, // preload 始终比 hook 晚, 默认 config 已初始化
|
||||
// ↑ 保留此参数的目的 -> 用于 configManager 中, configManager 的行为在 Renderer 和 Main 中是一致的
|
||||
version: __AURA_VERSION__,
|
||||
|
||||
Reference in New Issue
Block a user