From a4e56a7e2d2c4fda1ec3d0bfdecc15841a72cd32 Mon Sep 17 00:00:00 2001 From: ko1234 Date: Thu, 11 Sep 2025 10:52:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=91=8A=E8=AD=A6=E6=97=A5?= =?UTF-8?q?=E8=AA=8CAPI=E6=95=B4=E5=90=88=EF=BC=8C=E8=AA=BF=E6=95=B4?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E6=9F=A5=E8=A9=A2=E9=82=8F=E8=BC=AF=E8=88=87?= =?UTF-8?q?=E9=A1=AF=E7=A4=BA=EF=BC=8C=E5=84=AA=E5=8C=96=E5=84=80=E8=A1=A8?= =?UTF-8?q?=E6=9D=BF=E5=91=8A=E8=AD=A6=E9=A1=AF=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 24 ++++ src/apis/alert/api.js | 1 + src/apis/alert/index.js | 19 +++ src/components/alarm/AlarmDrawer.vue | 1 - src/components/forge/Forge.vue | 12 -- src/components/navbar/Navbar.vue | 5 +- src/components/navbar/NavbarItem.vue | 52 ++++++-- .../components/AlertQuery/AlertQuery.vue | 118 ++++++------------ .../components/AlertQuery/AlertSearch.vue | 2 - .../AlertQuery/AlertSearchAckBtns.vue | 2 +- .../AlertQuery/AlertSearchNormalBtns.vue | 10 +- .../AlertQuery/AlertSearchTimeRange.vue | 25 ++-- .../AlertQuery/AlertSearchTypesButton.vue | 30 ++--- .../components/AlertQuery/AlertTable.vue | 49 ++------ .../components/AlertQuery/AlertTableModal.vue | 31 ++--- .../dashboard/components/DashboardAlert.vue | 66 +++------- 16 files changed, 211 insertions(+), 236 deletions(-) diff --git a/src/App.vue b/src/App.vue index 689e491..6f4f4e6 100644 --- a/src/App.vue +++ b/src/App.vue @@ -3,9 +3,12 @@ import { RouterView } from "vue-router"; import Navbar from "./components/navbar/Navbar.vue"; import useUserInfoStore from "@/stores/useUserInfoStore"; import { ref, provide, onUnmounted, onMounted } from "vue"; +import { getAlertLog } from "@/apis/alert"; +import dayjs from "dayjs"; const store = useUserInfoStore(); +const alerts = ref([]); let isToastOpen = ref({ open: false, content: "", @@ -24,6 +27,16 @@ const cancelToastOpen = () => { }; }; +let alertInterval = null; +const getAlert = async () => { + const res = await getAlertLog({ + isRecovery: 1, + Start_date: dayjs().subtract(30, "day").format("YYYY-MM-DD"), + End_date: dayjs().format("YYYY-MM-DD"), + }); + alerts.value = (res.data || []).map((d) => ({ ...d, key: d.id })); +}; + const openToast = (status, content, to = "body", confirm = null) => { isToastOpen.value = { open: true, @@ -33,8 +46,19 @@ const openToast = (status, content, to = "body", confirm = null) => { confirm, }; }; + +onMounted(() => { + getAlert(); + alertInterval = setInterval(getAlert, 30 * 1000); +}); + +onUnmounted(() => { + if (alertInterval) clearInterval(alertInterval); +}); + provide("app_toast", { openToast, cancelToastOpen }); provide("app_toggle", { forgeLock, toggleForgeLock }); +provide("app_alerts", alerts);