20260809223428

This commit is contained in:
oneao committed 2026-08-09 22:34:28 +08:00
1 parent d72ca4193d
commit c4891538a7
466 files changed
+21000 -3339

No files matched your search

+126
View File
@@ -0,0 +1,126 @@
import { createRouter, createWebHistory } from 'vue-router'
import DefaultLayout from '@/layouts/DefaultLayout.vue'
import { useAuthStore } from '@/stores/auth'
const PlaceholderPage = () => import('@/views/base/PlaceholderPage.vue')
// Demo pages
const TablePage = () => import('@/views/demo/TableDemo.vue')
const FormPage = () => import('@/views/demo/FormDemo.vue')
const CardPage = () => import('@/views/demo/CardDemo.vue')
const SettingsPage = () => import('@/views/demo/SettingsDemo.vue')
const router = createRouter({
history: createWebHistory(),
routes: [
{
path: '/login',
name: 'login',
component: () => import('@/views/login/LoginView.vue'),
},
{
path: '/',
component: DefaultLayout,
redirect: '/dashboard',
meta: { requiresAuth: true },
children: [
{
path: '/dashboard',
name: 'dashboard',
component: () => import('@/views/dashboard/index.vue'),
meta: { title: '工作台' },
},
// Demo pages
{
path: '/demo/table',
name: 'demo-table',
component: TablePage,
meta: { title: '表格示例', section: 'Demo 页面' },
},
{
path: '/demo/form',
name: 'demo-form',
component: FormPage,
meta: { title: '表单示例', section: 'Demo 页面' },
},
{
path: '/demo/cards',
name: 'demo-cards',
component: CardPage,
meta: { title: '卡片示例', section: 'Demo 页面' },
},
{
path: '/demo/settings',
name: 'demo-settings',
component: SettingsPage,
meta: { title: '设置示例', section: 'Demo 页面' },
},
// Business pages
{
path: '/base/othercompany',
name: 'base-othercompany',
component: PlaceholderPage,
meta: { title: '合作伙伴' },
},
{
path: '/base/contact',
name: 'base-contact',
component: PlaceholderPage,
meta: { title: '联系人' },
},
{
path: '/base/otherdata',
name: 'base-otherdata',
component: PlaceholderPage,
meta: { title: '其他数据' },
},
{
path: '/system/module-management',
name: 'system-module-management',
component: PlaceholderPage,
meta: { title: '模块管理' },
},
{
path: '/system/i18n-type',
name: 'system-i18n-type',
component: PlaceholderPage,
meta: { title: '多语言类型' },
},
{
path: '/system/login-log',
name: 'system-login-log',
component: PlaceholderPage,
meta: { title: '登录日志' },
},
{
path: '/system/user',
name: 'system-user',
component: PlaceholderPage,
meta: { title: '用户管理' },
},
],
},
{
path: '/:pathMatch(.*)*',
redirect: '/dashboard',
},
],
})
// Auth guard
router.beforeEach((to) => {
const authStore = useAuthStore()
if (to.path === '/login') {
if (authStore.isAuthenticated) return '/dashboard'
return
}
if (to.matched.some(r => r.meta.requiresAuth)) {
if (!authStore.isAuthenticated) {
return { path: '/login', query: { redirect: to.fullPath } }
}
}
})
export default router