Explorar el Código

调整登录模块

louhangfei hace 2 años
padre
commit
b13ba7d17d

+ 3 - 1
.env

@@ -11,4 +11,6 @@ VITE_GLOB_APP_SHORT_NAME = SkyeyeAdmin
 VITE_GLOB_PROD_MOCK = false
 
 # App Download QrCode Url
-VITE_GLOB_APP_DOWNLOAD_QRCODE = http://58.144.197.158:19980/apk/skyeye.apk
+VITE_GLOB_APP_DOWNLOAD_QRCODE = http://58.144.197.158:19980/apk/skyeye.apk
+
+VITE_LOGIN_APP = '/skyeye-login/#/'

+ 1 - 1
.env.development

@@ -14,7 +14,7 @@ VITE_DROP_CONSOLE = true
 #VITE_PROXY = [["/appApi","http://localhost:8001"],["/upload","http://localhost:8001/upload"]]
 # VITE_PROXY=[["/temp","http://172.16.23.144:8800"],["/upload","http://172.16.23.144:8086"]]
 # VITE_PROXY=[["/skyeye-admin-api","http://172.16.23.144:8800/api"]]
-VITE_PROXY=[["/skyeye-admin-api","http://58.144.197.158:19980/skyeye-admin-api"],["/push_stream_host","http://58.144.197.158:19980/push_stream_host"]]
+VITE_PROXY=[["/skyeye-admin-api","http://58.144.197.158:19980/skyeye-admin-api"],["/eye_api","http://58.144.197.158:19980/eye_api"],["/push_stream_host","http://58.144.197.158:19980/push_stream_host"],["/skyeye-login","http://58.144.197.158:19980/skyeye-login"]]
 
 # API 接口地址
 VITE_GLOB_API_URL = 

+ 8 - 6
src/components/Lockscreen/Lockscreen.vue

@@ -94,6 +94,7 @@
   import { useBattery } from '@/hooks/useBattery';
   import { useLockscreenStore } from '@/store/modules/lockscreen';
   import { useUserStore } from '@/store/modules/user';
+  import { getRedirectUrl } from '@/utils/getRedirectUrl';
 
   const useLockscreen = useLockscreenStore();
   const userStore = useUserStore();
@@ -148,12 +149,13 @@
   const goLogin = () => {
     onLockLogin(false);
     useLockscreen.setLock(false);
-    router.replace({
-      path: '/login',
-      query: {
-        redirect: route.fullPath,
-      },
-    });
+    // router.replace({
+    //   path: '/login',
+    //   query: {
+    //     redirect: route.fullPath,
+    //   },
+    // });
+    window.location.href = getRedirectUrl();
   };
 </script>
 

+ 8 - 6
src/layout/components/Header/index.vue

@@ -227,6 +227,7 @@
   import { useDesignSetting } from '@/hooks/setting/useDesignSetting';
   import { Render, getRender } from '@/components/Render';
   import urlJoin from 'url-join';
+  import { getRedirectUrl } from '@/utils/getRedirectUrl';
 
   defineEmits(['update:collapsed']);
 
@@ -377,12 +378,13 @@
         // 移除标签页
         localStorage.removeItem(TABS_ROUTES);
         asyncRouteStore.setDynamicAddedRoute(false);
-        router.replace({
-          name: BASE_LOGIN_NAME,
-          query: {
-            redirect: route.fullPath,
-          },
-        });
+        // router.replace({
+        //   name: BASE_LOGIN_NAME,
+        //   query: {
+        //     redirect: route.fullPath,
+        //   },
+        // });
+        window.location.href = getRedirectUrl();
       });
     });
   };

+ 1 - 0
src/router/index.ts

@@ -35,6 +35,7 @@ export const LoginRoute: RouteRecordRaw = {
   // component: () => import('@/views/login/index.vue'), //v1.x 模板
   // component: () => import('@/views/login/newLogin.vue'), // 2.x新模板
   component: () => import('@/views/login/newLogin2.vue'), // 2.x全新模板
+  // redirect: '/',
   meta: {
     title: '登录',
   },

+ 15 - 11
src/router/router-guards.ts

@@ -7,6 +7,7 @@ import { storage } from '@/utils/Storage';
 import { PageEnum } from '@/enums/pageEnum';
 import { ErrorPageRoute } from '@/router/base';
 import NProgress from 'nprogress';
+import { getRedirectUrl } from '@/utils/getRedirectUrl';
 
 const LOGIN_PATH = PageEnum.BASE_LOGIN;
 
@@ -37,17 +38,20 @@ export function createRouterGuards(router: Router) {
         return;
       }
       // redirect login page
-      const redirectData: { path: string; replace: boolean; query?: Recordable<string> } = {
-        path: LOGIN_PATH,
-        replace: true,
-      };
-      if (to.path) {
-        redirectData.query = {
-          ...redirectData.query,
-          redirect: to.path,
-        };
-      }
-      next(redirectData);
+      // 这里登录要改造
+      // const redirectData: { path: string; replace: boolean; query?: Recordable<string> } = {
+      //   path: LOGIN_PATH,
+      //   replace: true,
+      // };
+      // if (to.path) {
+      //   redirectData.query = {
+      //     ...redirectData.query,
+      //     redirect: to.path,
+      //   };
+      // }
+      // next(redirectData);
+      window.location.href = getRedirectUrl();
+      next();
       return;
     }
 

+ 4 - 0
src/utils/getRedirectUrl.ts

@@ -0,0 +1,4 @@
+export const getRedirectUrl = () => {
+  const encodeUrl = encodeURIComponent(window.location.href);
+  return import.meta.env.VITE_LOGIN_APP + '?redirect=' + encodeUrl;
+};

+ 3 - 2
src/utils/http/axios/index.ts

@@ -24,6 +24,7 @@ const urlPrefix = globSetting.urlPrefix || '';
 
 import router from '@/router';
 import { storage } from '@/utils/Storage';
+import { getRedirectUrl } from '@/utils/getRedirectUrl';
 
 /**
  * @description: 数据处理,方便区分多种处理方式
@@ -125,8 +126,8 @@ const transform: AxiosTransform = {
         })
           .then(() => {
             storage.clear();
-            window.location.href = import.meta.env.VITE_PUBLIC_PATH + '#login';
-            window.location.reload();
+            window.location.href = getRedirectUrl();
+            // window.location.reload();
           })
           .catch(() => {});
         break;