新增文档列表的修改页面
This commit is contained in:
@@ -10,7 +10,7 @@ import { FileTypeTag } from "~/components/ui/FileTypeTag";
|
||||
import { FileTag } from "~/components/ui/FileTag";
|
||||
import { FilterPanel, FilterSelect, SearchFilter, DateRangeFilter } from "~/components/ui/FilterPanel";
|
||||
import documentsIndexStyles from "~/styles/pages/documents_index.css?url";
|
||||
import { getDocuments, deleteDocument, type DocumentUI } from "~/api/files/documents";
|
||||
import { getDocuments, deleteDocument, type DocumentUI, getFileDownloadUrl } from "~/api/files/documents";
|
||||
import { getDocumentTypes } from "~/api/document-types/document-types";
|
||||
|
||||
// 导入样式
|
||||
@@ -288,15 +288,30 @@ export default function DocumentsIndex() {
|
||||
};
|
||||
|
||||
// 下载文档
|
||||
const handleDownload = (path: string, fileName: string) => {
|
||||
const handleDownload = async (path: string, fileName: string) => {
|
||||
console.log('handleDownload',path,fileName)
|
||||
// 创建一个隐藏的a标签并点击它
|
||||
const a = document.createElement('a');
|
||||
a.href = path;
|
||||
a.download = fileName; // 设置下载的文件名
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
try {
|
||||
// 使用API获取授权的下载链接
|
||||
// const { data, error } = await getFileDownloadUrl(path);
|
||||
|
||||
// if (error || !data?.downloadUrl) {
|
||||
// console.error('获取下载链接失败:', error);
|
||||
// alert('获取下载链接失败: ' + (error || '未知错误'));
|
||||
// return;
|
||||
// }
|
||||
|
||||
// 创建一个隐藏的a标签并点击它
|
||||
const a = document.createElement('a');
|
||||
// a.href = data.downloadUrl;
|
||||
a.href = path;
|
||||
a.download = fileName; // 设置下载的文件名
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
} catch (err) {
|
||||
console.error('下载文件失败:', err);
|
||||
alert('下载文件失败: ' + (err instanceof Error ? err.message : '未知错误'));
|
||||
}
|
||||
};
|
||||
|
||||
// 删除文档
|
||||
|
||||
Reference in New Issue
Block a user