mirror of
https://github.com/HugoAura/Seewo-HugoAura.git
synced 2026-06-22 16:24:27 +08:00
[Feat] Basic PLS lifecycle mgmt
This commit is contained in:
@@ -8,7 +8,7 @@ const updatePlsStatusFromLocal = async () => {
|
||||
const plsStatus = (
|
||||
await global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.getPlsStats`)
|
||||
).data;
|
||||
global.__HUGO_AURA_GLOBAL__.plsStatus = plsStatus;
|
||||
global.__HUGO_AURA__.plsStats = plsStatus;
|
||||
return plsStatus;
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ const updatePlsSettingsFromLocal = async () => {
|
||||
const plsSettings = (
|
||||
await global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.getPlsSettings`)
|
||||
).data;
|
||||
global.__HUGO_AURA_GLOBAL__.plsSettings = plsSettings;
|
||||
global.__HUGO_AURA__.plsSettings = plsSettings;
|
||||
return plsSettings;
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ const updatePlsRulesFromLocal = async () => {
|
||||
const plsRules = (
|
||||
await global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.getPlsRules`)
|
||||
).data;
|
||||
global.__HUGO_AURA_GLOBAL__.plsRules = plsRules;
|
||||
global.__HUGO_AURA__.plsRules = plsRules;
|
||||
return plsRules;
|
||||
};
|
||||
|
||||
@@ -49,10 +49,11 @@ const genRandomHex = () => {
|
||||
const updatePlsConfigToRemote = async (configKey, configValue) => {
|
||||
const configLevels = configKey.split(".");
|
||||
/** @type {Record<any, any>} */
|
||||
// @ts-expect-error
|
||||
let localUpdateTarget =
|
||||
configLevels[0] === "ruleSettings"
|
||||
? global.__HUGO_AURA_GLOBAL__.plsRules
|
||||
: global.__HUGO_AURA_GLOBAL__.plsSettings;
|
||||
? global.__HUGO_AURA__.plsRules
|
||||
: global.__HUGO_AURA__.plsSettings;
|
||||
for (const level of configLevels.slice(0, -1)) {
|
||||
localUpdateTarget = localUpdateTarget[level];
|
||||
}
|
||||
@@ -80,8 +81,8 @@ const updatePlsConfigToRemote = async (configKey, configValue) => {
|
||||
|
||||
global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.ws.sendWsMessage`, data);
|
||||
global.ipcRenderer.invoke(`${IPC_METHOD_BASE}.syncPlsConfig`, {
|
||||
basic: global.__HUGO_AURA_GLOBAL__.plsSettings,
|
||||
rules: global.__HUGO_AURA_GLOBAL__.plsRules,
|
||||
basic: global.__HUGO_AURA__.plsSettings,
|
||||
rules: global.__HUGO_AURA__.plsRules,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ const showRelaunchPLSToast = () => {
|
||||
const toast = document.getElementById("relaunchPlsNotifyToast");
|
||||
const toastBs = bootstrap.Toast.getOrCreateInstance(toast);
|
||||
|
||||
if (global.__HUGO_AURA_GLOBAL__.plsStatus.detached) {
|
||||
if (global.__HUGO_AURA__.plsStats.detached) {
|
||||
const relaunchBtn = document.getElementById("plsRelaunchBtn");
|
||||
relaunchBtn.disabled = true;
|
||||
relaunchBtn.textContent = "分离模式下无法执行";
|
||||
@@ -71,6 +71,18 @@ const settingsRenderer = (pendingEl, settingsObj, isPls = false) => {
|
||||
powerIcon.setAttribute("data-bs-title", "需要重启 Electron 进程");
|
||||
entryTitle.appendChild(powerIcon);
|
||||
}
|
||||
if (entry.PLSRequired) {
|
||||
const plsIcon = document.createElement("i");
|
||||
plsIcon.classList.add(
|
||||
"layui-icon",
|
||||
"layui-icon-component",
|
||||
"aura-settings-entry-property-icon"
|
||||
);
|
||||
plsIcon.setAttribute("data-bs-toggle", "tooltip");
|
||||
plsIcon.setAttribute("data-bs-placement", "top");
|
||||
plsIcon.setAttribute("data-bs-title", "需要 PLS 支持");
|
||||
entryTitle.appendChild(plsIcon);
|
||||
}
|
||||
if (entry.restartPLS) {
|
||||
const plsIcon = document.createElement("i");
|
||||
plsIcon.classList.add(
|
||||
@@ -217,6 +229,35 @@ const settingsRenderer = (pendingEl, settingsObj, isPls = false) => {
|
||||
break;
|
||||
}
|
||||
|
||||
const setDisableStatus = (el, isDisable, hint = null) => {
|
||||
if (isDisable) {
|
||||
el.classList.add("ase-operation-area-disabled");
|
||||
if (hint) {
|
||||
el.setAttribute("data-bs-toggle", "tooltip");
|
||||
el.setAttribute("data-bs-placement", "top");
|
||||
el.setAttribute("data-bs-title", hint);
|
||||
}
|
||||
} else {
|
||||
el.setAttribute("data-bs-toggle", "");
|
||||
el.setAttribute("data-bs-placement", "");
|
||||
el.setAttribute("data-bs-title", "");
|
||||
el.classList.remove("ase-operation-area-disabled");
|
||||
}
|
||||
};
|
||||
|
||||
if (entry.PLSRequired) {
|
||||
if (!global.__HUGO_AURA__.plsStats.connected) {
|
||||
setDisableStatus(entryOperationArea, true, "连接至 PLS 以继续");
|
||||
}
|
||||
|
||||
document.addEventListener("onPLSStatsUpdate", (event) => {
|
||||
if (event.detail.connected) {
|
||||
setDisableStatus(entryOperationArea, false);
|
||||
} else {
|
||||
setDisableStatus(entryOperationArea, true, "连接至 PLS 以继续");
|
||||
}
|
||||
});
|
||||
}
|
||||
entryContainerEl.appendChild(entryOperationArea);
|
||||
const isShow = entry.auraIf();
|
||||
if (!isShow) entryContainerEl.classList.add("aura-settings-entry-hidden");
|
||||
@@ -245,12 +286,7 @@ const settingsRenderer = (pendingEl, settingsObj, isPls = false) => {
|
||||
}
|
||||
pendingEl.appendChild(formEl);
|
||||
|
||||
const tooltipTriggerList = document.querySelectorAll(
|
||||
'[data-bs-toggle="tooltip"]'
|
||||
);
|
||||
[...tooltipTriggerList].map(
|
||||
(tooltipTriggerEl) => new bootstrap.Tooltip(tooltipTriggerEl)
|
||||
);
|
||||
global.__HUGO_AURA_GLOBAL__.utils.refreshBsTooltip();
|
||||
};
|
||||
|
||||
module.exports = { settingsRenderer };
|
||||
|
||||
Reference in New Issue
Block a user