This commit is contained in:
sc 2021-08-02 17:01:35 +08:00
parent fb3e58ef11
commit 5c3bb39ff0
2 changed files with 25 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import tool from '@/utils/tool';
import systemRouter from './systemRouter';
import {beforeEach, afterEach} from './scrollBehavior';
//系统路由
const routes = systemRouter
@ -29,7 +30,7 @@ var isGetApiRouter = false;
router.beforeEach(async (to, from, next) => {
NProgress.start()
//动态标题
document.title = `${to.meta.title} - ${config.APP_NAME}`
@ -60,10 +61,12 @@ router.beforeEach(async (to, from, next) => {
}
isGetApiRouter = true;
}
beforeEach(to, from)
next();
});
router.afterEach(() => {
router.afterEach((to, from) => {
afterEach(to, from)
NProgress.done()
});

View File

@ -0,0 +1,20 @@
import store from '@/store'
import { nextTick } from 'vue'
export function beforeEach(to, from){
var adminMain = document.querySelector('#adminui-main')
if(!adminMain){return false}
store.commit("updateViewTags", {
fullPath: from.fullPath,
scrollTop: adminMain.scrollTop
})
}
export function afterEach(to){
var adminMain = document.querySelector('#adminui-main')
if(!adminMain){return false}
nextTick(()=>{
var beforeRoute = store.state.viewTags.viewTags.filter(v => v.fullPath == to.fullPath)[0]
adminMain.scrollTop = beforeRoute.scrollTop || 0
})
}