2023-06-07 04:23:20 +00:00
|
|
|
|
import { type RouteRecordRaw } from 'vue-router'
|
2023-05-28 17:16:19 +00:00
|
|
|
|
|
2023-06-07 04:23:20 +00:00
|
|
|
|
export const constantRoutes: RouteRecordRaw[] = [
|
|
|
|
|
// KUNGalgame 登录
|
|
|
|
|
{
|
|
|
|
|
name: 'Login',
|
|
|
|
|
path: '/login',
|
|
|
|
|
component: () => import('@/views/login/Login.vue'),
|
|
|
|
|
meta: {
|
|
|
|
|
title: '登录',
|
|
|
|
|
},
|
2023-05-28 17:16:19 +00:00
|
|
|
|
},
|
2023-06-07 04:23:20 +00:00
|
|
|
|
// KUNGalgame 联系我们
|
|
|
|
|
{
|
|
|
|
|
name: 'Contact',
|
|
|
|
|
path: '/contact',
|
|
|
|
|
component: () => import('@/views/contact/Contact.vue'),
|
|
|
|
|
meta: {
|
|
|
|
|
title: '联系我们',
|
|
|
|
|
},
|
2023-05-28 17:16:19 +00:00
|
|
|
|
},
|
|
|
|
|
|
2023-06-07 04:23:20 +00:00
|
|
|
|
// KUNGalgame 捐助我们
|
|
|
|
|
{
|
|
|
|
|
name: 'Donate',
|
|
|
|
|
path: '/donate',
|
|
|
|
|
component: () => import('@/views/donate/Donate.vue'),
|
|
|
|
|
meta: {
|
2023-08-05 05:24:26 +00:00
|
|
|
|
title: '赞助我们',
|
2023-06-07 04:23:20 +00:00
|
|
|
|
},
|
2023-05-28 17:16:19 +00:00
|
|
|
|
},
|
|
|
|
|
|
2023-06-07 04:23:20 +00:00
|
|
|
|
// KUNGalgame 用户协议
|
|
|
|
|
{
|
2023-09-24 08:02:18 +00:00
|
|
|
|
name: 'Agreement',
|
|
|
|
|
path: '/agreement',
|
|
|
|
|
component: () => import('@/views/agreement/Agreement.vue'),
|
2023-06-07 04:23:20 +00:00
|
|
|
|
meta: {
|
|
|
|
|
title: '用户协议',
|
|
|
|
|
},
|
2023-05-28 17:16:19 +00:00
|
|
|
|
},
|
|
|
|
|
|
2023-06-07 04:23:20 +00:00
|
|
|
|
// KUNGalgame 隐私政策
|
|
|
|
|
{
|
|
|
|
|
name: 'Privacy',
|
|
|
|
|
path: '/privacy',
|
|
|
|
|
component: () => import('@/views/privacy/Privacy.vue'),
|
|
|
|
|
meta: {
|
|
|
|
|
title: '隐私政策',
|
|
|
|
|
},
|
2023-05-28 17:16:19 +00:00
|
|
|
|
},
|
|
|
|
|
|
2023-06-07 04:23:20 +00:00
|
|
|
|
// KUNGalgame 重定向页面
|
|
|
|
|
{
|
|
|
|
|
name: 'Redirect',
|
|
|
|
|
path: '/redirect',
|
|
|
|
|
redirect: '/',
|
|
|
|
|
component: () => import('@/views/redirect/Redirect.vue'),
|
|
|
|
|
meta: {
|
|
|
|
|
title: '重定向',
|
|
|
|
|
},
|
|
|
|
|
children: [], // 添加一个空的 children 数组,redirect 配置项必须有 children
|
2023-05-28 17:16:19 +00:00
|
|
|
|
},
|
|
|
|
|
|
2023-06-07 04:23:20 +00:00
|
|
|
|
// KUNGalgame 404
|
|
|
|
|
{
|
|
|
|
|
name: '404',
|
|
|
|
|
path: '/:path(.*)*',
|
|
|
|
|
component: () => import('@/views/404/404.vue'),
|
|
|
|
|
meta: {
|
|
|
|
|
title: '404',
|
|
|
|
|
},
|
|
|
|
|
},
|
2023-05-28 17:16:19 +00:00
|
|
|
|
|
2023-06-07 04:23:20 +00:00
|
|
|
|
// KUNGalgame 403 TODO:
|
|
|
|
|
{
|
|
|
|
|
name: '403',
|
2023-10-10 12:12:01 +00:00
|
|
|
|
path: '/kungalgame403',
|
2023-06-07 04:23:20 +00:00
|
|
|
|
component: () => import('@/views/403/403.vue'),
|
|
|
|
|
meta: {
|
|
|
|
|
title: '403',
|
|
|
|
|
},
|
2023-05-28 17:16:19 +00:00
|
|
|
|
},
|
2023-06-07 04:23:20 +00:00
|
|
|
|
]
|
2023-05-28 17:16:19 +00:00
|
|
|
|
|
|
|
|
|
const isArray = (val: any): val is object =>
|
|
|
|
|
toString.call(val) === '[object Array]'
|
|
|
|
|
|
2023-05-29 09:18:38 +00:00
|
|
|
|
// 获取动态路由表
|
2023-06-07 04:23:20 +00:00
|
|
|
|
const getAsyncRoute = (): RouteRecordRaw[] => {
|
2023-05-28 17:16:19 +00:00
|
|
|
|
const modules = import.meta.glob('./modules/*.ts', {
|
|
|
|
|
eager: true,
|
|
|
|
|
import: 'default',
|
|
|
|
|
})
|
2023-06-07 04:23:20 +00:00
|
|
|
|
const asyncRoute: RouteRecordRaw[] = []
|
2023-05-28 17:16:19 +00:00
|
|
|
|
Object.values(modules).forEach((value) => {
|
|
|
|
|
const moduleList = isArray(value)
|
2023-06-07 04:23:20 +00:00
|
|
|
|
? [...(value as RouteRecordRaw[])]
|
|
|
|
|
: [value as RouteRecordRaw]
|
2023-05-28 17:16:19 +00:00
|
|
|
|
asyncRoute.push(...moduleList)
|
|
|
|
|
})
|
|
|
|
|
return asyncRoute
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-07 04:23:20 +00:00
|
|
|
|
const getRouteName = (routeList: RouteRecordRaw[]) => {
|
2023-05-28 17:16:19 +00:00
|
|
|
|
const routeArr: string[] = []
|
|
|
|
|
routeList.forEach((item) => {
|
|
|
|
|
routeArr.push(item.name as string)
|
|
|
|
|
if (item?.children) {
|
|
|
|
|
routeArr.push(...getRouteName(item?.children))
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return routeArr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 异步路由
|
|
|
|
|
export const asyncRoutes = getAsyncRoute()
|
|
|
|
|
|
|
|
|
|
// 路由白名单
|
2023-06-07 04:23:20 +00:00
|
|
|
|
export const WHITE_LIST = getRouteName(constantRoutes)
|