fix(接口测试): 响应体切换时 binary 文件未更新修复

This commit is contained in:
baiqi 2024-10-28 11:13:16 +08:00 committed by Craftsman
parent afb7b0569e
commit 494bb58e67
2 changed files with 17 additions and 1 deletions

View File

@ -245,6 +245,9 @@
.filter((item) => !item?.local)
.map((item) => item?.[props.fields.id] || '')
.filter((item) => item);
} else {
inputFileName.value = '';
inputFiles.value = [];
}
},
{

View File

@ -489,9 +489,22 @@
onBeforeMount(() => {
if (activeResponse.value.body.binaryBody && activeResponse.value.body.binaryBody.file) {
fileList.value = [activeResponse.value.body.binaryBody.file as unknown as MsFileItem];
} else {
fileList.value = [];
}
});
watch(
() => activeResponse.value.id,
() => {
if (activeResponse.value.body.binaryBody && activeResponse.value.body.binaryBody.file) {
fileList.value = [activeResponse.value.body.binaryBody.file as unknown as MsFileItem];
} else {
fileList.value = [];
}
}
);
async function handleFileChange() {
try {
if (fileList.value[0] && fileList.value[0].local && fileList.value[0].file && props.uploadTempFileApi) {
@ -509,7 +522,7 @@
activeResponse.value.body.binaryBody.file = {
...fileList.value[0],
fileId: fileList.value[0].uid,
fileName: fileList.value[0]?.originalName || '',
fileName: fileList.value[0]?.name || '',
fileAlias: fileList.value[0]?.name || '',
local: false,
};