Sfoglia il codice sorgente

新增会员到期跳转至购买页面

wyling007 3 anni fa
parent
commit
4f80f7b8c8
1 ha cambiato i file con 9 aggiunte e 17 eliminazioni
  1. 9 17
      src/route/guard.ts

+ 9 - 17
src/route/guard.ts

@@ -73,24 +73,16 @@ const guard = (router: Router) => {
 		try {
 			const userTime = dayjs(store.getters.getUserData.expireTime).valueOf();
 			const currentTime = dayjs().valueOf();
-			switch (to.path) {
-				case "/exercise":
-					if (userTime - currentTime > 0) {
-						next();
-					} else {
-						Toast.fail("会员到期");
-					}
-					break;
-				case "/mockTest":
-					if (userTime - currentTime > 0) {
-						next();
-					} else {
-						Toast.fail("会员到期");
-					}
-					break;
-				default:
+			const vipPathSet = new Set(["/exercise", "/mockTest"]);
+			if (vipPathSet.has(to.path)) {
+				if (userTime - currentTime > 0) {
 					next();
-					break;
+				} else {
+					Toast.fail("会员到期");
+					next("/buyVip");
+				}
+			} else {
+				next();
 			}
 		} catch (error) {}
 	});