feat: 网页title根据路由动态变化
This commit is contained in:
@@ -16,7 +16,6 @@ import 'element-plus/dist/index.css'
|
||||
import pinia from './store'
|
||||
|
||||
const app = createApp(App)
|
||||
console.log(app)
|
||||
//安装仓库
|
||||
app.use(pinia)
|
||||
app.use(router)
|
||||
|
||||
@@ -14,4 +14,11 @@ const router = createRouter({
|
||||
}
|
||||
},
|
||||
})
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.meta.title && to.meta.title != '') {
|
||||
let oldTitle = document.title
|
||||
document.title = <string>to.meta.title + ' - ' + oldTitle
|
||||
}
|
||||
next()
|
||||
})
|
||||
export default router
|
||||
|
||||
+43
-10
@@ -2,58 +2,91 @@
|
||||
export const constantRoute = [
|
||||
{
|
||||
path: '/',
|
||||
name: 'home',
|
||||
component: () => import('@/components/Home/Home.vue'),
|
||||
name: 'home',
|
||||
meta: {
|
||||
title: ""
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/timetran',
|
||||
component: () => import('@/components/TimeTran/TimeTran.vue'),
|
||||
name: 'timetran'
|
||||
name: 'timetran',
|
||||
meta: {
|
||||
title: "时间戳转换"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/MD5',
|
||||
component: () => import('@/components/MD5/MD5.vue'),
|
||||
name: 'MD5'
|
||||
name: 'MD5',
|
||||
meta: {
|
||||
title: "MD5在线加密"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/json',
|
||||
component: () => import('@/components/JsonTran/JsonTran.vue'),
|
||||
name: 'json'
|
||||
name: 'json',
|
||||
meta: {
|
||||
title: "Json在线转换"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/reg',
|
||||
component: () => import('@/components/RegTest/RegTest.vue'),
|
||||
name: 'reg'
|
||||
name: 'reg',
|
||||
meta: {
|
||||
title: "正则表达式测试"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/unicode',
|
||||
component: () => import('@/components/Unicode/Unicode.vue'),
|
||||
name: 'unicode'
|
||||
name: 'unicode',
|
||||
meta: {
|
||||
title: "Unicode转中文"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/wordcount',
|
||||
component: () => import('@/components/WordCount/WordCount.vue'),
|
||||
name: 'wordcount'
|
||||
name: 'wordcount',
|
||||
meta: {
|
||||
title: "在线字数统计"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/ip',
|
||||
component: () => import('@/components/Ip/Ip.vue'),
|
||||
name: 'ip'
|
||||
name: 'ip',
|
||||
meta: {
|
||||
title: "IP查询"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/scaletran',
|
||||
component: () => import('@/components/ScaleTran/ScaleTran.vue'),
|
||||
name: 'scaletran'
|
||||
name: 'scaletran',
|
||||
meta: {
|
||||
title: "常用进制转换"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/signimage',
|
||||
component: () => import('@/components/SignImage/SignImage.vue'),
|
||||
name: 'signimage'
|
||||
name: 'signimage',
|
||||
meta: {
|
||||
title: "在线编辑图片"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/404',
|
||||
component: () => import('@/components/404/404.vue'),
|
||||
name: '404',
|
||||
meta: {
|
||||
title: "404"
|
||||
}
|
||||
},
|
||||
{
|
||||
//重定向
|
||||
|
||||
Reference in New Issue
Block a user