diff --git a/src/aura/init/main/ipcModules/fsIpcHandler.js b/src/aura/init/main/ipcModules/fsIpcHandler.js old mode 100644 new mode 100755 index 6d0727a..cdb45b0 --- a/src/aura/init/main/ipcModules/fsIpcHandler.js +++ b/src/aura/init/main/ipcModules/fsIpcHandler.js @@ -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 }; diff --git a/src/aura/types/main/ipc/fs.d.ts b/src/aura/types/main/ipc/fs.d.ts old mode 100644 new mode 100755 index ff509d1..58483bd --- a/src/aura/types/main/ipc/fs.d.ts +++ b/src/aura/types/main/ipc/fs.d.ts @@ -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 } + >; +} diff --git a/src/aura/ui/composables/settingsRenderer.js b/src/aura/ui/composables/settingsRenderer.js index 2df7904..86cbb73 100755 --- a/src/aura/ui/composables/settingsRenderer.js +++ b/src/aura/ui/composables/settingsRenderer.js @@ -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) => { diff --git a/src/aura/ui/pages/configSubPages/behaviourCtrl/settings/deviceSecurity.js b/src/aura/ui/pages/configSubPages/behaviourCtrl/settings/deviceSecurity.js old mode 100644 new mode 100755 index 76b3adf..bb3c112 --- a/src/aura/ui/pages/configSubPages/behaviourCtrl/settings/deviceSecurity.js +++ b/src/aura/ui/pages/configSubPages/behaviourCtrl/settings/deviceSecurity.js @@ -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: "选择一种篡改模式, 选中的磁盘范围会被上报为冻结 (不是实际行为)", - 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: "选择一种篡改模式, 选中的磁盘范围会被上报为冻结 (不是实际行为)", + 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 }; diff --git a/src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.css b/src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.css old mode 100644 new mode 100755 index 96f4bb9..748bb7c --- a/src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.css +++ b/src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.css @@ -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; +} diff --git a/src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.html b/src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.html old mode 100644 new mode 100755 index cc829aa..b41db12 --- a/src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.html +++ b/src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.html @@ -1,91 +1,91 @@ -
-
- - - - - -

请稍候...

-
- -
- - - - - -

获取磁盘信息失败:

-
- -
- - - - - - - -

当前设备暂未绑定学校, 无法查询冰点信息

-
- -
-
-

C 盘

-
- -
-
- - - -

已冻结

-
-
- - - -

未冻结

-
-
-
-
+
+
+ + + + + +

请稍候...

+
+ +
+ + + + + +

获取磁盘信息失败:

+
+ +
+ + + + + + + +

当前设备暂未绑定学校, 无法查询冰点信息

+
+ +
+
+

C 盘

+
+ +
+
+ + + +

已冻结

+
+
+ + + +

未冻结

+
+
+
+
diff --git a/src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.js b/src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.js old mode 100644 new mode 100755 index 5322db5..401e248 --- a/src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.js +++ b/src/aura/ui/pages/configSubPages/behaviourCtrl/settings/previews/freezeOverridePreview/freezeOverridePreview.js @@ -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(); +})(); diff --git a/src/aura/utils/crypto.js b/src/aura/utils/crypto.js old mode 100644 new mode 100755 index 0779e55..4a472e7 --- a/src/aura/utils/crypto.js +++ b/src/aura/utils/crypto.js @@ -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 };