fix: 1.将合同模板和交叉评查中的文件下载改用通过后端api进行转发获取文件来下载。 2.修复登录过程中token认证的代码问题。 3.完善api-config文件中不同端口号不同的回调地址配置。

This commit is contained in:
2025-11-07 18:36:15 +08:00
parent 80f05da984
commit b375c35825
5 changed files with 153 additions and 180 deletions
+35 -12
View File
@@ -2,11 +2,15 @@
* 交叉评查文件信息组件
*/
// 导入统一的下载方法和提示服务
import { downloadFile } from '~/api/axios-client';
import { toastService } from '~/components/ui/Toast';
interface FileInfoProps {
fileInfo: {
fileName: string;
contractNumber: string;
fileSize?: string;
fileSize?: string;
fileFormat?: string;
pageCount?: number;
uploadTime?: string;
@@ -21,17 +25,36 @@ interface FileInfoProps {
export function FileInfo({ fileInfo, onConfirmResults }: FileInfoProps) {
const handleDownloadFile = () => {
if (fileInfo.path) {
// 创建一个隐藏的下载链接
const link = document.createElement('a');
link.href = fileInfo.path;
link.download = fileInfo.fileName;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
} else {
alert('文件路径不存在,无法下载');
// 使用统一的下载方法(与 rules-files.tsx 相同)
const handleDownloadFile = async () => {
if (!fileInfo.path) {
toastService.error('文件路径不存在,无法下载');
return;
}
try {
// 使用axios封装的下载方法
const blob = await downloadFile(fileInfo.path);
// 创建Blob URL
const blobUrl = URL.createObjectURL(blob);
// 创建一个隐藏的a标签并点击它
const a = document.createElement('a');
a.style.display = 'none';
a.href = blobUrl;
a.download = fileInfo.fileName || 'document';
document.body.appendChild(a);
a.click();
// 清理
setTimeout(() => {
document.body.removeChild(a);
URL.revokeObjectURL(blobUrl);
}, 100);
} catch (error) {
console.error('下载文件失败:', error);
toastService.error(`下载文件失败: ${error instanceof Error ? error.message : '未知错误'}`);
}
};