From a7c7f0b5da14a2ce8e6cec42a5dbf8bac091f8a8 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Thu, 11 Jan 2024 17:01:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=80=90=E7=B3=BB=E7=BB=9F=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E3=80=91=E6=94=AF=E6=8C=81=E7=B3=BB=E7=BB=9F=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E8=AE=BE=E7=BD=AE-=E5=89=8D=E7=AB=AF=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E6=97=B6=E9=97=B4=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/server/SysParameterServer.java | 16 +++++++++ .../main/resources/db/desktop/V2.3__ddl.sql | 2 ++ .../main/resources/db/migration/V2.3__ddl.sql | 2 ++ .../core-frontend/src/config/axios/service.ts | 36 ++++++++++++++++++- core/core-frontend/src/locales/zh-CN.ts | 3 +- .../system/parameter/basic/BasicEdit.vue | 17 +++++++-- .../system/parameter/basic/BasicInfo.vue | 3 +- .../dataease/api/system/SysParameterApi.java | 4 +++ .../constant/XpackSettingConstants.java | 1 + .../io/dataease/utils/WhitelistUtils.java | 1 + 10 files changed, 80 insertions(+), 5 deletions(-) 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 eb33745da1..f1a2cd8450 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 @@ -3,10 +3,12 @@ package io.dataease.system.server; import io.dataease.api.system.SysParameterApi; import io.dataease.api.system.request.OnlineMapEditor; import io.dataease.api.system.vo.SettingItemVO; +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.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -18,6 +20,7 @@ public class SysParameterServer implements SysParameterApi { @Resource private SysParameterManage sysParameterManage; + @Override public String singleVal(String key) { return sysParameterManage.singleVal(key); @@ -45,4 +48,17 @@ public class SysParameterServer implements SysParameterApi { public void saveBasicSetting(List settingItemVOS) { sysParameterManage.saveBasic(settingItemVOS); } + + @Override + public Integer RequestTimeOut() { + Integer frontTimeOut = 60; + List settingItemVOS = queryBasicSetting(); + for (int i = 0; i < settingItemVOS.size(); i++) { + SettingItemVO settingItemVO = settingItemVOS.get(i); + if (StringUtils.isNotBlank(settingItemVO.getPkey()) && settingItemVO.getPkey().equalsIgnoreCase(XpackSettingConstants.Front_Time_Out) && StringUtils.isNotBlank(settingItemVO.getPval())) { + frontTimeOut = Integer.parseInt(settingItemVO.getPval()); + } + } + return frontTimeOut; + } } diff --git a/core/core-backend/src/main/resources/db/desktop/V2.3__ddl.sql b/core/core-backend/src/main/resources/db/desktop/V2.3__ddl.sql index f8a9c19a0e..46e93a64e6 100644 --- a/core/core-backend/src/main/resources/db/desktop/V2.3__ddl.sql +++ b/core/core-backend/src/main/resources/db/desktop/V2.3__ddl.sql @@ -10,3 +10,5 @@ CREATE TABLE `visualization_watermark` ( ) COMMENT='仪表板水印设置表'; INSERT INTO `visualization_watermark` (`id`, `version`, `setting_content`, `create_by`, `create_time`) VALUES ('system_default', '1.0', '{\"enable\":false,\"enablePanelCustom\":true,\"type\":\"custom\",\"content\":\"水印\",\"watermark_color\":\"#DD1010\",\"watermark_x_space\":12,\"watermark_y_space\":36,\"watermark_fontsize\":15}', 'admin', NULL); + +INSERT INTO `core_sys_setting` (`id`, `pkey`, `pval`, `type`, `sort`) VALUES (9, 'basic.frontTimeOut', '60', 'text', 1); \ No newline at end of file diff --git a/core/core-backend/src/main/resources/db/migration/V2.3__ddl.sql b/core/core-backend/src/main/resources/db/migration/V2.3__ddl.sql index f8a9c19a0e..46e93a64e6 100644 --- a/core/core-backend/src/main/resources/db/migration/V2.3__ddl.sql +++ b/core/core-backend/src/main/resources/db/migration/V2.3__ddl.sql @@ -10,3 +10,5 @@ CREATE TABLE `visualization_watermark` ( ) COMMENT='仪表板水印设置表'; INSERT INTO `visualization_watermark` (`id`, `version`, `setting_content`, `create_by`, `create_time`) VALUES ('system_default', '1.0', '{\"enable\":false,\"enablePanelCustom\":true,\"type\":\"custom\",\"content\":\"水印\",\"watermark_color\":\"#DD1010\",\"watermark_x_space\":12,\"watermark_y_space\":36,\"watermark_fontsize\":15}', 'admin', NULL); + +INSERT INTO `core_sys_setting` (`id`, `pkey`, `pval`, `type`, `sort`) VALUES (9, 'basic.frontTimeOut', '60', 'text', 1); \ No newline at end of file diff --git a/core/core-frontend/src/config/axios/service.ts b/core/core-frontend/src/config/axios/service.ts index 97a2bbf65e..c932f2a188 100644 --- a/core/core-frontend/src/config/axios/service.ts +++ b/core/core-frontend/src/config/axios/service.ts @@ -13,6 +13,7 @@ import { usePermissionStoreWithOut } from '@/store/modules/permission' import { useLinkStoreWithOut } from '@/store/modules/link' import { config } from './config' import { configHandler } from './refresh' + type AxiosErrorWidthLoading = T & { config: { loading?: boolean @@ -25,8 +26,10 @@ type InternalAxiosRequestConfigWidthLoading = T & { import { ElMessage, ElMessageBox } from 'element-plus-secondary' import router from '@/router' + const { result_code } = config import { useCache } from '@/hooks/web/useCache' + const { wsCache } = useCache() export const PATH_URL = window.DataEaseBi @@ -38,10 +41,41 @@ export interface AxiosInstanceWithLoading extends AxiosInstance { config: AxiosRequestConfig & { loading?: boolean } ): Promise } + +const getTimeOut = () => { + let time = 100 + const url = PATH_URL + '/sysParameter/requestTimeOut' + const xhr = new XMLHttpRequest() + xhr.onreadystatechange = () => { + if (xhr.readyState === 4 && xhr.status === 200) { + if (xhr.responseText) { + try { + const response = JSON.parse(xhr.responseText) + if (response.code === 0) { + time = response.data + } else { + ElMessage.error('系统异常,请联系管理员') + } + } catch (e) { + ElMessage.error('系统异常,请联系管理员') + } + } else { + ElMessage.error('网络异常,请联系网管') + } + } + } + + xhr.open('get', url, false) + xhr.send() + console.log(time) + return time +} + // 创建axios实例 +const time = getTimeOut() const service: AxiosInstanceWithLoading = axios.create({ baseURL: PATH_URL, // api 的 base_url - timeout: config.request_timeout // 请求超时时间 + timeout: time ? time * 1000 : config.request_timeout // 请求超时时间 }) const mapping = { 'zh-CN': 'zh-CN', diff --git a/core/core-frontend/src/locales/zh-CN.ts b/core/core-frontend/src/locales/zh-CN.ts index 6aa5cfce70..e39fa744a9 100644 --- a/core/core-frontend/src/locales/zh-CN.ts +++ b/core/core-frontend/src/locales/zh-CN.ts @@ -2126,7 +2126,8 @@ export default { setting_basic: { autoCreateUser: '第三方自动创建用户', dsIntervalTime: '数据源检测时间间隔', - dsExecuteTime: '数据源检测频率' + dsExecuteTime: '数据源检测频率', + frontTimeOut: '请求超时时间(秒)' }, template_manage: { name_already_exists_type: '分类名称已存在', diff --git a/core/core-frontend/src/views/system/parameter/basic/BasicEdit.vue b/core/core-frontend/src/views/system/parameter/basic/BasicEdit.vue index 92768c6426..be9875c849 100644 --- a/core/core-frontend/src/views/system/parameter/basic/BasicEdit.vue +++ b/core/core-frontend/src/views/system/parameter/basic/BasicEdit.vue @@ -15,7 +15,8 @@ const options = [ const state = reactive({ form: reactive({ dsIntervalTime: '30', - dsExecuteTime: 'minute' + dsExecuteTime: 'minute', + frontTimeOut: '30' }), settingList: [] }) @@ -165,7 +166,19 @@ defineExpose({ 执行一次 -
+
+ +
+