mirror of https://github.com/halo-dev/halo
Support page title change.
parent
ecf582bf77
commit
1552fbd950
|
@ -1,6 +1,7 @@
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
import store from './store'
|
import store from './store'
|
||||||
|
import { setDocumentTitle, domTitle } from '@/utils/domUtil'
|
||||||
|
|
||||||
import NProgress from 'nprogress' // progress bar
|
import NProgress from 'nprogress' // progress bar
|
||||||
import 'nprogress/nprogress.css' // progress bar style
|
import 'nprogress/nprogress.css' // progress bar style
|
||||||
|
@ -11,6 +12,7 @@ const whiteList = ['Login', 'Install', 'NotFound'] // no redirect whitelist
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
NProgress.start()
|
NProgress.start()
|
||||||
|
to.meta && (typeof to.meta.title !== 'undefined' && setDocumentTitle(`${to.meta.title} - ${domTitle}`))
|
||||||
Vue.$log.debug('Token', store.getters.token)
|
Vue.$log.debug('Token', store.getters.token)
|
||||||
if (store.getters.token) {
|
if (store.getters.token) {
|
||||||
if (to.name === 'Login') {
|
if (to.name === 'Login') {
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
export const setDocumentTitle = function(title) {
|
||||||
|
document.title = title
|
||||||
|
const ua = navigator.userAgent
|
||||||
|
// eslint-disable-next-line
|
||||||
|
const regex = /\bMicroMessenger\/([\d\.]+)/
|
||||||
|
if (regex.test(ua) && /ip(hone|od|ad)/i.test(ua)) {
|
||||||
|
const i = document.createElement('iframe')
|
||||||
|
i.src = '/favicon.ico'
|
||||||
|
i.style.display = 'none'
|
||||||
|
i.onload = function() {
|
||||||
|
setTimeout(function() {
|
||||||
|
i.remove()
|
||||||
|
}, 9)
|
||||||
|
}
|
||||||
|
document.body.appendChild(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const domTitle = 'Halo Dashboard'
|
Loading…
Reference in New Issue