docs: annotate all shared frontend modules in Chinese
This commit is contained in:
1 parent
2be21c1c62
commit
408f8e5c98
55 files changed
+349
No files matched your search
@@ -1,13 +1,16 @@
|
||||
/** 多供应商实例数据展示适配;缺失/无效数值用 null 表示,避免误显示为有效的 0。 */
|
||||
function e(e) {
|
||||
if (e == null || e === ``) return null;
|
||||
let t = Number(e);
|
||||
return Number.isFinite(t) ? t : null;
|
||||
}
|
||||
// 远控端口必须处于 TCP/UDP 有效范围,空值和非整数返回 null。
|
||||
function t(t) {
|
||||
if (typeof t != `number` && typeof t != `string`) return null;
|
||||
let n = e(t);
|
||||
return n !== null && Number.isInteger(n) && n >= 1 && n <= 65535 ? n : null;
|
||||
}
|
||||
// 兼容接口返回对象或序列化对象,格式不符合时返回空对象供上层做缺值展示。
|
||||
function n(e) {
|
||||
if (typeof e == `string`)
|
||||
try {
|
||||
@@ -26,12 +29,14 @@ function r(e) {
|
||||
}
|
||||
return Array.isArray(e) ? e.filter((e) => e && typeof e == `object`) : [];
|
||||
}
|
||||
/** 将秒、毫秒或日期字符串归一为 Unix 秒;超过 10^12 的数值按毫秒处理。 */
|
||||
function i(t) {
|
||||
let n = e(t);
|
||||
if (n !== null) return n > 0xe8d4a51000 ? Math.floor(n / 1e3) : n || void 0;
|
||||
let r = Date.parse(String(t ?? ``).replace(` `, `T`));
|
||||
return Number.isFinite(r) ? Math.floor(r / 1e3) : void 0;
|
||||
}
|
||||
// 容量统一为 GB(1024 进制),无单位时使用 t;“不限”按既有展示协议返回 0。
|
||||
function a(e, t = `GB`) {
|
||||
if (typeof e == `string` && /不限|unlimited/i.test(e)) return 0;
|
||||
let n = /^\s*(-?\d+(?:\.\d+)?(?:e[+-]?\d+)?)\s*([KMGT]?B)?\s*$/i.exec(
|
||||
@@ -50,6 +55,10 @@ function a(e, t = `GB`) {
|
||||
}[r] ?? 1);
|
||||
return Number.isFinite(i) ? i : null;
|
||||
}
|
||||
/**
|
||||
* t 为模块名,r 为实例详情,i 为实时流量/配额响应;区分总量、计量模式和小时统计。
|
||||
* kky_ecs 的完整小时数据不冒充本周期累计量;配额是否加载与配额是否存在单独表达。
|
||||
*/
|
||||
function o(t, r, i) {
|
||||
let o = n(r),
|
||||
s = n(i),
|
||||
@@ -134,6 +143,7 @@ function o(t, r, i) {
|
||||
(T = l.mode === `traffic`),
|
||||
d && (T = d === `traffic`));
|
||||
}
|
||||
// 只有非小时统计才允许由总量和剩余量互推;否则不同时间口径不可直接相减。
|
||||
return (
|
||||
!E &&
|
||||
x !== null &&
|
||||
@@ -173,6 +183,7 @@ function o(t, r, i) {
|
||||
}
|
||||
);
|
||||
}
|
||||
// 大容量按 GB/TB 展示;null 用破折号,而不是把缺失值当作零。
|
||||
function s(e) {
|
||||
return e === null
|
||||
? `—`
|
||||
@@ -180,6 +191,7 @@ function s(e) {
|
||||
? `${(e / 1024).toFixed(2)} TB`
|
||||
: `${e.toFixed(2)} GB`;
|
||||
}
|
||||
// 小流量继续降为 MB/KB/B,避免低于 1 GB 的真实用量全部显示成 0.00 GB。
|
||||
function c(e) {
|
||||
return e === null
|
||||
? `—`
|
||||
@@ -193,6 +205,7 @@ function c(e) {
|
||||
? `${(e * 1024 ** 2).toFixed(2)} KB`
|
||||
: `${(e * 1024 ** 3).toFixed(0)} B`;
|
||||
}
|
||||
/** 归一磁盘名称、容量和时间,保留 raw 供模块特有操作读取原始字段。 */
|
||||
function l(t) {
|
||||
let o = n(t);
|
||||
return r(o.disk ?? o.disks ?? o.disk_list).map((t, n) => {
|
||||
@@ -211,6 +224,7 @@ function l(t) {
|
||||
};
|
||||
});
|
||||
}
|
||||
// 镜像名称按接口字段优先级读取,最后使用财务模块 host_data 中的系统名。
|
||||
function u(e) {
|
||||
let t = n(e),
|
||||
i = n(t.image),
|
||||
@@ -224,6 +238,7 @@ function u(e) {
|
||||
url: String(t.image_icon_url ?? i.icon_url ?? ``),
|
||||
};
|
||||
}
|
||||
// 操作日志存在多种字段命名;只归一数据,不在此层改变日志正文。
|
||||
function d(e, t) {
|
||||
let r = n(e);
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user