tangning 3 weeks ago
parent
commit
6b40eda22b
1 changed files with 12 additions and 3 deletions
  1. 12 3
      src/view/system/login.vue

+ 12 - 3
src/view/system/login.vue

@@ -116,9 +116,15 @@ watch(
 const imgKey = ref(guid());
 const refer = () => (imgKey.value = guid());
 const codeImg = computed(() => baseURL + getCode + "?key=" + imgKey.value);
-
+function isHttpHttpsUrl(path) {
+  // 严格匹配:以http:// 开头  或者  以https:// 开头
+  return path && (path.startsWith('http://') || path.startsWith('https://'))
+}
 // 表单提交
 const submitClick = async () => {
+  
+  const params: any = router.currentRoute.value.query;
+  console.log("params", params);
   if (verification.phone && verification.phone !== "88888888888") {
     return openErrorMsg(verification.phone);
   }
@@ -138,7 +144,6 @@ const submitClick = async () => {
       localStorage.setItem("remember", "0");
     }
 
-    const params: any = router.currentRoute.value.query;
     if ("redirect" in params && params.redirect) {
       const decodeOnce = (s: string): string => {
         try {
@@ -164,7 +169,11 @@ const submitClick = async () => {
       url.searchParams.delete("token");
       // url.searchParams.append("token", user.value.token);
       window.localStorage.setItem("token", user.value.token);
-      window.location.replace(url);
+      if(isHttpHttpsUrl(resolved)){//判断内链还是外链
+        window.location.replace(url);
+      }else{
+        router.push(resolved);
+      }
     } else {
       router.replace({ name: RouteName.dispatch });
     }