tangning 10 hónapja
szülő
commit
d161d1e918
2 módosított fájl, 42 hozzáadás és 28 törlés
  1. 2 28
      src/App.vue
  2. 40 0
      src/store/modules/user.ts

+ 2 - 28
src/App.vue

@@ -14,7 +14,6 @@
   // import { useLocale } from '/@/locales/useLocale';
   import { useUserStoreWithOut } from '/@/store/modules/user';
   import { useAppStoreWithOut } from '/@/store/modules/app';
-  import { addressKey } from '/@/api/jyUserPlatform/index';
   import { useMessage } from '/@/hooks/web/useMessage';
 
   // support Multi-language
@@ -27,37 +26,12 @@
     userStore.setToken(token);
     // localStorage.removeItem('token');
   }
-  function getUrlParams2() {
-    let url = window.location.href
-    let urlStr = url.split('?')[1]
-    const urlSearchParams = new URLSearchParams(urlStr)
-    const result = Object.fromEntries(urlSearchParams.entries())
-    let address = result['key']
-    if(address){
-      addressKey(address).then(res => {
-        if(res.status == 1){
-          createConfirm({
-            iconType: 'warning',
-            title: '警告',
-            content: `此平台已被禁用`,
-            onOk: async () => {
-              onClose()
-            },
-            onCancel: async () => {
-              onClose()
-            },
-          });
-          return
-        }
-        appStore.setTitle(res.platformName);
-      })
-    }
-  }
+
   const onClose = () => {
     window.opener = null;
     window.open('about:blank', '_top')?.close();
   };
-  getUrlParams2()
+  // getUrlParams2()
   // Listening to page changes and dynamically changing site titles
   useTitle();
 </script>

+ 40 - 0
src/store/modules/user.ts

@@ -12,10 +12,12 @@ import { useI18n } from '/@/hooks/web/useI18n';
 import { useMessage } from '/@/hooks/web/useMessage';
 import { router } from '/@/router';
 import { usePermissionStore } from '/@/store/modules/permission';
+import { useAppStoreWithOut } from '/@/store/modules/app';
 import { RouteRecordRaw } from 'vue-router';
 import { PAGE_NOT_FOUND_ROUTE } from '/@/router/routes/basic';
 import { isArray } from '/@/utils/is';
 import { h } from 'vue';
+import { addressKey } from '/@/api/jyUserPlatform/index';
 
 interface UserState {
   userInfo: Nullable<UserInfo>;
@@ -135,6 +137,11 @@ export const useUserStore = defineStore({
       return userInfo;
     },
     async getUserInfoAction(): Promise<UserInfo | null> {
+      //添加平台权限
+      const qxjy = await this.getUrlParams2();
+      if (!qxjy) {
+        return;
+      }
       if (!this.getToken) return null;
       const userInfo = await getUserInfo();
       const { roleId } = userInfo;
@@ -183,6 +190,39 @@ export const useUserStore = defineStore({
         },
       });
     },
+    async getUrlParams2() {
+      const { createConfirm } = useMessage();
+      const url = window.location.href;
+      const urlStr = url.split('?')[1];
+      const urlSearchParams = new URLSearchParams(urlStr);
+      const result = Object.fromEntries(urlSearchParams.entries());
+      const address = result['key'];
+      if (address) {
+        const res = await addressKey(address);
+        console.log('addressKey', res);
+        const appStore = useAppStoreWithOut();
+        appStore.setTitle(res.platformName);
+        if (res.status == 1) {
+          createConfirm({
+            iconType: 'warning',
+            title: '警告',
+            content: `此平台已被禁用`,
+            onOk: async () => {
+              window.opener = null;
+              window.open('about:blank', '_top')?.close();
+            },
+            onCancel: async () => {
+              window.opener = null;
+              window.open('about:blank', '_top')?.close();
+            },
+          });
+          return false;
+        }
+        return true;
+      } else {
+        return true;
+      }
+    },
   },
 });