Files
console-dev/app/lib/modules.js
T
cieanyau 651c36367f
前端验证 / verify (push) Failing after 15m2s
接入 ESLint 与 Prettier 并加入 CI 静态门禁
2026-11-07 01:24:36 +08:00

67 lines
2.0 KiB
JavaScript

/** 商品模块分类和操作系统图标选择;模块标识仍按后端协议保留,不作为面向会员的文案。 */
var e = {
cloud: [
`mf_cloud`,
`kky_ecs`,
`whmcs_cloud`,
`mf_finance`,
`remf_finance`,
`jy_cloud`,
],
dcim: [
`mf_dcim`,
`remf_dcim`,
`mf_finance_dcim`,
`remf_finance_dcim`,
`whmcs_dcim`,
`jy_dcim`,
],
common: [`idcsmart_common`, `mf_finance_common`],
};
/** 优先采用合法站内/HTTP(S)图片地址;否则从 e/n 的系统描述推断本地图标。 */
function t(e, t, n) {
let r = String(e ?? ``).trim();
// eslint-disable-next-line no-control-regex -- 安全边界:拒绝模块 URL 内的控制字符。
if (r && !/[\u0000-\u0020\u007f\\]/.test(r)) {
if (/^\/(?!\/)/.test(r)) return r;
try {
let e = new URL(r.startsWith(`//`) ? `https:${r}` : r);
if (/^(https?:)$/.test(e.protocol) && !e.username && !e.password)
return r;
} catch {}
}
// t 是恢复导出的保留参数;当前实现以 e 和 n 匹配系统别名,未知系统显示 Other。
let i = [
[`Windows`, [`windows`, `winserver`]],
[`Ubuntu`, [`ubuntu`]],
[`Debian`, [`debian`]],
[`TencentOS-Server`, [`tencentos`]],
[`CentOS`, [`centos`]],
[`Rocky`, [`rocky`]],
[`AlmaLinux`, [`almalinux`]],
[`OpenEuler`, [`openeuler`, `euleros`]],
[`RedHat`, [`redhat`, `rhel`]],
[`Fedora`, [`fedora`, `fedroa`]],
[`ArchLinux`, [`archlinux`]],
[`FreeBSD`, [`freebsd`]],
[`ESXi`, [`esxi`]],
[`XenServer`, [`xenserver`]],
[`OpenClaw`, [`openclaw`]],
],
a = [e, n].map((e) =>
String(e ?? ``)
.toLowerCase()
.replace(/[\s_.\-/]+/g, ``),
);
for (let e of a) {
let t = i.find(([, t]) => t.some((t) => e.includes(t)));
if (t) return `/images/os/${t[0]}.svg`;
}
return a.some((e) => /linux|alpine|opensuse|suse/.test(e))
? `/images/os/Linux.svg`
: e || n
? `/images/os/Other.svg`
: ``;
}
export { t as n, e as t };