feat: 网络请求+发布订阅模块

This commit is contained in:
2026-06-09 10:12:09 +08:00
parent 391def3c92
commit ed86444fe6
10 changed files with 636 additions and 2 deletions

View File

@@ -1,4 +1,6 @@
import { createRouter, createWebHistory } from 'vue-router'
import { eventBus, AppEvents } from '@/utils/eventBus'
import { useAccountStore } from '@/stores'
import { createRouterGuard } from './guard.ts'
import routes from './routes.ts'
@@ -13,4 +15,11 @@ const router = createRouter({
// 创建路由守卫
createRouterGuard(router)
/** 订阅 401 未授权事件:清除 token 并跳转登录页 */
eventBus.on(AppEvents.UNAUTHORIZED, () => {
const accountStore = useAccountStore()
accountStore.token = ''
router.push('/auth/login')
})
export default router