import { delay, http, HttpResponse } from '@lingshu/vite-plugin-msw/msw'; let statusIndex = 0; const handlers = [ http.get('/api/lcdp/v1/deploy/log', () => { return HttpResponse.json({ code: '0', message: '', data: [ { createTime: '1745394969', content: 'create Step 1/6: Start creating the deployment package', }, { createTime: '1745394969', content: 'create Step 2/6: Create the deployment package folder', }, { createTime: '1745394969', content: 'create Step 3_1/6: Generate the basic information and modeling information of the application', }, ], }); }), http.get('/api/lcdp/v1/deploy/page', () => { return HttpResponse.json({ code: '0', message: '', data: { total: 200, records: Array.from({ length: 10 }).fill(0).map((_, index) => { let status = index % 9; if (status === 3) { status = 4; } return { id: `id${index}`, name: { 'zh-CN': `name${index}` }, source: Math.random() > 0.5 ? 0 : 1, description: { 'zh-CN': `description${index}` }, status, createTime: 1745204687, createBy: `创建人${index}`, updateTime: 1745214608, updateBy: `修改人${index}`, fileId: `1914602934984368129`, }; }), }, }); }), http.post('/api/lcdp/v1/deploy/import', () => { return HttpResponse.json({ code: '0', message: '我是错误信息', data: null, }); }), http.post('/api/lcdp/v1/deploy/del', async () => { await delay(1500); return HttpResponse.json({ code: '0', message: '我是错误信息', data: null, }); }), http.post('/api/lcdp/v1/deploy/check-before-delete', async ({ request }) => { const data: any = await request.json(); const ids = data?.ids || []; return HttpResponse.json({ code: '0', message: '我是错误信息', data: ids.splice(1), }); }), http.get('/api/lcdp/v1/deploy/details', () => { return HttpResponse.json({ code: '0', message: '', data: { deployVo: { id: 'id1', name: { 'zh-CN': 'name1' }, description: { 'zh-CN': Array.from({ length: 30 }).fill('description1').join(';') }, source: 0, deployVersion: '202165465-456', }, appList: [ { appId: 'appId1', name: { 'zh-CN': '应用1' }, appCode: 'appCode1', groupName: { 'zh-CN': '分组1' }, businessName: { 'zh-CN': '业务1' }, description: { 'zh-CN': '描述1' }, }, ], resourceList: [ { fileName: '文件1', name: { 'zh-CN': '应用1' }, resType: 1, }, ], sqlList: [ { fileName: 'sql1.sql', name: { 'zh-CN': 'sql1.sql' }, }, ], }, }); }), http.post('/api/lcdp/v1/deploy/install', async () => { await delay(1500); return HttpResponse.json({ code: '0', message: '我是错误信息', data: null, }); }), http.get('/api/lcdp/v1/deploy/version', () => { return HttpResponse.json({ code: '0', message: '', data: '2025-04-22', }); }), http.post('/api/lcdp/v1/file', () => { const imgIds = ['1912073693347319809', '1912097892426190850', '1914231682645110786']; const tagId = Math.floor(Math.random() * 3); return HttpResponse.json({ code: '0', message: '', data: { id: imgIds[tagId], filename: 'filename.test', }, }); }), http.get('/api/lcdp/v1/deploy/app/info', () => { const status = [1, 2, 3, 4]; return HttpResponse.json({ code: '0', data: [ { appId: 'appId1', name: { 'zh-CN': '应用1' }, appCode: 'appCode1', groupName: { 'zh-CN': '分组1' }, businessName: { 'zh-CN': '业务1' }, description: { 'zh-CN': '描述1' }, status: status[++statusIndex % status.length], computePool: null, }, { appId: 'appId2', name: { 'zh-CN': '应用1' }, appCode: 'appCode2', groupName: { 'zh-CN': '分组1' }, businessName: { 'zh-CN': '业务1' }, description: { 'zh-CN': '描述1' }, status: 2, computePool: null, }, { appId: 'appId3', name: { 'zh-CN': '应用1' }, appCode: 'appCode3', groupName: { 'zh-CN': '分组1' }, businessName: { 'zh-CN': '业务1' }, description: { 'zh-CN': '描述1' }, status: 3, computePool: 'resource3', }, { appId: 'appId4', name: { 'zh-CN': '应用1' }, appCode: 'appCode4', groupName: { 'zh-CN': '分组1' }, businessName: { 'zh-CN': '业务1' }, description: { 'zh-CN': '描述1' }, status: 4, computePool: 'resource4', }, ], }); }), http.get('/api/lcdp/v1/deploy/app/log', () => { return HttpResponse.json({ code: '0', message: '', data: [ { createTime: '1745394969', content: 'create Step 1/6: Start creating the deployment package', }, { createTime: '1745394969', content: 'create Step 2/6: Create the deployment package folder', }, { createTime: '1745394969', content: 'create Step 3_1/6: Generate the basic information and modeling information of the application', }, ], }); }), http.post('/api/lcdp/v1/deploy/app/install', () => { return HttpResponse.json({ code: '0', }); }), ]; export default handlers;