Skip to content
This repository was archived by the owner on May 12, 2020. It is now read-only.

Commit b95664a

Browse files
committed
feat(router): add permission module and NProgress
1 parent b4efaa5 commit b95664a

5 files changed

Lines changed: 29 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"dependencies": {
1111
"element-ui": "^2.4.5",
1212
"normalize.css": "^8.0.1",
13+
"nprogress": "^0.2.0",
1314
"vue": "^2.5.17",
1415
"vue-router": "^3.0.1",
1516
"vuex": "^3.0.1"

src/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import Vue from 'vue'
2+
import 'normalize.css'
23
import App from './App.vue'
3-
import router from './router'
4+
// Shouldn't use Router instance directly without 'PERMISSION/index' processing.
5+
import router from './permission'
46
import store from './store'
5-
import 'normalize.css'
67
import './plugins/element.js'
78

89
Vue.config.productionTip = false

src/permission/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import router from 'ROUTER'
2+
import NProgress from 'nprogress'
3+
import 'nprogress/nprogress.css'
4+
5+
NProgress.configure({ showSpinner: false })
6+
7+
router.beforeEach((to, from, next) => {
8+
NProgress.start()
9+
next()
10+
})
11+
12+
router.afterEach((to, from) => {
13+
NProgress.done()
14+
})
15+
16+
export default router

src/router/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import { constantComponents } from './components'
44

55
Vue.use(Router)
66

7+
/**
8+
* ! NOTICE
9+
* This router instance should not be added directly without
10+
* `PERMISSION/index` processing.
11+
*/
712
export default new Router({
813
routes: [
914
{

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4791,6 +4791,10 @@ npm-run-path@^2.0.0:
47914791
gauge "~2.7.3"
47924792
set-blocking "~2.0.0"
47934793

4794+
nprogress@^0.2.0:
4795+
version "0.2.0"
4796+
resolved "http://registry.npm.taobao.org/nprogress/download/nprogress-0.2.0.tgz#cb8f34c53213d895723fcbab907e9422adbcafb1"
4797+
47944798
nth-check@^1.0.2, nth-check@~1.0.1:
47954799
version "1.0.2"
47964800
resolved "http://registry.npm.taobao.org/nth-check/download/nth-check-1.0.2.tgz#b2bd295c37e3dd58a3bf0700376663ba4d9cf05c"

0 commit comments

Comments
 (0)