From a463711b03a20120f2a298be15d71ca152d27f21 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Wed, 28 May 2025 13:57:31 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E7=AB=99=E7=82=B9ip?= =?UTF-8?q?=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/certd/monitor/site/api.ts | 11 +++ .../src/views/certd/monitor/site/crud.tsx | 47 +++++++++--- .../src/views/certd/monitor/site/ip/crud.tsx | 74 ++++++++++++------- .../src/views/certd/monitor/site/ip/index.vue | 20 ++--- .../src/views/certd/notification/common.tsx | 72 +++++++++--------- .../src/views/certd/notification/crud.tsx | 16 ++-- .../user/monitor/site-info-controller.ts | 14 +++- .../user/monitor/site-ip-controller.ts | 18 ++++- .../monitor/service/site-info-service.ts | 24 +++++- .../monitor/service/site-ip-service.ts | 46 +++++------- .../modules/monitor/service/site-tester.ts | 16 ++-- 11 files changed, 219 insertions(+), 139 deletions(-) diff --git a/packages/ui/certd-client/src/views/certd/monitor/site/api.ts b/packages/ui/certd-client/src/views/certd/monitor/site/api.ts index f5e7a64f..f1fb6065 100644 --- a/packages/ui/certd-client/src/views/certd/monitor/site/api.ts +++ b/packages/ui/certd-client/src/views/certd/monitor/site/api.ts @@ -55,4 +55,15 @@ export const siteInfoApi = { method: "post", }); }, + + async IpCheckChange(id: number, ipCheck: boolean) { + return await request({ + url: apiPrefix + "/ipCheckChange", + method: "post", + data: { + id, + ipCheck, + }, + }); + }, }; diff --git a/packages/ui/certd-client/src/views/certd/monitor/site/crud.tsx b/packages/ui/certd-client/src/views/certd/monitor/site/crud.tsx index 7d017d18..0b98c37b 100644 --- a/packages/ui/certd-client/src/views/certd/monitor/site/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/monitor/site/crud.tsx @@ -1,9 +1,9 @@ // @ts-ignore import { useI18n } from "vue-i18n"; -import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud"; +import { AddReq, ColumnCompositionProps, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud"; import { siteInfoApi } from "./api"; import dayjs from "dayjs"; -import { notification } from "ant-design-vue"; +import { Modal, notification } from "ant-design-vue"; import { useSettingStore } from "/@/store/settings"; import { mySuiteApi } from "/@/views/certd/suite/mine/api"; import { mitter } from "/@/utils/util.mitt"; @@ -119,10 +119,13 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat }); }, }, - ipMonitor: { - order: 0, + ipCheck: { + order: 10, type: "link", text: null, + show: compute(({ row }) => { + return row.ipCheck === true; + }), tooltip: { title: "IP管理", }, @@ -327,26 +330,46 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat }, }, ipCheck: { - title: "检查IP", - search: { - show: false, - }, + title: "开启IP检查", type: "dict-switch", dict: dict({ data: [ { label: "启用", value: false, color: "green" }, - { label: "禁用", value: true, color: "red" }, + { label: "禁用", value: true, color: "gray" }, ], }), form: { value: false, + rules: [{ required: true, message: "请选择" }], }, column: { - width: 100, - sorter: true, align: "center", + width: 100, + conditionalRender: false, + component: { + name: "a-switch", + vModel: "checked", + on: { + change({ row, $event }) { + Modal.confirm({ + title: "提示", + content: `确定${$event ? "开启" : "关闭"}IP检查?`, + onOk: async () => { + await api.IpCheckChange(row.id, $event); + await crudExpose.doRefresh(); + if ($event) { + openSiteIpMonitorDialog({ siteId: row.id }); + } + }, + onCancel: async () => { + await crudExpose.doRefresh(); + }, + }); + }, + }, + }, }, - }, + } as ColumnCompositionProps, ipCount: { title: "IP数量", search: { diff --git a/packages/ui/certd-client/src/views/certd/monitor/site/ip/crud.tsx b/packages/ui/certd-client/src/views/certd/monitor/site/ip/crud.tsx index 8b8ba1c3..60518bcf 100644 --- a/packages/ui/certd-client/src/views/certd/monitor/site/ip/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/monitor/site/ip/crud.tsx @@ -12,12 +12,15 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat const { crudBinding } = crudExpose; const pageRequest = async (query: UserPageQuery): Promise => { + if (!query.query) { + query.query = {}; + } + query.query.siteId = context.props.siteId; return await api.GetList(query); }; const editRequest = async (req: EditReq) => { const { form, row } = req; form.id = row.id; - form.siteId = context.props.siteId; const res = await api.UpdateObj(form); return res; }; @@ -73,6 +76,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat }, load: { text: "同步IP", + type: "primary", async click() { Modal.confirm({ title: "同步IP", @@ -87,6 +91,23 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat }); }, }, + checkAll: { + text: "检查全部", + type: "primary", + click: () => { + Modal.confirm({ + title: "确认", + content: "确认触发检查全部IP站点的证书吗?", + onOk: async () => { + await siteIpApi.CheckAll(context.props.siteId); + notification.success({ + message: "检查任务已提交", + description: "请稍后刷新页面查看结果", + }); + }, + }); + }, + }, }, }, rowHandle: { @@ -105,7 +126,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat await api.DoCheck(row.id); await crudExpose.doRefresh(); notification.success({ - message: "检查完成", + message: "检查任务已提交", }); }, }, @@ -152,7 +173,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat column: { width: 200, sorter: true, - show: true, + show: false, cellRender({ value }) { return ( @@ -173,6 +194,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat }, column: { width: 200, + show: false, sorter: true, cellRender({ value }) { return {value}; @@ -224,6 +246,29 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat }, }, }, + checkStatus: { + title: "检查状态", + search: { + show: false, + }, + type: "dict-select", + dict: checkStatusDict, + form: { + show: false, + }, + column: { + width: 100, + align: "center", + sorter: true, + cellRender({ value, row, key }) { + return ( + + + + ); + }, + }, + }, lastCheckTime: { title: "上次检查时间", search: { @@ -280,29 +325,6 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat align: "center", }, }, - checkStatus: { - title: "检查状态", - search: { - show: false, - }, - type: "dict-select", - dict: checkStatusDict, - form: { - show: false, - }, - column: { - width: 100, - align: "center", - sorter: true, - cellRender({ value, row, key }) { - return ( - - - - ); - }, - }, - }, remark: { title: "备注", search: { diff --git a/packages/ui/certd-client/src/views/certd/monitor/site/ip/index.vue b/packages/ui/certd-client/src/views/certd/monitor/site/ip/index.vue index d4c31fd6..27925b7c 100644 --- a/packages/ui/certd-client/src/views/certd/monitor/site/ip/index.vue +++ b/packages/ui/certd-client/src/views/certd/monitor/site/ip/index.vue @@ -5,7 +5,7 @@