1、布局大小存储改为本地存储2、多语言默认语言改为配置文件

This commit is contained in:
不做码农 2023-05-23 11:44:38 +08:00
parent 1de85b2521
commit ad054f6699
3 changed files with 44 additions and 35 deletions

View File

@ -28,10 +28,11 @@ export const constantRoutes = [
component: Layout,
hidden: true,
children: [
{
path: '/redirect/:path(.*)',
component: () => import('@/views/redirect/index.vue')
}]
{
path: '/redirect/:path(.*)',
component: () => import('@/views/redirect/index.vue')
}
]
},
{
path: '/login',
@ -49,7 +50,7 @@ export const constantRoutes = [
hidden: true
},
{
path: "/:pathMatch(.*)*",
path: '/:pathMatch(.*)*',
component: () => import('@/views/error/404'),
hidden: true
},
@ -63,12 +64,13 @@ export const constantRoutes = [
component: Layout,
redirect: '/index',
children: [
{
path: '/index',
component: () => import('@/views/index'),
name: 'Index',
meta: { title: '首页', icon: 'dashboard', affix: true, titleKey: 'menu.home' }
}]
{
path: '/index',
component: () => import('@/views/index'),
name: 'Index',
meta: { title: '首页', icon: 'dashboard', affix: true, titleKey: 'menu.home' }
}
]
},
{
path: '/user',
@ -76,12 +78,13 @@ export const constantRoutes = [
hidden: true,
redirect: 'noredirect',
children: [
{
path: 'profile',
component: () => import('@/views/system/user/profile/index'),
name: 'Profile',
meta: { title: '个人中心', icon: 'user', titleKey: 'menu.personalCenter' }
}]
{
path: 'profile',
component: () => import('@/views/system/user/profile/index'),
name: 'Profile',
meta: { title: '个人中心', icon: 'user', titleKey: 'menu.personalCenter' }
}
]
},
// 不用可删掉
{
@ -90,18 +93,19 @@ export const constantRoutes = [
hidden: false,
meta: { title: '组件示例', icon: 'icon', noCache: 'fasle' },
children: [
{
path: 'icon',
component: () => import('@/views/components/icons/index'),
name: 'icon',
meta: { title: '图标icon', icon: 'icon1', noCache: 'fasle', titleKey: 'menu.icon' }
}]
},
];
{
path: 'icon',
// component: () => import('@/views/components/icons/index'),
component: () => import('@/views/business/GenDemo'),
name: 'icon',
meta: { title: '图标icon', icon: 'icon1', noCache: 'fasle', titleKey: 'menu.icon' }
}
]
}
]
const router = createRouter({
history: createWebHistory(
import.meta.env.VITE_APP_ROUTER_PREFIX),
history: createWebHistory(import.meta.env.VITE_APP_ROUTER_PREFIX),
routes: constantRoutes,
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
@ -109,7 +113,7 @@ const router = createRouter({
} else {
return { top: 0 }
}
},
});
}
})
export default router;
export default router

View File

@ -75,5 +75,9 @@ export default {
/**
* 默认大小
*/
defaultSize: 'default'
defaultSize: 'default',
/**
* 默认语言
*/
defaultLang: 'zh-cn'
}

View File

@ -1,4 +1,5 @@
import Cookies from 'js-cookie'
import cache from '@/plugins/cache'
import defaultSettings from '@/settings'
const useAppStore = defineStore('app', {
state: () => ({
@ -8,8 +9,8 @@ const useAppStore = defineStore('app', {
hide: false
},
device: 'desktop',
size: Cookies.get('size') || defaultSettings.defaultSize,
lang: Cookies.get('lang') || 'zh-cn'
size: cache.local.get('size') || defaultSettings.defaultSize,
lang: cache.cookie.get('lang') || defaultSettings.defaultLang
}),
actions: {
toggleSideBar() {
@ -32,14 +33,14 @@ const useAppStore = defineStore('app', {
},
setSize(size) {
this.size = size
Cookies.set('size', size)
cache.local.set('size', size)
},
toggleSideBarHide(status) {
this.sidebar.hide = status
},
setLang(lang) {
this.lang = lang
Cookies.set('lang', lang)
cache.cookie.set('lang', lang)
}
}
})