feat: 【系统设置】支持系统参数设置-前端超时时间设置

This commit is contained in:
taojinlong 2024-01-11 17:01:17 +08:00
parent ecfca28ad2
commit a7c7f0b5da
10 changed files with 80 additions and 5 deletions

View File

@ -3,10 +3,12 @@ package io.dataease.system.server;
import io.dataease.api.system.SysParameterApi; import io.dataease.api.system.SysParameterApi;
import io.dataease.api.system.request.OnlineMapEditor; import io.dataease.api.system.request.OnlineMapEditor;
import io.dataease.api.system.vo.SettingItemVO; import io.dataease.api.system.vo.SettingItemVO;
import io.dataease.constant.XpackSettingConstants;
import io.dataease.system.dao.auto.entity.CoreSysSetting; import io.dataease.system.dao.auto.entity.CoreSysSetting;
import io.dataease.system.manage.SysParameterManage; import io.dataease.system.manage.SysParameterManage;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -18,6 +20,7 @@ public class SysParameterServer implements SysParameterApi {
@Resource @Resource
private SysParameterManage sysParameterManage; private SysParameterManage sysParameterManage;
@Override @Override
public String singleVal(String key) { public String singleVal(String key) {
return sysParameterManage.singleVal(key); return sysParameterManage.singleVal(key);
@ -45,4 +48,17 @@ public class SysParameterServer implements SysParameterApi {
public void saveBasicSetting(List<SettingItemVO> settingItemVOS) { public void saveBasicSetting(List<SettingItemVO> settingItemVOS) {
sysParameterManage.saveBasic(settingItemVOS); sysParameterManage.saveBasic(settingItemVOS);
} }
@Override
public Integer RequestTimeOut() {
Integer frontTimeOut = 60;
List<SettingItemVO> 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;
}
} }

View File

@ -10,3 +10,5 @@ CREATE TABLE `visualization_watermark` (
) COMMENT='仪表板水印设置表'; ) 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 `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);

View File

@ -10,3 +10,5 @@ CREATE TABLE `visualization_watermark` (
) COMMENT='仪表板水印设置表'; ) 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 `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);

View File

@ -13,6 +13,7 @@ import { usePermissionStoreWithOut } from '@/store/modules/permission'
import { useLinkStoreWithOut } from '@/store/modules/link' import { useLinkStoreWithOut } from '@/store/modules/link'
import { config } from './config' import { config } from './config'
import { configHandler } from './refresh' import { configHandler } from './refresh'
type AxiosErrorWidthLoading<T> = T & { type AxiosErrorWidthLoading<T> = T & {
config: { config: {
loading?: boolean loading?: boolean
@ -25,8 +26,10 @@ type InternalAxiosRequestConfigWidthLoading<T> = T & {
import { ElMessage, ElMessageBox } from 'element-plus-secondary' import { ElMessage, ElMessageBox } from 'element-plus-secondary'
import router from '@/router' import router from '@/router'
const { result_code } = config const { result_code } = config
import { useCache } from '@/hooks/web/useCache' import { useCache } from '@/hooks/web/useCache'
const { wsCache } = useCache() const { wsCache } = useCache()
export const PATH_URL = window.DataEaseBi export const PATH_URL = window.DataEaseBi
@ -38,10 +41,41 @@ export interface AxiosInstanceWithLoading extends AxiosInstance {
config: AxiosRequestConfig<D> & { loading?: boolean } config: AxiosRequestConfig<D> & { loading?: boolean }
): Promise<R> ): Promise<R>
} }
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实例 // 创建axios实例
const time = getTimeOut()
const service: AxiosInstanceWithLoading = axios.create({ const service: AxiosInstanceWithLoading = axios.create({
baseURL: PATH_URL, // api base_url baseURL: PATH_URL, // api base_url
timeout: config.request_timeout // 请求超时时间 timeout: time ? time * 1000 : config.request_timeout // 请求超时时间
}) })
const mapping = { const mapping = {
'zh-CN': 'zh-CN', 'zh-CN': 'zh-CN',

View File

@ -2126,7 +2126,8 @@ export default {
setting_basic: { setting_basic: {
autoCreateUser: '第三方自动创建用户', autoCreateUser: '第三方自动创建用户',
dsIntervalTime: '数据源检测时间间隔', dsIntervalTime: '数据源检测时间间隔',
dsExecuteTime: '数据源检测频率' dsExecuteTime: '数据源检测频率',
frontTimeOut: '请求超时时间'
}, },
template_manage: { template_manage: {
name_already_exists_type: '分类名称已存在', name_already_exists_type: '分类名称已存在',

View File

@ -15,7 +15,8 @@ const options = [
const state = reactive({ const state = reactive({
form: reactive({ form: reactive({
dsIntervalTime: '30', dsIntervalTime: '30',
dsExecuteTime: 'minute' dsExecuteTime: 'minute',
frontTimeOut: '30'
}), }),
settingList: [] settingList: []
}) })
@ -165,7 +166,19 @@ defineExpose({
</el-select> </el-select>
<span class="ds-span">执行一次</span> <span class="ds-span">执行一次</span>
</div> </div>
<div v-else /> <div v-else-if="item.pkey === 'frontTimeOut'">
<el-input-number
v-model="state.form.frontTimeOut"
autocomplete="off"
step-strictly
class="text-left"
:min="1"
:placeholder="t('common.inputText')"
controls-position="right"
type="number"
/>
</div>
<v-else />
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>

View File

@ -22,7 +22,7 @@ const editor = ref()
const infoTemplate = ref() const infoTemplate = ref()
const tooltips = [ const tooltips = [
{ {
key: '请求超时时间', key: 'setting_basic.frontTimeOut',
val: '请求超时时间(单位:秒,注意:保存后刷新浏览器生效)' val: '请求超时时间(单位:秒,注意:保存后刷新浏览器生效)'
} }
] ]
@ -45,6 +45,7 @@ const search = cb => {
item.pval = item.pval item.pval = item.pval
} }
item.pkey = 'setting_' + item.pkey item.pkey = 'setting_' + item.pkey
console.log(item.pkey)
state.templateList.push(item) state.templateList.push(item)
} }
cb && cb() cb && cb()

View File

@ -39,4 +39,8 @@ public interface SysParameterApi {
@PostMapping("/basic/save") @PostMapping("/basic/save")
void saveBasicSetting(@RequestBody List<SettingItemVO> settingItemVOS); void saveBasicSetting(@RequestBody List<SettingItemVO> settingItemVOS);
@Operation(summary = "查询超时时间(非xpack)")
@GetMapping("/requestTimeOut")
public Integer RequestTimeOut();
} }

View File

@ -3,4 +3,5 @@ package io.dataease.constant;
public class XpackSettingConstants { public class XpackSettingConstants {
public static final String AUTO_CREATE_USER = "basic.autoCreateUser"; public static final String AUTO_CREATE_USER = "basic.autoCreateUser";
public static final String Front_Time_Out = "basic.frontTimeOut";
} }

View File

@ -18,6 +18,7 @@ public class WhitelistUtils {
"/panel.html", "/panel.html",
"/lark/info", "/lark/info",
"/lark/token", "/lark/token",
"/sysParameter/requestTimeOut",
"/setting/authentication/status", "/setting/authentication/status",
"/"); "/");