frpc&frps router

This commit is contained in:
hal-wang 2021-01-25 19:44:20 +08:00
parent 984f7ee28d
commit 57628713ee
4 changed files with 107 additions and 98 deletions

View File

@ -8,6 +8,7 @@
"serve:s": "vue-cli-service serve --mode dev-frps", "serve:s": "vue-cli-service serve --mode dev-frps",
"build:c": "vue-cli-service build --mode frpc", "build:c": "vue-cli-service build --mode frpc",
"build:s": "vue-cli-service build --mode frps", "build:s": "vue-cli-service build --mode frps",
"build:all": "npm run build:s && npm run build:c",
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {

37
web/src/router/frpc.js Normal file
View File

@ -0,0 +1,37 @@
import AdminLayout from '@/components/AdminLayout'
const routes = [
{
path: '/frpc/config',
component: AdminLayout,
meta: {
icon: 'config'
},
children: [
{
path: '',
component: () => import('@/views/frpc/Configure'),
meta: {
title: 'Configure'
}
}
]
},
{
path: '/frpc',
component: AdminLayout,
meta: {
icon: 'dashboard'
},
children: [
{
path: '',
component: () => import('@/views/frpc/Overview'),
meta: {
title: 'Overview'
}
}
]
}
]
export default routes

66
web/src/router/frps.js Normal file
View File

@ -0,0 +1,66 @@
import AdminLayout from '@/components/AdminLayout'
const routes = [
{
path: '/frps',
component: AdminLayout,
meta: {
icon: 'dashboard'
},
children: [
{
path: '',
component: () => import('@/views/frps/Overview'),
meta: {
title: 'Overview'
}
}
]
},
{
path: '/frps/proxies',
component: AdminLayout,
meta: {
title: 'Proxies',
icon: 'proxy'
},
children: [
{
path: 'tcp',
component: () => import('@/views/frps/ProxiesTcp'),
meta: {
title: 'TCP'
}
},
{
path: 'udp',
component: () => import('@/views/frps/ProxiesUdp'),
meta: {
title: 'UDP'
}
},
{
path: 'http',
component: () => import('@/views/frps/ProxiesHttp'),
meta: {
title: 'HTTP'
}
},
{
path: 'https',
component: () => import('@/views/frps/ProxiesHttps'),
meta: {
title: 'HTTPS'
}
},
{
path: 'stcp',
component: () => import('@/views/frps/ProxiesStcp'),
meta: {
title: 'STCP'
}
}
]
}
]
export default routes

View File

@ -18,103 +18,7 @@ const allRoutes = [
} }
] ]
}, },
{ ...require(`./${process.env.VUE_APP_TYPE}`).default,
path: '/frps',
component: AdminLayout,
meta: {
icon: 'dashboard',
type: 'frps'
},
children: [
{
path: '',
component: () => import('@/views/frps/Overview'),
meta: {
title: 'Overview'
}
}
]
},
{
path: '/frps/proxies',
component: AdminLayout,
meta: {
title: 'Proxies',
icon: 'proxy',
type: 'frps'
},
children: [
{
path: 'tcp',
component: () => import('@/views/frps/ProxiesTcp'),
meta: {
title: 'TCP'
}
},
{
path: 'udp',
component: () => import('@/views/frps/ProxiesUdp'),
meta: {
title: 'UDP'
}
},
{
path: 'http',
component: () => import('@/views/frps/ProxiesHttp'),
meta: {
title: 'HTTP'
}
},
{
path: 'https',
component: () => import('@/views/frps/ProxiesHttps'),
meta: {
title: 'HTTPS'
}
},
{
path: 'stcp',
component: () => import('@/views/frps/ProxiesStcp'),
meta: {
title: 'STCP'
}
}
]
},
{
path: '/frpc',
component: AdminLayout,
meta: {
icon: 'dashboard',
type: 'frpc'
},
children: [
{
path: '',
component: () => import('@/views/frpc/Overview'),
meta: {
title: 'Overview'
}
}
]
},
{
path: '/frpc/config',
component: AdminLayout,
meta: {
icon: 'config',
type: 'frpc'
},
children: [
{
path: '',
component: () => import('@/views/frpc/Configure'),
meta: {
title: 'Configure'
}
}
]
},
{ {
path: '/help', path: '/help',
component: AdminLayout, component: AdminLayout,
@ -132,7 +36,7 @@ const allRoutes = [
// filter routes recursively // filter routes recursively
const filterRoutes = function(routes) { const filterRoutes = function(routes) {
const newRoutes = routes.filter(route => !route.meta || !route.meta.type || route.meta.type === process.env.VUE_APP_TYPE) const newRoutes = routes.filter(route => !!route)
for (const route in newRoutes) { for (const route in newRoutes) {
if (route.children) { if (route.children) {
route.children = filterRoutes(route.children) route.children = filterRoutes(route.children)
@ -142,6 +46,7 @@ const filterRoutes = function(routes) {
} }
export const routes = filterRoutes(allRoutes) export const routes = filterRoutes(allRoutes)
console.log('allRoutes', allRoutes, routes)
const router = new Router({ const router = new Router({
routes routes