Browse Source

feat:[双语] 菜单不从语言配置,还是设置成中文,从对象返回

luojie
memorylkf 3 weeks ago
parent
commit
7a5dda02aa
7 changed files with 52 additions and 8 deletions
  1. +2
    -2
      src/components/Breadcrumb/index.vue
  2. +1
    -1
      src/lang/en.js
  3. +0
    -2
      src/lang/zh.js
  4. +2
    -2
      src/layout/components/Sidebar/SidebarItem.vue
  5. +1
    -1
      src/layout/components/TagsView/index.vue
  6. +2
    -0
      src/main.js
  7. +44
    -0
      src/utils/menu.js

+ 2
- 2
src/components/Breadcrumb/index.vue View File

@ -2,8 +2,8 @@
<el-breadcrumb class="app-breadcrumb" separator="/"> <el-breadcrumb class="app-breadcrumb" separator="/">
<transition-group name="breadcrumb"> <transition-group name="breadcrumb">
<el-breadcrumb-item v-for="(item, index) in levelList" :key="item.path"> <el-breadcrumb-item v-for="(item, index) in levelList" :key="item.path">
<span v-if="item.redirect === 'noRedirect' || index == levelList.length - 1" class="no-redirect">{{ $t('menu.'+item.meta.title) }}</span>
<a v-else @click.prevent="handleLink(item)">{{ $t('menu.'+item.meta.title) }}</a>
<span v-if="item.redirect === 'noRedirect' || index == levelList.length - 1" class="no-redirect">{{ getMenuName(item.meta.title) }}</span>
<a v-else @click.prevent="handleLink(item)">{{ getMenuName(item.meta.title) }}</a>
</el-breadcrumb-item> </el-breadcrumb-item>
</transition-group> </transition-group>
</el-breadcrumb> </el-breadcrumb>

+ 1
- 1
src/lang/en.js View File

@ -85,7 +85,7 @@ export default {
name: 'name', name: 'name',
namePlaceholder: 'namePlaceholder', namePlaceholder: 'namePlaceholder',
status: 'status', status: 'status',
statusAll: 'statusAll',
statusAll: 'All',
statusVisible: 'visible', statusVisible: 'visible',
statusHide: 'hide', statusHide: 'hide',

+ 0
- 2
src/lang/zh.js View File

@ -107,8 +107,6 @@ export default {
addMenu: '添加菜单', addMenu: '添加菜单',
modifyMenu: '修改菜单', modifyMenu: '修改菜单',
addMent: '添加菜单',
addMent: '添加菜单',
root: '主类目', root: '主类目',

+ 2
- 2
src/layout/components/Sidebar/SidebarItem.vue View File

@ -3,14 +3,14 @@
<template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow"> <template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow">
<app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path, onlyOneChild.query)"> <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path, onlyOneChild.query)">
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}"> <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">
<item :icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)" :title="$t('menu.'+onlyOneChild.meta.title)" />
<item :icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)" :title="getMenuName(onlyOneChild.meta.title)" />
</el-menu-item> </el-menu-item>
</app-link> </app-link>
</template> </template>
<el-submenu v-else ref="subMenu" :index="resolvePath(item.path)" popper-append-to-body> <el-submenu v-else ref="subMenu" :index="resolvePath(item.path)" popper-append-to-body>
<template slot="title"> <template slot="title">
<item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="$t('menu.'+item.meta.title)" />
<item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="getMenuName(item.meta.title)" />
</template> </template>
<sidebar-item <sidebar-item
v-for="(child, index) in item.children" v-for="(child, index) in item.children"

+ 1
- 1
src/layout/components/TagsView/index.vue View File

@ -15,7 +15,7 @@
@contextmenu.prevent.native="openMenu(tag,$event)" @contextmenu.prevent.native="openMenu(tag,$event)"
> >
<svg-icon v-if="tagsIcon && tag.meta && tag.meta.icon && tag.meta.icon !== '#'" :icon-class="tag.meta.icon" /> <svg-icon v-if="tagsIcon && tag.meta && tag.meta.icon && tag.meta.icon !== '#'" :icon-class="tag.meta.icon" />
{{ $t('menu.'+tag.title) }}
{{ getMenuName(tag.title) }}
<span v-if="!isAffix(tag)" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)" /> <span v-if="!isAffix(tag)" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)" />
</router-link> </router-link>
</scroll-pane> </scroll-pane>

+ 2
- 0
src/main.js View File

@ -26,6 +26,7 @@ import {
selectDictLabels, selectDictLabels,
handleTree handleTree
} from '@/utils/ruoyi' } from '@/utils/ruoyi'
import { getMenuName } from '@/utils/menu'
// 分页组件 // 分页组件
import Pagination from '@/components/Pagination' import Pagination from '@/components/Pagination'
// 自定义表格工具组件 // 自定义表格工具组件
@ -53,6 +54,7 @@ Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download Vue.prototype.download = download
Vue.prototype.handleTree = handleTree Vue.prototype.handleTree = handleTree
Vue.prototype.getMenuName = getMenuName
// 全局组件挂载 // 全局组件挂载
Vue.component('DictTag', DictTag) Vue.component('DictTag', DictTag)

+ 44
- 0
src/utils/menu.js View File

@ -0,0 +1,44 @@
// 菜单语言适配
let menuObj = {
个人中心: 'PersonalCenter',
工作台: 'Workbench',
试验管理: 'TrialManage',
表单管理: 'FormManage',
非试验表单: 'NonTrialForm',
麻精药表单: 'DrugForm',
资源库管理: 'ResourceManage',
试剂管理: 'ReagentManage',
供试品管理: 'SpecimenManage',
给药制剂管理: 'DosageManage',
麻精药管理: 'DrugManage',
钥匙管理: 'KeyManage',
仪器管理: 'InstrumentManage',
档案管理: 'ArchiveManage',
试验档案管理: 'TrialArchiveManage',
非试验档案管理: 'NonTrialArchiveManage',
麻精药配置档案管理: 'DrugConfigArchiveManage',
供试品档案管理: 'SpecimenArchiveManage',
给药制剂档案管理: 'DosageArchiveManage',
麻精药档案管理: 'DrugArchiveManage',
试剂档案管理: 'ReagentArchiveManage',
档案记录: 'ArchiveRecord',
系统管理: 'SystemManage',
菜单管理: 'MenuManage',
角色管理: 'RoleManage',
用户管理: 'UserManage',
'部门/学科管理': 'DeptManage',
模板管理: 'TemplateManage',
字典管理: 'DictManage',
日志管理: 'LogManage'
}
export function getMenuName(menuName) {
if (!this.$i18n.locale || this.$i18n.locale === 'zh_CN') {
return menuName
}
return menuObj[menuName]
}

Loading…
Cancel
Save