Files
wukuang/apps/lcdp/mock/DataModels.mock.ts
T
2026-05-23 14:05:22 +08:00

36 lines
1018 B
TypeScript

import { http, HttpResponse } from '@lingshu/vite-plugin-msw/msw';
const handlers = [
http.post('/api/runtime/v1/extension/invoke-method', () => {
return HttpResponse.json({
code: '0',
data: {
fileName: '测试文件.zip',
contentLength: 250,
contentType: '.zip',
objectKey: 'I am objectKey',
},
});
}),
http.get('/api/runtime/v1/extension/invoke-file', async () => {
// 创建模拟 CSV 文件内容
const csvContent = `Name,Email,Phone
John Doe,john@example.com,555-1234
Jane Smith,jane@example.com,555-5678
Bob Johnson,bob@example.com,555-9012`;
// 将 CSV 内容转换为 Uint8Array (Blob)
const fileBlob = new Blob([csvContent], { type: 'text/csv' });
const buffer = await fileBlob.arrayBuffer();
HttpResponse.arrayBuffer(buffer, {
headers: {
'Content-Disposition': 'attachment; filename="users.csv"',
'Content-Type': 'text/csv',
},
});
}),
];
export default handlers;