feat: 更新上传假数据处理逻辑,添加原始响应方法并支持选择禁用选项
This commit is contained in:
@ -7,7 +7,7 @@ export default defineFakeRoute([
|
||||
timeout: 2000,
|
||||
method: 'POST',
|
||||
url: '/fake/upload',
|
||||
response: (_, __, res) => {
|
||||
/* response: (_, __, res) => {
|
||||
fail = !fail;
|
||||
if (fail) {
|
||||
res.statusCode = 500;
|
||||
@ -19,6 +19,16 @@ export default defineFakeRoute([
|
||||
return {
|
||||
url: 'https://picsum.photos/200/300',
|
||||
};
|
||||
}, */
|
||||
rawResponse(req, res) {
|
||||
fail = !fail;
|
||||
if (fail) {
|
||||
res.writeHead(500, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({ error: 'Upload failed' }));
|
||||
} else {
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({ url: 'https://picsum.photos/200/300' }));
|
||||
}
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
@ -13,6 +13,7 @@ interface FileUploadInst extends FileUploadState {
|
||||
progress: number;
|
||||
}[];
|
||||
files: FileExt[];
|
||||
chooseDisabled?: boolean;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
Reference in New Issue
Block a user