From 1219bbc5e2f999c65d8d8c83282777b468321fe0 Mon Sep 17 00:00:00 2001
From: wangrong <wangrong@shsening.com>
Date: 星期六, 25 七月 2026 19:34:39 +0800
Subject: [PATCH] 修改萤石云token获取

---
 src/modules/monitor/views/device.vue |   29 ++++++++++-------------------
 1 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/src/modules/monitor/views/device.vue b/src/modules/monitor/views/device.vue
index 75bd43c..4f9edfb 100644
--- a/src/modules/monitor/views/device.vue
+++ b/src/modules/monitor/views/device.vue
@@ -37,40 +37,31 @@
 const { service } = useCool();
 
 const deviceList = ref<any[]>([]);
-const ysToken = ref<string>('');
+let ysToken = ref('');
 
-/** 鎷胯悿鐭� token */
 async function fetchYsToken() {
-  if (ysToken.value) return; // 宸叉湁灏变笉鍐嶉噸澶嶆嬁
+  if (ysToken.value) return;
   try {
-    const res = await service.monitor.ys7.getToken();
-    ysToken.value = res.accessToken;
-  } catch (e) {
-    console.error('钀ょ煶 Token 鑾峰彇澶辫触', e);
+    //const res = await service.monitor.ys7.getToken();
+	const res = await service.base.sys.param.stringbykey({key:"ys7.accessToken"});
+	ysToken = res;
+  } catch (e: any) {
+    console.error('钀ょ煶 Token 鑾峰彇澶辫触', e?.response?.data?.message || e.message);
   }
 }
 
-onMounted(() => {
-  fetchYsToken();
-});
+onMounted(fetchYsToken);
 
-/** 鏍戣妭鐐圭偣鍑� */
 async function handleTreeSelect(businessId: string | number | null) {
   if (!businessId) {
     deviceList.value = [];
     return;
   }
-
-  // 淇濋櫓锛歵oken 涓囦竴鎱簬鏍戠偣鍑�
-  if (!ysToken.value) {
-    await fetchYsToken();
-  }
-
+  if (!ysToken.value) await fetchYsToken();
   try {
     const res = await service.basicdata.iot.getYsDevices({ businessId });
     deviceList.value = res || [];
-  } catch (err) {
-    console.error('鑾峰彇钀ょ煶璁惧鍒楄〃澶辫触', err);
+  } catch {
     deviceList.value = [];
   }
 }

--
Gitblit v1.9.1