From 39765402803c3b2721b081e52ab863058caf1a80 Mon Sep 17 00:00:00 2001 From: ko1234 Date: Tue, 12 Aug 2025 10:40:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A0=90=E8=A8=AD2d=E5=9C=96=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=20|=20=E7=B3=BB=E7=B5=B1=E5=B0=8F=E5=8D=A1=E9=A0=90=E8=A8=AD?= =?UTF-8?q?=E8=89=B2=E8=99=9F=20|=20deleteBuilding()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 5 ++++- src/views/dashboard/Dashboard.vue | 19 +++++++++++++------ .../components/DashboardSysProgressModal.vue | 2 +- .../headquarters/HeadquartersManagement.vue | 6 +++++- .../components/SysProgressModal.vue | 2 +- src/views/system/System.vue | 18 +++++++++++++----- src/views/system/components/SystemCard.vue | 4 ++-- 7 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index b806ff3..5558e27 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -12,10 +12,11 @@ import SettingManagement from "@/views/setting/SettingManagement.vue"; import HeadquartersManagement from "@/views/headquarters/HeadquartersManagement.vue"; import Login from "@/views/login/Login.vue"; import useUserInfoStore from "@/stores/useUserInfoStore"; +import useBuildingStore from "@/stores/useBuildingStore"; import useGetCookie from "@/hooks/useGetCookie"; import System from "@/views/system/System.vue"; import SystemFloor from "@/views/system/SystemFloor.vue"; - + import Test from "@/views/Test.vue"; import SystemMain from "@/views/system/SystemMain.vue"; @@ -112,9 +113,11 @@ router.beforeEach(async (to, from, next) => { const auth = useUserInfoStore(); const token = useGetCookie("JWT-Authorization"); const user_name = useGetCookie("user_name"); + const buildingStore = useBuildingStore(); if ((authRequired && !token) || to.path === "/") { auth.user.token = ""; + buildingStore.deleteBuilding(); next({ path: "/login" }); } else if (!authRequired) { document.cookie = "JWT-Authorization=; Max-Age=0"; diff --git a/src/views/dashboard/Dashboard.vue b/src/views/dashboard/Dashboard.vue index aef0243..ea8eea3 100644 --- a/src/views/dashboard/Dashboard.vue +++ b/src/views/dashboard/Dashboard.vue @@ -35,16 +35,23 @@ watch( (newBuilding) => { if (newBuilding) { formState.value.building_guid = newBuilding.building_guid; - imgBaseUrl.value = store.previewImageExt - ? `${FILE_BASEURL}/upload/setting/previewImage/${newBuilding.building_guid}${store.previewImageExt}` - : import.meta.env.MODE === "production" - ? "dist/build_img.jpg" - : "/build_img.jpg"; } }, { immediate: true, deep: true } ); +watch( + () => store.previewImageExt, + (newExt) => { + if (formState.value.building_guid) { + imgBaseUrl.value = newExt + ? `${FILE_BASEURL}/upload/setting/previewImage/${formState.value.building_guid}${newExt}` + : "/build_img.jpg"; + } + }, + { immediate: true } +); + watch( () => formState.value, (newVal) => { @@ -139,7 +146,7 @@ onUnmounted(() => { diff --git a/src/views/dashboard/components/DashboardSysProgressModal.vue b/src/views/dashboard/components/DashboardSysProgressModal.vue index d6d63c9..170e3cc 100644 --- a/src/views/dashboard/components/DashboardSysProgressModal.vue +++ b/src/views/dashboard/components/DashboardSysProgressModal.vue @@ -88,7 +88,7 @@ watch( - {{ $t("table.time") }} + {{ $t("operation.updated_time") }} diff --git a/src/views/headquarters/HeadquartersManagement.vue b/src/views/headquarters/HeadquartersManagement.vue index f6773d1..fc8bf6b 100644 --- a/src/views/headquarters/HeadquartersManagement.vue +++ b/src/views/headquarters/HeadquartersManagement.vue @@ -28,7 +28,11 @@ import ElecCompare from "./components/ElecCompare.vue";
- +
diff --git a/src/views/headquarters/components/SysProgressModal.vue b/src/views/headquarters/components/SysProgressModal.vue index f7ede9f..73b38ec 100644 --- a/src/views/headquarters/components/SysProgressModal.vue +++ b/src/views/headquarters/components/SysProgressModal.vue @@ -93,7 +93,7 @@ watch( - {{ $t("table.time") }} + {{ $t("operation.updated_time") }} diff --git a/src/views/system/System.vue b/src/views/system/System.vue index c20709f..8b3a8ef 100644 --- a/src/views/system/System.vue +++ b/src/views/system/System.vue @@ -130,11 +130,6 @@ watch( (newBuilding) => { if (Boolean(newBuilding)) { getData(); - imgBaseUrl.value = buildingStore.previewImageExt - ? `${FILE_BASEURL}/upload/setting/previewImage/${newBuilding.building_guid}${buildingStore.previewImageExt}` - : import.meta.env.MODE === "production" - ? "dist/build_img.jpg" - : "/build_img.jpg"; } }, { @@ -143,6 +138,19 @@ watch( } ); + +watch( + () => buildingStore.previewImageExt, + (newValue) => { + if (buildingStore.selectedBuilding && buildingStore.selectedBuilding.building_guid) { + imgBaseUrl.value = buildingStore.previewImageExt + ? `${FILE_BASEURL}/upload/setting/previewImage/${buildingStore.selectedBuilding.building_guid}${newValue}` + : "/build_img.jpg"; + } + }, + { immediate: true } +); + watch( () => deptData.value, (newVal) => { diff --git a/src/views/system/components/SystemCard.vue b/src/views/system/components/SystemCard.vue index 9893c2f..9d86f82 100644 --- a/src/views/system/components/SystemCard.vue +++ b/src/views/system/components/SystemCard.vue @@ -25,8 +25,8 @@ const getDeviceStatusColor = (device) => { if (device.full_name === 'SmartSocket-AA001') return 'red'; if (device.full_name === 'SmartSocket-AA003' || device.full_name === 'SmartSocket-AA004') return 'gray'; const state = getDeviceRealtimeState(device.device_number); - if (state === 'offnormal' || state === '') return device.device_close_color || 'gray'; - return device.device_normal_color; + if (state === 'offnormal' || state === '') return device.device_close_color || '#9D9D9D'; + return device.device_normal_color || '#009100'; }; // 狀態文字