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 +}); + +