From 467075a2ee6b2d7b183bd8b0046f2a62bebaeba3 Mon Sep 17 00:00:00 2001 From: shizhongming Date: Mon, 26 Feb 2024 20:33:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E6=A8=A1=E5=9D=97-?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96):=20=E4=BC=98=E5=8C=96=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E5=88=86=E7=BB=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/sys/sysI18nApi.ts | 39 ++++ .../system/views/i18n/I18nMainView.vue | 26 +-- .../views/i18n/components/I18nGroupList.vue | 167 ++++++++++++------ .../system/views/i18n/components/i18n.api.ts | 6 +- .../views/i18n/components/i18n.config.ts | 4 + .../system/views/i18n/components/i18nList.vue | 8 +- 6 files changed, 170 insertions(+), 80 deletions(-) create mode 100644 src/api/sys/sysI18nApi.ts diff --git a/src/api/sys/sysI18nApi.ts b/src/api/sys/sysI18nApi.ts new file mode 100644 index 000000000..2fd57451e --- /dev/null +++ b/src/api/sys/sysI18nApi.ts @@ -0,0 +1,39 @@ +import { ApiServiceEnum, defHttp } from '@/utils/http/axios'; +import { isNull } from '@/utils/is'; + +enum Api { + listFront = 'sys/i18n/listFront', +} + +export const listFrontApi = async (locale: string) => { + const i18nData: Recordable = await defHttp.post({ + service: ApiServiceEnum.SMART_SYSTEM, + url: Api.listFront, + data: { + value: locale, + }, + }); + const result: Recordable = {}; + if (isNull(i18nData)) { + return result; + } + Object.keys(i18nData).forEach((key) => { + const value = i18nData[key]; + convertObject(result, key.split('.'), value); + }); + return result; +}; + +const convertObject = (data: any, keyList: string[], value: string) => { + if (keyList.length > 0) { + if (keyList.length === 1) { + data[keyList[0]] = value; + } else { + const firstKey = keyList[0]; + if (!data[firstKey]) { + data[firstKey] = {}; + } + convertObject(data[firstKey], keyList.slice(1), value); + } + } +}; diff --git a/src/modules/system/views/i18n/I18nMainView.vue b/src/modules/system/views/i18n/I18nMainView.vue index f2b044b03..d8ffed04d 100644 --- a/src/modules/system/views/i18n/I18nMainView.vue +++ b/src/modules/system/views/i18n/I18nMainView.vue @@ -3,10 +3,10 @@ - + - + @@ -17,29 +17,15 @@ -