mirror of
https://github.com/HugoAura/Seewo-HugoAura.git
synced 2026-06-25 02:34:26 +08:00
[Feat] Further PLS ctrl & childProc perf improvements
This commit is contained in:
@@ -137,3 +137,62 @@
|
||||
.acs-bc-pls-status-page-status-area.failed p {
|
||||
color: rgb(175, 0, 0);
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-area.warning
|
||||
.acs-bc-pls-status-page-status-area-circle {
|
||||
background-color: rgb(212, 127, 0);
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-area.warning p {
|
||||
color: rgb(212, 127, 0);
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-area.info
|
||||
.acs-bc-pls-status-page-status-area-circle {
|
||||
background-color: #3d78ff;
|
||||
}
|
||||
|
||||
.acs-bc-pls-status-page-status-area.info p {
|
||||
color: #3d78ff;
|
||||
}
|
||||
|
||||
.acs-bc-psp-toast.body-display-none .toast-body {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.acs-bc-psp-toast.body-display-none .toast-header {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.acs-bc-psp-toast[closable="false"] .btn-close {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.acs-bc-psp-toast[variant="success"] .toast-header {
|
||||
background-color: rgb(6, 196, 65);
|
||||
color: rgb(255, 255, 255);
|
||||
}
|
||||
|
||||
.acs-bc-psp-toast[variant="warning"] .toast-header {
|
||||
background-color: rgb(225, 178, 44);
|
||||
color: rgb(255 255 255);
|
||||
}
|
||||
|
||||
.acs-bc-psp-toast[variant="error"] .toast-header {
|
||||
background-color: rgb(217, 57, 4);
|
||||
color: rgb(255 255 255);
|
||||
}
|
||||
|
||||
.acs-bc-psp-toast[variant="info"] .toast-header {
|
||||
background-color: rgb(0, 149, 222);
|
||||
color: rgb(255 255 255);
|
||||
}
|
||||
|
||||
.acs-bc-psp-toast[variant="success"] .btn-close,
|
||||
.acs-bc-psp-toast[variant="warning"] .btn-close,
|
||||
.acs-bc-psp-toast[variant="error"] .btn-close,
|
||||
.acs-bc-psp-toast[variant="info"] .btn-close {
|
||||
color: rgb(255, 255, 255);
|
||||
filter: invert(1);
|
||||
opacity: 0.95;
|
||||
}
|
||||
|
||||
@@ -92,6 +92,36 @@
|
||||
</svg>
|
||||
<p>卸载服务</p>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-psp-operation-btn" id="acsBcPsp-operBtn-Start">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 32 32"
|
||||
>
|
||||
<path
|
||||
fill="var(--svg-color)"
|
||||
d="M7 28a1 1 0 0 1-1-1V5a1 1 0 0 1 1.482-.876l20 11a1 1 0 0 1 0 1.752l-20 11A1 1 0 0 1 7 28M8 6.69v18.62L24.925 16Z"
|
||||
/>
|
||||
</svg>
|
||||
<p>启动服务</p>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-psp-operation-btn" id="acsBcPsp-operBtn-Stop">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 32 32"
|
||||
>
|
||||
<path
|
||||
fill="var(--svg-color)"
|
||||
d="M24 8v16H8V8zm0-2H8a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2"
|
||||
/>
|
||||
</svg>
|
||||
<p>停止服务</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-pls-status-page-status-el">
|
||||
@@ -133,4 +163,18 @@
|
||||
<p id="acs-bc-psp-version-text">不可用</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toast-container position-fixed bottom-0 end-0 p-3">
|
||||
<div id="plsStatusNotifyToast" class="acs-bc-psp-toast toast" data-bs-autohide="false">
|
||||
<div class="toast-header">
|
||||
<strong class="me-auto" id="plsStatusNotifyToastTitle"></strong>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-close"
|
||||
data-bs-dismiss="toast"
|
||||
></button>
|
||||
</div>
|
||||
<div class="toast-body" id="plsStatusNotifyToastBody"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,32 +1,254 @@
|
||||
if (!global.__HUGO_AURA_UI_FUNCTIONS__.subConfig)
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig = {};
|
||||
|
||||
if (!global.__HUGO_AURA_UI_REACTIVES__.subConfig)
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig = {};
|
||||
|
||||
(() => {
|
||||
const REQUIRE_BASE = "../../aura/ui/pages/configSubPages/behaviourCtrl";
|
||||
const IPC_METHOD_BASE = "$aura.pls";
|
||||
|
||||
const lifecycleStatus = {
|
||||
installed: false,
|
||||
detached: false,
|
||||
svcInstalled: false,
|
||||
svcRunning: false,
|
||||
};
|
||||
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.plsStatus = {
|
||||
toastAutoHideTimeout: null,
|
||||
};
|
||||
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus = {
|
||||
updateOperationBtnStatus: async (btnName, side, btnContent = null) => {
|
||||
updateToast: async (
|
||||
variant,
|
||||
title,
|
||||
body = null,
|
||||
closable = true,
|
||||
autoHide = true,
|
||||
hideAfter = 3000
|
||||
) => {
|
||||
const toastRootEl = document.getElementById("plsStatusNotifyToast");
|
||||
const toastHeaderEl = document.getElementById(
|
||||
"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.plsStatus
|
||||
.toastAutoHideTimeout;
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
await global.__HUGO_AURA_GLOBAL__.utils.sleep(160);
|
||||
}
|
||||
|
||||
toastRootEl.setAttribute("variant", variant);
|
||||
toastHeaderEl.innerHTML = title;
|
||||
if (body) {
|
||||
toastBodyEl.innerHTML = body;
|
||||
toastRootEl.classList.remove("body-display-none");
|
||||
} else {
|
||||
toastRootEl.classList.add("body-display-none");
|
||||
}
|
||||
|
||||
toastRootEl.setAttribute("closable", closable.toString());
|
||||
|
||||
bsToastIns.show();
|
||||
if (autoHide && hideAfter) {
|
||||
global.__HUGO_AURA_UI_REACTIVES__.subConfig.plsStatus.toastAutoHideTimeout =
|
||||
setTimeout(() => {
|
||||
bsToastIns.hide();
|
||||
}, hideAfter);
|
||||
}
|
||||
},
|
||||
|
||||
updateOperationBtnStatus: async (
|
||||
btnName,
|
||||
isDisabled,
|
||||
btnContent = null
|
||||
) => {
|
||||
const btnEl = document.getElementById(`acsBcPsp-operBtn-${btnName}`);
|
||||
if (!btnEl) return false;
|
||||
btnEl.setAttribute("aura-disabled", side ? "true" : "false");
|
||||
btnEl.setAttribute("aura-disabled", isDisabled ? "true" : "false");
|
||||
if (btnContent) {
|
||||
const btnPEl = btnEl.getElementsByTagName("p")[0];
|
||||
btnPEl.textContent = btnContent;
|
||||
}
|
||||
if (side) {
|
||||
if (isDisabled) {
|
||||
btnEl.onclick = () => {};
|
||||
} else {
|
||||
switch (btnName) {
|
||||
case "Refresh":
|
||||
btnEl.onclick = () =>
|
||||
btnEl.onclick = () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"warning",
|
||||
"正在更新",
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
null
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.refreshPlsStatus();
|
||||
};
|
||||
break;
|
||||
case "Download":
|
||||
break;
|
||||
|
||||
// ↓ 这边的确可以把这些全都合并到一个可复用 fn 里去, 但没必要
|
||||
case "Install":
|
||||
btnEl.onclick = async () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"info",
|
||||
"正在请求安装",
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
null
|
||||
);
|
||||
const ret = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.plsLifecycleControl`,
|
||||
{ target: "instSvc" }
|
||||
);
|
||||
if (ret.success) {
|
||||
lifecycleStatus.svcInstalled = true;
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"success",
|
||||
"服务安装成功",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
2000
|
||||
);
|
||||
} else {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"error",
|
||||
"服务安装失败",
|
||||
"<p>检查日志以获取详细信息</p>",
|
||||
true,
|
||||
false,
|
||||
null
|
||||
);
|
||||
}
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
};
|
||||
break;
|
||||
case "Uninstall":
|
||||
btnEl.onclick = async () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"info",
|
||||
"正在请求卸载",
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
null
|
||||
);
|
||||
const ret = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.plsLifecycleControl`,
|
||||
{ target: "rmSvc" }
|
||||
);
|
||||
if (ret.success) {
|
||||
lifecycleStatus.svcInstalled = false;
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"success",
|
||||
"服务卸载成功",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
2000
|
||||
);
|
||||
} else {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"error",
|
||||
"服务卸载失败",
|
||||
"<p>检查日志以获取详细信息</p>",
|
||||
true,
|
||||
false,
|
||||
null
|
||||
);
|
||||
}
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
};
|
||||
break;
|
||||
case "Start":
|
||||
btnEl.onclick = async () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"info",
|
||||
"正在请求启动",
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
null
|
||||
);
|
||||
const ret = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.plsLifecycleControl`,
|
||||
{ target: "startSvc" }
|
||||
);
|
||||
if (ret.success) {
|
||||
lifecycleStatus.svcRunning = true;
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"success",
|
||||
"PLS 已启动",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
2000
|
||||
);
|
||||
await global.__HUGO_AURA_GLOBAL__.utils.sleep(100);
|
||||
await ipcRenderer.invoke(`${IPC_METHOD_BASE}.retryPlsConnect`);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
} else {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"error",
|
||||
"PLS 启动失败",
|
||||
"<p>检查 PLS 日志目录以获取详细信息</p>",
|
||||
true,
|
||||
false,
|
||||
null
|
||||
);
|
||||
}
|
||||
};
|
||||
break;
|
||||
case "Stop":
|
||||
btnEl.onclick = async () => {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"info",
|
||||
"正在请求停止",
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
null
|
||||
);
|
||||
const ret = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.plsLifecycleControl`,
|
||||
{ target: "stopSvc" }
|
||||
);
|
||||
if (ret.success) {
|
||||
lifecycleStatus.svcRunning = false;
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"success",
|
||||
"PLS 已停止",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
2000
|
||||
);
|
||||
} else {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
"error",
|
||||
"PLS 停止失败",
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
null
|
||||
);
|
||||
}
|
||||
};
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -35,32 +257,59 @@ if (!global.__HUGO_AURA_UI_FUNCTIONS__.subConfig)
|
||||
return true;
|
||||
},
|
||||
|
||||
updateStatus: async () => {
|
||||
updateStatusContent: async () => {
|
||||
const curPlsStats = await updatePlsStatusFromLocal();
|
||||
|
||||
const acIdInst = "acs-bc-psp-installStatus-container";
|
||||
const atIdInst = "acs-bc-psp-installStatus-text";
|
||||
switch (curPlsStats.installed) {
|
||||
switch (lifecycleStatus.installed) {
|
||||
case true:
|
||||
updateStatusEl(acIdInst, atIdInst, "SUCCESS", "已安装");
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Install", false);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Uninstall", false);
|
||||
if (!lifecycleStatus.svcInstalled) {
|
||||
updateStatusEl(acIdInst, atIdInst, "WARNING", "已下载, 服务未安装");
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Install", false);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Uninstall", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", true);
|
||||
} else {
|
||||
updateStatusEl(acIdInst, atIdInst, "SUCCESS", "已安装");
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Install", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Uninstall", false);
|
||||
}
|
||||
break;
|
||||
case false:
|
||||
updateStatusEl(acIdInst, atIdInst, "PENDING", "未安装");
|
||||
updateStatusEl(acIdInst, atIdInst, "PENDING", "未下载");
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Install", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Uninstall", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", true);
|
||||
}
|
||||
|
||||
const acIdLaunch = "acs-bc-psp-launchStatus-container";
|
||||
const atIdLaunch = "acs-bc-psp-launchStatus-text";
|
||||
switch (curPlsStats.launched) {
|
||||
case true:
|
||||
updateStatusEl(acIdLaunch, atIdLaunch, "SUCCESS", "已启动");
|
||||
break;
|
||||
case false:
|
||||
updateStatusEl(acIdLaunch, atIdLaunch, "PENDING", "未启动");
|
||||
break;
|
||||
|
||||
if (lifecycleStatus.detached) {
|
||||
updateStatusEl(acIdLaunch, atIdLaunch, "INFO", "已分离");
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", true);
|
||||
} else if (lifecycleStatus.svcInstalled && lifecycleStatus.installed) {
|
||||
switch (lifecycleStatus.svcRunning || curPlsStats.launched) {
|
||||
case true:
|
||||
if (curPlsStats.status !== "notReady") {
|
||||
updateStatusEl(acIdLaunch, atIdLaunch, "SUCCESS", "已启动");
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", false);
|
||||
} else {
|
||||
updateStatusEl(acIdLaunch, atIdLaunch, "WARNING", "启动中");
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", true);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", false);
|
||||
}
|
||||
break;
|
||||
case false:
|
||||
updateStatusEl(acIdLaunch, atIdLaunch, "PENDING", "未启动");
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Start", false);
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Stop", true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const acIdConn = "acs-bc-psp-connStatus-container";
|
||||
@@ -70,7 +319,11 @@ if (!global.__HUGO_AURA_UI_FUNCTIONS__.subConfig)
|
||||
updateStatusEl(acIdConn, atIdConn, "SUCCESS", "已连接");
|
||||
break;
|
||||
case false:
|
||||
updateStatusEl(acIdConn, atIdConn, "FAILED", "连接失败");
|
||||
if (curPlsStats.status !== "notReady") {
|
||||
updateStatusEl(acIdConn, atIdConn, "FAILED", "连接失败");
|
||||
} else {
|
||||
updateStatusEl(acIdConn, atIdConn, "PENDING", "等待启动");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -82,7 +335,53 @@ if (!global.__HUGO_AURA_UI_FUNCTIONS__.subConfig)
|
||||
}
|
||||
},
|
||||
|
||||
refreshPlsStatus: async () => {
|
||||
refreshPlsStatus: async (init = false) => {
|
||||
const binExistsRet = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.getPlsBinExists`
|
||||
);
|
||||
if (binExistsRet.success && binExistsRet.data.isExists) {
|
||||
lifecycleStatus.installed = true;
|
||||
} else {
|
||||
lifecycleStatus.installed = false;
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
return;
|
||||
}
|
||||
|
||||
const isDetachedRet = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.plsLifecycleQuery`,
|
||||
{ target: "isDetached" }
|
||||
);
|
||||
if (isDetachedRet.success && isDetachedRet.result) {
|
||||
lifecycleStatus.detached = true;
|
||||
} else {
|
||||
lifecycleStatus.detached = false;
|
||||
}
|
||||
|
||||
const isSvcInstalledRet = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.plsLifecycleQuery`,
|
||||
{ target: "isSvcInstalled" }
|
||||
);
|
||||
if (isSvcInstalledRet.success && isSvcInstalledRet.result) {
|
||||
lifecycleStatus.svcInstalled = true;
|
||||
} else {
|
||||
lifecycleStatus.svcInstalled = false;
|
||||
}
|
||||
|
||||
const isSvcRunningRet = await ipcRenderer.invoke(
|
||||
`${IPC_METHOD_BASE}.plsLifecycleQuery`,
|
||||
{ target: "isSvcStart" }
|
||||
);
|
||||
if (isSvcRunningRet.success && isSvcRunningRet.result) {
|
||||
lifecycleStatus.svcRunning = true;
|
||||
} else {
|
||||
lifecycleStatus.svcRunning = false;
|
||||
}
|
||||
|
||||
if (init) {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
return;
|
||||
}
|
||||
|
||||
const updateOperationBtnStatus =
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus
|
||||
.updateOperationBtnStatus;
|
||||
@@ -95,10 +394,18 @@ if (!global.__HUGO_AURA_UI_FUNCTIONS__.subConfig)
|
||||
|
||||
ipcRenderer.once(
|
||||
`${IPC_METHOD_BASE}.post.updateRetryStatus`,
|
||||
async (_evt, _arg) => {
|
||||
async (_evt, arg) => {
|
||||
await global.__HUGO_AURA_GLOBAL__.utils.sleep(50);
|
||||
updateOperationBtnStatus("Refresh", false, "刷新状态");
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatus();
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateToast(
|
||||
arg.success ? "success" : "error",
|
||||
arg.success ? "更新成功" : "连接失败",
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
3000
|
||||
);
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__.subConfig.plsStatus.updateStatusContent();
|
||||
}
|
||||
);
|
||||
} else if (result.success && result.status === "Already") {
|
||||
@@ -147,6 +454,9 @@ if (!global.__HUGO_AURA_UI_FUNCTIONS__.subConfig)
|
||||
areaContainerEl.className =
|
||||
"acs-bc-pls-status-page-status-area warning";
|
||||
break;
|
||||
case "INFO":
|
||||
areaContainerEl.className = "acs-bc-pls-status-page-status-area info";
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -155,11 +465,11 @@ if (!global.__HUGO_AURA_UI_FUNCTIONS__.subConfig)
|
||||
};
|
||||
|
||||
const onMounted = () => {
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Refresh", false);
|
||||
initBsTooltip();
|
||||
GLOBAL_FUNCTIONS.updateStatus();
|
||||
GLOBAL_FUNCTIONS.updateOperationBtnStatus("Refresh", false);
|
||||
GLOBAL_FUNCTIONS.refreshPlsStatus(true);
|
||||
document.addEventListener("onPLSStatsUpdate", () => {
|
||||
GLOBAL_FUNCTIONS.updateStatus();
|
||||
GLOBAL_FUNCTIONS.updateStatusContent();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -4,53 +4,48 @@ const {
|
||||
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 = [
|
||||
{
|
||||
id: 0,
|
||||
categoryName: "可访问性",
|
||||
child: [
|
||||
/*
|
||||
{
|
||||
index: 0,
|
||||
id: "authToken",
|
||||
type: "input",
|
||||
subType: "text",
|
||||
name: "WebSocket 认证密钥",
|
||||
description: "选择一个安全的密钥, 用于 PLS 侧验证 Aura 前端身份",
|
||||
restart: true,
|
||||
reload: false,
|
||||
restartPLS: true,
|
||||
associateVal: null,
|
||||
auraIf: () => true,
|
||||
defaultValue: "",
|
||||
placeHolder: "输入一个密钥",
|
||||
valueGetter: () => {
|
||||
return global.__HUGO_AURA_CONFIG__.plsToken;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
if (newVal === "" || !newVal)
|
||||
return { valid: false, hint: "请输入认证密钥" };
|
||||
|
||||
if (newVal.length < 8) {
|
||||
return { valid: false, hint: "至少输入 8 位字符" };
|
||||
}
|
||||
|
||||
global.__HUGO_AURA_CONFIG__.plsToken = newVal;
|
||||
return { valid: true };
|
||||
},
|
||||
},
|
||||
*/
|
||||
{
|
||||
index: 0,
|
||||
id: "plsListenPort",
|
||||
type: "input",
|
||||
subType: "text",
|
||||
name: "PLS WS 监听端口",
|
||||
description: "PLS 的 WebSocket 服务器将监听指定的端口",
|
||||
subType: "number",
|
||||
name: "PLS WS 默认监听端口",
|
||||
description: "PLS 的 WebSocket 服务器将默认监听指定的端口",
|
||||
reactive: true,
|
||||
reactiveVal: ["root.settings"],
|
||||
restart: false,
|
||||
reload: false,
|
||||
PLSRequired: true,
|
||||
restartPLS: true,
|
||||
restartPLS: false,
|
||||
warning: true,
|
||||
warningContent: "PLS 仍会在默认端口被占用时, 自动随机端口重试",
|
||||
associateVal: null,
|
||||
auraIf: () => true,
|
||||
defaultValue: "",
|
||||
@@ -64,14 +59,114 @@ const basicSettings = [
|
||||
return { valid: false, hint: "请输入端口号" };
|
||||
|
||||
const numberNewVal = Number(newVal);
|
||||
if (numberNewVal === NaN || !(10000 <= numberNewVal <= 65535)) {
|
||||
if (numberNewVal === NaN || !(10000 <= numberNewVal) || !(newVal <= 65535)) {
|
||||
return { valid: false, hint: "请输入合法的端口号 (10000 ~ 65535)" };
|
||||
}
|
||||
|
||||
global.__HUGO_AURA__.plsSettings.wsPort = numberNewVal;
|
||||
updatePlsConfigToRemote("wsPort", numberNewVal);
|
||||
return { valid: true };
|
||||
},
|
||||
},
|
||||
{
|
||||
index: 1,
|
||||
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:
|
||||
'路径相对于 "%USERPROFILE%\\Documents\\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:
|
||||
'路径相对于 "%USERPROFILE%\\Documents\\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__.plsSettings) return "";
|
||||
return global.__HUGO_AURA__.plsSettings.regenCert;
|
||||
},
|
||||
callbackFn: (newVal) => {
|
||||
if (typeof newVal !== "boolean") return false;
|
||||
|
||||
global.__HUGO_AURA__.plsSettings.regenCert = newVal;
|
||||
updatePlsConfigToRemote("regenCert", newVal);
|
||||
return true;
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user