mirror of
https://gitee.com/log4j/pig-ui.git
synced 2024-12-23 05:40:20 +08:00
Merge remote-tracking branch 'origin/lei_dev' into hui_dev
# Conflicts: # src/i18n/index.ts
This commit is contained in:
commit
95c3ac6530
@ -15,12 +15,12 @@ import { info } from '/@/api/admin/i18n'
|
||||
*/
|
||||
|
||||
// element plus 自带国际化
|
||||
import zhcnLocale from 'element-plus/lib/locale/lang/zh-cn';
|
||||
import enLocale from 'element-plus/lib/locale/lang/en';
|
||||
import zhcnLocale from 'element-plus/lib/locale/lang/zh-cn';
|
||||
|
||||
// 定义变量内容
|
||||
const messages = {};
|
||||
const element = { en: enLocale, 'zh-cn': zhcnLocale };
|
||||
const element = { en: enLocale, 'zh-cn': zhcnLocale};
|
||||
const itemize = { en: [] as any[], 'zh-cn': [] as any[] };
|
||||
const modules: Record<string, any> = import.meta.glob('./**/*.ts', { eager: true });
|
||||
const pages: Record<string, any> = import.meta.glob('./../../**/**/**/i18n/*.ts', { eager: true });
|
||||
@ -46,6 +46,7 @@ function mergeArrObj<T>(list: T, key: string) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
// 从后台获取数据
|
||||
info().then((res: any) => {
|
||||
itemize["zh-cn"].push(...res.data['zh-cn'])
|
||||
@ -59,8 +60,23 @@ info().then((res: any) => {
|
||||
...mergeArrObj(itemize, key),
|
||||
};
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
// 远程获取i18n
|
||||
const infoI18n = await info()
|
||||
itemize["zh-cn"].push(...infoI18n.data['zh-cn'])
|
||||
itemize.en.push(...infoI18n.data.en)
|
||||
|
||||
for (const key in itemize) {
|
||||
messages[key] = {
|
||||
name: key,
|
||||
el: element[key].el,
|
||||
...mergeArrObj(itemize, key),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// 读取 pinia 默认语言
|
||||
const stores = useThemeConfig(pinia);
|
||||
const { themeConfig } = storeToRefs(stores);
|
||||
|
@ -119,10 +119,10 @@ const setFilterRoutes = () => {
|
||||
};
|
||||
// 传送当前子级数据到菜单中
|
||||
const setSendChildren = (path: string) => {
|
||||
const currentPathSplit = path.split('/');
|
||||
const parentRoute = searchParent(routesList.value,path) as any
|
||||
let currentData: MittMenu = { children: [] };
|
||||
state.columnsAsideList.map((v: RouteItem, k: number) => {
|
||||
if (v.path === `/${currentPathSplit[1]}`) {
|
||||
if (v.path === parentRoute.path) {
|
||||
v['k'] = k;
|
||||
currentData['item'] = { ...v };
|
||||
currentData['children'] = [{ ...v }];
|
||||
@ -143,16 +143,32 @@ const filterRoutesFun = <T extends RouteItem>(arr: T[]): T[] => {
|
||||
};
|
||||
// tagsView 点击时,根据路由查找下标 columnsAsideList,实现左侧菜单高亮
|
||||
const setColumnsMenuHighlight = (path: string) => {
|
||||
state.routeSplit = path.split('/');
|
||||
state.routeSplit.shift();
|
||||
const routeFirst = `/${state.routeSplit[0]}`;
|
||||
const currentSplitRoute = state.columnsAsideList.find((v: RouteItem) => v.path === routeFirst);
|
||||
const parentRoute = searchParent(routesList.value,path) as any
|
||||
const currentSplitRoute = state.columnsAsideList.find((v: RouteItem) => v.path === parentRoute.path);
|
||||
if (!currentSplitRoute) return false;
|
||||
// 延迟拿值,防止取不到
|
||||
setTimeout(() => {
|
||||
onColumnsAsideDown(currentSplitRoute.k);
|
||||
}, 0);
|
||||
};
|
||||
|
||||
// 使用递归查询对应的父级路由
|
||||
const searchParent = (routesList: any,path: string) => {
|
||||
let route = undefined
|
||||
routesList.forEach(item => {
|
||||
if(item.path === path){
|
||||
route = item;
|
||||
return
|
||||
}
|
||||
if(item.children && searchParent(item.children,path)){
|
||||
route = item
|
||||
return;
|
||||
}
|
||||
})
|
||||
return route
|
||||
}
|
||||
|
||||
|
||||
// 页面加载时
|
||||
onMounted(() => {
|
||||
setFilterRoutes();
|
||||
|
@ -91,10 +91,13 @@ const filterRoutesFun = <T extends RouteItem>(arr: T[]): T[] => {
|
||||
};
|
||||
// 传送当前子级数据到菜单中
|
||||
const setSendClassicChildren = (path: string) => {
|
||||
const currentPathSplit = path.split('/');
|
||||
let currentData: MittMenu = { children: [] };
|
||||
if(!state.defaultActive){
|
||||
const route = searchParent(routesList.value,path as string) as any
|
||||
state.defaultActive = route!.path
|
||||
}
|
||||
filterRoutesFun(routesList.value).map((v, k) => {
|
||||
if (v.path === `/${currentPathSplit[1]}`) {
|
||||
if (v.path === state.defaultActive) {
|
||||
v['k'] = k;
|
||||
currentData['item'] = { ...v };
|
||||
currentData['children'] = [{ ...v }];
|
||||
@ -106,14 +109,38 @@ const setSendClassicChildren = (path: string) => {
|
||||
// 设置页面当前路由高亮
|
||||
const setCurrentRouterHighlight = (currentRoute: RouteToFrom) => {
|
||||
const { path, meta } = currentRoute;
|
||||
const route = searchParent(routesList.value,path as string) as any
|
||||
if (themeConfig.value.layout === 'classic') {
|
||||
state.defaultActive = `/${path?.split('/')[1]}`;
|
||||
if(route){
|
||||
state.defaultActive = route!.path
|
||||
}else{
|
||||
state.defaultActive = `/${path?.split('/')[1]}`;
|
||||
}
|
||||
} else {
|
||||
const pathSplit = meta?.isDynamic ? meta.isDynamicPath!.split('/') : path!.split('/');
|
||||
if (pathSplit.length >= 4 && meta?.isHide) state.defaultActive = pathSplit.splice(0, 3).join('/');
|
||||
else state.defaultActive = path;
|
||||
}
|
||||
};
|
||||
|
||||
// 使用递归查询对应的父级路由
|
||||
const searchParent = (routesList: any,path: string) => {
|
||||
let route = undefined
|
||||
routesList.forEach(item => {
|
||||
if(item.path === path){
|
||||
route = item;
|
||||
return
|
||||
}
|
||||
if(item.children && searchParent(item.children,path)){
|
||||
route = item
|
||||
return;
|
||||
}
|
||||
})
|
||||
return route
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 打开外部链接
|
||||
const onALinkClick = (val: RouteItem) => {
|
||||
other.handleOpenLink(val);
|
||||
|
@ -3,10 +3,10 @@
|
||||
<el-card shadow="hover" class="layout-padding-auto">
|
||||
<el-row v-show="showSearch" class="mb8">
|
||||
<el-form :model="state.queryForm" ref="queryRef" :inline="true">
|
||||
<el-form-item label="类型" prop="dictType">
|
||||
<el-input placeholder="请输入类型" v-model="state.queryForm.dictType" style="max-width: 180px" />
|
||||
<el-form-item :label="$t('sysdict.dictType')" prop="dictType">
|
||||
<el-input :placeholder="$t('sysdict.inputDictTypeTip')" v-model="state.queryForm.dictType" style="max-width: 180px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="字典类型" prop="systemFlag">
|
||||
<el-form-item :label="$t('sysdict.systemFlag')" prop="systemFlag">
|
||||
<el-select v-model="state.queryForm.systemFlag" clearable>
|
||||
<el-option v-for="(item, index) in dict_type" :label="item.label" :value="item.value"
|
||||
:key="index"></el-option>
|
||||
@ -37,25 +37,24 @@
|
||||
@selection-change="handleSelectionChange">
|
||||
<el-table-column align="center" type="selection" :selectable='handleSelectable' width="50">
|
||||
</el-table-column>
|
||||
<el-table-column type="index" label="序号" width="50" />
|
||||
<el-table-column label="类型" show-overflow-tooltip>
|
||||
<el-table-column type="index" :label="$t('sysdict.index')" width="80" />
|
||||
<el-table-column :label="$t('sysdict.dictType')" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<el-button text type="primary" @click="showDictITem(scope.row)">{{ scope.row.dictType }}</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="description" label="描述" show-overflow-tooltip sortable></el-table-column>
|
||||
<el-table-column prop="systemFlag" label="字典类型" show-overflow-tooltip>
|
||||
<el-table-column prop="description" :label="$t('sysdict.description')" show-overflow-tooltip sortable></el-table-column>
|
||||
<el-table-column prop="systemFlag" :label="$t('sysdict.systemFlag')" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<dict-tag :options="dict_type" :value="scope.row.systemFlag"></dict-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remarks" label="备注信息" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column prop="createTime" label="创建时间" show-overflow-tooltip sortable></el-table-column>
|
||||
|
||||
<el-table-column label="操作" width="200">
|
||||
<el-table-column prop="remarks" :label="$t('sysdict.remarks')" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column prop="createTime" :label="$t('sysdict.createTime')" show-overflow-tooltip sortable></el-table-column>
|
||||
<el-table-column :label="$t('common.action')" width="200">
|
||||
<template #default="scope">
|
||||
<el-button text type="primary" @click="showDictITem(scope.row)">字典项</el-button>
|
||||
<el-button text type="primary" @click="onOpenEditDic('edit', scope.row)">修改</el-button>
|
||||
<el-button text type="primary" @click="showDictITem(scope.row)">{{ $t('sysdict.dictItem') }}</el-button>
|
||||
<el-button text type="primary" @click="onOpenEditDic('edit', scope.row)">{{ $t('common.editBtn') }}</el-button>
|
||||
<el-tooltip :content="$t('sysdict.deleteDisabledTip')" :disabled="scope.row.systemFlag === 1"
|
||||
placement="top">
|
||||
<span style="margin-left: 12px">
|
||||
|
Loading…
Reference in New Issue
Block a user