This commit is contained in:
van
2026-04-30 17:30:42 +08:00
parent d8cae128fa
commit 77712048d4
6 changed files with 90 additions and 26 deletions

View File

@@ -67,6 +67,8 @@
import { getCodeImg } from "@/api/login"
import Cookies from "js-cookie"
import { encrypt, decrypt } from '@/utils/jsencrypt'
import store from '@/store'
import { firstLeafPathFromSidebarRoutes } from '@/utils/route-nav'
export default {
name: "Login",
@@ -147,11 +149,10 @@ export default {
// 先获取用户信息和生成路由,然后再跳转
this.$store.dispatch('GetInfo').then(() => {
this.$store.dispatch('GenerateRoutes').then(() => {
// 使用 replace 而不是 push避免路由历史问题
const redirectPath = this.redirect || "/sloworder/index"
const fallback = firstLeafPathFromSidebarRoutes(store.getters.sidebarRouters) || '/user/profile'
const redirectPath = this.redirect || fallback
this.$router.replace(redirectPath).catch(() => {
// 如果目标路由不存在,跳转到默认路由
this.$router.replace("/sloworder/index")
this.$router.replace(fallback)
})
})
})