first commit
This commit is contained in:
commit
db5762abd4
687 files changed
+171307
No files matched your search
@@ -0,0 +1,100 @@
|
||||
function e(e, t) {
|
||||
let n = typeof e == `string` ? e.trim() : ``;
|
||||
return t === `area` || Number(t) === 12
|
||||
? `区域`
|
||||
: t === `os` || Number(t) === 5
|
||||
? `操作系统`
|
||||
: /^(区域|地区|地域|数据中心|机房)$/.test(n)
|
||||
? `区域`
|
||||
: /^(线路|网络线路)$/.test(n)
|
||||
? `线路`
|
||||
: /^(带宽|网络带宽|带宽上限)$/.test(n)
|
||||
? `带宽上限`
|
||||
: /^(镜像|系统|系统镜像|镜像名称|操作系统)$/.test(n)
|
||||
? `操作系统`
|
||||
: /^(系统版本|镜像版本)$/.test(n)
|
||||
? `镜像版本`
|
||||
: n;
|
||||
}
|
||||
function t(e) {
|
||||
let t = typeof e == `string` ? e.trim() : ``;
|
||||
return /^(normal|classic|经典网络)$/i.test(t)
|
||||
? `经典网络`
|
||||
: /^(vpc(?:\s*网络)?|私有网络)$/i.test(t)
|
||||
? `VPC 网络`
|
||||
: t;
|
||||
}
|
||||
function n(e) {
|
||||
if (typeof e == `string`)
|
||||
try {
|
||||
return n(JSON.parse(e));
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
return e && typeof e == `object` && !Array.isArray(e) ? e : {};
|
||||
}
|
||||
function r(e) {
|
||||
return typeof e == `string` ? e.trim() : ``;
|
||||
}
|
||||
function i(i, a, o) {
|
||||
let s = n(a),
|
||||
c = n(o),
|
||||
l = n(s.data_center ?? c.data_center),
|
||||
u =
|
||||
s.config_options ??
|
||||
s.configoptions ??
|
||||
c.config_options ??
|
||||
c.configoptions,
|
||||
d = [];
|
||||
if (Array.isArray(u)) d = u.map(n);
|
||||
else if (typeof u == `string`)
|
||||
try {
|
||||
let e = JSON.parse(u);
|
||||
Array.isArray(e) && (d = e.map(n));
|
||||
} catch {}
|
||||
let f = (t) => d.find((n) => e(n.option_name ?? n.name, n.option_type) === t),
|
||||
p = (e) => {
|
||||
let t = f(e);
|
||||
return t
|
||||
? r(t.sub_name ?? t.value ?? t.cascade_path) ||
|
||||
(Array.isArray(t.subs)
|
||||
? t.subs
|
||||
.map((e) => r(n(e).option_name))
|
||||
.filter(Boolean)
|
||||
.join(` / `)
|
||||
: ``)
|
||||
: ``;
|
||||
},
|
||||
m = [r(l.city), r(l.area)].filter(Boolean),
|
||||
h = m.length
|
||||
? [...new Set(m)].join(` / `)
|
||||
: r(l.name) || r(l.country) || r(s.data_center) || r(c.data_center);
|
||||
return i === `kky_ecs`
|
||||
? {
|
||||
region: r(s.line_name) || r(c.line_name) || h,
|
||||
line: r(s.network_name) || r(c.network_name),
|
||||
networkType: `经典网络`,
|
||||
}
|
||||
: i === `jy_cloud` || i === `jy_dcim`
|
||||
? {
|
||||
region:
|
||||
h ||
|
||||
r(s.region_name) ||
|
||||
r(s.area_name) ||
|
||||
p(`区域`) ||
|
||||
r(s.line_name) ||
|
||||
r(c.line_name),
|
||||
line: r(n(s.line).name) || r(s.line_name) || r(c.line_name),
|
||||
networkType: t(s.network_type ?? c.network_type),
|
||||
}
|
||||
: {
|
||||
region: h || p(`区域`),
|
||||
line:
|
||||
r(n(s.line).name) ||
|
||||
r(s.line_name) ||
|
||||
r(n(c.line).name) ||
|
||||
p(`线路`),
|
||||
networkType: t(s.network_type ?? c.network_type) || t(p(`网络类型`)),
|
||||
};
|
||||
}
|
||||
export { i as n, t as r, e as t };
|
||||
Reference in new issue
Block a user