From 39f0d1e126678093bebd42d2ac77265f0d620264 Mon Sep 17 00:00:00 2001 From: tao Date: Tue, 30 Sep 2025 15:46:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=87=E6=8D=A2LMS?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=8A=9F=E8=83=BD=EF=BC=9A=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E4=B8=8D=E5=85=81=E8=AE=B8=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/LmsStatus/index.vue | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/LmsStatus/index.vue b/src/components/LmsStatus/index.vue index 461f945..b74eef3 100644 --- a/src/components/LmsStatus/index.vue +++ b/src/components/LmsStatus/index.vue @@ -10,7 +10,7 @@ LMS 状态 - + @@ -37,6 +37,7 @@ import { message } from 'ant-design-vue'; const { visible: dialogVisible, show, hide } = useDialog(); const isOnline = ref(false); +const loading = ref(false); const lmsStatus = computed(() => isOnline.value ? '在线' : '离线'); const onlineStatusClass = computed(() => { @@ -45,12 +46,19 @@ const onlineStatusClass = computed(() => { // 当请求发送成功后才切换状态 async function handleToggleOnline(checked: boolean | string | number) { - await updateLmsWorkMode(checked ? 1 : 0).then(() => { + console.log('checked', checked); + loading.value = true; + + try { + await updateLmsWorkMode(checked ? 1 : 0); isOnline.value = Boolean(checked); message.success('切换成功'); - }).catch((error) => { + } catch (e) { + isOnline.value = !Boolean(checked); message.error('切换失败'); - }); + } finally { + loading.value = false; + } } const modalTitle = ref('LMS 状态');