Add NProgress

This commit is contained in:
Aicirou 2020-07-05 01:12:24 +08:00
parent adedafde03
commit eda64c8483
3 changed files with 13 additions and 3 deletions

7
package-lock.json generated
View File

@ -2288,7 +2288,7 @@
}, },
"@babel/types": { "@babel/types": {
"version": "7.0.0-beta.35", "version": "7.0.0-beta.35",
"resolved": "https://registry.npm.taobao.org/@babel/types/download/@babel/types-7.0.0-beta.35.tgz?cache=0&sync_timestamp=1593521074992&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Ftypes%2Fdownload%2F%40babel%2Ftypes-7.0.0-beta.35.tgz", "resolved": "https://registry.npm.taobao.org/@babel/types/download/@babel/types-7.0.0-beta.35.tgz?cache=0&sync_timestamp=1588185770735&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Ftypes%2Fdownload%2F%40babel%2Ftypes-7.0.0-beta.35.tgz",
"integrity": "sha1-z5M6mpo4SEynJLM1uI2Dcm1auWA=", "integrity": "sha1-z5M6mpo4SEynJLM1uI2Dcm1auWA=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -8601,6 +8601,11 @@
"set-blocking": "~2.0.0" "set-blocking": "~2.0.0"
} }
}, },
"nprogress": {
"version": "0.2.0",
"resolved": "https://registry.npm.taobao.org/nprogress/download/nprogress-0.2.0.tgz",
"integrity": "sha1-y480xTIT2JVyP8urkH6UIq28r7E="
},
"nth-check": { "nth-check": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "http://registry.npm.taobao.org/nth-check/download/nth-check-1.0.2.tgz", "resolved": "http://registry.npm.taobao.org/nth-check/download/nth-check-1.0.2.tgz",

View File

@ -24,6 +24,7 @@
"lowdb": "^1.0.0", "lowdb": "^1.0.0",
"marked": "^1.1.0", "marked": "^1.1.0",
"node-sass": "^4.14.0", "node-sass": "^4.14.0",
"nprogress": "^0.2.0",
"plyr": "^3.6.2", "plyr": "^3.6.2",
"sass-loader": "^8.0.2", "sass-loader": "^8.0.2",
"v-viewer": "^1.5.1", "v-viewer": "^1.5.1",

View File

@ -1,9 +1,11 @@
import Vue from "vue"; import Vue from "vue";
import febAlive from "feb-alive"; import febAlive from "feb-alive";
import VueRouter from "vue-router"; import VueRouter from "vue-router";
import NProgress from "nprogress";
import "nprogress/nprogress.css";
// 路由数据 // 路由数据
import routes from "./routes"; import routes from "./routes";
import store from '@/store/index'; import store from "@/store/index";
// 在router实例化之前重写history // 在router实例化之前重写history
febAlive.resetHistory(); febAlive.resetHistory();
@ -43,15 +45,17 @@ Vue.use(febAlive, { router });
* 权限验证 * 权限验证
*/ */
router.beforeEach(async (to, from, next) => { router.beforeEach(async (to, from, next) => {
NProgress.start();
if (process.env.NODE_ENV === "development") { if (process.env.NODE_ENV === "development") {
console.log("before:"); console.log("before:");
console.log(to, from); console.log(to, from);
} }
store.dispatch("acrou/cancelToken/cancel") store.dispatch("acrou/cancelToken/cancel");
next(); next();
}); });
router.afterEach((to) => { router.afterEach((to) => {
NProgress.done();
if (process.env.NODE_ENV === "development") { if (process.env.NODE_ENV === "development") {
console.log("after:"); console.log("after:");
console.log(to); console.log(to);