first commit

This commit is contained in:
cieanyau committed 2026-11-06 00:04:38 +08:00
commit db5762abd4
687 files changed
+171307

No files matched your search

@@ -0,0 +1,454 @@
<script>
import "~/assets/styles/ProductConfigurationSummary.BqZns1LB.css";
import { toDisplayString } from "vue";
import { renderList } from "vue";
import { onBeforeUnmount } from "vue";
import { watch } from "vue";
import { ref } from "vue";
import { createCommentVNode } from "vue";
import { computed } from "vue";
import { createElementBlock } from "vue";
import { Fragment } from "vue";
import { createElementVNode } from "vue";
import { unref } from "vue";
import { defineComponent } from "vue";
import { openBlock } from "vue";
import { useApi } from "~/lib/auth.js";
import { t as _plugin_vue_export_helper_t } from "~/lib/_plugin-vue_export-helper.js";
import { t as product_name_t } from "~/lib/product-name.js";
import { a as storage_capacity_a } from "~/lib/storage-capacity.js";
import { t as storage_capacity_t } from "~/lib/storage-capacity.js";
import { t as product_order_module_t } from "~/lib/product-order-module.js";
var y = {
timeoutMs: 5e3,
},
b = new Set([`remf_finance`, `remf_finance_dcim`, `remf_finance_common`]);
function x(e) {
return typeof e == `string` || typeof e == `number` ? String(e).trim() : ``;
}
function S(e) {
let t = x(e);
if (!/^\d+(?:\.\d+)?$/.test(t)) return;
let n = Number(t);
return Number.isFinite(n) && n > 0 ? n : void 0;
}
function C(e) {
let t = e.trim().replace(/\s+/g, ``).toLowerCase();
if (/^(cpu|处理器|cpu核心|cpu核数|核心数)$/.test(t)) return `cpu`;
if (/^(内存|运行内存|memory|ram)$/.test(t)) return `memory`;
if (/^(系统盘|系统磁盘)$/.test(t)) return `system`;
if (/^(数据盘|数据磁盘)$/.test(t)) return `data`;
if (/^(磁盘|硬盘|存储|disk)$/.test(t)) return `disk`;
if (
/^(?:(?:上行|下行|上联|下联|入站|出站|流入|流出|峰值|突发|共享|独享|网络|公网))*带宽(?:上限)?$/.test(
t,
)
)
return `bandwidth`;
if (/^(流量|流量额度|月流量|每月流量|流量包|traffic)$/.test(t))
return `traffic`;
}
function w(e) {
let t = e.match(/^(\d+(?:\.\d+)?)\s*(?:c\s*v?cpu|核|核心|v?cpu|cores?|c)?$/i);
return t && S(t[1])
? `${Number(t[1])}核`
: e.length <= 42 &&
/^(?:\d+\s*[x×*]\s*)?(?:Intel|AMD|Xeon|EPYC|E[3579]-|Ryzen)/i.test(e) &&
/^[\w\s.*×()+-]+$/.test(e)
? e.replace(/\s+/g, ` `)
: ``;
}
function T(e) {
let t = e.match(
/^(?:(\d+)\s*[x×*]\s*)?(\d+(?:\.\d+)?)\s*(TB|GB|MB|T|G|M)(?:\s*(SSD|HDD|NVMe|SAS|SATA|DDR[345](?:\s+ECC)?|ECC))?$/i,
);
if (!t || !S(t[2]) || (t[1] !== void 0 && !S(t[1]))) return ``;
let n = t[3].toUpperCase().replace(/^([TGM])$/, `$1B`);
return `${t[1] ? `${Number(t[1])}×` : ``}${Number(t[2])}${n}${t[4] ? ` ${t[4]}` : ``}`;
}
function E(e, t) {
let n = e
.replace(/\s+/g, ``)
.match(
/^((?:(?:突发|峰值|共享|独享|上行|下行|入站|出站|流入|流出|带宽))*)(\d+(?:\.\d+)?)(Mbps|Gbps|Kbps|M|G)((?:(?:突发|峰值|共享|独享|带宽))*)$/i,
);
if (!n || !S(n[2])) return ``;
let r = `${t}${n[1]}${n[4]}`,
i = /共享/.test(r) ? `共享` : /独享/.test(r) ? `独享` : ``,
a = /峰值/.test(r) ? `峰值` : /突发/.test(r) ? `突发` : ``,
o = /^g/i.test(n[3]) ? `Gbps` : /^k/i.test(n[3]) ? `Kbps` : `Mbps`;
return `${i}${a}${Number(n[2])}${o}`;
}
function D(e) {
let t = ``,
n = ``,
r = ``,
i = [],
a = [];
for (let o of e) {
let e = C(o.label);
if (e === `cpu` && !t) t = w(o.value);
else if (e === `memory` && !n) n = T(o.value);
else if (
e === `traffic` &&
!r &&
/^\d+(?:\.\d+)?\s*[TGM]B?$/i.test(o.value)
)
r = T(o.value);
else if (e === `disk` || e === `system` || e === `data`) {
let t = storage_capacity_t(o.value),
n =
t && t.size > 0
? `${t.size}${t.unit}${t.type ? ` ${t.type}` : ``}`
: T(o.value);
n &&
i.push(
`${n}${e === `system` ? `系统盘` : e === `data` ? `数据盘` : `磁盘`}`,
);
} else if (e === `bandwidth`) {
let e = E(o.value, o.label),
t = /上行|上联|出站|流出/.test(o.label)
? `上行`
: /下行|下联|入站|流入/.test(o.label)
? `下行`
: ``;
e &&
a.push({
direction: t,
value: e,
});
}
}
let o = [...new Set(a.map((e) => e.value))],
s =
o.length === 1
? o[0]
: [...new Set(a.map((e) => `${e.direction}${e.value}`))].join(` / `);
return [t, n, [...new Set(i)].join(`+`), s, r ? `${r}流量` : ``].filter(
(e) => !!e,
);
}
function O(e) {
if (e.kind !== `quantity`) return e.choices[0]?.label ?? ``;
let t =
e.unit ||
(C(e.label) === `system` || C(e.label) === `data` || C(e.label) === `disk`
? `GB`
: C(e.label) === `bandwidth`
? `Mbps`
: ``);
return `${e.min}${t}`;
}
function k(e) {
return (
e &&
(e.type === `step` || e.type === `total`
? (e.min_value ?? e.value)
: e.value)
);
}
function A(e, t, n = ``) {
return {
label: e,
value: S(t) === void 0 ? `` : `${Number(t)}${n}`,
};
}
async function j(e, t) {
if (!product_name_t(t.name)) return [];
let n = (t, n) => e.get(t, n, !1, y);
try {
let r = await product_order_module_t(
{
get: n,
},
t,
);
if (b.has(r)) {
let n = await e.getRaw(`/product/${t.id}/${r}/order_page`, void 0, y),
i = storage_capacity_a(n);
return i.linkDefinitions?.length ||
i.options.some((e) => e.kind === `cascade`)
? []
: D(
i.options.flatMap((e) =>
!C(e.label) || e.kind === `boolean` || e.kind === `os`
? []
: [
{
label: e.label,
value: O(e),
},
],
),
);
}
if (r === `idcsmart_common`) {
let e = await n(`/idcsmart_common/product/${t.id}/configoption`);
return e.advanced_rules?.length
? []
: D(
(e.configoptions ?? []).flatMap((e) =>
e.is_show !== 1 ||
!C(e.option_name) ||
![
`select`,
`multi_select`,
`quantity`,
`quantity_range`,
].includes(e.option_type)
? []
: [
{
label: e.option_name,
value:
e.option_type === `quantity` ||
e.option_type === `quantity_range`
? `${e.qty_min ?? 1}${e.unit ?? ``}`
: (e.subs?.[0]?.option_name ?? ``),
},
],
),
);
}
if (r === `mf_cloud`) {
let e = await n(`/product/${t.id}/mf_cloud/order_page`, {
id: t.id,
billing_cycle: `recurring_prepayment`,
}),
r = e.config,
i = e.system_disk?.[0],
a =
Number(r?.disk_range_limit_switch) === 1 && S(r?.disk_range_limit)
? Number(r.disk_range_limit)
: 1,
o = (e.system_disk ?? [])
.filter(
(e) =>
(e.other_config?.disk_type ?? ``) ===
(i?.other_config?.disk_type ?? ``),
)
.flatMap((e) => {
let t = S(k(e));
if (t === void 0) return [];
if (e.type !== `step` && e.type !== `total`) return [t];
let n = Math.ceil(t / a) * a,
r = Number(e.max_value ?? e.min_value ?? e.value);
return n <= Math.floor(r / a) * a ? [n] : [];
}),
s = [
A(`CPU`, e.cpu?.[0]?.value),
A(`内存`, k(e.memory?.[0]), r?.memory_unit || `GB`),
A(`系统盘`, o.length ? Math.min(...o) : void 0, `GB`),
];
Number(r?.free_disk_switch) === 1 &&
s.push(A(`数据盘`, r.free_disk_size, `GB`));
let c = e.data_center?.[0]?.city?.[0]?.area?.[0]?.line?.[0];
if (c?.id) {
let e = await n(`/product/${t.id}/mf_cloud/line/${c.id}`);
if (e.bill_type === `bw`) s.push(A(`带宽`, k(e.bw?.[0]), `Mbps`));
else if (e.bill_type === `flow`) {
let t = e.flow?.[0];
s.push(A(`流量`, t?.value, `GB`));
let n = t?.bw?.[0] ?? t?.other_config;
n &&
s.push(
A(`上行带宽`, n.out_bw, `Mbps`),
A(`下行带宽`, n.in_bw, `Mbps`),
);
}
}
return D(s);
}
if (r === `mf_dcim` || r === `remf_dcim`) {
let e = await n(`/product/${t.id}/${r}/order_page`);
if (e.config_limit?.length || e.limit_rule?.length) return [];
let i = e.model_config?.[0];
if (!i) return [];
let a = [
{
label: `CPU`,
value: x(i.cpu),
},
{
label: `内存`,
value: x(i.memory),
},
{
label: `磁盘`,
value: x(i.disk),
},
],
o = e.data_center
?.flatMap((e) => e.city ?? [])
.flatMap((e) => e.area ?? [])
.flatMap((e) => e.line ?? [])[0];
if (o?.id) {
let e = await n(`/product/${t.id}/${r}/line/${o.id}`);
e.bill_type === `bw`
? a.push(A(`带宽`, k(e.bw?.[0]), `Mbps`))
: e.bill_type === `flow` && a.push(A(`流量`, k(e.flow?.[0]), `GB`));
}
return D(a);
}
if (r === `kky_ecs`) {
let e = await n(`/product/${t.id}/kky_ecs/order_page`, {
id: t.id,
}),
r = e.package_list?.find(
(e) => Number(e.is_sell_out) !== 1 && S(e.cpu_num) && S(e.memory),
);
if (!r) return [];
let i = e.system_disk_config?.[String(r.id)],
a =
i &&
Number.isFinite(Number(i.min)) &&
Number.isFinite(Number(i.max)) &&
Math.max(Number(i.min), Number(i.max)) > 0,
o = [
A(`CPU`, r.cpu_num),
A(`内存`, r.memory, `GB`),
A(
`系统盘`,
a ? Math.max(0, Math.min(Number(i.min), Number(i.max))) : void 0,
`GB`,
),
],
s = e.network_list?.find(
(t) => e.bill_method_list?.[String(r.id)]?.[String(t.id)]?.length,
),
c = s
? e.bill_method_list?.[String(r.id)]?.[String(s.id)]?.[0]
: void 0;
return (c && o.push(A(`带宽`, c.config?.min, `Mbps`)), D(o));
}
} catch {}
return [];
}
var M = {
key: 0,
class: `product-configuration-summary`,
"aria-label": `默认配置`,
},
N = {
key: 0,
class: `summary-separator`,
"aria-hidden": `true`,
},
P = Object.assign(
_plugin_vue_export_helper_t(
defineComponent({
__name: `ProductConfigurationSummary`,
props: {
product: {},
summary: {},
},
setup(d) {
let m = d,
g = useApi(),
_ = ref([]),
v = computed(() => {
let e = (e) => /(?:[KMG]bps|流量)$/i.test(e);
return [_.value.filter((t) => !e(t)), _.value.filter(e)].filter(
(e) => e.length,
);
}),
y = 0;
return (
watch(
() => [
m.product.id,
m.product.name,
m.product.module,
m.product.res_module,
m.summary,
],
async () => {
let e = ++y;
if (((_.value = []), product_name_t(m.product.name))) {
if (m.summary !== void 0) {
_.value = m.summary;
return;
}
try {
let t = await j(g, m.product);
e === y && (_.value = t);
} catch {}
}
},
{
immediate: !0,
},
),
onBeforeUnmount(() => {
y++;
}),
(n, r) =>
unref(product_name_t)(d.product.name) && unref(_).length
? (openBlock(),
createElementBlock(`p`, M, [
(openBlock(!0),
createElementBlock(
Fragment,
null,
renderList(
unref(v),
(n, r) => (
openBlock(),
createElementBlock(
`span`,
{
key: r,
class: `summary-line`,
},
[
(openBlock(!0),
createElementBlock(
Fragment,
null,
renderList(
n,
(t, n) => (
openBlock(),
createElementBlock(
Fragment,
{
key: n,
},
[
n
? (openBlock(),
createElementBlock(`span`, N, `·`))
: createCommentVNode(``, !0),
createElementVNode(
`span`,
null,
toDisplayString(t),
1,
),
],
64,
)
),
),
128,
)),
],
)
),
),
128,
)),
]))
: createCommentVNode(``, !0)
);
},
}),
[[`__scopeId`, `data-v-cb8d72e4`]],
),
{
__name: `ProductConfigurationSummary`,
},
);
export { j as n };
export default P;
</script>