Skip to content

Commit

Permalink
feat: 全局语言包改完文件夹形式设置
Browse files Browse the repository at this point in the history
  • Loading branch information
yuntian001 committed Aug 19, 2022
1 parent e35fa8b commit 33202c9
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<el-breadcrumb-item
v-for="(item, index) in breadcrumbList"
:key="index"
:to="index === breadcrumbList.length - 1 ? undefined : item"
:to="index === breadcrumbList.length - 1 || !item.redirect ? undefined : item"
>{{ $t(item.meta!.title!) }}</el-breadcrumb-item
>
</el-breadcrumb>
Expand Down
4 changes: 3 additions & 1 deletion src/layout/components/menu/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ const menuTextColor = computed(() => mixColor(themeConfig.menuBg, menuActiveColo
color: var(--el-menu-active-color);
}
}
.el-sub-menu__title {
padding-right: 28px;
}
.el-sub-menu__title:hover,
.el-menu-item:hover {
background-color: rgba(var(--el-color-primary-rgb), 0.3);
Expand Down
2 changes: 1 addition & 1 deletion src/locales/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const setI18nLanguage = async (locale: string, isLoading = true, i18n?: G
if (i18n === useGlobalStore().i18n) {
useSettingStore().locale = locale;
const messageArr = [
setLocaleMessage(i18n, locale, [async (locale) => await import(`./lang/${locale}.json`)]),
setLocaleMessage(i18n, locale, [async (locale) => await import(`./lang/${locale}/index.ts`)]),
loadMessage<{ default: Language }>(
[
async (locale) => await import(`../../node_modules/element-plus/es/locale/lang/${locale}.mjs`),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"通知": "Notice",
"消息": "Message Box",
"待办": "Backlog",
"首页": "Index",
"文档": "Document",
"清除缓存": "Clear Cache",
"并": "And",
Expand Down
7 changes: 7 additions & 0 deletions src/locales/lang/en/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { forOwn } from 'lodash-es';
const modules = import.meta.glob('./*.json', { eager: true, import: 'default' });
const langs = {} as Record<string, string>;
forOwn(modules, (value) => {
Object.assign(langs, value);
});
export default langs;
13 changes: 13 additions & 0 deletions src/locales/lang/en/menu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"首页": "Index",
"示例": "Example",
"权限": "Permission",
"组件语言包": "Component Language Pack",
"请求示例": "Request Example",
"页面权限": "Page Permission",
"多级菜单": "Multilevel Menu",
"多级菜单1": "Multilevel Menu 1",
"多级菜单1-1": "Multilevel Menu 1-1",
"多级菜单1-1-1": "Multilevel Menu 1-1-1",
"多级菜单1-2": "Multilevel Menu 1-2"
}
File renamed without changes.
7 changes: 7 additions & 0 deletions src/locales/lang/zh-cn/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { forOwn } from 'lodash-es';
const modules = import.meta.glob('./*.json', { eager: true, import: 'default' });
const langs = {} as Record<string, string>;
forOwn(modules, (value) => {
Object.assign(langs, value);
});
export default langs;
8 changes: 8 additions & 0 deletions src/router/routes/example/5-pagePermission.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { RouteRecordRaw } from 'vue-router';
export const routes: RouteRecordRaw[] = [
{
path: 'pagePermission',
component: async () => await import('@/views/example/pagePermission.vue'),
meta: { title: '页面权限', rule: ['edit'] },
},
];
File renamed without changes.
1 change: 1 addition & 0 deletions src/views/example/pagePermission.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<template>当前页面 admin/editor可见</template>
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default ({ command, mode }: ConfigEnv): UserConfigExport => {
VueI18nPlugin({
/* options */
// locale messages resource pre-compile option
include: './src/**/lang/**.json',
include: ['./src/**/lang/**/*.json', './src/**/lang/*.json'],
}),
viteMockServe({
mockPath: 'mock/apiDemo',
Expand Down

0 comments on commit 33202c9

Please sign in to comment.