From eda64c8483efd7263280c128d62b156a1469c9fc Mon Sep 17 00:00:00 2001 From: Aicirou <2643053021@qq.com> Date: Sun, 5 Jul 2020 01:12:24 +0800 Subject: [PATCH] :sparkles:Add NProgress --- package-lock.json | 7 ++++++- package.json | 1 + src/router/index.js | 8 ++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 94d2138..e8e67f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2288,7 +2288,7 @@ }, "@babel/types": { "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=", "dev": true, "requires": { @@ -8601,6 +8601,11 @@ "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": { "version": "1.0.2", "resolved": "http://registry.npm.taobao.org/nth-check/download/nth-check-1.0.2.tgz", diff --git a/package.json b/package.json index 30f176e..73b4f47 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "lowdb": "^1.0.0", "marked": "^1.1.0", "node-sass": "^4.14.0", + "nprogress": "^0.2.0", "plyr": "^3.6.2", "sass-loader": "^8.0.2", "v-viewer": "^1.5.1", diff --git a/src/router/index.js b/src/router/index.js index 80c9c3c..15a4e2f 100755 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,9 +1,11 @@ import Vue from "vue"; import febAlive from "feb-alive"; import VueRouter from "vue-router"; +import NProgress from "nprogress"; +import "nprogress/nprogress.css"; // 路由数据 import routes from "./routes"; -import store from '@/store/index'; +import store from "@/store/index"; // 在router实例化之前重写history febAlive.resetHistory(); @@ -43,15 +45,17 @@ Vue.use(febAlive, { router }); * 权限验证 */ router.beforeEach(async (to, from, next) => { + NProgress.start(); if (process.env.NODE_ENV === "development") { console.log("before:"); console.log(to, from); } - store.dispatch("acrou/cancelToken/cancel") + store.dispatch("acrou/cancelToken/cancel"); next(); }); router.afterEach((to) => { + NProgress.done(); if (process.env.NODE_ENV === "development") { console.log("after:"); console.log(to);