export const downloadFile = (blob: any, fileName: string) => { const downUrl = window.URL.createObjectURL(new Blob([blob])); const elementA = document.createElement('a'); elementA.href = downUrl; elementA.download = fileName; elementA.style.display = 'none'; document.body.appendChild(elementA); elementA.click(); document.body.removeChild(elementA); }; // 其他工具函数... // 切片数据 分为 正常 和 废弃两种 export const processSliceData = (data: any) => { const result = data.reduce((acc: any, item: any) => { // 1. 筛选出 slice_type 为 'deprecated' 的 chunks const deprecatedChunks = item.chunk_info_list.filter((chunk: any) => chunk.slice_type === 'deprecated'); // 2. 筛选出 slice_type 不为 'deprecated' 的 chunks (例如 'normal') const normalChunks = item.chunk_info_list.filter((chunk: any) => chunk.slice_type !== 'deprecated'); // 3. 如果筛选结果不为空,则创建一个新的文档对象并添加到对应的数组中 if (deprecatedChunks.length > 0) { acc.withDeprecated.push({ ...item, // 复制原文档的所有属性 chunk_info_list: deprecatedChunks // 用筛选后的 chunks 替换原有的 chunk_info_list }); } if (normalChunks.length > 0) { acc.withoutDeprecated.push({ ...item, // 复制原文档的所有属性 chunk_info_list: normalChunks // 用筛选后的 chunks 替换原有的 chunk_info_list }); } // 返回累加器以供下一次迭代使用 return acc; }, { withDeprecated: [], withoutDeprecated: [] }); return result; } // 重定向地址 export const replaceUrl = 'http://10.1.14.17:3200/login'; // export const replaceUrl = 'http://192.168.110.12:3100/login';