Skip to content

Commit

Permalink
feat: auto-routing
Browse files Browse the repository at this point in the history
  • Loading branch information
FairyEver committed Apr 23, 2020
1 parent a0959e6 commit eeb01a7
Show file tree
Hide file tree
Showing 13 changed files with 147 additions and 112 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "vue-cli-service serve",
"build": "vue-cli-service build --report",
"lint": "vue-cli-service lint --fix"
"lint": "vue-cli-service lint --fix",
"dev": "vue-cli-service serve"
},
"dependencies": {
"core-js": "^3.6.4",
Expand All @@ -14,6 +14,7 @@
"lodash": "^4.17.15",
"vue": "^2.6.11",
"vue-router": "^3.1.6",
"vue-router-layout": "^0.1.2",
"vuex": "^3.1.3"
},
"devDependencies": {
Expand All @@ -34,6 +35,8 @@
"eslint-plugin-vue": "^6.2.2",
"sass": "^1.26.3",
"sass-loader": "^8.0.2",
"vue-auto-routing": "^0.4.0",
"vue-cli-plugin-auto-routing": "^0.3.3",
"vue-template-compiler": "^2.6.11"
},
"config": {
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions src/pages/about.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<route-meta>
{
"title": "关于"
}
</route-meta>

<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>
11 changes: 11 additions & 0 deletions src/pages/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<route-meta>
{
"title": "首页"
}
</route-meta>

<template>
<div>
home
</div>
</template>
25 changes: 25 additions & 0 deletions src/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Vue from 'vue'
import Router from 'vue-router'
import routes from 'vue-auto-routing'
import { createRouterLayout } from 'vue-router-layout'

Vue.use(Router)

const RouterLayout = createRouterLayout(layout => {
return import('@/layouts/' + layout + '.vue')
})

export const router = new Router({
routes: [
{
path: '/',
component: RouterLayout,
children: routes
}
]
})

export const menus = routes.map(route => ({
path: route.path,
title: route.meta.title
}))
45 changes: 0 additions & 45 deletions src/router/index.js

This file was deleted.

11 changes: 0 additions & 11 deletions src/views/class1/1/page.vue

This file was deleted.

11 changes: 0 additions & 11 deletions src/views/class1/2/page.vue

This file was deleted.

11 changes: 0 additions & 11 deletions src/views/class2/1/page.vue

This file was deleted.

11 changes: 0 additions & 11 deletions src/views/class2/2/page.vue

This file was deleted.

15 changes: 0 additions & 15 deletions src/views/index.vue

This file was deleted.

8 changes: 7 additions & 1 deletion vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ module.exports = {
css: {
loaderOptions: {
sass: {
prependData: `@import '~@/assets/style/public.scss';`
prependData: '@import \'~@/assets/style/public.scss\';'
}
}
},
chainWebpack: config => {
VueFilenameInjector(config, {
propName: '__source'
})
},
pluginOptions: {
autoRouting: {
chunkNamePrefix: 'page-',
nested: false
}
}
}
93 changes: 88 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -880,11 +880,32 @@
call-me-maybe "^1.0.1"
glob-to-regexp "^0.3.0"

"@nodelib/[email protected]":
version "2.1.3"
resolved "https://registry.npm.taobao.org/@nodelib/fs.scandir/download/@nodelib/fs.scandir-2.1.3.tgz#3a582bdb53804c6ba6d146579c46e52130cf4a3b"
integrity sha1-Olgr21OATGum0UZXnEblITDPSjs=
dependencies:
"@nodelib/fs.stat" "2.0.3"
run-parallel "^1.1.9"

"@nodelib/[email protected]", "@nodelib/fs.stat@^2.0.2":
version "2.0.3"
resolved "https://registry.npm.taobao.org/@nodelib/fs.stat/download/@nodelib/fs.stat-2.0.3.tgz#34dc5f4cabbc720f4e60f75a747e7ecd6c175bd3"
integrity sha1-NNxfTKu8cg9OYPdadH5+zWwXW9M=

"@nodelib/fs.stat@^1.1.2":
version "1.1.3"
resolved "https://registry.npm.taobao.org/@nodelib/fs.stat/download/@nodelib/fs.stat-1.1.3.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40nodelib%2Ffs.stat%2Fdownload%2F%40nodelib%2Ffs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
integrity sha1-K1o6s/kYzKSKjHVMCBaOPwPrphs=

"@nodelib/fs.walk@^1.2.3":
version "1.2.4"
resolved "https://registry.npm.taobao.org/@nodelib/fs.walk/download/@nodelib/fs.walk-1.2.4.tgz#011b9202a70a6366e436ca5c065844528ab04976"
integrity sha1-ARuSAqcKY2bkNspcBlhEUoqwSXY=
dependencies:
"@nodelib/fs.scandir" "2.1.3"
fastq "^1.6.0"

"@soda/friendly-errors-webpack-plugin@^1.7.1":
version "1.7.1"
resolved "https://registry.npm.taobao.org/@soda/friendly-errors-webpack-plugin/download/@soda/friendly-errors-webpack-plugin-1.7.1.tgz#706f64bcb4a8b9642b48ae3ace444c70334d615d"
Expand Down Expand Up @@ -1839,7 +1860,7 @@ braces@^2.3.1, braces@^2.3.2:
split-string "^3.0.2"
to-regex "^3.0.1"

braces@~3.0.2:
braces@^3.0.1, braces@~3.0.2:
version "3.0.2"
resolved "https://registry.npm.taobao.org/braces/download/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
integrity sha1-NFThpGLujVmeI23zNs2epPiv4Qc=
Expand Down Expand Up @@ -3769,6 +3790,18 @@ fast-glob@^2.2.6:
merge2 "^1.2.3"
micromatch "^3.1.10"

fast-glob@^3.0.4:
version "3.2.2"
resolved "https://registry.npm.taobao.org/fast-glob/download/fast-glob-3.2.2.tgz?cache=0&sync_timestamp=1582318370324&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffast-glob%2Fdownload%2Ffast-glob-3.2.2.tgz#ade1a9d91148965d4bf7c51f72e1ca662d32e63d"
integrity sha1-reGp2RFIll1L98UfcuHKZi0y5j0=
dependencies:
"@nodelib/fs.stat" "^2.0.2"
"@nodelib/fs.walk" "^1.2.3"
glob-parent "^5.1.0"
merge2 "^1.3.0"
micromatch "^4.0.2"
picomatch "^2.2.1"

fast-json-stable-stringify@^2.0.0:
version "2.1.0"
resolved "https://registry.npm.taobao.org/fast-json-stable-stringify/download/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
Expand All @@ -3779,6 +3812,13 @@ fast-levenshtein@~2.0.6:
resolved "https://registry.npm.taobao.org/fast-levenshtein/download/fast-levenshtein-2.0.6.tgz?cache=0&sync_timestamp=1573614520618&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffast-levenshtein%2Fdownload%2Ffast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=

fastq@^1.6.0:
version "1.7.0"
resolved "https://registry.npm.taobao.org/fastq/download/fastq-1.7.0.tgz#fcd79a08c5bd7ec5b55cd3f5c4720db551929801"
integrity sha1-/NeaCMW9fsW1XNP1xHINtVGSmAE=
dependencies:
reusify "^1.0.4"

faye-websocket@^0.10.0:
version "0.10.0"
resolved "https://registry.npm.taobao.org/faye-websocket/download/faye-websocket-0.10.0.tgz#4e492f8d04dfb6f89003507f6edbf2d501e7c6f4"
Expand Down Expand Up @@ -4142,7 +4182,7 @@ glob-parent@^3.1.0:
is-glob "^3.1.0"
path-dirname "^1.0.0"

glob-parent@^5.0.0, glob-parent@~5.1.0:
glob-parent@^5.0.0, glob-parent@^5.1.0, glob-parent@~5.1.0:
version "5.1.1"
resolved "https://registry.npm.taobao.org/glob-parent/download/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229"
integrity sha1-tsHvQXxOVmPqSY8cRa+saRa7wik=
Expand Down Expand Up @@ -5535,7 +5575,7 @@ merge-stream@^2.0.0:
resolved "https://registry.npm.taobao.org/merge-stream/download/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
integrity sha1-UoI2KaFN0AyXcPtq1H3GMQ8sH2A=

merge2@^1.2.3:
merge2@^1.2.3, merge2@^1.3.0:
version "1.3.0"
resolved "https://registry.npm.taobao.org/merge2/download/merge2-1.3.0.tgz#5b366ee83b2f1582c48f87e47cf1a9352103ca81"
integrity sha1-WzZu6DsvFYLEj4fkfPGpNSEDyoE=
Expand Down Expand Up @@ -5569,6 +5609,14 @@ micromatch@^3.0.4, micromatch@^3.1.10, micromatch@^3.1.4:
snapdragon "^0.8.1"
to-regex "^3.0.2"

micromatch@^4.0.2:
version "4.0.2"
resolved "https://registry.npm.taobao.org/micromatch/download/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259"
integrity sha1-T8sJmb+fvC/L3SEvbWKbmlbDklk=
dependencies:
braces "^3.0.1"
picomatch "^2.0.5"

miller-rabin@^4.0.0:
version "4.0.1"
resolved "https://registry.npm.taobao.org/miller-rabin/download/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d"
Expand Down Expand Up @@ -6398,7 +6446,7 @@ performance-now@^2.1.0:
resolved "https://registry.npm.taobao.org/performance-now/download/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=

picomatch@^2.0.4, picomatch@^2.0.7:
picomatch@^2.0.4, picomatch@^2.0.5, picomatch@^2.0.7, picomatch@^2.2.1:
version "2.2.2"
resolved "https://registry.npm.taobao.org/picomatch/download/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad"
integrity sha1-IfMz6ba46v8CRo9RRupAbTRfTa0=
Expand Down Expand Up @@ -6831,7 +6879,7 @@ prepend-http@^1.0.0:
resolved "https://registry.npm.taobao.org/prepend-http/download/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc"
integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=

prettier@^1.18.2:
prettier@1.19.1, prettier@^1.18.2:
version "1.19.1"
resolved "https://registry.npm.taobao.org/prettier/download/prettier-1.19.1.tgz?cache=0&sync_timestamp=1586174253764&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fprettier%2Fdownload%2Fprettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
integrity sha1-99f1/4qc2HKnvkyhQglZVqYHl8s=
Expand Down Expand Up @@ -7337,6 +7385,11 @@ retry@^0.12.0:
resolved "https://registry.npm.taobao.org/retry/download/retry-0.12.0.tgz#1b42a6266a21f07421d1b0b54b7dc167b01c013b"
integrity sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=

reusify@^1.0.4:
version "1.0.4"
resolved "https://registry.npm.taobao.org/reusify/download/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76"
integrity sha1-kNo4Kx4SbvwCFG6QhFqI2xKSXXY=

rgb-regex@^1.0.1:
version "1.0.1"
resolved "https://registry.npm.taobao.org/rgb-regex/download/rgb-regex-1.0.1.tgz#c0e0d6882df0e23be254a475e8edd41915feaeb1"
Expand Down Expand Up @@ -7381,6 +7434,11 @@ run-async@^2.2.0, run-async@^2.4.0:
dependencies:
is-promise "^2.1.0"

run-parallel@^1.1.9:
version "1.1.9"
resolved "https://registry.npm.taobao.org/run-parallel/download/run-parallel-1.1.9.tgz#c9dd3a7cf9f4b2c4b6244e173a6ed866e61dd679"
integrity sha1-yd06fPn0ssS2JE4XOm7YZuYd1nk=

run-queue@^1.0.0, run-queue@^1.0.3:
version "1.0.3"
resolved "https://registry.npm.taobao.org/run-queue/download/run-queue-1.0.3.tgz#e848396f057d223f24386924618e25694161ec47"
Expand Down Expand Up @@ -8587,6 +8645,18 @@ vm-browserify@^1.0.1:
resolved "https://registry.npm.taobao.org/vm-browserify/download/vm-browserify-1.1.2.tgz?cache=0&sync_timestamp=1572870772154&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvm-browserify%2Fdownload%2Fvm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0"
integrity sha1-eGQcSIuObKkadfUR56OzKobl3aA=

vue-auto-routing@^0.4.0:
version "0.4.1"
resolved "https://registry.npm.taobao.org/vue-auto-routing/download/vue-auto-routing-0.4.1.tgz#c601d47a3a7adfd03f98ebf7b23c50eb6189c88c"
integrity sha1-xgHUejp639A/mOv3sjxQ62GJyIw=
dependencies:
vue-route-generator "^0.4.3"

vue-cli-plugin-auto-routing@^0.3.3:
version "0.3.3"
resolved "https://registry.npm.taobao.org/vue-cli-plugin-auto-routing/download/vue-cli-plugin-auto-routing-0.3.3.tgz#18bbb29a3334b518676353ed8f23d4c0e2721d53"
integrity sha1-GLuymjM0tRhnY1PtjyPUwOJyHVM=

vue-eslint-parser@^7.0.0:
version "7.0.0"
resolved "https://registry.npm.taobao.org/vue-eslint-parser/download/vue-eslint-parser-7.0.0.tgz#a4ed2669f87179dedd06afdd8736acbb3a3864d6"
Expand Down Expand Up @@ -8615,6 +8685,19 @@ vue-loader@^15.9.1:
vue-hot-reload-api "^2.3.0"
vue-style-loader "^4.1.0"

vue-route-generator@^0.4.3:
version "0.4.3"
resolved "https://registry.npm.taobao.org/vue-route-generator/download/vue-route-generator-0.4.3.tgz#9a4c31f155cbe02f98962f286a16173890228afa"
integrity sha1-mkwx8VXL4C+Yli8oahYXOJAiivo=
dependencies:
fast-glob "^3.0.4"
prettier "1.19.1"

vue-router-layout@^0.1.2:
version "0.1.5"
resolved "https://registry.npm.taobao.org/vue-router-layout/download/vue-router-layout-0.1.5.tgz#4e0454d10428a114be91d6458ffa4242664c6d70"
integrity sha1-TgRU0QQooRS+kdZFj/pCQmZMbXA=

vue-router@^3.1.6:
version "3.1.6"
resolved "https://registry.npm.taobao.org/vue-router/download/vue-router-3.1.6.tgz#45f5a3a3843e31702c061dd829393554e4328f89"
Expand Down

0 comments on commit eeb01a7

Please sign in to comment.