tangning 10 месяцев назад
Родитель
Сommit
0afa80c6b5
3 измененных файлов с 71 добавлено и 41 удалено
  1. 0 6
      src/App.vue
  2. 37 34
      src/store/modules/user.ts
  3. 34 1
      src/views/sys/login/Login.vue

+ 0 - 6
src/App.vue

@@ -26,12 +26,6 @@
     userStore.setToken(token);
     // localStorage.removeItem('token');
   }
-
-  const onClose = () => {
-    window.opener = null;
-    window.open('about:blank', '_top')?.close();
-  };
-  // getUrlParams2()
   // Listening to page changes and dynamically changing site titles
   useTitle();
 </script>

+ 37 - 34
src/store/modules/user.ts

@@ -138,12 +138,15 @@ export const useUserStore = defineStore({
     },
     async getUserInfoAction(): Promise<UserInfo | null> {
       //添加平台权限
-      const qxjy = await this.getUrlParams2();
-      if (!qxjy) {
-        return;
-      }
       if (!this.getToken) return null;
       const userInfo = await getUserInfo();
+      const appStore = useAppStoreWithOut();
+      userInfo.platformName && appStore.setTitle(userInfo.platformName);
+      // const qxjy = await this.getUrlParams2(userInfo);
+      // console.log('qxjy', qxjy);
+      // if (!qxjy) {
+      //   return;
+      // }
       const { roleId } = userInfo;
       if (isArray(roleId)) {
         const roleList = roleId.map((item) => item.value) as RoleEnum[];
@@ -190,38 +193,38 @@ export const useUserStore = defineStore({
         },
       });
     },
-    async getUrlParams2() {
+    async getUrlParams2(res) {
       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;
+      // 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;
+      // }
     },
   },
 });

+ 34 - 1
src/views/sys/login/Login.vue

@@ -100,7 +100,10 @@
   import { useLocaleStore } from '/@/store/modules/locale';
   import { useRootSetting } from '/@/hooks/setting/useRootSetting';
   import { useUserStoreWithOut } from '/@/store/modules/user';
+  import { addressKey } from '/@/api/jyUserPlatform/index';
+  import { useAppStoreWithOut } from '/@/store/modules/app';
 
+  const appStore = useAppStoreWithOut();
 
   defineProps({
     sessionTimeout: {
@@ -116,7 +119,37 @@
   const localeStore = useLocaleStore();
   const showLocale = localeStore.getShowPicker;
   const title = computed(() => globSetting?.title ?? '');
-  useUserStore.getUrlParams2()
+  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()
 </script>
 <style lang="less">
   @prefix-cls: ~'@{namespace}-login';