소스 검색

Merge branch '2023-9-6_上线'

liushengqiang 1 년 전
부모
커밋
22a63ed01f
3개의 변경된 파일16개의 추가작업 그리고 44개의 파일을 삭제
  1. 0 16
      src/pc/create/index.tsx
  2. 0 28
      src/pc/home/index.tsx
  3. 16 0
      src/utils/request.ts

+ 0 - 16
src/pc/create/index.tsx

@@ -44,22 +44,6 @@ export default defineComponent({
 				data.list = data.list.concat(res.data.rows);
 				data.finish = res.data.rows.length < forms.rows;
 			}
-			// 重新登录
-			if (res.code === 5000) {
-				const browserInfo = browser();
-				if (browserInfo.isApp) {
-					postMessage({ api: "login" });
-				} else {
-					// 判断是否在应用中
-					window.parent.postMessage(
-					{
-						api: "onLogin",
-					},
-					"*"
-					);
-				}
-				return;
-			}
 			data.loading = false;
 		};
 		const handleReset = () => {

+ 0 - 28
src/pc/home/index.tsx

@@ -1539,13 +1539,6 @@ export default defineComponent({
 				}
 			}
 			data.loading = false;
-			// 重新登录
-			if (res.code === 5000) {
-				window.location.href = `${
-					/(192|localhost)/.test(location.origin) ? "https://test.lexiaoya.cn" : location.origin
-				}/classroom`;
-				return;
-			}
 			return res;
 		};
 		const setSaveLoading = (tips: boolean) => {
@@ -1579,13 +1572,6 @@ export default defineComponent({
 						filePath: wavUrl,
 						coverImg: pngUrl,
 					});
-					// 重新登录
-					if (res.code === 5000) {
-						window.location.href = `${
-							/(192|localhost)/.test(location.origin) ? "https://test.lexiaoya.cn" : location.origin
-						}/classroom`;
-						return;
-					}
 				} else {
 					const res = await api_musicSheetCreationSave({
 						name: data.musicName || "未命名乐谱",
@@ -1611,13 +1597,6 @@ export default defineComponent({
 						}
 						location.hash = hash[0] + "?" + qs.stringify(qs_data);
 					}
-					// 重新登录
-					if (res.code === 5000) {
-						window.location.href = `${
-							/(192|localhost)/.test(location.origin) ? "https://test.lexiaoya.cn" : location.origin
-						}/classroom`;
-						return;
-					}
 				}
 			} catch (error) {
 				console.log(error);
@@ -1978,13 +1957,6 @@ export default defineComponent({
 					message.info("已是最新版本");
 				}
 			}
-			// 重新登录
-			if (res.code === 5000) {
-				window.location.href = `${
-					/(192|localhost)/.test(location.origin) ? "https://test.lexiaoya.cn" : location.origin
-				}/classroom`;
-				return;
-			}
 		};
 
 		return () => (

+ 16 - 0
src/utils/request.ts

@@ -44,6 +44,7 @@ request.interceptors.request.use(
 
 request.interceptors.response.use(
 	async (res, options) => {
+		console.log(options)
 		if (res.status > 299 || res.status < 200) {
 			const msg = res.statusText + ", 状态码" + res.status;
 			showToast(msg);
@@ -61,6 +62,21 @@ request.interceptors.response.use(
 			}
 			throw new Error(msg);
 		}
+		if (data.code === 5000) {
+			// 判断是否在应用中
+			window.parent.postMessage(
+			{
+				api: "onLogin",
+			},
+			"*"
+			);
+			setTimeout(() => {
+				window.location.href = `${
+					/(192|localhost)/.test(location.origin) ? "https://test.lexiaoya.cn" : location.origin
+				}/classroom`;
+			}, 500)
+			return;
+		}
 		return data;
 	},
 	{ global: false }