forked from github/dataease
Merge pull request #11905 from dataease/pr@dev-v2@refactor_template-limit
refactor(工作台): 增加模板限制大小到35MB同时前端增加大小校验
This commit is contained in:
commit
61b5df9ae9
@ -73,6 +73,7 @@ import { useI18n } from '@/hooks/web/useI18n'
|
||||
const emits = defineEmits(['closeEditTemplateDialog', 'refresh', 'addCategoryInfo'])
|
||||
const { t } = useI18n()
|
||||
const filesRef = ref(null)
|
||||
const maxImageSize = 35000000
|
||||
const props = defineProps({
|
||||
pid: {
|
||||
type: String,
|
||||
@ -244,7 +245,8 @@ const importTemplate = () => {
|
||||
if (response.data.indexOf('exist') > -1) {
|
||||
ElMessage.warning('当前名称已在模版管理中存在,请修改')
|
||||
} else {
|
||||
save(state.templateInfo).then(response => {
|
||||
save(state.templateInfo).then(rsp => {
|
||||
console.log('====' + JSON.stringify(rsp))
|
||||
ElMessage.success(t('导入成功'))
|
||||
emits('refresh', getRefreshPInfo())
|
||||
emits('closeEditTemplateDialog')
|
||||
@ -258,6 +260,10 @@ const importTemplate = () => {
|
||||
const handleFileChange = e => {
|
||||
const file = e.target.files[0]
|
||||
const reader = new FileReader()
|
||||
if (file.size > maxImageSize) {
|
||||
ElMessage.success('模板大小需小于35MB')
|
||||
return
|
||||
}
|
||||
reader.onload = res => {
|
||||
const result = res.target.result as string
|
||||
state.importTemplateInfo = JSON.parse(result)
|
||||
|
@ -1,8 +1,10 @@
|
||||
package io.dataease.jackson;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.core.StreamReadConstraints;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
@ -23,4 +25,18 @@ public class JacksonConfig {
|
||||
return objectMapper;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Jackson2ObjectMapperBuilderCustomizer customJackson() {
|
||||
return jacksonObjectMapperBuilder -> {
|
||||
// 增大最大字符串长度限制到 350000000(或根据需要设置)
|
||||
StreamReadConstraints constraints = StreamReadConstraints.builder()
|
||||
.maxStringLength(35000000) // 设置更大的限制值
|
||||
.build();
|
||||
|
||||
jacksonObjectMapperBuilder.postConfigurer(objectMapper ->
|
||||
objectMapper.getFactory().setStreamReadConstraints(constraints)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user