Sfoglia il codice sorgente

Merge branch 'master' of http://182.92.126.35:3000/hrx/vent-forewarn-micro

lxh 1 anno fa
parent
commit
30376c6b3b

+ 1 - 1
src/layouts/default/header/MultipleHeader.vue

@@ -5,7 +5,7 @@
     v-if="getIsShowPlaceholderDom"
   ></div>
   <div :style="getWrapStyle" :class="getClass">
-    <LayoutHeader v-if="getShowInsetHeaderRef" />
+    <LayoutHeader />
     <MultipleTabs v-if="getShowTabs" :key="tabStore.getLastDragEndIndex" />
   </div>
 </template>

+ 8 - 2
src/layouts/default/index.vue

@@ -5,7 +5,7 @@
     <Layout :class="[layoutClass, `${prefixCls}-out`]">
       <LayoutSideBar v-if="getShowSidebar || getIsMobile" />
       <Layout :class="`${prefixCls}-main`">
-        <LayoutMultipleHeader />
+        <LayoutMultipleHeader v-if="username !== 'autoAdmin'" />
         <LayoutContent />
         <LayoutFooter />
       </Layout>
@@ -14,7 +14,7 @@
 </template>
 
 <script lang="ts" setup>
-  import { computed, unref } from 'vue';
+  import { computed, unref, ref } from 'vue';
   import { Layout } from 'ant-design-vue';
   import { createAsyncComponent } from '@/utils/factory/createAsyncComponent';
 
@@ -31,6 +31,9 @@
   import { useAppInject } from '@/hooks/web/useAppInject';
 
   import { useMultipleTabSetting } from '@/hooks/setting/useMultipleTabSetting';
+  import { useUserStore } from '@/store/modules/user';
+
+  const userStore = useUserStore();
 
   const LayoutFeatures = createAsyncComponent(() => import('@/layouts/default/feature/index.vue'));
   const LayoutFooter = createAsyncComponent(() => import('@/layouts/default/footer/index.vue'));
@@ -58,6 +61,9 @@
 
     return cls;
   });
+
+  const userInfo = userStore.getUserInfo;
+  const username = ref(userInfo.username ? userInfo.username : '');
 </script>
 <style lang="less">
   @prefix-cls: ~'@{namespace}-default-layout';

+ 23 - 22
src/router/guard/permissionGuard.ts

@@ -52,30 +52,31 @@ export function createPermissionGuard(router: Router) {
     // token or user does not exist
     if (!token) {
       // You can access without permission. You need to set the routing meta.ignoreAuth to true
-      if (to.meta.ignoreAuth) {
-        next();
+      if (to.query['auto'] === 'true') {
+        // 自动登录
+        const userStore = useUserStoreWithOut();
+        await userStore.autoLogin();
+        next(to.path);
+        return;
+      } else {
+        if (to.meta.ignoreAuth) {
+          next();
+          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);
         return;
       }
-      // 自动登录
-      const userStore = useUserStoreWithOut();
-      await userStore.autoLogin();
-      next(to.path);
-
-      // 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);
-
-      return;
     }
 
     // Jump to the 404 page after processing the login

+ 1 - 1
src/store/modules/user.ts

@@ -105,7 +105,7 @@ export const useUserStore = defineStore({
     async autoLogin() {
       try {
         const loginParams = {
-          username: 'admin',
+          username: 'autoAdmin',
           password: '123456',
           captcha: '1234',
           checkKey: new Date().getTime(),

+ 0 - 1
src/utils/http/axios/index.ts

@@ -79,7 +79,6 @@ const transform: AxiosTransform = {
     // 在此处根据自己项目的实际情况对不同的code执行不同的操作
     // 如果不希望中断当前请求,请return数据,否则直接抛出异常即可
     let timeoutMsg = '';
-    debugger;
     switch (code) {
       case ResultEnum.TIMEOUT:
         timeoutMsg = t('sys.api.timeoutMessage');