modify(login): 修改登录返回对象,新增返回用户信息

This commit is contained in:
2025-12-28 22:01:24 +08:00
parent 82652efed7
commit 62642ee86a
87 changed files with 2730 additions and 755 deletions
+28 -2
View File
@@ -1,11 +1,27 @@
import { createRouter, createWebHistory } from 'vue-router'
import MainView from '@/views/Main.vue'
import TestView from '@/views/Test.vue'
import { useAuthStore } from '@/stores/auth'
import { useMessage } from '@/components/messages/useAlert'
const message = useMessage();
const routes = [
{ path: '/auth/login', component: () => import('@/views/auth/Login.vue') },
{ path: '/', component: MainView },
{ path: '/index', component: MainView },
{
path: '/',
component: MainView,
meta: {
requiresAuth: true
}
},
{
path: '/index',
component: MainView,
meta: {
requiresAuth: true
}
},
{ path: '/test', component: TestView },
]
@@ -14,4 +30,14 @@ const router = createRouter({
routes,
})
router.beforeEach((to, from, next) => {
const authStore = useAuthStore();
if (to.meta.requiresAuth && !authStore.isLoggedIn) {
message.info('未登录,即将跳转...');
next('auth/login');
} else {
next();
}
})
export default router