From 6a7fc0a5262470f717866c10a9ff5ab7641df27b Mon Sep 17 00:00:00 2001 From: baiy Date: Sat, 15 Jun 2019 15:52:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=87=92=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E6=89=93=E5=8C=85=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router.js | 88 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 25 deletions(-) diff --git a/src/router.js b/src/router.js index 642aba7..42153de 100644 --- a/src/router.js +++ b/src/router.js @@ -1,41 +1,79 @@ import Vue from 'vue' import Router from 'vue-router' -import {trim,stat} from "./helper"; +import {stat} from "./helper"; +Vue.use(Router); // 路由配置 const routes = [ - // {path: '/', name: 'home', component: () => import('./views/index.vue')}, + { + path: "/tool/base64", + component: r => require(['./views/tool/base64.vue'], r) + }, + { + path: "/tool/code", + component: r => require(['./views/tool/code.vue'], r) + }, + { + path: "/tool/decimalConvert", + component: r => require(['./views/tool/decimalConvert.vue'], r) + }, + { + path: "/tool/diffs", + component: r => require(['./views/tool/diffs.vue'], r) + }, + { + path: "/tool/encrypt", + component: r => require(['./views/tool/encrypt.vue'], r) + }, + { + path: "/tool/hash", + component: r => require(['./views/tool/hash.vue'], r) + }, + { + path: "/tool/ip", + component: r => require(['./views/tool/ip.vue'], r) + }, + { + path: "/tool/phpArraySerialize", + component: r => require(['./views/tool/phpArraySerialize.vue'], r) + }, + { + path: "/tool/pinyin", + component: r => require(['./views/tool/pinyin.vue'], r) + }, + { + path: "/tool/qrCode", + component: r => require(['./views/tool/qrCode.vue'], r) + }, + { + path: "/tool/randomString", + component: r => require(['./views/tool/randomString.vue'], r) + }, + { + path: "/tool/regex", + component: r => require(['./views/tool/regex.vue'], r) + }, + { + path: "/tool/timestamp", + component: r => require(['./views/tool/timestamp.vue'], r) + }, + { + path: "/tool/unicode", + component: r => require(['./views/tool/unicode.vue'], r) + }, + { + path: "/tool/url", + component: r => require(['./views/tool/url.vue'], r) + }, ]; -// 路由自动加载 -const routeComponent = require.context( - './views', - true, - /\.vue$/ -); - -routeComponent.keys().forEach(fileName => { - // 过滤组件 - if (fileName.indexOf('components/') !== -1 || fileName === "index") { - return; - } - const path = '/' + trim(fileName.replace(/^\.\/(.*)\.\w+$/, '$1'), '/', 'left'); - routes.push({ - path: path, - name: path, - component: routeComponent(fileName).default - }) -}); - -Vue.use(Router); - const router = new Router({routes}); stat('index'); router.afterEach(to => { - stat('tool',{tool:to.name}) + stat('tool', {tool: to.path}) }); export default router \ No newline at end of file -- GitLab