From 9fb6bb0ed68aa4939ed78205cb5e1e262f3b6d10 Mon Sep 17 00:00:00 2001 From: dzq Date: Wed, 21 May 2025 15:05:15 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=99=BA=E8=83=BD=E6=9F=9C=E5=8D=A1?= =?UTF-8?q?=E7=89=87):=20=E4=BC=98=E5=8C=96=E6=99=BA=E8=83=BD=E6=9F=9C?= =?UTF-8?q?=E5=8D=A1=E7=89=87=E8=A1=A8=E5=8D=95=E6=A8=A1=E6=80=81=E6=A1=86?= =?UTF-8?q?=E7=9A=84=E6=98=BE=E7=A4=BA=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将智能柜卡片表单模态框从`el-dialog`改为`el-drawer`,提升用户体验。同时修复了重复显示登录提示的问题,并优化了代码格式。 --- src/utils/http/index.ts | 38 +++++++++------- .../cabinet/smart-cabinet-card/index.vue | 7 +-- .../smart-cabinet-card-form-modal.vue | 45 +++++++++---------- 3 files changed, 46 insertions(+), 44 deletions(-) diff --git a/src/utils/http/index.ts b/src/utils/http/index.ts index 8801de5..6382eac 100644 --- a/src/utils/http/index.ts +++ b/src/utils/http/index.ts @@ -49,6 +49,9 @@ class PureHttp { /** 防止重复刷新token */ private static isRefreshing = false; + /** 防止重复显示登录提示 */ + private static isShowingLogin = false; + /** 初始化配置对象 */ private static initConfig: PureHttpRequestConfig = {}; @@ -90,10 +93,10 @@ class PureHttp { return whiteList.some(v => config.url.endsWith(v)) ? config : new Promise(resolve => { - const data = getToken(); - config.headers["Authorization"] = formatToken(data.token); - resolve(config); - }); + const data = getToken(); + config.headers["Authorization"] = formatToken(data.token); + resolve(config); + }); }, error => { return Promise.reject(error); @@ -137,22 +140,25 @@ class PureHttp { if (response.data.code !== 0) { // token失效时弹出过期提示 if (response.data.code === 106) { - ElMessageBox.confirm( - "登录状态已过期,您可以继续留在该页面,或者重新登录", - "系统提示", - { - confirmButtonText: "重新登录", - cancelButtonText: "取消", - type: "warning" - } - ) - .then(() => { + if (!PureHttp.isShowingLogin) { + PureHttp.isShowingLogin = true; + ElMessageBox.confirm( + "登录状态已过期,您可以继续留在该页面,或者重新登录", + "系统提示", + { + confirmButtonText: "重新登录", + cancelButtonText: "取消", + type: "warning" + } + ).then(() => { removeToken(); router.push("/login"); - }) - .catch(() => { + }).catch(() => { message("取消重新登录", { type: "info" }); + }).finally(() => { + PureHttp.isShowingLogin = false; }); + } NProgress.done(); return Promise.reject(msg); } else { diff --git a/src/views/cabinet/smart-cabinet-card/index.vue b/src/views/cabinet/smart-cabinet-card/index.vue index ce89f0f..cbf1bd9 100644 --- a/src/views/cabinet/smart-cabinet-card/index.vue +++ b/src/views/cabinet/smart-cabinet-card/index.vue @@ -125,8 +125,7 @@ onMounted(() => {
- 柜体名称:{{ item.cabinetName }} @@ -150,7 +149,9 @@ onMounted(() => {
- + + + diff --git a/src/views/cabinet/smart-cabinet-card/smart-cabinet-card-form-modal.vue b/src/views/cabinet/smart-cabinet-card/smart-cabinet-card-form-modal.vue index a55ba1f..9f4e080 100644 --- a/src/views/cabinet/smart-cabinet-card/smart-cabinet-card-form-modal.vue +++ b/src/views/cabinet/smart-cabinet-card/smart-cabinet-card-form-modal.vue @@ -22,7 +22,7 @@ const props = defineProps({ } }); -const emit = defineEmits(["update:visible", "refresh"]); +const emit = defineEmits(["update:modelValue", "refresh"]); const formRef = ref(); const formData = reactive({ @@ -60,7 +60,7 @@ const handleConfirm = async () => { const closeDialog = () => { formRef.value.resetFields(); - emit("update:visible", false); + emit("update:modelValue", false); }; const templateOptions = Object.entries(CabinetImgMap).map(([value, item]) => ({ @@ -70,32 +70,27 @@ const templateOptions = Object.entries(CabinetImgMap).map(([value, item]) => ({ \ No newline at end of file