feat(系统设置): 支持上传文件大小限制(测试跟踪&&系统设置&&项目设置)

--task=1016193 --user=宋昌昌 系统配置支持自定义文件大小限制-后端-V2 https://www.tapd.cn/55049933/s/1576397
This commit is contained in:
song-cc-rock 2024-09-13 16:34:59 +08:00 committed by Craftsman
parent 5b099a1694
commit b7e2753c84
31 changed files with 222 additions and 69 deletions

View File

@ -83,9 +83,9 @@
</template>
<script>
import { getCurrentUserId, publicKeyEncrypt } from '../../utils/token';
import { DEFAULT_LANGUAGE, PRIMARY_COLOR } from '../../utils/constants';
import { hasLicense, hasPermissions, saveLicense } from '../../utils/permission';
import {getCurrentUserId, publicKeyEncrypt} from '../../utils/token';
import {DEFAULT_LANGUAGE, PRIMARY_COLOR, UPLOAD_LIMIT} from '../../utils/constants';
import {hasLicense, hasPermissions, saveLicense} from '../../utils/permission';
import {
checkLdapOpen,
getAuthSource,
@ -96,13 +96,13 @@ import {
saveBaseUrl
} from "../../api/user";
import {useUserStore} from "@/store"
import {getQueryVariable, getUrlParameterWidthRegExp, operationConfirm} from "../../utils";
import {operationConfirm} from "../../utils";
import {getModuleList} from "../../api/module";
import {getLicense} from "../../api/license";
import {setLanguage} from "../../i18n";
import {getLarkCallback, getLarkSuiteCallback, getPlatformParamUrl} from "../../api/qrcode";
import {getPlatformParamUrl} from "../../api/qrcode";
import tabQrCode from "../login/tabQrCode.vue";
import axios from "axios";
import {getSystemBaseSetting} from "@/api/system";
const checkLicense = () => {
return getLicense()
@ -336,6 +336,7 @@ export default {
sessionStorage.setItem('changePassword', response.message);
localStorage.setItem('AuthenticateType', this.form.authenticate);
this.getLanguage(response.data.language);
this.setMaxUploadSize();
//
this.checkRedirectUrl();
});
@ -348,6 +349,14 @@ export default {
});
}
},
setMaxUploadSize() {
getSystemBaseSetting().then((res) => {
let maxSize = res.data.maxSize;
if (maxSize) {
localStorage.setItem(UPLOAD_LIMIT, maxSize);
}
});
},
redirectAuth(authId) {
if (authId === 'LDAP' || authId === 'LOCAL') {
return;

View File

@ -1209,8 +1209,8 @@ const message = {
delete_file_when_uploading: 'The current operation may interrupt the file being uploaded!',
delete_file_confirm: 'Confirm delete file:',
unrelated_file_confirm: 'Confirm unrelated file: ',
file_size_out_of_bounds: 'File size out of bounds, file name: ',
file_size_limit: 'The number of files exceeds the limit',
file_size_limit: "Supports any type of file up to {size} MB",
file_size_out_of_bounds: "The file size should not exceed {size} MB",
delete_file: 'The file already exists, please delete the file with the same name first!',
thread_num: 'VUs:',
file_type_limit: 'Only files in image format can be uploaded',
@ -1982,7 +1982,7 @@ const message = {
label: 'Import',
title: 'API test import',
data_format: 'Data format',
file_size_limit: 'The file size does not exceed 50 M',
file_size_limit: 'The file size does not exceed {size} M',
tip: 'Instructions',
export_tip: 'Export Tip',
ms_tip: 'Support for MeterSphere JSON format',

View File

@ -178,7 +178,7 @@ export default {
"Disassociating the project will also cancel the associated test cases under the project",
img_loading_fail: "Image failed to load",
pdf_loading_fail: "PDF loading failed",
upload_tip: "file size limit[0-50MB]",
upload_tip: "File size limit [{0}-{1}]MB",
add_attachment: "Add",
attachment: "Attachment",
dump_module: "Please select dump directory",

View File

@ -155,7 +155,7 @@ export default {
cancel_relevance_project: "取消项目关联会同时取消该项目下已关联的测试用例",
img_loading_fail: "图片加载失败",
pdf_loading_fail: "PDF加载失败",
upload_tip: "文件大小限制[0-50MB]",
upload_tip: "文件大小限制 [{0}-{1}]MB",
add_attachment: "添加",
attachment: "附件",
dump_module: "请选择转存目录",

View File

@ -155,7 +155,7 @@ export default {
cancel_relevance_project: "取消項目關聯會同時取消該項目下已關聯的測試用例",
img_loading_fail: "圖片加載失敗",
pdf_loading_fail: "PDF加載失敗",
upload_tip: "文件大小限制[0-50MB]",
upload_tip: "文件大小限制 [{0}-{1}]MB",
add_attachment: "添加",
attachment: "附件",
dump_module: "請選擇轉存目錄",

View File

@ -1960,7 +1960,7 @@ const message = {
label: '导入',
title: '接口测试导入',
data_format: '数据格式',
file_size_limit: '文件大小不超过 50 M',
file_size_limit: '文件大小不超过 {size} M',
support_format: '支持p12,jks,pfx格式',
tip: '说明',
export_tip: '导出方法',

View File

@ -1959,7 +1959,7 @@ const message = {
label: '導入',
title: '接口測試導入',
data_format: '數據格式',
file_size_limit: '文件大小不超過 50 M',
file_size_limit: '文件大小不超過 {size} M',
support_format: '支持p12,jks,pfx格式',
tip: '說明',
export_tip: '導出方法',

View File

@ -18,6 +18,7 @@ export const LicenseKey = 'License';
export const PROJECT_VERSION_ENABLE = 'PROJECT_VERSION_ENABLE';
export const DEFAULT_LANGUAGE = 'default_language';
export const CURRENT_LANGUAGE = 'current_language';
export const UPLOAD_LIMIT = "upload_limit";
export const ROLE_ADMIN = 'admin';
export const ROLE_ORG_ADMIN = 'org_admin';

View File

@ -4,6 +4,7 @@ import {
ORIGIN_COLOR,
ORIGIN_COLOR_SHALLOW,
PRIMARY_COLOR,
UPLOAD_LIMIT,
} from "./constants";
import i18n from "../i18n";
import html2canvas from "html2canvas";
@ -518,3 +519,7 @@ export function getUrlParameterWidthRegExp(name) {
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
export function getUploadSizeLimit() {
return localStorage.getItem(UPLOAD_LIMIT);
}

View File

@ -0,0 +1,17 @@
package io.metersphere.file.annotation;
import java.lang.annotation.*;
/**
* @author song-cc-rock
*/
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface MsFileLimit {
/**
* 文件大小限制 (单位: MB)
*/
long maxSize() default 0;
}

View File

@ -0,0 +1,78 @@
package io.metersphere.file.aspect;
import io.metersphere.base.domain.SystemParameter;
import io.metersphere.base.domain.SystemParameterExample;
import io.metersphere.base.mapper.SystemParameterMapper;
import io.metersphere.commons.exception.MSException;
import io.metersphere.file.annotation.MsFileLimit;
import io.metersphere.i18n.Translator;
import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import java.lang.reflect.Method;
import java.util.List;
/**
* @author song-cc-rock
*/
@Aspect
@Component
public class MsFileLimitAspect {
@Resource
private SystemParameterMapper systemParameterMapper;
@Pointcut("@annotation(io.metersphere.file.annotation.MsFileLimit)")
public void limitPointCut() {
}
@Before("limitPointCut()")
public void before(JoinPoint joinPoint) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
MsFileLimit limit = method.getAnnotation(MsFileLimit.class);
// 获取方法参数
Object[] args = joinPoint.getArgs();
// 获取文件大小限制 (默认使用系统参数中的文件限制大小, 如果注解中有配置则使用注解中的配置)
long fileMaxSize = limit.maxSize() != 0 ? limit.maxSize() : getFileMaxSize();
for (Object arg : args) {
// 单个文件
if (arg instanceof MultipartFile file) {
// 判断文件大小是否超过限制
if (file.getSize() > fileMaxSize * 1024 * 1024) {
MSException.throwException(Translator.get("file_upload.size_limit"));
}
}
// 多个文件
if (arg instanceof List<?> files) {
// List<MultipartFile> 类型参数跳过
if (CollectionUtils.isEmpty(files) || !(files.get(0) instanceof MultipartFile)) {
continue;
}
files.forEach(f -> {
if (f instanceof MultipartFile file) {
// 判断文件大小是否超过限制
if (file.getSize() > fileMaxSize * 1024 * 1024) {
MSException.throwException(Translator.get("file_upload.size_limit"));
}
}
});
}
}
}
private Long getFileMaxSize() {
SystemParameterExample example = new SystemParameterExample();
example.createCriteria().andParamKeyEqualTo("base.file.upload.size");
List<SystemParameter> systemParameters = systemParameterMapper.selectByExample(example);
return Long.parseLong(systemParameters.get(0).getParamValue());
}
}

View File

@ -9,6 +9,7 @@ import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.dto.FileMetadataDTO;
import io.metersphere.file.annotation.MsFileLimit;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.metadata.service.FileMetadataService;
import io.metersphere.metadata.vo.*;
@ -45,6 +46,7 @@ public class FileMetadataController {
return PageUtils.setPageInfo(page, fileMetadataService.getFileMetadataByProject(projectId, request));
}
@MsFileLimit
@PostMapping(value = "/create")
@RequiresPermissions("PROJECT_FILE:READ+UPLOAD+JAR")
@MsAuditLog(module = OperLogModule.PROJECT_FILE_MANAGEMENT, type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = FileMetadataService.class)

View File

@ -84,8 +84,8 @@ quartz.scheduler-name=msServerJob
quartz.thread-count=10
quartz.properties.org.quartz.jobStore.acquireTriggersWithinLock=true
# file upload
spring.servlet.multipart.max-file-size=500MB
spring.servlet.multipart.max-request-size=500MB
spring.servlet.multipart.max-file-size=1024MB
spring.servlet.multipart.max-request-size=1024MB
# actuator
management.server.port=8083
management.endpoints.web.exposure.include=*

View File

@ -72,4 +72,5 @@ jira_auth_error=
# issue template copy
target_issue_template_not_checked=
source_issue_template_is_empty=
select_resource_error_and_check=
select_resource_error_and_check=
file_upload.size_limit=

View File

@ -410,4 +410,5 @@ version_name_is_null=Version name is not null
current_version_already_exists=Current version already exists
Prepare=Prepare
Underway=Underway
Completed=Completed
Completed=Completed
file_upload.size_limit=The file size exceeds the system limit

View File

@ -408,4 +408,5 @@ Prepare=未开始
Underway=进行中
Completed=已完成
can_not_move_to_repository_node=不能移动到存储库节点
can_not_move_to_repository_file=不能移动存储库中的文件
can_not_move_to_repository_file=不能移动存储库中的文件
file_upload.size_limit=文件大小超过系统限制

View File

@ -407,4 +407,5 @@ Prepare=未開始
Underway=進行中
Completed=已完成
can_not_move_to_repository_node=不能移動到存儲庫節點
can_not_move_to_repository_file=不能移動存儲庫中的文件
can_not_move_to_repository_file=不能移動存儲庫中的文件
file_upload.size_limit=文件大小超過系統限制

View File

@ -27,7 +27,7 @@
<i class="el-icon-upload"></i>
<div class="el-upload__text" v-html="$t('load_test.upload_tips')"></div>
<div class="el-upload__tip" slot="tip">
{{ $t('api_test.api_import.file_size_limit') }}
{{ $t('api_test.api_import.file_size_limit', {size: this.uploadSize}) }}
{{ '' + $t('api_test.api_import.ms_env_import_file_limit') }}
</div>
</el-upload>
@ -45,6 +45,7 @@
<script>
import {importEnvironment} from "../../../api/environment";
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import {getUploadSizeLimit} from "metersphere-frontend/src/utils/index";
export default {
name: "EnvironmentImport",
@ -79,7 +80,11 @@ export default {
}
}
},
computed: {
uploadSize() {
return getUploadSizeLimit();
}
},
methods: {
handleFileChange(file, uploadFiles) {
@ -124,13 +129,13 @@ export default {
handleRemove() {
},
uploadValidate(file) { //.json20M
uploadValidate(file) { //.json
const extension = file.name.substring(file.name.lastIndexOf('.') + 1);
if (!(extension === 'json')) {
this.$warning(this.$t('api_test.api_import.ms_env_import_file_limit'));
}
if (file.size / 1024 / 1024 > 20) {
this.$warning(this.$t('api_test.api_import.file_size_limit'));
if (file.size / 1024 / 1024 > this.uploadSize) {
this.$warning(this.$t('api_test.api_import.file_size_limit', {size: this.uploadSize}));
}
},
open() {

View File

@ -5,15 +5,16 @@ import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.exception.MSException;
import io.metersphere.file.annotation.MsFileLimit;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.request.PluginDTO;
import io.metersphere.request.PluginRequest;
import io.metersphere.service.PluginService;
import jakarta.annotation.Resource;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import jakarta.annotation.Resource;
import java.util.List;
@ -24,6 +25,7 @@ public class PluginController {
@Resource
private PluginService pluginService;
@MsFileLimit
@PostMapping("/add/{scenario}")
@RequiresPermissions(PermissionConstants.SYSTEM_PLUGIN_UPLOAD)
@MsAuditLog(module = OperLogModule.PLUGIN_MANAGE, type = OperLogConstants.CREATE, title = "#file.getOriginalFilename()", msClass = PluginService.class)

View File

@ -13,6 +13,7 @@ import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.UserDTO;
import io.metersphere.dto.UserGroupPermissionDTO;
import io.metersphere.excel.domain.ExcelResponse;
import io.metersphere.file.annotation.MsFileLimit;
import io.metersphere.i18n.Translator;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
@ -228,6 +229,7 @@ public class UserController {
userService.userTemplateExport(response);
}
@MsFileLimit
@PostMapping("/import")
@MsAuditLog(module = OperLogModule.SYSTEM_USER, type = OperLogConstants.IMPORT)
public ExcelResponse testCaseImport(MultipartFile file, HttpServletRequest request) {

View File

@ -35,7 +35,7 @@
:file-list="fileList">
<i class="el-icon-upload"></i>
<div class="el-upload__text" v-html="$t('load_test.upload_tips')"></div>
<div class="el-upload__tip" slot="tip">{{ $t('api_test.api_import.file_size_limit') }}</div>
<div class="el-upload__tip" slot="tip">{{ $t('api_test.api_import.file_size_limit', {size: this.uploadSize}) }}</div>
</el-upload>
</el-row>
<el-row>
@ -54,6 +54,7 @@ import MsTableButton from 'metersphere-frontend/src/components/MsTableButton';
import {listenGoBack, removeGoBackListener} from "metersphere-frontend/src/utils";
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import {exportUserExample, userImport} from "../../../api/user";
import {getUploadSizeLimit} from "metersphere-frontend/src/utils/index";
export default {
name: "UserImport",
@ -69,6 +70,11 @@ export default {
isLoading: false
}
},
computed: {
uploadSize() {
return getUploadSizeLimit();
}
},
methods: {
handleExceed(files, fileList) {
this.$warning(this.$t('test_track.case.import.upload_limit_count'));
@ -79,7 +85,7 @@ export default {
this.$warning(this.$t('test_track.case.import.upload_limit_format'));
return false;
}
if (file.size / 1024 / 1024 > 50) {
if (file.size / 1024 / 1024 > this.uploadSize) {
this.$warning(this.$t('commons.upload_limit_size'));
return false;
}

View File

@ -38,6 +38,7 @@
<script>
import {getSystemBaseSetting, saveSystemBaseSetting} from "../../../api/system";
import {UPLOAD_LIMIT} from 'metersphere-frontend/src/utils/constants';
export default {
name: "BaseSetting",
@ -106,7 +107,6 @@ export default {
res.data.docUrl = 'https://metersphere.io/docs/index.html'
}
this.formInline = res.data;
console.log(this.formInline);
this.$nextTick(() => {
if (this.$refs.formInline) {
this.$refs.formInline.clearValidate();
@ -139,6 +139,9 @@ export default {
];
this.loading = saveSystemBaseSetting(param).then(res => {
if (res.success) {
if (this.formInline.maxSize) {
localStorage.setItem(UPLOAD_LIMIT, this.formInline.maxSize);
}
this.$success(this.$t('commons.save_success'));
} else {
this.$error(this.$t('commons.save_failed'));

View File

@ -27,7 +27,7 @@
<i class="el-icon-upload"></i>
<div class="el-upload__text" v-html="$t('load_test.upload_tips')"></div>
<div class="el-upload__tip" slot="tip">
{{ $t('api_test.api_import.file_size_limit') }} {{'' + $t('api_test.api_import.ms_env_import_file_limit') }}
{{ $t('api_test.api_import.file_size_limit', {size: this.uploadSize}) }} {{'' + $t('api_test.api_import.ms_env_import_file_limit') }}
</div>
</el-upload>
</el-col>
@ -44,6 +44,7 @@
<script>
import {importEnvironment} from "../../../api/environment";
import {getUploadSizeLimit} from "metersphere-frontend/src/utils/index";
export default {
name: "EnvironmentImport",
@ -72,7 +73,11 @@ export default {
}
}
},
computed: {
uploadSize() {
return getUploadSizeLimit();
}
},
methods: {
handleFileChange(file, uploadFiles) {
@ -124,13 +129,13 @@ export default {
handleRemove() {
},
uploadValidate(file) { //.json20M
uploadValidate(file) { //.json
const extension = file.name.substring(file.name.lastIndexOf('.') + 1);
if (!(extension === 'json')) {
this.$warning(this.$t('api_test.api_import.ms_env_import_file_limit'));
}
if (file.size / 1024 / 1024 > 20) {
this.$warning(this.$t('api_test.api_import.file_size_limit'));
if (file.size / 1024 / 1024 > this.uploadSize) {
this.$warning(this.$t('api_test.api_import.file_size_limit', {size: this.uploadSize}));
}
},
open() {

View File

@ -6,6 +6,7 @@ import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.exception.MSException;
import io.metersphere.constants.AttachmentType;
import io.metersphere.file.annotation.MsFileLimit;
import io.metersphere.i18n.Translator;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.metadata.service.FileMetadataService;
@ -36,6 +37,7 @@ public class AttachmentController {
@Resource
private FileMetadataService fileMetadataService;
@MsFileLimit
@MsAuditLog(module = OperLogModule.TRACK_BUG, type = OperLogConstants.UPDATE, content = "#msClass.getLogDetails(#request.belongId, #request.belongType, #file.getOriginalFilename(), false)", msClass = AttachmentService.class)
@PostMapping(value = "/issue/upload", consumes = {"multipart/form-data"})
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ_EDIT)
@ -46,6 +48,7 @@ public class AttachmentController {
attachmentService.uploadAttachment(request, file);
}
@MsFileLimit
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.UPDATE, content = "#msClass.getLogDetails(#request.belongId, #request.belongType, #file.getOriginalFilename(), false)", msClass = AttachmentService.class)
@PostMapping(value = "/testcase/upload", consumes = {"multipart/form-data"})
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT)

View File

@ -16,6 +16,7 @@ import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.CustomFieldDao;
import io.metersphere.dto.IssuesStatusCountDao;
import io.metersphere.excel.domain.ExcelResponse;
import io.metersphere.file.annotation.MsFileLimit;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.notice.annotation.SendNotice;
@ -85,6 +86,7 @@ public class IssuesController {
return PageUtils.setPageInfo(page, issuesService.relateList(request));
}
@MsFileLimit
@PostMapping(value = "/add", consumes = {"multipart/form-data"})
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ_CREATE)
@MsAuditLog(module = OperLogModule.TRACK_BUG, type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#issuesRequest)", msClass = IssuesService.class)

View File

@ -14,6 +14,7 @@ import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.*;
import io.metersphere.excel.domain.ExcelResponse;
import io.metersphere.file.annotation.MsFileLimit;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.annotation.MsRequestLog;
import io.metersphere.notice.annotation.SendNotice;
@ -241,6 +242,7 @@ public class TestCaseController {
return testCaseService.getProjectByTestCaseId(testCaseId);
}
@MsFileLimit
@PostMapping(value = "/add", consumes = {"multipart/form-data"})
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_CREATE)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseService.class)

View File

@ -91,7 +91,7 @@
<el-button v-popover:popover icon="el-icon-plus" size="small" class="add-attachment">{{
$t("case.add_attachment")
}}</el-button>
<div class="opt-tip">{{ $t("case.file_size_limit") }}</div>
<div class="opt-tip">{{ $t("case.file_size_limit", {size: uploadSize}) }}</div>
<div class="attachment-preview">
<case-attachment-viewer
:tableData="tableData"
@ -117,6 +117,7 @@ import {byteToSize, getCurrentUser, getTypeByFileName, hasPermission,} from "@/b
import axios from "axios";
import {getUUID} from "metersphere-frontend/src/utils";
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import {getUploadSizeLimit} from "metersphere-frontend/src/utils/index";
import {
attachmentList,
@ -171,6 +172,9 @@ export default {
},
hasProjectFilePermission() {
return hasPermission("PROJECT_FILE:READ");
},
uploadSize() {
return getUploadSizeLimit();
}
},
watch: {
@ -200,11 +204,11 @@ export default {
* upload file methods
*/
fileValidator(file) {
return file.size < 50 * 1024 * 1024;
return file.size < this.uploadSize * 1024 * 1024;
},
beforeUpload(file) {
if (!this.fileValidator(file)) {
this.$error(this.$t("case.file_size_out_of_bounds"), false);
this.$error(this.$t("case.file_size_out_of_bounds", {size: this.uploadSize}), false);
return false;
}
@ -267,7 +271,6 @@ export default {
//
progress = 100;
progressCallback({ progress, status: "error" });
this.$success(this.$t('attachment.upload_error'), false)
self.cancelFileToken.forEach((token, index, array) => {
if (token.name === file.name) {
array.splice(token, 1);
@ -287,7 +290,7 @@ export default {
this.tableData = [...arr];
},
handleExceed(files, fileList) {
this.$error(this.$t("load_test.file_size_limit"), false);
this.$error(this.$t("load_test.file_size_limit", {size: this.uploadSize}), false);
},
handleSuccess(response, file, fileList) {
let readyFiles = fileList.filter((item) => item.status === "ready");

View File

@ -244,7 +244,7 @@
</div>
<div class="local-upload-tips">
<span slot="tip" class="el-upload__tip">
{{ $t("test_track.case.upload_tip") }}
{{ $t("test_track.case.upload_tip", [0, uploadSize]) }}
</span>
</div>
</el-col>
@ -343,31 +343,31 @@ import TestCaseIssueList from "@/business/issue/TestCaseIssueList";
import IssueEditDetail from "@/business/issue/IssueEditDetail";
import {byteToSize, getTypeByFileName, getUUID,} from "metersphere-frontend/src/utils";
import {
getCurrentProjectID,
getCurrentUser,
getCurrentUserId,
getCurrentWorkspaceId,
getCurrentProjectID,
getCurrentUser,
getCurrentUserId,
getCurrentWorkspaceId,
} from "metersphere-frontend/src/utils/token";
import {hasLicense, hasPermission,} from "metersphere-frontend/src/utils/permission";
import {
enableThirdPartTemplate,
getComments,
getFollow,
getIssuePartTemplateWithProject,
getPlatformFormOption,
getPlatformTransitions,
getTapdCurrentOwner,
getTapdUser,
saveFollow,
saveOrUpdateIssue,
enableThirdPartTemplate,
getComments,
getFollow,
getIssuePartTemplateWithProject,
getPlatformFormOption,
getPlatformTransitions,
getTapdCurrentOwner,
getTapdUser,
saveFollow,
saveOrUpdateIssue,
} from "@/api/issue";
import {
attachmentList,
deleteIssueAttachment,
dumpAttachment,
relatedIssueAttachment,
unrelatedIssueAttachment,
uploadIssueAttachment,
attachmentList,
deleteIssueAttachment,
dumpAttachment,
relatedIssueAttachment,
unrelatedIssueAttachment,
uploadIssueAttachment,
} from "@/api/attachment";
import CustomFiledFormItem from "metersphere-frontend/src/components/form/CustomFiledFormItem";
import MsMarkDownText from "metersphere-frontend/src/components/MsMarkDownText";
@ -379,6 +379,7 @@ import axios from "axios";
import MsFileMetadataList from "metersphere-frontend/src/components/environment/commons/variable/QuoteFileList";
import MsFileBatchMove from "metersphere-frontend/src/components/environment/commons/variable/FileBatchMove";
import {parseMdImage, saveMarkDownImg} from "@/business/utils/sdk-utils";
import {getUploadSizeLimit} from "metersphere-frontend/src/utils/index";
export default {
name: "IssueEditDetail",
@ -523,6 +524,9 @@ export default {
hasProjectFilePermission() {
return hasPermission("PROJECT_FILE:READ");
},
uploadSize() {
return getUploadSizeLimit();
}
},
watch: {
tabActiveName() {
@ -856,11 +860,11 @@ export default {
}
},
fileValidator(file) {
return file.size < 50 * 1024 * 1024;
return file.size < this.uploadSize * 1024 * 1024;
},
beforeUpload(file) {
if (!this.fileValidator(file)) {
this.$error(this.$t("case.file_size_out_of_bounds"), false);
this.$error(this.$t("case.file_size_out_of_bounds", {size: this.uploadSize}), false);
return false;
}
@ -947,7 +951,7 @@ export default {
this.tableData = [...arr];
},
handleExceed(files, fileList) {
this.$error(this.$t("load_test.file_size_limit"));
this.$error(this.$t("load_test.file_size_limit", {size: this.uploadSize}), false);
},
handleSuccess(response, file, fileList) {
let readyFiles = fileList.filter((item) => item.status === "success");

View File

@ -106,8 +106,8 @@ const message = {
commented: "Commented",
add_attachment: "Add Attachment",
file_size_limit:
"Any type of file is supported, and the file size does not exceed 50MB",
file_size_out_of_bounds: "File size does not exceed 50MB",
"Any type of file is supported, and the file size does not exceed {size} MB",
file_size_out_of_bounds: "File size does not exceed {size} MB",
upload_at: "upload",
relate_at: "relate",
add_steps: "Add Steps",

View File

@ -105,8 +105,8 @@ const message = {
none: "暂无",
commented: "发布了评论",
add_attachment: "添加附件",
file_size_limit: "支持任意类型文件,文件大小不超过 50MB",
file_size_out_of_bounds: "文件大小不超过 50MB",
file_size_limit: "支持任意类型文件,文件大小不超过 {size} MB",
file_size_out_of_bounds: "文件大小不超过 {size} MB",
upload_at: "上传于",
relate_at: "关联于",
add_steps: "添加步骤",

View File

@ -105,8 +105,8 @@ const message = {
none: "暫無",
commented: "髮佈了評論",
add_attachment: "添加附件",
file_size_limit: "支持任意類型文件,文件大小不超過 50MB",
file_size_out_of_bounds: "文件大小不超過 50MB",
file_size_limit: "支持任意類型文件,文件大小不超過 {size} MB",
file_size_out_of_bounds: "文件大小不超過 {size} MB",
upload_at: "上傳於",
relate_at: "關聯於",
add_steps: "添加步骤",