Преглед на файлове

忽略前端重复请求(console.error('前台打印: 重复请求,请稍后重试'))

lifanagju_citu преди 6 месеца
родител
ревизия
c69f8b2eef
променени са 1 файла, в които са добавени 8 реда и са изтрити 6 реда
  1. 8 6
      utils/request.js

+ 8 - 6
utils/request.js

@@ -162,7 +162,6 @@ http.interceptors.request.use(
  */
 http.interceptors.response.use(
 	(response) => {
-		// console.log(1, 'response', response)
 		// 约定:如果是 /auth/ 下的 URL 地址,并且返回了 accessToken 说明是登录相关的接口,则自动设置登陆令牌
 		if (response.config.url.indexOf('/system/auth/') >= 0 && response.data?.data?.accessToken) {
 			const useUserStore = userStore()
@@ -197,11 +196,14 @@ http.interceptors.response.use(
 
       // 错误提示
 			if (response.config.custom.showError) {
-				uni.showToast({
-					title: response.data.msg || '服务器开小差啦,请稍后再试~',
-					icon: 'none',
-					mask: true,
-				});
+				if (response.data?.msg === '重复请求,请稍后重试') console.error('前台打印: 重复请求,请稍后重试')
+				else {
+					uni.showToast({
+						title: response.data.msg || '服务器开小差啦,请稍后再试~',
+						icon: 'none',
+						mask: true,
+					});
+				}
       }
 		}