feat: 更新上传假数据处理逻辑,添加原始响应方法并支持选择禁用选项
All checks were successful
/ build-and-deploy-to-vercel (push) Successful in 1m19s
/ depcheck (push) Successful in 1m19s
/ playwright (push) Successful in 3m28s

This commit is contained in:
严浩
2024-12-16 00:38:02 +08:00
parent abe0262130
commit 5f0eaa2579
2 changed files with 12 additions and 1 deletions

View File

@ -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' }));
}
},
},
]);

View File

@ -13,6 +13,7 @@ interface FileUploadInst extends FileUploadState {
progress: number;
}[];
files: FileExt[];
chooseDisabled?: boolean;
}
</script>