231 lines
5.1 KiB
TypeScript
231 lines
5.1 KiB
TypeScript
// Author: fruit.com.cn
|
|
|
|
import { createRouter, createWebHashHistory } from 'vue-router'
|
|
import type { RouteRecordRaw } from 'vue-router'
|
|
import type { App } from 'vue'
|
|
import { Layout } from '@/utils/routerHelper'
|
|
|
|
export const constantRouterMap: AppRouteRecordRaw[] = [
|
|
{
|
|
path: '/',
|
|
component: Layout,
|
|
redirect: '/dashboard/index',
|
|
name: 'Root',
|
|
meta: {
|
|
hidden: true
|
|
}
|
|
},
|
|
{
|
|
path: '/redirect',
|
|
component: Layout,
|
|
name: 'RedirectParent',
|
|
children: [
|
|
{
|
|
path: '/redirect/:path(.*)',
|
|
name: 'Redirect',
|
|
component: () => import('@/views/Redirect/Redirect.vue'),
|
|
meta: {}
|
|
}
|
|
],
|
|
meta: {
|
|
hidden: true,
|
|
noTagsView: true
|
|
}
|
|
},
|
|
{
|
|
path: '/login',
|
|
component: () => import('@/views/Login/Login.vue'),
|
|
name: 'Login',
|
|
meta: {
|
|
hidden: true,
|
|
title: '登录',
|
|
noTagsView: true
|
|
}
|
|
},
|
|
{
|
|
path: '/404',
|
|
component: () => import('@/views/Error/404.vue'),
|
|
name: 'NoFind',
|
|
meta: {
|
|
hidden: true,
|
|
title: '404',
|
|
noTagsView: true
|
|
}
|
|
}
|
|
]
|
|
|
|
export const asyncRouterMap: AppRouteRecordRaw[] = [
|
|
{
|
|
path: '/dashboard',
|
|
component: Layout,
|
|
redirect: '/dashboard/index',
|
|
name: 'Dashboard',
|
|
meta: {
|
|
title: '工作台',
|
|
icon: 'ant-design:dashboard-filled'
|
|
},
|
|
children: [
|
|
{
|
|
path: 'index',
|
|
name: 'dashboard',
|
|
component: () => import('@/views/common/DashboardView.vue'),
|
|
meta: {
|
|
title: '工作台',
|
|
icon: 'ant-design:dashboard-filled',
|
|
affix: true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: '/content',
|
|
component: Layout,
|
|
redirect: '/content/dramas',
|
|
name: 'Content',
|
|
meta: {
|
|
title: '内容管理',
|
|
icon: 'ep:video-camera',
|
|
alwaysShow: true
|
|
},
|
|
children: [
|
|
{
|
|
path: 'dramas',
|
|
name: 'dramas',
|
|
component: () => import('@/views/contentManagement/DramaManagementView.vue'),
|
|
meta: {
|
|
title: '短剧管理'
|
|
}
|
|
},
|
|
{
|
|
path: 'episodes',
|
|
name: 'episodes',
|
|
component: () => import('@/views/contentManagement/EpisodeManagementView.vue'),
|
|
meta: {
|
|
title: '剧集管理'
|
|
}
|
|
},
|
|
{
|
|
path: 'banners',
|
|
name: 'banners',
|
|
component: () => import('@/views/contentManagement/BannerManagementView.vue'),
|
|
meta: {
|
|
title: '轮播图管理'
|
|
}
|
|
},
|
|
{
|
|
path: 'categories',
|
|
name: 'categories',
|
|
component: () => import('@/views/contentManagement/CategoryManagementView.vue'),
|
|
meta: {
|
|
title: '类型管理'
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: '/user',
|
|
component: Layout,
|
|
redirect: '/user/app-users',
|
|
name: 'UserCenter',
|
|
meta: {
|
|
title: '用户管理',
|
|
icon: 'ep:user',
|
|
alwaysShow: true
|
|
},
|
|
children: [
|
|
{
|
|
path: 'app-users',
|
|
name: 'app-users',
|
|
component: () => import('@/views/userManagement/AppUsersView.vue'),
|
|
meta: {
|
|
title: 'App 用户'
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: '/system',
|
|
component: Layout,
|
|
redirect: '/system/access',
|
|
name: 'System',
|
|
meta: {
|
|
title: '后台管理',
|
|
icon: 'ep:setting',
|
|
alwaysShow: true
|
|
},
|
|
children: [
|
|
{
|
|
path: 'access',
|
|
name: 'access',
|
|
component: () => import('@/views/permission/RoleManagementView.vue'),
|
|
meta: {
|
|
title: '角色权限配置'
|
|
}
|
|
},
|
|
{
|
|
path: 'admin-users',
|
|
name: 'admin-users',
|
|
component: () => import('@/views/userManagement/AdminUsersView.vue'),
|
|
meta: {
|
|
title: '管理员用户列表'
|
|
}
|
|
},
|
|
{
|
|
path: 'menus',
|
|
name: 'menus',
|
|
component: () => import('@/views/permission/MenuManagementView.vue'),
|
|
meta: {
|
|
title: '菜单管理'
|
|
}
|
|
},
|
|
{
|
|
path: 'role-categories',
|
|
name: 'role-categories',
|
|
component: () => import('@/views/permission/RoleCategoriesView.vue'),
|
|
meta: {
|
|
title: '角色分类'
|
|
}
|
|
},
|
|
{
|
|
path: 'settings',
|
|
name: 'settings',
|
|
component: () => import('@/views/systemManagement/SettingsView.vue'),
|
|
meta: {
|
|
title: '系统设置'
|
|
}
|
|
},
|
|
{
|
|
path: 'operation-logs',
|
|
name: 'operation-logs',
|
|
component: () => import('@/views/systemManagement/OperationLogView.vue'),
|
|
meta: {
|
|
title: '操作日志'
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
|
|
const router = createRouter({
|
|
history: createWebHashHistory(),
|
|
strict: true,
|
|
routes: constantRouterMap as RouteRecordRaw[],
|
|
scrollBehavior: () => ({ left: 0, top: 0 })
|
|
})
|
|
|
|
export const resetRouter = (): void => {
|
|
const resetWhiteNameList = ['Redirect', 'RedirectParent', 'Login', 'NoFind', 'Root']
|
|
router.getRoutes().forEach((route) => {
|
|
const { name } = route
|
|
if (name && !resetWhiteNameList.includes(name as string)) {
|
|
router.hasRoute(name) && router.removeRoute(name)
|
|
}
|
|
})
|
|
}
|
|
|
|
export const setupRouter = (app: App<Element>) => {
|
|
app.use(router)
|
|
}
|
|
|
|
export default router
|