Ver código fonte

perf(views): 获取设备属性列表时显示 loading

wangcong 2 semanas atrás
pai
commit
250f959e2e
2 arquivos alterados com 20 adições e 4 exclusões
  1. 4 0
      src/styles/tdesign.css
  2. 16 4
      src/views/components/DataSource.vue

+ 4 - 0
src/styles/tdesign.css

@@ -643,4 +643,8 @@
 
 .t-popup{
   box-shadow: 0px 9px 28px 8px rgba(8,11,15,0.12), 0px 6px 16px 0px rgba(8,11,15,0.20), 0px 3px 6px -4px rgba(8,11,15,0.26);
+}
+
+.t-loading__overlay {
+  background-color: rgba(0, 0, 0, 0.45);
 }

+ 16 - 4
src/views/components/DataSource.vue

@@ -1098,7 +1098,7 @@ import {
   DragDropIcon
 } from 'tdesign-icons-vue-next';
 import { typeOptions } from '@/services/common';
-import { MessagePlugin } from 'tdesign-vue-next';
+import { LoadingPlugin, MessagePlugin } from 'tdesign-vue-next';
 import { Pen, deepClone } from '@meta2d/core';
 import { useDot } from '@/services/common';
 import { cdn } from '@/services/api';
@@ -1267,9 +1267,21 @@ const onOkIot = () => {
 };
 
 const onShowIot = async () => {
-  await getIotTree();
-  getCheckedIots();
-  iotDialog.value.show = true;
+  LoadingPlugin(true);
+
+  try {
+    await getIotTree();
+    getCheckedIots();
+    iotDialog.value.show = true;
+  } catch (err) {
+    if (err instanceof Error) {
+      MessagePlugin.error(err.message);
+    }
+
+    console.error(err);
+  } finally {
+    LoadingPlugin(false);
+  }
 };
 
 const iots = ref([]);