feat: enhance project configuration and add new features

This commit is contained in:
严浩
2025-09-09 18:19:23 +08:00
parent 88483c26e6
commit 4851b83c37
28 changed files with 4323 additions and 37 deletions

26
fake/upload.fake.ts Normal file
View File

@@ -0,0 +1,26 @@
// fake/user.fake.ts
import { defineFakeRoute } from 'vite-plugin-fake-server/client';
let fail = !false;
export default defineFakeRoute([
{
method: 'POST',
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' }));
}
},
response: () => {
return {
url: 'https://picsum.photos/200/300',
};
},
timeout: 2000,
url: '/fake/upload',
},
]);