Browse Source

fix: 解决没有mac地址页面也可以调整的问题

chenzhen2 2 years ago
parent
commit
b5e3c77bec
1 changed files with 37 additions and 33 deletions
  1. 37 33
      src/views/home/index.vue

+ 37 - 33
src/views/home/index.vue

@@ -170,44 +170,48 @@ export default defineComponent({
       },
       // 查询工作空间
       queryWorkSpace() {
-        let params: any = {
-          criteria: {
-            macAddress: proxyData.userInfo.mac,
-            isMajorSpace: 1,
-          },
-          orders: [
-            {
-              column: "createTime",
-
-              asc: false,
+        if (!proxyData.userInfo.mac) {
+          proxyData.showLogin = true;
+        } else {
+          let params: any = {
+            criteria: {
+              macAddress: proxyData.userInfo.mac,
+              isMajorSpace: 1,
             },
-          ],
-          page: 1,
-          size: 1,
-        };
-        queryWorkSpace(params)
-          .then((res: any) => {
-            let resData: any = res;
-            if (resData.result === "success") {
-              let content: any = resData?.content ?? [];
-              if (content && content.length) {
-                proxyData.showLogin = false;
-                let projectId: any = content[0].projectId;
-                store.commit(UserMutationTypes.SET_PROJECT_ID, projectId);
-                router.push({
-                  name: "envmonitor",
-                  query: { spaceId: content[0].spaceId },
-                });
+            orders: [
+              {
+                column: "createTime",
+
+                asc: false,
+              },
+            ],
+            page: 1,
+            size: 1,
+          };
+          queryWorkSpace(params)
+            .then((res: any) => {
+              let resData: any = res;
+              if (resData.result === "success") {
+                let content: any = resData?.content ?? [];
+                if (content && content.length) {
+                  proxyData.showLogin = false;
+                  let projectId: any = content[0].projectId;
+                  store.commit(UserMutationTypes.SET_PROJECT_ID, projectId);
+                  router.push({
+                    name: "envmonitor",
+                    query: { spaceId: content[0].spaceId },
+                  });
+                } else {
+                  proxyData.showLogin = true;
+                }
               } else {
                 proxyData.showLogin = true;
               }
-            } else {
+            })
+            .catch(() => {
               proxyData.showLogin = true;
-            }
-          })
-          .catch(() => {
-            proxyData.showLogin = true;
-          });
+            });
+        }
       },
       /**
        * 获取mac地址