lina/src/guards.js
fit2bot 114704f668
perf: 优化主题配色 (#1859)
* perf: 优化主题配色

* perf: 修改主题

* perf: 修改更新 theme

* perf: 修改主题

* perf: 修改 avart

* perf: css

* perf: css

Co-authored-by: ibuler <ibuler@qq.com>
2022-07-05 14:31:50 +08:00

48 lines
1.2 KiB
JavaScript

/* eslint-disable no-unused-vars */
import router from './router'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
import { startup } from '@/utils/startup'
import store from '@/store'
import { isSameView } from '@/utils/jms'
NProgress.configure({
showSpinner: false
}) // NProgress Configuration
router.beforeEach(async(to, from, next) => {
// start progress bar
NProgress.start()
try {
await startup({ to, from, next })
next()
} catch (e) {
const msg = 'Start service error: ' + e
// debug(e)
}
})
function generateViewRoutesIfChange({ to, from }) {
const sameView = isSameView(to, from)
if (!sameView) {
return store.dispatch('permission/generateViewRoutes', { to: to, from: from })
}
}
function setPageTitle() {
const currentRoute = router.currentRoute
const loginTitle = store.getters.publicSettings['INTERFACE']['login_title']
const routeTitle = currentRoute.meta.title
if (routeTitle) {
document.title = routeTitle + ' - ' + loginTitle
}
}
router.afterEach(async(to, from) => {
// finish progress bar
await setPageTitle()
await generateViewRoutesIfChange({ to, from })
NProgress.done()
})