Parcourir la source

修改登录router。修改permission的登录后跳转,不跳转到欢迎页面了。

jxq il y a 1 mois
Parent
commit
3af4ff9904
2 fichiers modifiés avec 12 ajouts et 2 suppressions
  1. 10 1
      src/plugins/permission.ts
  2. 2 1
      src/views/login/index.vue

+ 10 - 1
src/plugins/permission.ts

@@ -51,7 +51,16 @@ export function setupPermission() {
             accessRoutes.forEach((route) => {
               router.addRoute(route);
             });
-            next({ ...to, replace: true });
+            console.log("accessRoutes", to, accessRoutes);
+
+            if (to.path === "/welcome") {
+              let toPath =
+                accessRoutes[0].path + "/" + accessRoutes[0].children[0].path;
+
+              next({ path: toPath });
+            } else {
+              next({ ...to, replace: true });
+            }
           } catch (error) {
             console.error("beforeEach error", error);
             // 移除 token 并跳转登录页

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

@@ -115,7 +115,7 @@ import { getCaptchaApi, getOrgListApi, getUserDicts } from "@/api/auth";
 import { LoginData } from "@/api/auth/types";
 import { Sunny, Moon } from "@element-plus/icons-vue";
 import { LocationQuery, LocationQueryValue, useRoute } from "vue-router";
-import router from "@/router";
+
 import defaultSettings from "@/settings";
 import { ThemeEnum } from "@/enums/ThemeEnum";
 import { usePermissionStore } from "@/store/modules/permission";
@@ -196,6 +196,7 @@ function getOrgList() {
  * 登录
  */
 const route = useRoute();
+const router = useRouter();
 function handleLogin() {
   loginFormRef.value.validate((valid: boolean) => {
     if (valid) {