Michael Wang %!s(int64=3) %!d(string=hai) anos
pai
achega
7ba59d2be2
Modificáronse 2 ficheiros con 8 adicións e 5 borrados
  1. 5 0
      src/features/UserLogin/UserLogin.vue
  2. 3 5
      src/router/index.ts

+ 5 - 0
src/features/UserLogin/UserLogin.vue

@@ -1,6 +1,7 @@
 <script lang="ts" setup>
 import { loginApi } from "@/api/login";
 import { store } from "@/store/store";
+import { useRouter } from "vue-router";
 
 logger({ cnl: ["console"], pgn: "登录页面", act: "首次渲染" });
 
@@ -13,6 +14,8 @@ const domain = import.meta.env.DEV
   : "";
 const rootOrgId = 0;
 
+const router = useRouter();
+
 async function handleLoginClick() {
   const res = await loginApi(
     accountType,
@@ -24,6 +27,8 @@ async function handleLoginClick() {
   console.log(res);
 
   store.user = res.data.content;
+
+  void router.push({ name: "ChangePassword" });
 }
 </script>
 

+ 3 - 5
src/router/index.ts

@@ -5,7 +5,7 @@ import ChangePassword from "@/features/ChangePassword/ChangePassword.vue";
 import { resetStore, store } from "@/store/store";
 
 const routes: RouteRecordRaw[] = [
-  { path: "/", component: UserLogin },
+  { path: "/", redirect: "/login" },
   { path: "/login", component: UserLogin, name: "UserLogin" },
   {
     path: "/",
@@ -14,6 +14,7 @@ const routes: RouteRecordRaw[] = [
       {
         path: "password",
         component: ChangePassword,
+        name: "ChangePassword",
       },
     ],
   },
@@ -40,13 +41,10 @@ router.beforeEach((to, from, next) => {
     _hmt.push(["_trackPageview", "/oe-web" + to.fullPath]);
   }
 
-  if (to.path.match(/^\/?/) || to.path.match(/^\/login\/.?$/)) {
+  if (to.name === "UserLogin") {
     resetStore();
     next();
   } else {
-    if (!localStorage.getItem("domain")) {
-      alert("地址出错,找不到机构!请关闭应用后重试!");
-    }
     if (!store.user.token) {
       next({ path: loginPath });
     } else {