From 2fe2e67a80a757a18a9ef9d5ea51907c837cf08e Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Tue, 24 Dec 2024 14:44:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E5=AE=9A=E4=B9=89=E5=A4=96?= =?UTF-8?q?=E9=83=A8=E5=9B=BD=E9=99=85=E5=8C=96=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/config/DeMvcConfig.java | 4 +++ .../system/server/SysParameterServer.java | 31 +++++++++++++++--- .../core-frontend/src/config/axios/service.ts | 5 ++- .../src/layout/components/AccountOperator.vue | 2 +- .../src/layout/components/LangSelector.vue | 20 ++++++++---- .../src/plugins/vue-i18n/index.ts | 32 +++++++++++++++---- .../core-frontend/src/store/modules/locale.ts | 27 ++++++++++++++-- core/core-frontend/src/store/modules/user.ts | 3 +- .../dataease/api/system/SysParameterApi.java | 3 ++ .../constant/StaticResourceConstants.java | 2 ++ .../io/dataease/utils/WhitelistUtils.java | 2 ++ 11 files changed, 107 insertions(+), 24 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/config/DeMvcConfig.java b/core/core-backend/src/main/java/io/dataease/config/DeMvcConfig.java index 3a06641dd3..7893027bf1 100644 --- a/core/core-backend/src/main/java/io/dataease/config/DeMvcConfig.java +++ b/core/core-backend/src/main/java/io/dataease/config/DeMvcConfig.java @@ -37,6 +37,10 @@ public class DeMvcConfig implements WebMvcConfigurer { String geoUrlPattern = ensureBoth(GEO_URL, AuthConstant.DE_API_PREFIX, URL_SEPARATOR) + "**"; registry.addResourceHandler(geoUrlPattern).addResourceLocations(geoDir); + String i18nDir = FILE_PROTOCOL + ensureSuffix(I18N_DIR, FILE_SEPARATOR); + String i18nUrlPattern = ensureBoth(I18N_URL, AuthConstant.DE_API_PREFIX, URL_SEPARATOR) + "**"; + registry.addResourceHandler(i18nUrlPattern).addResourceLocations(i18nDir); + } @Override diff --git a/core/core-backend/src/main/java/io/dataease/system/server/SysParameterServer.java b/core/core-backend/src/main/java/io/dataease/system/server/SysParameterServer.java index c914ff7946..b3822500b6 100644 --- a/core/core-backend/src/main/java/io/dataease/system/server/SysParameterServer.java +++ b/core/core-backend/src/main/java/io/dataease/system/server/SysParameterServer.java @@ -4,14 +4,17 @@ import io.dataease.api.system.SysParameterApi; import io.dataease.api.system.request.OnlineMapEditor; import io.dataease.api.system.vo.SettingItemVO; import io.dataease.api.system.vo.ShareBaseVO; +import io.dataease.constant.StaticResourceConstants; import io.dataease.constant.XpackSettingConstants; import io.dataease.system.dao.auto.entity.CoreSysSetting; import io.dataease.system.manage.SysParameterManage; import jakarta.annotation.Resource; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.io.File; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -52,10 +55,9 @@ public class SysParameterServer implements SysParameterApi { @Override public Integer RequestTimeOut() { - Integer frontTimeOut = 60; + int frontTimeOut = 60; List settingItemVOS = queryBasicSetting(); - for (int i = 0; i < settingItemVOS.size(); i++) { - SettingItemVO settingItemVO = settingItemVOS.get(i); + for (SettingItemVO settingItemVO : settingItemVOS) { if (StringUtils.isNotBlank(settingItemVO.getPkey()) && settingItemVO.getPkey().equalsIgnoreCase(XpackSettingConstants.Front_Time_Out) && StringUtils.isNotBlank(settingItemVO.getPval())) { frontTimeOut = Integer.parseInt(settingItemVO.getPval()); } @@ -69,8 +71,7 @@ public class SysParameterServer implements SysParameterApi { map.put(XpackSettingConstants.DEFAULT_SORT, "1"); List settingItemVOS = queryBasicSetting(); - for (int i = 0; i < settingItemVOS.size(); i++) { - SettingItemVO settingItemVO = settingItemVOS.get(i); + for (SettingItemVO settingItemVO : settingItemVOS) { if (StringUtils.isNotBlank(settingItemVO.getPkey()) && settingItemVO.getPkey().equalsIgnoreCase(XpackSettingConstants.DEFAULT_SORT) && StringUtils.isNotBlank(settingItemVO.getPval())) { map.put(XpackSettingConstants.DEFAULT_SORT, settingItemVO.getPval()); } @@ -95,4 +96,24 @@ public class SysParameterServer implements SysParameterApi { public ShareBaseVO shareBase() { return sysParameterManage.shareBase(); } + + @Override + public Map i18nOptions() { + File dir = new File(StaticResourceConstants.I18N_DIR); + File[] files = null; + if (!dir.exists() || ObjectUtils.isEmpty(files = dir.listFiles())) { + return null; + } + Map result = new HashMap<>(); + for (File file : files) { + String name = file.getName(); + int start = name.indexOf("custom_") + 7; + int end = name.indexOf("front"); + String i18nName = name.substring(start, end - 1).replace("_", "-"); + String languageName = name.substring(end + 6, name.lastIndexOf(".")); + result.put(i18nName, languageName); + } + return result; + } + } diff --git a/core/core-frontend/src/config/axios/service.ts b/core/core-frontend/src/config/axios/service.ts index 7c60e8125a..984f451bde 100644 --- a/core/core-frontend/src/config/axios/service.ts +++ b/core/core-frontend/src/config/axios/service.ts @@ -171,7 +171,10 @@ service.interceptors.response.use( } else if (response.config.url.match(/^\/map|geo\/\d{3}\/\d+\.json$/)) { // TODO 处理静态文件 return response - } else if (response.config.url.includes('DEXPack.umd.js')) { + } else if ( + response.config.url.includes('DEXPack.umd.js') || + response.config.url.includes('/i18n/custom_') + ) { return response } else if (response.config.url.startsWith('/xpackComponent/pluginStaticInfo/extensions-')) { return response diff --git a/core/core-frontend/src/layout/components/AccountOperator.vue b/core/core-frontend/src/layout/components/AccountOperator.vue index 55f32300a5..1a05c63de3 100644 --- a/core/core-frontend/src/layout/components/AccountOperator.vue +++ b/core/core-frontend/src/layout/components/AccountOperator.vue @@ -279,7 +279,7 @@ if (uid.value === '1') { padding-bottom: 0 !important; } .language-popover { - max-height: 112px; + // max-height: 112px; .ed-popper__arrow { display: none; } diff --git a/core/core-frontend/src/layout/components/LangSelector.vue b/core/core-frontend/src/layout/components/LangSelector.vue index d6cd6804b2..cf90896b1f 100644 --- a/core/core-frontend/src/layout/components/LangSelector.vue +++ b/core/core-frontend/src/layout/components/LangSelector.vue @@ -1,12 +1,15 @@