From f8082d5557283329c760e4084cca5da996cf418b Mon Sep 17 00:00:00 2001 From: kevin Date: Sat, 1 Nov 2025 18:49:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=A1=86=E5=8A=9F=E8=83=BDok?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ops_vue/src/components/MyOffcanvas.vue | 36 +++++++++++++------ frontent/ops_vue/src/i18n/zh-CN.json | 4 +-- frontent/ops_vue/src/views/HomeView.vue | 7 ++-- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/frontent/ops_vue/src/components/MyOffcanvas.vue b/frontent/ops_vue/src/components/MyOffcanvas.vue index 873ae3c..4479277 100644 --- a/frontent/ops_vue/src/components/MyOffcanvas.vue +++ b/frontent/ops_vue/src/components/MyOffcanvas.vue @@ -6,29 +6,45 @@ const offcanvasTop = ref(null) let ov: Offcanvas const alertType=ref() // 可选值:'success', 'warning', 'danger', 'info' const alertText=ref() +let autoCloseTimeout:number onMounted(() => { // 确保在组件挂载后初始化 if (offcanvasTop.value) { - ov = new Offcanvas(offcanvasTop.value) + ov = new Offcanvas(offcanvasTop.value,{ + backdrop: false, + }) //ov.show(); //console.log('Offcanvas initialized:', ov) } }) -// function showOffcanvas() { -// if (ov) { -// ov.show() -// } -// } function showAlert(type: string, text: string) { - alertType.value = type; alertText.value = text; + + alertType.value = type; + //console.log(ov); if (ov) { - ov.show() + ov.hide(); + ov.show(); + if(autoCloseTimeout) + { + clearTimeout(autoCloseTimeout); + } + autoCloseTimeout=setTimeout(() => { + //console.log("timeout"); + ov.hide(); + }, 5000); + + } } +defineExpose({ + showAlert +}); + +