refactor: modularize frontend flows

This commit is contained in:
Lan
2026-06-03 02:01:57 +08:00
parent 6c29b36279
commit 72249dd2dd
85 changed files with 4654 additions and 4363 deletions
+96 -42
View File
@@ -1,50 +1,104 @@
import { createRouter, createWebHashHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
import { ROUTE_NAMES, ROUTES } from '@/constants'
import { readStoredToken } from '@/utils/auth-storage'
const publicPageMeta = {
showGlobalControls: true,
showRouteLoading: true
}
const adminPageMeta = {
requiresAuth: true,
showGlobalControls: false,
showRouteLoading: true
}
const routes: RouteRecordRaw[] = [
{
path: '/',
name: ROUTE_NAMES.RETRIEVE,
component: () => import('@/views/RetrievewFileView.vue'),
meta: {
...publicPageMeta,
title: 'retrieve'
}
},
{
path: ROUTES.SEND,
name: ROUTE_NAMES.SEND,
component: () => import('@/views/SendFileView.vue'),
meta: {
...publicPageMeta,
title: 'send'
}
},
{
path: ROUTES.ADMIN,
name: ROUTE_NAMES.ADMIN,
component: () => import('@/layout/AdminLayout/AdminLayout.vue'),
redirect: ROUTES.DASHBOARD,
meta: adminPageMeta,
children: [
{
path: 'dashboard',
name: ROUTE_NAMES.DASHBOARD,
component: () => import('@/views/manage/DashboardView.vue'),
meta: {
...adminPageMeta,
title: 'dashboard'
}
},
{
path: 'files',
name: ROUTE_NAMES.FILE_MANAGE,
component: () => import('@/views/manage/FileManageView.vue'),
meta: {
...adminPageMeta,
title: 'files'
}
},
{
path: 'settings',
name: ROUTE_NAMES.SETTINGS,
component: () => import('@/views/manage/SystemSettingsView.vue'),
meta: {
...adminPageMeta,
title: 'settings'
}
}
]
},
{
path: ROUTES.LOGIN,
name: ROUTE_NAMES.LOGIN,
component: () => import('@/views/manage/LoginView.vue'),
meta: {
showGlobalControls: true,
showRouteLoading: true,
title: 'login'
}
},
{
path: '/:pathMatch(.*)*',
redirect: ROUTES.HOME
}
]
// 预加载 SendFileView 组件
const SendFileView = () => import('../views/SendFileView.vue')
const router = createRouter({
history: createWebHashHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'Retrieve',
component: () => import('@/views/RetrievewFileView.vue')
},
{
path: '/send',
name: 'Send',
component: SendFileView
},
{
path: '/admin',
name: 'Manage',
component: () => import('@/layout/AdminLayout/AdminLayout.vue'),
redirect: '/admin/dashboard',
children: [
{
path: '/admin/dashboard',
name: 'Dashboard',
component: () => import('@/views/manage/DashboardView.vue')
},
{
path: '/admin/files',
name: 'FileManage',
component: () => import('@/views/manage/FileManageView.vue')
},
{
path: '/admin/settings',
name: 'Settings',
component: () => import('@/views/manage/SystemSettingsView.vue')
}
]
},
{
path: '/login',
name: 'Login',
component: () => import('@/views/manage/LoginView.vue')
}
]
routes
})
router.beforeEach((to) => {
if (to.meta.requiresAuth && !readStoredToken()) {
return {
path: ROUTES.LOGIN,
query: {
redirect: to.fullPath
}
}
}
})
export default router