first commit
This commit is contained in:
commit
db5762abd4
687 files changed
+171307
No files matched your search
@@ -0,0 +1,636 @@
|
||||
<script>
|
||||
import "~/assets/styles/DcimDefence.BYaQccXZ.css";
|
||||
import { toDisplayString } from "vue";
|
||||
import { onMounted } from "vue";
|
||||
import { useId } from "vue";
|
||||
import { onBeforeUnmount } from "vue";
|
||||
import { watch } from "vue";
|
||||
import { createBlock } from "vue";
|
||||
import { ref } from "vue";
|
||||
import { withCtx } from "vue";
|
||||
import { createCommentVNode } from "vue";
|
||||
import { computed } from "vue";
|
||||
import { isRef } from "vue";
|
||||
import { createElementBlock } from "vue";
|
||||
import { Fragment } from "vue";
|
||||
import { createElementVNode } from "vue";
|
||||
import { createTextVNode } from "vue";
|
||||
import { unref } from "vue";
|
||||
import { defineComponent } from "vue";
|
||||
import { createVNode } from "vue";
|
||||
import { openBlock } from "vue";
|
||||
import { navigateTo } from "#app";
|
||||
import { useApi } from "~/lib/auth.js";
|
||||
import dialog from "primevue/dialog";
|
||||
import button from "primevue/button";
|
||||
import { t as _plugin_vue_export_helper_t } from "~/lib/_plugin-vue_export-helper.js";
|
||||
import message from "primevue/message";
|
||||
import select from "primevue/select";
|
||||
import OperationNotice from "~/components/OperationNotice.vue";
|
||||
import skeleton from "primevue/skeleton";
|
||||
var T = {
|
||||
class: `defence`,
|
||||
},
|
||||
E = {
|
||||
class: `head`,
|
||||
},
|
||||
D = [`id`],
|
||||
O = {
|
||||
class: `rows`,
|
||||
},
|
||||
k = {
|
||||
key: 0,
|
||||
class: `config-error`,
|
||||
},
|
||||
A = {
|
||||
key: 1,
|
||||
class: `muted`,
|
||||
},
|
||||
j = {
|
||||
class: `form`,
|
||||
},
|
||||
re = [`id`],
|
||||
ie = {
|
||||
key: 0,
|
||||
},
|
||||
ae = {
|
||||
key: 1,
|
||||
class: `muted`,
|
||||
},
|
||||
M = Object.assign(
|
||||
_plugin_vue_export_helper_t(
|
||||
defineComponent({
|
||||
__name: `DcimDefence`,
|
||||
props: {
|
||||
hostId: {},
|
||||
module: {},
|
||||
ip: {},
|
||||
additionalIp: {},
|
||||
peak: {},
|
||||
active: {
|
||||
type: Boolean,
|
||||
},
|
||||
upgradeAllowed: {
|
||||
type: Boolean,
|
||||
default: !0,
|
||||
},
|
||||
},
|
||||
setup(g) {
|
||||
let x = g,
|
||||
M = useApi(),
|
||||
N = ref(``),
|
||||
P = useId(),
|
||||
F = ref(x.ip),
|
||||
I = computed(() => [
|
||||
...new Set(
|
||||
[x.ip, ...(x.additionalIp || ``).split(/[,;]/)]
|
||||
.map((e) => e.trim())
|
||||
.filter(Boolean),
|
||||
),
|
||||
]),
|
||||
L = ref([]),
|
||||
R = ref(``),
|
||||
z = ref(!1),
|
||||
B = ref(``),
|
||||
V = ref(!1),
|
||||
H = ref(!1),
|
||||
U = ref(``),
|
||||
W = ref(!1),
|
||||
G = ref(``),
|
||||
K = ref(null),
|
||||
q = 0,
|
||||
J = 0,
|
||||
Y = !1,
|
||||
X = computed(() =>
|
||||
L.value.filter((e) => String(e.value) !== String(R.value)),
|
||||
);
|
||||
async function Z() {
|
||||
let e = ++q,
|
||||
t = F.value,
|
||||
n = x.hostId;
|
||||
if (
|
||||
((L.value = []),
|
||||
(R.value = ``),
|
||||
(B.value = ``),
|
||||
(z.value = !0),
|
||||
!t || x.upgradeAllowed === !1)
|
||||
) {
|
||||
z.value = !1;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
let r = await M.get(`/${x.module}/${n}/upgrade_defence_config`, {
|
||||
ip: t,
|
||||
});
|
||||
if (Y || e !== q || t !== F.value || n !== x.hostId) return;
|
||||
((L.value = Array.isArray(r.defence) ? r.defence : []),
|
||||
(R.value = r.current_defence ?? ``));
|
||||
} catch (t) {
|
||||
!Y &&
|
||||
e === q &&
|
||||
(B.value = t instanceof Error ? t.message : `防御配置暂不可用`);
|
||||
} finally {
|
||||
!Y && e === q && (z.value = !1);
|
||||
}
|
||||
}
|
||||
function oe() {
|
||||
x.upgradeAllowed !== !1 &&
|
||||
x.active &&
|
||||
!H.value &&
|
||||
!z.value &&
|
||||
X.value.length &&
|
||||
(J++,
|
||||
(U.value = ``),
|
||||
(K.value = null),
|
||||
(G.value = ``),
|
||||
(V.value = !0));
|
||||
}
|
||||
function Q() {
|
||||
H.value || ((V.value = !1), J++, (W.value = !1), (K.value = null));
|
||||
}
|
||||
async function $() {
|
||||
if (x.upgradeAllowed === !1) return;
|
||||
let e = ++J,
|
||||
t = U.value,
|
||||
n = F.value,
|
||||
r = x.hostId;
|
||||
if (((K.value = null), (G.value = ``), (W.value = !0), !t)) {
|
||||
W.value = !1;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
let i = await M.get(`/${x.module}/${r}/upgrade_defence/price`, {
|
||||
ip: n,
|
||||
peak_defence: t,
|
||||
});
|
||||
if (
|
||||
Y ||
|
||||
e !== J ||
|
||||
t !== U.value ||
|
||||
n !== F.value ||
|
||||
r !== x.hostId
|
||||
)
|
||||
return;
|
||||
if (
|
||||
i.price == null ||
|
||||
!Number.isFinite(Number(i.price)) ||
|
||||
Number(i.price) < 0
|
||||
)
|
||||
throw Error(`防御报价无效,请重试`);
|
||||
K.value = i;
|
||||
} catch (t) {
|
||||
!Y &&
|
||||
e === J &&
|
||||
(G.value = t instanceof Error ? t.message : `获取防御报价失败`);
|
||||
} finally {
|
||||
!Y && e === J && (W.value = !1);
|
||||
}
|
||||
}
|
||||
async function se() {
|
||||
if (
|
||||
x.upgradeAllowed === !1 ||
|
||||
H.value ||
|
||||
!x.active ||
|
||||
!V.value ||
|
||||
!K.value ||
|
||||
W.value ||
|
||||
!X.value.some((e) => String(e.value) === String(U.value))
|
||||
)
|
||||
return;
|
||||
let e = J,
|
||||
t = x.hostId,
|
||||
n = F.value;
|
||||
((H.value = !0), (G.value = ``), (N.value = ``));
|
||||
try {
|
||||
let r = await M.post(`/${x.module}/${t}/upgrade_defence/order`, {
|
||||
ip: n,
|
||||
peak_defence: U.value,
|
||||
});
|
||||
if (Y || e !== J || t !== x.hostId || n !== F.value) return;
|
||||
if (!r.id)
|
||||
throw Error(`订单编号未返回,请在订单管理中检查后再试`);
|
||||
((V.value = !1), await navigateTo(`/orders/${r.id}`));
|
||||
} catch (t) {
|
||||
!Y &&
|
||||
e === J &&
|
||||
(N.value = t instanceof Error ? t.message : `创建防御订单失败`);
|
||||
} finally {
|
||||
!Y && e === J && (H.value = !1);
|
||||
}
|
||||
}
|
||||
return (
|
||||
watch(F, () => {
|
||||
(Q(), Z());
|
||||
}),
|
||||
watch([() => x.hostId, () => x.module], () => {
|
||||
(q++, J++, (H.value = !1), (V.value = !1), (F.value = x.ip), Z());
|
||||
}),
|
||||
onMounted(Z),
|
||||
onBeforeUnmount(() => {
|
||||
((Y = !0), q++, J++);
|
||||
}),
|
||||
(t, n) => {
|
||||
let r = OperationNotice,
|
||||
i = message,
|
||||
o = select,
|
||||
l = button,
|
||||
y = skeleton,
|
||||
b = dialog;
|
||||
return (
|
||||
openBlock(),
|
||||
createElementBlock(
|
||||
Fragment,
|
||||
null,
|
||||
[
|
||||
createVNode(
|
||||
r,
|
||||
{
|
||||
message: unref(N),
|
||||
severity: `error`,
|
||||
},
|
||||
null,
|
||||
8,
|
||||
[`message`],
|
||||
),
|
||||
createElementVNode(`div`, T, [
|
||||
createVNode(
|
||||
i,
|
||||
{
|
||||
severity: `info`,
|
||||
closable: !1,
|
||||
},
|
||||
{
|
||||
default: withCtx(() => [
|
||||
(n[3] ||= createTextVNode(`当前实例可查看`, -1)),
|
||||
g.upgradeAllowed === !1
|
||||
? createCommentVNode(``, !0)
|
||||
: (openBlock(),
|
||||
createElementBlock(
|
||||
Fragment,
|
||||
{
|
||||
key: 0,
|
||||
},
|
||||
[createTextVNode(`和调整`)],
|
||||
64,
|
||||
)),
|
||||
(n[4] ||= createTextVNode(
|
||||
`平台提供的防御配置,暂未提供攻击事件与黑洞记录查询。`,
|
||||
-1,
|
||||
)),
|
||||
]),
|
||||
_: 1,
|
||||
},
|
||||
),
|
||||
createElementVNode(`div`, E, [
|
||||
(n[5] ||= createElementVNode(
|
||||
`h3`,
|
||||
null,
|
||||
`DDoS 防护`,
|
||||
-1,
|
||||
)),
|
||||
createElementVNode(
|
||||
`span`,
|
||||
{
|
||||
id: `${unref(P)}-ip-label`,
|
||||
},
|
||||
`IP 地址`,
|
||||
8,
|
||||
D,
|
||||
),
|
||||
createVNode(
|
||||
o,
|
||||
{
|
||||
modelValue: unref(F),
|
||||
"onUpdate:modelValue": (n[0] ||= (e) =>
|
||||
isRef(F) ? (F.value = e) : null),
|
||||
options: unref(I),
|
||||
"aria-labelledby": `${unref(P)}-ip-label`,
|
||||
disabled: unref(H),
|
||||
},
|
||||
null,
|
||||
8,
|
||||
[
|
||||
`modelValue`,
|
||||
`options`,
|
||||
`aria-labelledby`,
|
||||
`disabled`,
|
||||
],
|
||||
),
|
||||
createVNode(
|
||||
l,
|
||||
{
|
||||
label: `刷新`,
|
||||
text: ``,
|
||||
icon: `pi pi-refresh`,
|
||||
loading: unref(z),
|
||||
onClick: Z,
|
||||
},
|
||||
null,
|
||||
8,
|
||||
[`loading`],
|
||||
),
|
||||
]),
|
||||
createElementVNode(`dl`, O, [
|
||||
createElementVNode(`div`, null, [
|
||||
(n[6] ||= createElementVNode(
|
||||
`dt`,
|
||||
null,
|
||||
`防御峰值`,
|
||||
-1,
|
||||
)),
|
||||
createElementVNode(`dd`, null, [
|
||||
createTextVNode(
|
||||
toDisplayString(
|
||||
unref(R) || g.peak != null
|
||||
? `${unref(R) || g.peak} Gbps`
|
||||
: `未提供`,
|
||||
),
|
||||
1,
|
||||
),
|
||||
g.upgradeAllowed !== !1 && unref(X).length
|
||||
? (openBlock(),
|
||||
createBlock(
|
||||
l,
|
||||
{
|
||||
key: 0,
|
||||
label: `调整防御`,
|
||||
text: ``,
|
||||
size: `small`,
|
||||
disabled: !g.active || unref(H),
|
||||
onClick: oe,
|
||||
},
|
||||
null,
|
||||
8,
|
||||
[`disabled`],
|
||||
))
|
||||
: createCommentVNode(``, !0),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
unref(B)
|
||||
? (openBlock(),
|
||||
createElementBlock(`div`, k, [
|
||||
createElementVNode(
|
||||
`span`,
|
||||
null,
|
||||
toDisplayString(unref(B)),
|
||||
1,
|
||||
),
|
||||
createVNode(l, {
|
||||
label: `重试`,
|
||||
text: ``,
|
||||
size: `small`,
|
||||
onClick: Z,
|
||||
}),
|
||||
]))
|
||||
: g.upgradeAllowed !== !1 &&
|
||||
!unref(z) &&
|
||||
!unref(X).length
|
||||
? (openBlock(),
|
||||
createElementBlock(
|
||||
`p`,
|
||||
A,
|
||||
`此 IP 暂无可选的防御调整配置。`,
|
||||
))
|
||||
: createCommentVNode(``, !0),
|
||||
(n[7] ||= createElementVNode(`h3`, null, `攻击记录`, -1)),
|
||||
(n[8] ||= createElementVNode(
|
||||
`p`,
|
||||
{
|
||||
class: `unavailable`,
|
||||
},
|
||||
`攻击记录暂不可用`,
|
||||
-1,
|
||||
)),
|
||||
(n[9] ||= createElementVNode(`h3`, null, `黑洞记录`, -1)),
|
||||
(n[10] ||= createElementVNode(
|
||||
`p`,
|
||||
{
|
||||
class: `unavailable`,
|
||||
},
|
||||
`黑洞记录暂不可用`,
|
||||
-1,
|
||||
)),
|
||||
]),
|
||||
g.upgradeAllowed === !1
|
||||
? createCommentVNode(``, !0)
|
||||
: (openBlock(),
|
||||
createBlock(
|
||||
b,
|
||||
{
|
||||
key: 0,
|
||||
visible: unref(V),
|
||||
header: `确认调整防御`,
|
||||
modal: ``,
|
||||
style: {
|
||||
width: `480px`,
|
||||
},
|
||||
closable: !unref(H),
|
||||
"close-on-escape": !unref(H),
|
||||
"onUpdate:visible": (n[2] ||= (e) => {
|
||||
e || Q();
|
||||
}),
|
||||
},
|
||||
{
|
||||
footer: withCtx(() => [
|
||||
createVNode(
|
||||
l,
|
||||
{
|
||||
label: `取消`,
|
||||
severity: `secondary`,
|
||||
outlined: ``,
|
||||
disabled: unref(H),
|
||||
onClick: Q,
|
||||
},
|
||||
null,
|
||||
8,
|
||||
[`disabled`],
|
||||
),
|
||||
createVNode(
|
||||
l,
|
||||
{
|
||||
label: `确认并创建订单`,
|
||||
loading: unref(H),
|
||||
disabled:
|
||||
unref(H) ||
|
||||
!unref(K) ||
|
||||
unref(W) ||
|
||||
!g.active,
|
||||
onClick: se,
|
||||
},
|
||||
null,
|
||||
8,
|
||||
[`loading`, `disabled`],
|
||||
),
|
||||
]),
|
||||
default: withCtx(() => [
|
||||
createElementVNode(`div`, j, [
|
||||
createElementVNode(
|
||||
`p`,
|
||||
null,
|
||||
`实例 #` +
|
||||
toDisplayString(g.hostId) +
|
||||
` · ` +
|
||||
toDisplayString(unref(F)),
|
||||
1,
|
||||
),
|
||||
createElementVNode(
|
||||
`span`,
|
||||
{
|
||||
id: `${unref(P)}-peak-label`,
|
||||
},
|
||||
`防御配置`,
|
||||
8,
|
||||
re,
|
||||
),
|
||||
createVNode(
|
||||
o,
|
||||
{
|
||||
modelValue: unref(U),
|
||||
"onUpdate:modelValue": (n[1] ||= (e) =>
|
||||
isRef(U) ? (U.value = e) : null),
|
||||
options: unref(X),
|
||||
"option-label": `desc`,
|
||||
"option-value": `value`,
|
||||
"aria-labelledby": `${unref(P)}-peak-label`,
|
||||
disabled: unref(H),
|
||||
placeholder: `选择防御配置`,
|
||||
onChange: $,
|
||||
},
|
||||
null,
|
||||
8,
|
||||
[
|
||||
`modelValue`,
|
||||
`options`,
|
||||
`aria-labelledby`,
|
||||
`disabled`,
|
||||
],
|
||||
),
|
||||
unref(W)
|
||||
? (openBlock(),
|
||||
createBlock(y, {
|
||||
key: 0,
|
||||
height: `60px`,
|
||||
}))
|
||||
: unref(K)
|
||||
? (openBlock(),
|
||||
createElementBlock(
|
||||
Fragment,
|
||||
{
|
||||
key: 1,
|
||||
},
|
||||
[
|
||||
createElementVNode(`p`, null, [
|
||||
(n[11] ||= createTextVNode(
|
||||
`本次费用:`,
|
||||
-1,
|
||||
)),
|
||||
createElementVNode(
|
||||
`strong`,
|
||||
null,
|
||||
`¥` +
|
||||
toDisplayString(unref(K).price),
|
||||
1,
|
||||
),
|
||||
]),
|
||||
unref(K).renew_price_difference ==
|
||||
null
|
||||
? createCommentVNode(``, !0)
|
||||
: (openBlock(),
|
||||
createElementBlock(
|
||||
`p`,
|
||||
ie,
|
||||
`续费差价:¥` +
|
||||
toDisplayString(
|
||||
unref(K)
|
||||
.renew_price_difference,
|
||||
),
|
||||
1,
|
||||
)),
|
||||
unref(K).description
|
||||
? (openBlock(),
|
||||
createElementBlock(
|
||||
`p`,
|
||||
ae,
|
||||
toDisplayString(
|
||||
unref(K).description,
|
||||
),
|
||||
1,
|
||||
))
|
||||
: createCommentVNode(``, !0),
|
||||
],
|
||||
64,
|
||||
))
|
||||
: createCommentVNode(``, !0),
|
||||
unref(G)
|
||||
? (openBlock(),
|
||||
createBlock(
|
||||
i,
|
||||
{
|
||||
key: 2,
|
||||
severity: `error`,
|
||||
closable: !1,
|
||||
},
|
||||
{
|
||||
default: withCtx(() => [
|
||||
createTextVNode(
|
||||
toDisplayString(unref(G)),
|
||||
1,
|
||||
),
|
||||
!unref(H) && !unref(K)
|
||||
? (openBlock(),
|
||||
createBlock(l, {
|
||||
key: 0,
|
||||
label: `重试报价`,
|
||||
text: ``,
|
||||
size: `small`,
|
||||
onClick: $,
|
||||
}))
|
||||
: createCommentVNode(``, !0),
|
||||
]),
|
||||
_: 1,
|
||||
},
|
||||
))
|
||||
: createCommentVNode(``, !0),
|
||||
createVNode(
|
||||
i,
|
||||
{
|
||||
severity: `info`,
|
||||
closable: !1,
|
||||
},
|
||||
{
|
||||
default: withCtx(() => [
|
||||
...(n[12] ||= [
|
||||
createTextVNode(
|
||||
`确认后将创建调整订单,请核对费用后完成付款。`,
|
||||
-1,
|
||||
),
|
||||
]),
|
||||
]),
|
||||
_: 1,
|
||||
},
|
||||
),
|
||||
]),
|
||||
]),
|
||||
_: 1,
|
||||
},
|
||||
8,
|
||||
[`visible`, `closable`, `close-on-escape`],
|
||||
)),
|
||||
],
|
||||
64,
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
}),
|
||||
[[`__scopeId`, `data-v-2f38c55b`]],
|
||||
),
|
||||
{
|
||||
__name: `DcimDefence`,
|
||||
},
|
||||
);
|
||||
export {};
|
||||
export default M;
|
||||
</script>
|
||||
Reference in new issue
Block a user