Ver Fonte

feature/404&&自动登录实现

dengrui há 10 meses atrás
pai
commit
48c7398a47
3 ficheiros alterados com 44 adições e 21 exclusões
  1. 4 4
      src/router/modules/constant.ts
  2. 7 16
      src/views/error-page/404.vue
  3. 33 1
      src/views/login/index.vue

+ 4 - 4
src/router/modules/constant.ts

@@ -25,12 +25,12 @@ const constantRoutes: RouteRecordRaw[] = [
     name: "/",
     meta: { hidden: true },
     component: Layout,
-    redirect: "/welcome",
+    redirect: "/statistic",
     children: [
       {
-        path: "welcome",
-        component: () => import("@/views/welcome/index.vue"),
-        name: "Welcome",
+        path: "main",
+        component: () => import("@/views/statistic/statistic/index.vue"),
+        name: "StatisticMain",
         meta: { hidden: true },
       },
     ],

+ 7 - 16
src/views/error-page/404.vue

@@ -33,22 +33,13 @@ function message() {
         />
       </div>
       <div class="bullshit">
-        <div class="bullshit__oops">OOPS!</div>
-        <div class="bullshit__info">
-          All rights reserved
-          <a
-            style="color: #20a0ff"
-            href="https://wallstreetcn.com"
-            target="_blank"
-            >wallstreetcn</a
-          >
-        </div>
-        <div class="bullshit__headline">{{ message() }}</div>
-        <div class="bullshit__info">
-          Please check that the URL you entered is correct, or click the button
-          below to return to the homepage.
-        </div>
-        <a href="" class="bullshit__return-home">Back to home</a>
+        <div class="bullshit__oops">出点了小问题!</div>
+        <div class="bullshit__info">找不到此路径</div>
+        <div class="bullshit__headline"></div>
+        <div class="bullshit__info">请确权限问题或者路径是否输入正确。</div>
+        <router-link to="/">
+          <div href="" class="bullshit__return-home">返回主页面</div>
+        </router-link>
       </div>
     </div>
   </div>

+ 33 - 1
src/views/login/index.vue

@@ -224,7 +224,33 @@ function handleLogin() {
     }
   });
 }
-
+//自动登录
+const toLogin = () => {
+  loading.value = true;
+  userStore
+    .login(loginData.value)
+    .then(async () => {
+      const query: LocationQuery = route.query;
+      const redirect = (query.redirect as LocationQueryValue) ?? "/";
+      const otherQueryParams = Object.keys(query).reduce(
+        (acc: any, cur: string) => {
+          if (cur !== "redirect") {
+            acc[cur] = query[cur];
+          }
+          return acc;
+        },
+        {}
+      );
+      router.push({ path: redirect, query: otherQueryParams });
+    })
+    .catch(() => {
+      // getCaptcha();
+      console.log("catch");
+    })
+    .finally(() => {
+      loading.value = false;
+    });
+};
 /**
  * 主题切换
  */
@@ -253,6 +279,12 @@ function checkCapslock(e: any) {
 }
 
 onMounted?.(() => {
+  // 处理SSO
+  const query: LocationQuery = route.query;
+  if (query.token) {
+    loginData.value.token = query.token + "";
+    toLogin();
+  }
   toggleTheme();
 });
 </script>