YangJian0701 1 tahun lalu
induk
melakukan
e48bf5060c
2 mengubah file dengan 6 tambahan dan 7 penghapusan
  1. 5 1
      src/utils/index.ts
  2. 1 6
      src/views/login/loadingBtn.vue

+ 5 - 1
src/utils/index.ts

@@ -4,7 +4,7 @@ import type { AxiosInstance, AxiosError, AxiosRequestConfig, InternalAxiosReques
 import { ElMessage, ElNotification } from 'element-plus'
 import { ResultEnum, ResultData, ContentType } from './interface/index'
 import {diffhost } from './diffhost/index'
-
+import { loadingFun, closeFun } from "@/plugins/loading";
 import router from '@/router/index'
 type LoadingType = {
 	close?: () => void
@@ -36,6 +36,7 @@ class RequestHttp {
 		 */
 
 		this.service.interceptors.request.use((config: InternalAxiosRequestConfig) => {
+			loadingFun()
 			config.headers.Authorization = 'Bearer '+sessionStorage.getItem('token')
 			const host = diffhost(config)
 			const url1 = process.env.VUE_APP_BASE_URL1
@@ -97,6 +98,9 @@ class RequestHttp {
 					ElMessage.error(params.msg)
 					break;
 			}
+			setTimeout(() => {
+				closeFun()
+			}, 500);
 		}
 	}
 	// * 常用请求方法封装

+ 1 - 6
src/views/login/loadingBtn.vue

@@ -19,7 +19,6 @@
 </template>
 <script setup lang="ts">
 import { loginsetItem, JudgmentStatus } from "@/plugins/login";
-import { loadingFun, closeFun } from "@/plugins/loading";
 
 import { ElMessage ,ElNotification} from 'element-plus'
 import { login } from "@/api/index";
@@ -49,7 +48,6 @@ const submitForm = async () => {
         ElMessage.error('账号或者密码不能为空');
         return
     }
-    loadingFun()
     const froms = { ...props.data.form }
     // froms.password = md5(froms.password)
     console.log('登录',store)
@@ -63,10 +61,7 @@ const submitForm = async () => {
             message: 'ok,登录成功,欢迎进入宝智达出入库管理系统!',
             type: 'success',
         })
-        setTimeout(() => {
-            closeFun()
-            router.push('/home')
-        }, 1500);
+        router.push('/home')
     }
 }
 </script>