diff --git a/src/router.js b/src/router.js index 642aba77ecd540052b9b3ec6e689b6c0c85862cb..42153de8f95a57f47ac79239b1c6726df3f021a4 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