From e0243a29ebd9617ff660dcae75b44dd3e09b956d Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期五, 13 九月 2024 10:21:27 +0800 Subject: [PATCH] 全局意向提示词 --- src/utils/request.ts | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/utils/request.ts b/src/utils/request.ts index 70eebb1..65cb2ad 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -1,4 +1,4 @@ -import type { AxiosInstance, AxiosRequestConfig } from 'axios'; +import type { AxiosInstance, AxiosRequestConfig, CancelToken } from 'axios'; import axios from 'axios'; import { ElLoadingService, ElMessage } from 'element-plus'; import router from '../router'; @@ -10,6 +10,7 @@ loading?: boolean; noAuth?: boolean; handleFail?: boolean; + cancelToken?: CancelToken | undefined; }; export const checkAuth = () => { const session = Local.get(accessSessionKey); @@ -37,14 +38,15 @@ clearAccessTokens(); window.location.reload(); }); +window.handleNoAuth = handleNoAuth; let requestNum = 0; let loadingInstance: ReturnType<typeof ElLoadingService>; const addLoading = () => { - // 澧炲姞loading 濡傛灉pending璇锋眰鏁伴噺绛変簬1锛屽脊鍑簂oading, 闃叉閲嶅寮瑰嚭 + // 澧炲姞loading 濡傛灉pending璇锋眰鏁伴噺绛変簬1锛屽脊鍑簂oading, 闃叉閲嶅寮瑰嚭F requestNum++; if (requestNum == 1) { - loadingInstance = ElLoadingService({ + loadingInstance = ElLoadingService({ text: '鍔犺浇涓�...', target: '.layout-parent', }); @@ -72,7 +74,7 @@ config.headers['hswatersession'] = accessSession; } if (!noAuth) { - if (!accessSession ) { + if (!accessSession) { handleNoAuth(); } } @@ -111,7 +113,7 @@ switch (serveData?.err_code) { case ErrorCode.Auth: handleNoAuth(); - throw '鏉冮檺楠岃瘉澶辫触'; + throw '鏉冮檺楠岃瘉澶辫触'; break; case ErrorCode.Exception: ElMessage.error('鍐呴儴閿欒锛�'); -- Gitblit v1.9.3