引入 vue-i18n,支持简体中文、繁体中文、英文三种语言。 提取所有页面硬编码中文为国际化词条,Header 右上角新增语言切换下拉菜单。 语言偏好存储于 localStorage,首次访问根据 navigator.language 自动检测。 同步切换 Element Plus 组件语言,校验规则改为 computed 保证切换后实时更新。
31 lines
2.0 KiB
TypeScript
31 lines
2.0 KiB
TypeScript
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
|
|
|
|
import Login from '@/views/Login.vue'
|
|
import Home from '@/views/Home.vue'
|
|
import Welcome from '@/views/Welcome.vue'
|
|
|
|
const routes: Array<RouteRecordRaw> = [
|
|
{ path: '/login', name: 'Login', component: Login },
|
|
{ path: '/', name: 'Home', component: Home, children: [
|
|
{ path: '/', name: 'Welcome', component: Welcome },
|
|
{ path: '/system/user', name: 'SystemUser', component: () => import('@/views/system/SystemUser.vue'), meta: { titleKey: 'route.systemUser' } },
|
|
{ path: '/system/role', name: 'SystemRole', component: () => import('@/views/system/SystemRole.vue'), meta: { titleKey: 'route.systemRole' } },
|
|
{ path: '/system/config', name: 'SystemConfig', component: () => import('@/views/system/SystemConfig.vue'), meta: { titleKey: 'route.systemConfig' } },
|
|
{ path: '/system/article', name: 'Article', component: () => import('@/views/system/Article.vue'), meta: { titleKey: 'route.article' } },
|
|
{ path: '/system/statistics', name: 'Statistics', component: () => import('@/views/system/Statistics.vue'), meta: { titleKey: 'route.statistics' } },
|
|
|
|
{ path: '/api/music', name: 'Music', component: () => import('@/views/api/Music.vue'), meta: { titleKey: 'route.music' } },
|
|
{ path: '/api/hitokoto', name: 'Hitokoto', component: () => import('@/views/api/Hitokoto.vue'), meta: { titleKey: 'route.hitokoto' } },
|
|
{ path: '/api/photoWall', name: 'PhotoWall', component: () => import('@/views/api/PhotoWall.vue'), meta: { titleKey: 'route.photoWall' } },
|
|
{ path: '/api/sourceImage', name: 'SourceImage', component: () => import('@/views/api/SourceImage.vue'), meta: { titleKey: 'route.sourceImage' } },
|
|
|
|
{ path: '/debug/captcha', name: 'CaptchaSandbox', component: () => import('@/views/debug/CaptchaSandbox.vue'), meta: { titleKey: 'route.captcha' } },
|
|
]}
|
|
]
|
|
|
|
export const router = createRouter({
|
|
history: createWebHashHistory(),
|
|
routes
|
|
})
|
|
|
|
export const filterExclude = ['/login'] |