mirror of
https://github.com/HugoAura/Seewo-HugoAura.git
synced 2026-06-22 16:24:27 +08:00
[Fix] Minor UX tweaks: freezeOverride components
This commit is contained in:
372
src/aura/init/main/ipcModules/fsIpcHandler.js
Normal file → Executable file
372
src/aura/init/main/ipcModules/fsIpcHandler.js
Normal file → Executable file
@@ -1,186 +1,186 @@
|
||||
// @ts-check
|
||||
|
||||
const __SCOPE = "main";
|
||||
|
||||
const { exec } = require("child_process");
|
||||
const nodeHttp = require("http");
|
||||
const nodeHttps = require("https");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const { genRandomHex } = require("../../../utils/crypto");
|
||||
|
||||
const composableFunctions = {
|
||||
/**
|
||||
*
|
||||
* @param {string} url
|
||||
* @param {string} targetPath
|
||||
* @param {((arg: DownloadTask) => any)} progressCallback
|
||||
*/
|
||||
downloadFile: async (url, targetPath, progressCallback) => {
|
||||
if (!progressCallback) return false;
|
||||
const taskId = genRandomHex();
|
||||
|
||||
/**
|
||||
* @type {DownloadTask}
|
||||
*/
|
||||
const failedTemplate = {
|
||||
id: taskId,
|
||||
progress: 100,
|
||||
status: "failed",
|
||||
dlUrl: url,
|
||||
savePath: targetPath,
|
||||
message: "",
|
||||
};
|
||||
|
||||
if (!url || !targetPath) {
|
||||
failedTemplate.message = "Invalid arg";
|
||||
progressCallback(failedTemplate);
|
||||
return false;
|
||||
}
|
||||
if (!fs.existsSync(path.dirname(targetPath))) {
|
||||
failedTemplate.message = "Path not exists";
|
||||
progressCallback(failedTemplate);
|
||||
}
|
||||
const httpModuleIns = url.startsWith("https") ? nodeHttps : nodeHttp;
|
||||
|
||||
global.__HUGO_AURA__.fsTasks?.downloadTasks.set(taskId, {
|
||||
status: "waiting",
|
||||
cancelReq: null,
|
||||
});
|
||||
|
||||
const fsStream = fs.createWriteStream(targetPath);
|
||||
|
||||
const dlReq = httpModuleIns.get(url, (response) => {
|
||||
if (response.statusCode !== 200) {
|
||||
fsStream.close();
|
||||
failedTemplate.message = `Request error: HTTP ${response.statusCode}`;
|
||||
progressCallback(failedTemplate);
|
||||
return false;
|
||||
}
|
||||
|
||||
const contentLength = response.headers["content-length"];
|
||||
// @ts-expect-error
|
||||
const totalBytes = parseInt(contentLength, 10) || 0; // No error handling 😆
|
||||
let curRecvBytes = 0;
|
||||
|
||||
global.__HUGO_AURA__.fsTasks?.downloadTasks.set(taskId, {
|
||||
status: "progressing",
|
||||
cancelReq: () => {
|
||||
dlReq.destroy();
|
||||
fsStream.close();
|
||||
fs.unlink(targetPath, () => {});
|
||||
global.__HUGO_AURA__.fsTasks?.downloadTasks.delete(taskId);
|
||||
progressCallback({
|
||||
id: taskId,
|
||||
progress: 100,
|
||||
curBytes: curRecvBytes,
|
||||
totalBytes: totalBytes,
|
||||
status: "cancelled",
|
||||
dlUrl: url,
|
||||
savePath: targetPath,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
response.on("data", (chunk) => {
|
||||
curRecvBytes += chunk.length;
|
||||
const curProgress =
|
||||
totalBytes > 0 ? (curRecvBytes / totalBytes) * 100 : 0;
|
||||
progressCallback({
|
||||
id: taskId,
|
||||
progress: curProgress.toFixed(2),
|
||||
curBytes: curRecvBytes,
|
||||
totalBytes: totalBytes,
|
||||
status: "progressing",
|
||||
dlUrl: url,
|
||||
savePath: targetPath,
|
||||
});
|
||||
});
|
||||
|
||||
response.pipe(fsStream);
|
||||
|
||||
fsStream.on("finish", () => {
|
||||
fsStream.close();
|
||||
progressCallback({
|
||||
id: taskId,
|
||||
progress: (100).toFixed(2),
|
||||
curBytes: curRecvBytes,
|
||||
totalBytes: totalBytes,
|
||||
status: "done",
|
||||
dlUrl: url,
|
||||
savePath: targetPath,
|
||||
});
|
||||
});
|
||||
|
||||
global.__HUGO_AURA__.fsTasks?.downloadTasks.delete(taskId);
|
||||
return true;
|
||||
});
|
||||
|
||||
dlReq.on("error", (e) => {
|
||||
fsStream.close();
|
||||
fs.unlink(targetPath, () => {});
|
||||
failedTemplate.message =
|
||||
"Request error: Unexpected error while downloading file";
|
||||
failedTemplate.errorObj = e;
|
||||
progressCallback(failedTemplate);
|
||||
global.__HUGO_AURA__.fsTasks?.downloadTasks.delete(taskId);
|
||||
return false;
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMain} ipcMain
|
||||
*/
|
||||
const applyFsIpcHandler = (ipcMain) => {
|
||||
const methodBase = "$aura.fs";
|
||||
|
||||
global.__HUGO_AURA__.fsTasks = {
|
||||
downloadTasks: new Map(),
|
||||
};
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.dl.cancelDownloadTask`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _evt
|
||||
* @param {{ targetTaskId: string }} arg
|
||||
* @returns {{ success: boolean, error: string | null }}
|
||||
*/
|
||||
(_evt, arg) => {
|
||||
if (!arg.targetTaskId) {
|
||||
return {
|
||||
success: false,
|
||||
error: "ARG_INVALID",
|
||||
};
|
||||
}
|
||||
|
||||
if (!global.__HUGO_AURA__.fsTasks?.downloadTasks.has(arg.targetTaskId)) {
|
||||
return {
|
||||
success: false,
|
||||
error: "TASK_ID_NOT_FOUND",
|
||||
};
|
||||
}
|
||||
|
||||
const taskObj = global.__HUGO_AURA__.fsTasks.downloadTasks.get(
|
||||
arg.targetTaskId
|
||||
);
|
||||
if (!taskObj?.cancelReq) {
|
||||
return {
|
||||
success: false,
|
||||
error: "TASK_NOT_STARTED",
|
||||
};
|
||||
}
|
||||
|
||||
taskObj.cancelReq();
|
||||
return {
|
||||
success: true,
|
||||
error: null,
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = { fsComposables: composableFunctions, applyFsIpcHandler };
|
||||
// @ts-check
|
||||
|
||||
const __SCOPE = "main";
|
||||
|
||||
const { exec } = require("child_process");
|
||||
const nodeHttp = require("http");
|
||||
const nodeHttps = require("https");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const { genRandomHex } = require("../../../utils/crypto");
|
||||
|
||||
const composableFunctions = {
|
||||
/**
|
||||
*
|
||||
* @param {string} url
|
||||
* @param {string} targetPath
|
||||
* @param {((arg: DownloadTask) => any)} progressCallback
|
||||
*/
|
||||
downloadFile: async (url, targetPath, progressCallback) => {
|
||||
if (!progressCallback) return false;
|
||||
const taskId = genRandomHex();
|
||||
|
||||
/**
|
||||
* @type {DownloadTask}
|
||||
*/
|
||||
const failedTemplate = {
|
||||
id: taskId,
|
||||
progress: 100,
|
||||
status: "failed",
|
||||
dlUrl: url,
|
||||
savePath: targetPath,
|
||||
message: "",
|
||||
};
|
||||
|
||||
if (!url || !targetPath) {
|
||||
failedTemplate.message = "Invalid arg";
|
||||
progressCallback(failedTemplate);
|
||||
return false;
|
||||
}
|
||||
if (!fs.existsSync(path.dirname(targetPath))) {
|
||||
failedTemplate.message = "Path not exists";
|
||||
progressCallback(failedTemplate);
|
||||
}
|
||||
const httpModuleIns = url.startsWith("https") ? nodeHttps : nodeHttp;
|
||||
|
||||
global.__HUGO_AURA__.fsTasks?.downloadTasks.set(taskId, {
|
||||
status: "waiting",
|
||||
cancelReq: null,
|
||||
});
|
||||
|
||||
const fsStream = fs.createWriteStream(targetPath);
|
||||
|
||||
const dlReq = httpModuleIns.get(url, (response) => {
|
||||
if (response.statusCode !== 200) {
|
||||
fsStream.close();
|
||||
failedTemplate.message = `Request error: HTTP ${response.statusCode}`;
|
||||
progressCallback(failedTemplate);
|
||||
return false;
|
||||
}
|
||||
|
||||
const contentLength = response.headers["content-length"];
|
||||
// @ts-expect-error
|
||||
const totalBytes = parseInt(contentLength, 10) || 0; // No error handling 😆
|
||||
let curRecvBytes = 0;
|
||||
|
||||
global.__HUGO_AURA__.fsTasks?.downloadTasks.set(taskId, {
|
||||
status: "progressing",
|
||||
cancelReq: () => {
|
||||
dlReq.destroy();
|
||||
fsStream.close();
|
||||
fs.unlink(targetPath, () => {});
|
||||
global.__HUGO_AURA__.fsTasks?.downloadTasks.delete(taskId);
|
||||
progressCallback({
|
||||
id: taskId,
|
||||
progress: 100,
|
||||
curBytes: curRecvBytes,
|
||||
totalBytes: totalBytes,
|
||||
status: "cancelled",
|
||||
dlUrl: url,
|
||||
savePath: targetPath,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
response.on("data", (chunk) => {
|
||||
curRecvBytes += chunk.length;
|
||||
const curProgress =
|
||||
totalBytes > 0 ? (curRecvBytes / totalBytes) * 100 : 0;
|
||||
progressCallback({
|
||||
id: taskId,
|
||||
progress: curProgress.toFixed(2),
|
||||
curBytes: curRecvBytes,
|
||||
totalBytes: totalBytes,
|
||||
status: "progressing",
|
||||
dlUrl: url,
|
||||
savePath: targetPath,
|
||||
});
|
||||
});
|
||||
|
||||
response.pipe(fsStream);
|
||||
|
||||
fsStream.on("finish", () => {
|
||||
fsStream.close();
|
||||
progressCallback({
|
||||
id: taskId,
|
||||
progress: (100).toFixed(2),
|
||||
curBytes: curRecvBytes,
|
||||
totalBytes: totalBytes,
|
||||
status: "done",
|
||||
dlUrl: url,
|
||||
savePath: targetPath,
|
||||
});
|
||||
});
|
||||
|
||||
global.__HUGO_AURA__.fsTasks?.downloadTasks.delete(taskId);
|
||||
return true;
|
||||
});
|
||||
|
||||
dlReq.on("error", (e) => {
|
||||
fsStream.close();
|
||||
fs.unlink(targetPath, () => {});
|
||||
failedTemplate.message =
|
||||
"Request error: Unexpected error while downloading file";
|
||||
failedTemplate.errorObj = e;
|
||||
progressCallback(failedTemplate);
|
||||
global.__HUGO_AURA__.fsTasks?.downloadTasks.delete(taskId);
|
||||
return false;
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMain} ipcMain
|
||||
*/
|
||||
const applyFsIpcHandler = (ipcMain) => {
|
||||
const methodBase = "$aura.fs";
|
||||
|
||||
global.__HUGO_AURA__.fsTasks = {
|
||||
downloadTasks: new Map(),
|
||||
};
|
||||
|
||||
ipcMain.handle(
|
||||
`${methodBase}.dl.cancelDownloadTask`,
|
||||
/**
|
||||
*
|
||||
* @param {import("electron").IpcMainInvokeEvent} _evt
|
||||
* @param {{ targetTaskId: string }} arg
|
||||
* @returns {{ success: boolean, error: string | null }}
|
||||
*/
|
||||
(_evt, arg) => {
|
||||
if (!arg.targetTaskId) {
|
||||
return {
|
||||
success: false,
|
||||
error: "ARG_INVALID",
|
||||
};
|
||||
}
|
||||
|
||||
if (!global.__HUGO_AURA__.fsTasks?.downloadTasks.has(arg.targetTaskId)) {
|
||||
return {
|
||||
success: false,
|
||||
error: "TASK_ID_NOT_FOUND",
|
||||
};
|
||||
}
|
||||
|
||||
const taskObj = global.__HUGO_AURA__.fsTasks.downloadTasks.get(
|
||||
arg.targetTaskId
|
||||
);
|
||||
if (!taskObj?.cancelReq) {
|
||||
return {
|
||||
success: false,
|
||||
error: "TASK_NOT_STARTED",
|
||||
};
|
||||
}
|
||||
|
||||
taskObj.cancelReq();
|
||||
return {
|
||||
success: true,
|
||||
error: null,
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = { fsComposables: composableFunctions, applyFsIpcHandler };
|
||||
|
||||
42
src/aura/types/main/ipc/fs.d.ts
vendored
Normal file → Executable file
42
src/aura/types/main/ipc/fs.d.ts
vendored
Normal file → Executable file
@@ -1,21 +1,21 @@
|
||||
type DownloadTaskID = string;
|
||||
type DownloadTaskStatus = "waiting" | "progressing" | "done" | "failed" | "cancelled";
|
||||
|
||||
interface DownloadTask {
|
||||
id: DownloadTaskID;
|
||||
progress: float;
|
||||
curBytes?: number;
|
||||
totalBytes?: number;
|
||||
status: DownloadTaskStatus;
|
||||
dlUrl: string | null;
|
||||
savePath: string | null;
|
||||
message?: string;
|
||||
errorObj?: Error;
|
||||
}
|
||||
|
||||
interface FSTasks {
|
||||
downloadTasks: Map<
|
||||
DownloadTaskID,
|
||||
{ status: DownloadTaskStatus; cancelReq: any }
|
||||
>;
|
||||
}
|
||||
type DownloadTaskID = string;
|
||||
type DownloadTaskStatus = "waiting" | "progressing" | "done" | "failed" | "cancelled";
|
||||
|
||||
interface DownloadTask {
|
||||
id: DownloadTaskID;
|
||||
progress: float;
|
||||
curBytes?: number;
|
||||
totalBytes?: number;
|
||||
status: DownloadTaskStatus;
|
||||
dlUrl: string | null;
|
||||
savePath: string | null;
|
||||
message?: string;
|
||||
errorObj?: Error;
|
||||
}
|
||||
|
||||
interface FSTasks {
|
||||
downloadTasks: Map<
|
||||
DownloadTaskID,
|
||||
{ status: DownloadTaskStatus; cancelReq: any }
|
||||
>;
|
||||
}
|
||||
|
||||
@@ -36,9 +36,13 @@ const showToast = (entry) => {
|
||||
showReloadToast();
|
||||
} else if (entry.restart) {
|
||||
showRelaunchToast();
|
||||
} else if (entry.restartPLS) {
|
||||
}
|
||||
|
||||
/*
|
||||
else if (entry.restartPLS) {
|
||||
showRelaunchPLSToast();
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
const insertOrRemoveEl = (parent, child, isInsert = true) => {
|
||||
|
||||
186
src/aura/ui/pages/configSubPages/behaviourCtrl/settings/deviceSecurity.js
Normal file → Executable file
186
src/aura/ui/pages/configSubPages/behaviourCtrl/settings/deviceSecurity.js
Normal file → Executable file
@@ -1,93 +1,93 @@
|
||||
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;
|
||||
|
||||
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: () => {
|
||||
return global.__HUGO_AURA__.plsRules.client.security.uploadFreezeInfo
|
||||
.enable;
|
||||
},
|
||||
defaultValue: "allFreeze",
|
||||
templates: ["allFreeze", "systemOnly", "exceptSecondDisk"],
|
||||
templateLabels: ["全部冻结", "仅系统盘", "仅第二磁盘"],
|
||||
valueGetter: () => {
|
||||
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 };
|
||||
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;
|
||||
|
||||
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: () => {
|
||||
return global.__HUGO_AURA__.plsRules.client.security.uploadFreezeInfo
|
||||
.enable;
|
||||
},
|
||||
defaultValue: "allFreeze",
|
||||
templates: ["allFreeze", "systemOnly", "exceptSecondDisk"],
|
||||
templateLabels: ["全部冻结", "仅系统盘", "第二磁盘除外"],
|
||||
valueGetter: () => {
|
||||
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 };
|
||||
|
||||
204
src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.css
Normal file → Executable file
204
src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.css
Normal file → Executable file
@@ -1,100 +1,104 @@
|
||||
.acs-bc-dsc-fop-container {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-please-wait,
|
||||
.acs-bc-dsc-fop-on-req-error,
|
||||
.acs-bc-dsc-fop-on-not-bind {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-please-wait svg,
|
||||
.acs-bc-dsc-fop-on-req-error svg,
|
||||
.acs-bc-dsc-fop-on-not-bind svg {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-please-wait p,
|
||||
.acs-bc-dsc-fop-on-req-error p,
|
||||
.acs-bc-dsc-fop-on-not-bind p {
|
||||
margin-left: 0.5rem;
|
||||
margin-top: -1px;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-please-wait[auraIf="false"],
|
||||
.acs-bc-dsc-fop-on-req-error[auraIf="false"],
|
||||
.acs-bc-dsc-fop-on-not-bind[auraIf="false"],
|
||||
.acs-bc-dsc-fop-main[auraIf="false"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-main .disks-container {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-disk-el {
|
||||
padding: 5px 10px;
|
||||
border-radius: 3px;
|
||||
border: 0.5px solid rgba(0, 0, 0, 0.25);
|
||||
margin-left: 0.375rem;
|
||||
margin-right: 0.375rem;
|
||||
|
||||
/* transition: all 0.5s; */
|
||||
/* 没有用, 因为元素全被重新创建了 */
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-disk-el.active {
|
||||
background-color: #1d70f2;
|
||||
color: white;
|
||||
border: 0.5px solid rgba(0, 0, 0, 0.125);
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-main-hint-area {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin-top: 1rem;
|
||||
margin-bottom: -0.25rem;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-main-hint-area svg {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-main-hint-area div {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-main-hint-area p {
|
||||
margin-top: -1px;
|
||||
margin-left: 0.25rem;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-main-hint-area .acs-bc-dsc-fop-main-hint-freeze {
|
||||
margin-right: 0.5rem;
|
||||
color: #1d70f2;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-main-hint-area .acs-bc-dsc-fop-main-hint-unfreeze {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
.acs-bc-dsc-fop-container {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-please-wait,
|
||||
.acs-bc-dsc-fop-on-req-error,
|
||||
.acs-bc-dsc-fop-on-not-bind {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-please-wait svg,
|
||||
.acs-bc-dsc-fop-on-req-error svg,
|
||||
.acs-bc-dsc-fop-on-not-bind svg {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-please-wait p,
|
||||
.acs-bc-dsc-fop-on-req-error p,
|
||||
.acs-bc-dsc-fop-on-not-bind p {
|
||||
margin-left: 0.5rem;
|
||||
margin-top: -1px;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-please-wait[auraIf="false"],
|
||||
.acs-bc-dsc-fop-on-req-error[auraIf="false"],
|
||||
.acs-bc-dsc-fop-on-not-bind[auraIf="false"],
|
||||
.acs-bc-dsc-fop-main[auraIf="false"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-main .disks-container {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-disk-el {
|
||||
padding: 5px 10px;
|
||||
border-radius: 3px;
|
||||
border: 0.5px solid rgba(0, 0, 0, 0.25);
|
||||
margin-left: 0.375rem;
|
||||
margin-right: 0.375rem;
|
||||
|
||||
transition: all 0.5s;
|
||||
/* 没有用, 因为元素全被重新创建了 */
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-disk-el.active {
|
||||
background-color: #1d70f2;
|
||||
color: white;
|
||||
border: 0.5px solid rgba(0, 0, 0, 0.125);
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-disk-el.active:hover {
|
||||
background-color: #4e8df2;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-main-hint-area {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin-top: 1rem;
|
||||
margin-bottom: -0.25rem;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-main-hint-area svg {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-main-hint-area div {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-main-hint-area p {
|
||||
margin-top: -1px;
|
||||
margin-left: 0.25rem;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-main-hint-area .acs-bc-dsc-fop-main-hint-freeze {
|
||||
margin-right: 0.5rem;
|
||||
color: #1d70f2;
|
||||
}
|
||||
|
||||
.acs-bc-dsc-fop-main-hint-area .acs-bc-dsc-fop-main-hint-unfreeze {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
182
src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.html
Normal file → Executable file
182
src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.html
Normal file → Executable file
@@ -1,91 +1,91 @@
|
||||
<div class="acs-bc-dsc-fop-container">
|
||||
<div class="acs-bc-dsc-fop-please-wait" auraIf="true">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 32 32"
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M16 30a14 14 0 1 1 14-14a14 14 0 0 1-14 14m0-26a12 12 0 1 0 12 12A12 12 0 0 0 16 4"
|
||||
/>
|
||||
<path fill="currentColor" d="M20.59 22L15 16.41V7h2v8.58l5 5.01z" />
|
||||
</svg>
|
||||
|
||||
<p>请稍候...</p>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-dsc-fop-on-req-error" auraIf="false">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 32 32"
|
||||
>
|
||||
<path fill="currentColor" d="M9 10.555L10.555 9L23 21.444L21.444 23z" />
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M16 2A13.914 13.914 0 0 0 2 16a13.914 13.914 0 0 0 14 14a13.914 13.914 0 0 0 14-14A13.914 13.914 0 0 0 16 2m0 26a12 12 0 1 1 12-12a12.035 12.035 0 0 1-12 12"
|
||||
/>
|
||||
</svg>
|
||||
|
||||
<p>获取磁盘信息失败: <font id="acsBcDscFopOnReqErrorDetail"></font></p>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-dsc-fop-on-not-bind" auraIf="false">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 32 32"
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M31.324 11.261A14.27 14.27 0 0 0 22.25 8H22v2h.25c2.608 0 5.155.837 7.246 2.372a12.18 12.18 0 0 1-7.548 7.036q.052-.605.052-1.22C22 10.366 15.635 4 7.812 4c-.929 0-1.856.09-2.757.268l-.657.13l-.13.657A14.3 14.3 0 0 0 4 7.812c0 4.124 1.78 7.831 4.598 10.426A14.2 14.2 0 0 0 8 22.254l.001.001a14.27 14.27 0 0 0 3.261 9.07l.439.53l.652-.22a14.18 14.18 0 0 0 9.237-10.046a14.18 14.18 0 0 0 10.045-9.237l.22-.652zM12.372 29.496A12.27 12.27 0 0 1 10 22.251c0-.912.113-1.796.303-2.652a14.1 14.1 0 0 0 9.105 2.349a12.18 12.18 0 0 1-7.036 7.548m7.51-9.613q-.833.116-1.694.117c-2.715 0-5.218-.904-7.247-2.412a12.4 12.4 0 0 1 4.048-5.204l-1.28-1.53A14.3 14.3 0 0 0 9.37 16.2A12.14 12.14 0 0 1 6.117 6.117A12 12 0 0 1 7.812 6C14.532 6 20 11.468 20 18.188q0 .862-.117 1.695Z"
|
||||
/>
|
||||
<circle cx="20" cy="2" r="2" fill="currentColor" />
|
||||
<circle cx="27" cy="26" r="2" fill="currentColor" />
|
||||
<circle cx="2" cy="20" r="2" fill="currentColor" />
|
||||
</svg>
|
||||
|
||||
<p>当前设备暂未绑定学校, 无法查询冰点信息</p>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-dsc-fop-main" auraIf="false">
|
||||
<div class="disks-container">
|
||||
<p class="acs-bc-dsc-fop-disk-el">C 盘</p>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-dsc-fop-main-hint-area">
|
||||
<div class="acs-bc-dsc-fop-main-hint-freeze">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 32 32"
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M21.415 12H28v-2h-4.585L28 5.415L26.586 4L22 8.587V4h-2v6.587L18.587 12H17V8h-2v4h-1.587L12 10.587V4h-2v4.587L5.414 4L4 5.415L8.585 10H4v2h6.585L12 13.415V15H8v2h4v1.587L10.587 20H4v2h4.587L4 26.586l1.414 1.415L10 23.415V28h2v-6.585L13.415 20H15v4h2v-4h1.585L20 21.415V28h2v-4.585l4.585 4.586L28 26.586L23.413 22H28v-2h-6.587L20 18.587V17h4v-2h-4v-1.585ZM18 18h-4v-4h4Z"
|
||||
/>
|
||||
</svg>
|
||||
<p>已冻结</p>
|
||||
</div>
|
||||
<div class="acs-bc-dsc-fop-main-hint-unfreeze">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 32 32"
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M16 12.005a4 4 0 1 1-4 4a4.005 4.005 0 0 1 4-4m0-2a6 6 0 1 0 6 6a6 6 0 0 0-6-6M5.394 6.813L6.81 5.399l3.505 3.506L8.9 10.319zM2 15.005h5v2H2zm3.394 10.193L8.9 21.692l1.414 1.414l-3.505 3.506zM15 25.005h2v5h-2zm6.687-1.9l1.414-1.414l3.506 3.506l-1.414 1.414zm3.313-8.1h5v2h-5zm-3.313-6.101l3.506-3.506l1.414 1.414l-3.506 3.506zM15 2.005h2v5h-2z"
|
||||
/>
|
||||
</svg>
|
||||
<p>未冻结</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="acs-bc-dsc-fop-container">
|
||||
<div class="acs-bc-dsc-fop-please-wait" auraIf="true">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 32 32"
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M16 30a14 14 0 1 1 14-14a14 14 0 0 1-14 14m0-26a12 12 0 1 0 12 12A12 12 0 0 0 16 4"
|
||||
/>
|
||||
<path fill="currentColor" d="M20.59 22L15 16.41V7h2v8.58l5 5.01z" />
|
||||
</svg>
|
||||
|
||||
<p>请稍候...</p>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-dsc-fop-on-req-error" auraIf="false">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 32 32"
|
||||
>
|
||||
<path fill="currentColor" d="M9 10.555L10.555 9L23 21.444L21.444 23z" />
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M16 2A13.914 13.914 0 0 0 2 16a13.914 13.914 0 0 0 14 14a13.914 13.914 0 0 0 14-14A13.914 13.914 0 0 0 16 2m0 26a12 12 0 1 1 12-12a12.035 12.035 0 0 1-12 12"
|
||||
/>
|
||||
</svg>
|
||||
|
||||
<p>获取磁盘信息失败: <font id="acsBcDscFopOnReqErrorDetail"></font></p>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-dsc-fop-on-not-bind" auraIf="false">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 32 32"
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M31.324 11.261A14.27 14.27 0 0 0 22.25 8H22v2h.25c2.608 0 5.155.837 7.246 2.372a12.18 12.18 0 0 1-7.548 7.036q.052-.605.052-1.22C22 10.366 15.635 4 7.812 4c-.929 0-1.856.09-2.757.268l-.657.13l-.13.657A14.3 14.3 0 0 0 4 7.812c0 4.124 1.78 7.831 4.598 10.426A14.2 14.2 0 0 0 8 22.254l.001.001a14.27 14.27 0 0 0 3.261 9.07l.439.53l.652-.22a14.18 14.18 0 0 0 9.237-10.046a14.18 14.18 0 0 0 10.045-9.237l.22-.652zM12.372 29.496A12.27 12.27 0 0 1 10 22.251c0-.912.113-1.796.303-2.652a14.1 14.1 0 0 0 9.105 2.349a12.18 12.18 0 0 1-7.036 7.548m7.51-9.613q-.833.116-1.694.117c-2.715 0-5.218-.904-7.247-2.412a12.4 12.4 0 0 1 4.048-5.204l-1.28-1.53A14.3 14.3 0 0 0 9.37 16.2A12.14 12.14 0 0 1 6.117 6.117A12 12 0 0 1 7.812 6C14.532 6 20 11.468 20 18.188q0 .862-.117 1.695Z"
|
||||
/>
|
||||
<circle cx="20" cy="2" r="2" fill="currentColor" />
|
||||
<circle cx="27" cy="26" r="2" fill="currentColor" />
|
||||
<circle cx="2" cy="20" r="2" fill="currentColor" />
|
||||
</svg>
|
||||
|
||||
<p>当前设备暂未绑定学校, 无法查询冰点信息</p>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-dsc-fop-main" auraIf="false">
|
||||
<div class="disks-container">
|
||||
<p class="acs-bc-dsc-fop-disk-el">C 盘</p>
|
||||
</div>
|
||||
|
||||
<div class="acs-bc-dsc-fop-main-hint-area">
|
||||
<div class="acs-bc-dsc-fop-main-hint-freeze">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 32 32"
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M21.415 12H28v-2h-4.585L28 5.415L26.586 4L22 8.587V4h-2v6.587L18.587 12H17V8h-2v4h-1.587L12 10.587V4h-2v4.587L5.414 4L4 5.415L8.585 10H4v2h6.585L12 13.415V15H8v2h4v1.587L10.587 20H4v2h4.587L4 26.586l1.414 1.415L10 23.415V28h2v-6.585L13.415 20H15v4h2v-4h1.585L20 21.415V28h2v-4.585l4.585 4.586L28 26.586L23.413 22H28v-2h-6.587L20 18.587V17h4v-2h-4v-1.585ZM18 18h-4v-4h4Z"
|
||||
/>
|
||||
</svg>
|
||||
<p>已冻结</p>
|
||||
</div>
|
||||
<div class="acs-bc-dsc-fop-main-hint-unfreeze">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 32 32"
|
||||
>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M16 12.005a4 4 0 1 1-4 4a4.005 4.005 0 0 1 4-4m0-2a6 6 0 1 0 6 6a6 6 0 0 0-6-6M5.394 6.813L6.81 5.399l3.505 3.506L8.9 10.319zM2 15.005h5v2H2zm3.394 10.193L8.9 21.692l1.414 1.414l-3.505 3.506zM15 25.005h2v5h-2zm6.687-1.9l1.414-1.414l3.506 3.506l-1.414 1.414zm3.313-8.1h5v2h-5zm-3.313-6.101l3.506-3.506l1.414 1.414l-3.506 3.506zM15 2.005h2v5h-2z"
|
||||
/>
|
||||
</svg>
|
||||
<p>未冻结</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
312
src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.js
Normal file → Executable file
312
src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.js
Normal file → Executable file
@@ -1,156 +1,156 @@
|
||||
// @ts-check
|
||||
|
||||
(() => {
|
||||
const REQUIRE_BASE = "../..";
|
||||
const { genRandomHex } = require(`${REQUIRE_BASE}/aura/utils/crypto`);
|
||||
|
||||
const composables = {
|
||||
getAndUpdateDiskInfo: async (curConfig) => {
|
||||
const progressingEl = document.getElementsByClassName(
|
||||
"acs-bc-dsc-fop-please-wait"
|
||||
)[0];
|
||||
const onErrorEl = document.getElementsByClassName(
|
||||
"acs-bc-dsc-fop-on-req-error"
|
||||
)[0];
|
||||
const onNotBindEl = document.getElementsByClassName(
|
||||
"acs-bc-dsc-fop-on-not-bind"
|
||||
)[0];
|
||||
const mainEl = document.getElementsByClassName("acs-bc-dsc-fop-main")[0];
|
||||
const diskContainerEl =
|
||||
document.getElementsByClassName("disks-container")[0];
|
||||
|
||||
const seewoProxyPort = window._ACCEPT_DATA.data.ports.SeewoProxyHTTP;
|
||||
|
||||
const reqPromise = new Promise((resolve) => {
|
||||
fetch(
|
||||
`https://127.0.0.1:${seewoProxyPort}/forward/freeze/api/v1/get_disk_data`,
|
||||
{
|
||||
headers: {
|
||||
accept: "application/json, text/plain, */*",
|
||||
"X-Auth-Traceid": genRandomHex(),
|
||||
},
|
||||
}
|
||||
)
|
||||
.then(async (response) => {
|
||||
const parsedData = await response.json();
|
||||
|
||||
resolve({
|
||||
success: true,
|
||||
data: parsedData,
|
||||
status: response.status,
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
resolve({ success: false, data: null, errorObj: e });
|
||||
});
|
||||
});
|
||||
|
||||
const responseInfo = await reqPromise;
|
||||
|
||||
progressingEl.setAttribute("auraIf", "false");
|
||||
|
||||
if (!responseInfo.success) {
|
||||
onNotBindEl.setAttribute("auraIf", "false");
|
||||
mainEl.setAttribute("auraIf", "false");
|
||||
onErrorEl.setAttribute("auraIf", "true");
|
||||
const detailEl = document.getElementById("acsBcDscFopOnReqErrorDetail");
|
||||
// @ts-expect-error
|
||||
detailEl.textContent = responseInfo.errorObj;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (responseInfo.status !== 200) {
|
||||
onErrorEl.setAttribute("auraIf", "false");
|
||||
mainEl.setAttribute("auraIf", "false");
|
||||
onNotBindEl.setAttribute("auraIf", "true");
|
||||
return;
|
||||
}
|
||||
|
||||
diskContainerEl.innerHTML = ``;
|
||||
|
||||
const curDisks = [];
|
||||
for (const disk of responseInfo.data.data[0].disksData) {
|
||||
curDisks.push({ name: disk.diskName, status: disk.protectedStatus });
|
||||
}
|
||||
|
||||
const diskElTemplate = document.createElement("p");
|
||||
diskElTemplate.classList.add("acs-bc-dsc-fop-disk-el");
|
||||
if (!curConfig.enable) {
|
||||
for (const disk of curDisks) {
|
||||
const curDiskEl = diskElTemplate.cloneNode();
|
||||
if (disk.status !== 0) {
|
||||
// @ts-expect-error
|
||||
curDiskEl.classList.add("active");
|
||||
}
|
||||
curDiskEl.textContent = `${disk.name.toUpperCase()} 盘`;
|
||||
diskContainerEl.appendChild(curDiskEl);
|
||||
}
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
onErrorEl.setAttribute("auraIf", "false");
|
||||
onNotBindEl.setAttribute("auraIf", "false");
|
||||
mainEl.setAttribute("auraIf", "true");
|
||||
},
|
||||
};
|
||||
|
||||
const onMounted = () => {
|
||||
const rootEl = document.getElementsByClassName(
|
||||
"acs-bc-dsc-fop-container"
|
||||
)[0];
|
||||
|
||||
const eventListener = (_event) => {
|
||||
if (!global.__HUGO_AURA__.plsRules) return;
|
||||
composables.getAndUpdateDiskInfo(
|
||||
global.__HUGO_AURA__.plsRules.client.security.uploadFreezeInfo
|
||||
);
|
||||
};
|
||||
rootEl.addEventListener("onAssociateValueUpdated", eventListener);
|
||||
|
||||
setTimeout(() => {
|
||||
eventListener();
|
||||
}, 100);
|
||||
};
|
||||
|
||||
onMounted();
|
||||
})();
|
||||
// @ts-check
|
||||
|
||||
(() => {
|
||||
const REQUIRE_BASE = "../..";
|
||||
const { genRandomHex } = require(`${REQUIRE_BASE}/aura/utils/crypto`);
|
||||
|
||||
const composables = {
|
||||
getAndUpdateDiskInfo: async (curConfig) => {
|
||||
const progressingEl = document.getElementsByClassName(
|
||||
"acs-bc-dsc-fop-please-wait"
|
||||
)[0];
|
||||
const onErrorEl = document.getElementsByClassName(
|
||||
"acs-bc-dsc-fop-on-req-error"
|
||||
)[0];
|
||||
const onNotBindEl = document.getElementsByClassName(
|
||||
"acs-bc-dsc-fop-on-not-bind"
|
||||
)[0];
|
||||
const mainEl = document.getElementsByClassName("acs-bc-dsc-fop-main")[0];
|
||||
const diskContainerEl =
|
||||
document.getElementsByClassName("disks-container")[0];
|
||||
|
||||
const seewoProxyPort = window._ACCEPT_DATA.data.ports.SeewoProxyHTTP;
|
||||
|
||||
const reqPromise = new Promise((resolve) => {
|
||||
fetch(
|
||||
`https://127.0.0.1:${seewoProxyPort}/forward/freeze/api/v1/get_disk_data`,
|
||||
{
|
||||
headers: {
|
||||
accept: "application/json, text/plain, */*",
|
||||
"X-Auth-Traceid": genRandomHex(),
|
||||
},
|
||||
}
|
||||
)
|
||||
.then(async (response) => {
|
||||
const parsedData = await response.json();
|
||||
|
||||
resolve({
|
||||
success: true,
|
||||
data: parsedData,
|
||||
status: response.status,
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
resolve({ success: false, data: null, errorObj: e });
|
||||
});
|
||||
});
|
||||
|
||||
const responseInfo = await reqPromise;
|
||||
|
||||
progressingEl.setAttribute("auraIf", "false");
|
||||
|
||||
if (!responseInfo.success) {
|
||||
onNotBindEl.setAttribute("auraIf", "false");
|
||||
mainEl.setAttribute("auraIf", "false");
|
||||
onErrorEl.setAttribute("auraIf", "true");
|
||||
const detailEl = document.getElementById("acsBcDscFopOnReqErrorDetail");
|
||||
// @ts-expect-error
|
||||
detailEl.textContent = responseInfo.errorObj;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (responseInfo.status !== 200) {
|
||||
onErrorEl.setAttribute("auraIf", "false");
|
||||
mainEl.setAttribute("auraIf", "false");
|
||||
onNotBindEl.setAttribute("auraIf", "true");
|
||||
return;
|
||||
}
|
||||
|
||||
diskContainerEl.innerHTML = ``;
|
||||
|
||||
const curDisks = [];
|
||||
for (const disk of responseInfo.data.data[0].disksData) {
|
||||
curDisks.push({ name: disk.diskName, status: disk.protectedStatus });
|
||||
}
|
||||
|
||||
const diskElTemplate = document.createElement("p");
|
||||
diskElTemplate.classList.add("acs-bc-dsc-fop-disk-el");
|
||||
if (!curConfig.enable) {
|
||||
for (const disk of curDisks) {
|
||||
const curDiskEl = diskElTemplate.cloneNode();
|
||||
if (disk.status !== 0) {
|
||||
// @ts-expect-error
|
||||
curDiskEl.classList.add("active");
|
||||
}
|
||||
curDiskEl.textContent = `${disk.name.toUpperCase()} 盘`;
|
||||
diskContainerEl.appendChild(curDiskEl);
|
||||
}
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
onErrorEl.setAttribute("auraIf", "false");
|
||||
onNotBindEl.setAttribute("auraIf", "false");
|
||||
mainEl.setAttribute("auraIf", "true");
|
||||
},
|
||||
};
|
||||
|
||||
const onMounted = () => {
|
||||
const rootEl = document.getElementsByClassName(
|
||||
"acs-bc-dsc-fop-container"
|
||||
)[0];
|
||||
|
||||
const eventListener = (_event) => {
|
||||
if (!global.__HUGO_AURA__.plsRules) return;
|
||||
composables.getAndUpdateDiskInfo(
|
||||
global.__HUGO_AURA__.plsRules.client.security.uploadFreezeInfo
|
||||
);
|
||||
};
|
||||
rootEl.addEventListener("onAssociateValueUpdated", eventListener);
|
||||
|
||||
setTimeout(() => {
|
||||
eventListener();
|
||||
}, 100);
|
||||
};
|
||||
|
||||
onMounted();
|
||||
})();
|
||||
|
||||
28
src/aura/utils/crypto.js
Normal file → Executable file
28
src/aura/utils/crypto.js
Normal file → Executable file
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
const genRandomHex = () => {
|
||||
let result = "";
|
||||
for (let i = 0; i < 8; i++) {
|
||||
const randomNum = Math.floor(Math.random() * 0x10000);
|
||||
result += randomNum.toString(16).padStart(4, "0");
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = { genRandomHex };
|
||||
/**
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
const genRandomHex = () => {
|
||||
let result = "";
|
||||
for (let i = 0; i < 8; i++) {
|
||||
const randomNum = Math.floor(Math.random() * 0x10000);
|
||||
result += randomNum.toString(16).padStart(4, "0");
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = { genRandomHex };
|
||||
|
||||
Reference in New Issue
Block a user