export default { 'POST /api/v1/images/queryimagesList': (req: any, res: any) => { const { page_size, page_num } = req.body; const data = []; function getRandomFormat() { const random = Math.random(); // 生成 0 ~ 1 的随机数 if (random < 0.33) { return 1; } else if (random < 0.66) { return 2; } else { return 3; } } for (let i = 1; i <= page_size; i++) { data.push({ image_id: i, image_name: `周俊星${(page_num - 1) * page_size + i}`, image_type: getRandomFormat(), bt_path: `/serve/logs`, storage_path: '/mock/images', create_time: +new Date(), }); } const result = { error_code: '0000000000', message: '操作成功', data: { paging: { total: 520, total_num: 520, page_num: page_num, page_size: page_size, }, data: data, }, }; setTimeout(() => { res.send(result); }, 500); }, 'POST /api/v1/images/file/chunk/upload': (req: any, res: any) => { // 打印所有接收到的字段 console.log('=== 分片上传信息 ==='); console.log('文件ID:', req.body.file_id); console.log('文件名:', req.body.file_name); console.log('文件大小:', req.body.file_size); console.log('分片索引:', req.body.shard_index); console.log('分片总数:', req.body.shard_total); console.log('分片大小:', req.body.chunk_size); console.log('分片MD5:', req.body.chunk_md5); // 如果有文件上传,打印文件信息 if (req.files && req.files.chunk) { console.log('上传的分片文件:', req.files.chunk); } // 模拟上传进度 const shardIndex = parseInt(req.body.shard_index); const shardTotal = parseInt(req.body.shard_total); console.log(`分片上传进度: ${shardIndex + 1}/${shardTotal}`); // 模拟上传完成(最后一个分片) if (shardIndex === shardTotal - 1) { console.log('文件上传完成!'); res.send({ success: true, error_code: '0000000000', message: '操作成功', data: { file_id: req.body.file_id, message: '文件上传成功', }, }); } else { // 模拟上传中 const progress = Math.round(((shardIndex + 1) / shardTotal) * 100); console.log(`上传进度: ${progress}%`); res.send({ success: false, error_code: '1221000001', message: `上传中... ${progress}%`, data: { uploaded: shardIndex + 1, total: shardTotal, progress: progress, }, }); } }, };