add loading progress

pull/217/head
Hao Wu 2019-10-14 23:36:21 +08:00
parent 838a03086e
commit 38ae98a8a9
2 changed files with 28 additions and 15 deletions

View File

@ -1,12 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
<link rel="stylesheet" href="//at.alicdn.com/t/font_830376_qzecyukz0s.css">
<title>vue-manage-system</title>
<link href="https://unpkg.com/nprogress@0.2.0/nprogress.css" rel="stylesheet" />
<script src="https://unpkg.com/nprogress@0.2.0/nprogress.js"></script>
</head>
<body>
<noscript>
<strong>We're sorry but vms doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
@ -14,4 +18,5 @@
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

View File

@ -22,8 +22,11 @@ const i18n = new VueI18n({
//使用钩子函数对路由进行权限跳转
router.beforeEach((to, from, next) => {
NProgress.start()
document.title = `${to.meta.title} | vue-manage-system`;
const role = localStorage.getItem('ms_username');
if (!role && to.path !== '/login') {
next('/login');
} else if (to.meta.permission) {
@ -41,6 +44,11 @@ router.beforeEach((to, from, next) => {
}
});
router.afterEach((_to, _from) => {
// Complete the animation of the route progress bar.
NProgress.done()
})
new Vue({
router,
i18n,