From 57628713ee17132fa37bd93ff66962f7f8420240 Mon Sep 17 00:00:00 2001 From: hal-wang Date: Mon, 25 Jan 2021 19:44:20 +0800 Subject: [PATCH] frpc&frps router --- web/package.json | 1 + web/src/router/frpc.js | 37 +++++++++++++++ web/src/router/frps.js | 66 ++++++++++++++++++++++++++ web/src/router/index.js | 101 ++-------------------------------------- 4 files changed, 107 insertions(+), 98 deletions(-) create mode 100644 web/src/router/frpc.js create mode 100644 web/src/router/frps.js diff --git a/web/package.json b/web/package.json index 322af3d1..3458b774 100644 --- a/web/package.json +++ b/web/package.json @@ -8,6 +8,7 @@ "serve:s": "vue-cli-service serve --mode dev-frps", "build:c": "vue-cli-service build --mode frpc", "build:s": "vue-cli-service build --mode frps", + "build:all": "npm run build:s && npm run build:c", "lint": "vue-cli-service lint" }, "dependencies": { diff --git a/web/src/router/frpc.js b/web/src/router/frpc.js new file mode 100644 index 00000000..53b0138d --- /dev/null +++ b/web/src/router/frpc.js @@ -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 diff --git a/web/src/router/frps.js b/web/src/router/frps.js new file mode 100644 index 00000000..d7fed308 --- /dev/null +++ b/web/src/router/frps.js @@ -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 diff --git a/web/src/router/index.js b/web/src/router/index.js index 285066c0..8fb1a2f6 100644 --- a/web/src/router/index.js +++ b/web/src/router/index.js @@ -18,103 +18,7 @@ const allRoutes = [ } ] }, - { - 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' - } - } - ] - }, + ...require(`./${process.env.VUE_APP_TYPE}`).default, { path: '/help', component: AdminLayout, @@ -132,7 +36,7 @@ const allRoutes = [ // filter routes recursively 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) { if (route.children) { route.children = filterRoutes(route.children) @@ -142,6 +46,7 @@ const filterRoutes = function(routes) { } export const routes = filterRoutes(allRoutes) +console.log('allRoutes', allRoutes, routes) const router = new Router({ routes