|
@@ -623,23 +623,17 @@ const getCategoryTree = async () => {
|
|
|
categoryTree.value = response.data || [];
|
|
categoryTree.value = response.data || [];
|
|
|
categoryList.value = flattenCategories(categoryTree.value);
|
|
categoryList.value = flattenCategories(categoryTree.value);
|
|
|
|
|
|
|
|
- console.log('getCategoryTree - response.data:', response.data);
|
|
|
|
|
- console.log('getCategoryTree - categoryTree.value:', categoryTree.value);
|
|
|
|
|
-
|
|
|
|
|
// 获取顶级分类(parent_id为0的分类)
|
|
// 获取顶级分类(parent_id为0的分类)
|
|
|
topCategories.value = categoryTree.value.filter((category) => category.parentId === 0 || category.parentId === null);
|
|
topCategories.value = categoryTree.value.filter((category) => category.parentId === 0 || category.parentId === null);
|
|
|
- console.log('getCategoryTree - topCategories.value:', topCategories.value);
|
|
|
|
|
|
|
|
|
|
// 默认不选择任何顶级分类,显示所有文件
|
|
// 默认不选择任何顶级分类,显示所有文件
|
|
|
if (!currentTopCategory.value) {
|
|
if (!currentTopCategory.value) {
|
|
|
currentTopCategory.value = null;
|
|
currentTopCategory.value = null;
|
|
|
queryParams.value.categoryType = null;
|
|
queryParams.value.categoryType = null;
|
|
|
- console.log('getCategoryTree - set currentTopCategory to null (show all files)');
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return response;
|
|
return response;
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
- console.error('获取分类树失败:', error);
|
|
|
|
|
ElMessage.error('获取分类树失败');
|
|
ElMessage.error('获取分类树失败');
|
|
|
throw error;
|
|
throw error;
|
|
|
}
|
|
}
|
|
@@ -687,7 +681,6 @@ const toggleExpand = (categoryId) => {
|
|
|
// 如果未展开,则展开
|
|
// 如果未展开,则展开
|
|
|
expandedKeys.value.push(categoryId);
|
|
expandedKeys.value.push(categoryId);
|
|
|
}
|
|
}
|
|
|
- console.log('toggleExpand - categoryId:', categoryId, 'expandedKeys:', expandedKeys.value);
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 文件类型判断
|
|
// 文件类型判断
|
|
@@ -845,8 +838,6 @@ const handlePreview = (file) => {
|
|
|
|
|
|
|
|
// 下载文件
|
|
// 下载文件
|
|
|
const handleDownload = async (file) => {
|
|
const handleDownload = async (file) => {
|
|
|
- console.log('下载文件:', file);
|
|
|
|
|
-
|
|
|
|
|
if (!file.url && !file.path) {
|
|
if (!file.url && !file.path) {
|
|
|
ElMessage.error('文件URL不存在');
|
|
ElMessage.error('文件URL不存在');
|
|
|
return;
|
|
return;
|
|
@@ -868,22 +859,15 @@ const handleDownload = async (file) => {
|
|
|
fileName = fileName + '.' + extension;
|
|
fileName = fileName + '.' + extension;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- console.log('文件URL:', fileUrl);
|
|
|
|
|
- console.log('文件名:', fileName);
|
|
|
|
|
- console.log('文件类型:', file.type);
|
|
|
|
|
- console.log('文件扩展名:', extension);
|
|
|
|
|
-
|
|
|
|
|
try {
|
|
try {
|
|
|
// 如果URL是OSS ID(纯数字),需要先获取文件信息
|
|
// 如果URL是OSS ID(纯数字),需要先获取文件信息
|
|
|
if (/^\d+$/.test(fileUrl)) {
|
|
if (/^\d+$/.test(fileUrl)) {
|
|
|
- console.log('检测到OSS ID,获取文件信息');
|
|
|
|
|
try {
|
|
try {
|
|
|
const { listByIds } = await import('@/api/system/oss');
|
|
const { listByIds } = await import('@/api/system/oss');
|
|
|
const res = await listByIds(fileUrl);
|
|
const res = await listByIds(fileUrl);
|
|
|
if (res.data && res.data.length > 0) {
|
|
if (res.data && res.data.length > 0) {
|
|
|
fileUrl = res.data[0].url;
|
|
fileUrl = res.data[0].url;
|
|
|
fileName = res.data[0].originalName || fileName;
|
|
fileName = res.data[0].originalName || fileName;
|
|
|
- console.log('获取到OSS文件信息:', fileUrl, fileName);
|
|
|
|
|
} else {
|
|
} else {
|
|
|
ElMessage.error('未找到对应的文件信息');
|
|
ElMessage.error('未找到对应的文件信息');
|
|
|
return;
|
|
return;
|
|
@@ -1002,9 +986,6 @@ const handleDownload = async (file) => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- console.log('使用的MIME类型:', mimeType);
|
|
|
|
|
- console.log('最终文件名:', fileName);
|
|
|
|
|
-
|
|
|
|
|
// 创建带有正确MIME类型的blob
|
|
// 创建带有正确MIME类型的blob
|
|
|
const correctBlob = new Blob([blob], { type: mimeType });
|
|
const correctBlob = new Blob([blob], { type: mimeType });
|
|
|
|
|
|
|
@@ -1028,13 +1009,10 @@ const handleDownload = async (file) => {
|
|
|
// 更新下载次数
|
|
// 更新下载次数
|
|
|
updateDownloadCount(file.id)
|
|
updateDownloadCount(file.id)
|
|
|
.then(() => {
|
|
.then(() => {
|
|
|
- console.log('下载次数已更新');
|
|
|
|
|
})
|
|
})
|
|
|
.catch((error) => {
|
|
.catch((error) => {
|
|
|
- console.error('更新下载次数失败:', error);
|
|
|
|
|
});
|
|
});
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
- console.error('下载文件失败:', error);
|
|
|
|
|
const msg = error instanceof Error ? error.message : String(error);
|
|
const msg = error instanceof Error ? error.message : String(error);
|
|
|
ElMessage.error('下载文件失败: ' + msg);
|
|
ElMessage.error('下载文件失败: ' + msg);
|
|
|
}
|
|
}
|
|
@@ -1042,7 +1020,6 @@ const handleDownload = async (file) => {
|
|
|
|
|
|
|
|
// 重命名文件
|
|
// 重命名文件
|
|
|
const handleRename = (file) => {
|
|
const handleRename = (file) => {
|
|
|
- console.log('重命名文件:', file);
|
|
|
|
|
renameForm.value = {
|
|
renameForm.value = {
|
|
|
id: file.id,
|
|
id: file.id,
|
|
|
name: file.name || file.originalName || '',
|
|
name: file.name || file.originalName || '',
|
|
@@ -1088,13 +1065,7 @@ const submitRename = async () => {
|
|
|
// 刷新文件列表
|
|
// 刷新文件列表
|
|
|
getList();
|
|
getList();
|
|
|
|
|
|
|
|
- console.log('重命名文件:', {
|
|
|
|
|
- id: renameForm.value.id,
|
|
|
|
|
- oldName: renameForm.value.originalName,
|
|
|
|
|
- newName: renameForm.value.name.trim()
|
|
|
|
|
- });
|
|
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
- console.error('重命名失败:', error);
|
|
|
|
|
ElMessage.error('重命名失败');
|
|
ElMessage.error('重命名失败');
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
@@ -1185,7 +1156,6 @@ const updateFileInfoCategory = async (fileId, categoryId) => {
|
|
|
};
|
|
};
|
|
|
// 这里需要调用更新文件信息的API,暂时注释掉
|
|
// 这里需要调用更新文件信息的API,暂时注释掉
|
|
|
// await updateFileInfo(fileInfo);
|
|
// await updateFileInfo(fileInfo);
|
|
|
- console.log('更新文件分类:', fileId, categoryId);
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 添加分类
|
|
// 添加分类
|
|
@@ -1208,7 +1178,6 @@ const handleAddCategory = () => {
|
|
|
|
|
|
|
|
// 添加子分类
|
|
// 添加子分类
|
|
|
const handleAddChildCategory = (parentCategory) => {
|
|
const handleAddChildCategory = (parentCategory) => {
|
|
|
- console.log('添加子分类,父分类:', parentCategory);
|
|
|
|
|
categoryDialogVisible.value = true;
|
|
categoryDialogVisible.value = true;
|
|
|
categoryDialogTitle.value = `添加子分类 - ${parentCategory.name}`;
|
|
categoryDialogTitle.value = `添加子分类 - ${parentCategory.name}`;
|
|
|
categoryForm.value = {
|
|
categoryForm.value = {
|
|
@@ -1317,15 +1286,11 @@ const submitCategory = async () => {
|
|
|
|
|
|
|
|
// 上传前检查
|
|
// 上传前检查
|
|
|
const beforeUpload = (file) => {
|
|
const beforeUpload = (file) => {
|
|
|
- console.log('开始上传文件:', file.name, '原始MIME类型:', file.type);
|
|
|
|
|
-
|
|
|
|
|
// 获取准确的MIME类型
|
|
// 获取准确的MIME类型
|
|
|
const actualMimeType = getFileMimeType(file);
|
|
const actualMimeType = getFileMimeType(file);
|
|
|
const fileName = file.name || '';
|
|
const fileName = file.name || '';
|
|
|
const extension = fileName.split('.').pop()?.toLowerCase();
|
|
const extension = fileName.split('.').pop()?.toLowerCase();
|
|
|
|
|
|
|
|
- console.log('检测到的MIME类型:', actualMimeType, '文件扩展名:', extension);
|
|
|
|
|
-
|
|
|
|
|
// 如果选择了分类或有分类类型,检查文件类型
|
|
// 如果选择了分类或有分类类型,检查文件类型
|
|
|
const categoryTypeToCheck = uploadForm.value.categoryType || getCategoryType(uploadForm.value.categoryId);
|
|
const categoryTypeToCheck = uploadForm.value.categoryType || getCategoryType(uploadForm.value.categoryId);
|
|
|
|
|
|
|
@@ -1369,7 +1334,6 @@ const beforeUpload = (file) => {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- console.log('文件类型验证通过:', fileTypeText, '类型');
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 检查文件大小 (50MB)
|
|
// 检查文件大小 (50MB)
|
|
@@ -1379,7 +1343,6 @@ const beforeUpload = (file) => {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- console.log('文件大小验证通过:', (file.size / 1024 / 1024).toFixed(2), 'MB');
|
|
|
|
|
return true;
|
|
return true;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -1470,7 +1433,6 @@ const onUploadSuccess = (response, file) => {
|
|
|
ossId: response.data?.ossId || ''
|
|
ossId: response.data?.ossId || ''
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- console.log('文件上传成功,MIME类型:', mimeType, '扩展名:', extension);
|
|
|
|
|
} else {
|
|
} else {
|
|
|
ElMessage.error('上传失败:' + response.msg);
|
|
ElMessage.error('上传失败:' + response.msg);
|
|
|
}
|
|
}
|
|
@@ -1518,17 +1480,6 @@ const submitUpload = async () => {
|
|
|
viewCount: 0
|
|
viewCount: 0
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- console.log('保存文件信息到后端:', {
|
|
|
|
|
- 文件名: fileInfo.name,
|
|
|
|
|
- 原始文件名: fileInfo.originalName,
|
|
|
|
|
- MIME类型: fileInfo.type,
|
|
|
|
|
- 文件扩展名: fileInfo.extension,
|
|
|
|
|
- 文件大小: (fileInfo.size / 1024 / 1024).toFixed(2) + 'MB',
|
|
|
|
|
- 文件主分类: fileInfo.categoryType,
|
|
|
|
|
- 分类ID: fileInfo.categoryId,
|
|
|
|
|
- 文件URL: fileInfo.url
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
return addFileInfo(fileInfo);
|
|
return addFileInfo(fileInfo);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -1797,7 +1748,6 @@ const handlePreviewText = (file) => {
|
|
|
|
|
|
|
|
// 切换顶级分类
|
|
// 切换顶级分类
|
|
|
const switchTopCategory = (topCategory) => {
|
|
const switchTopCategory = (topCategory) => {
|
|
|
- console.log('switchTopCategory - switching to:', topCategory);
|
|
|
|
|
currentTopCategory.value = topCategory;
|
|
currentTopCategory.value = topCategory;
|
|
|
currentCategory.value = null;
|
|
currentCategory.value = null;
|
|
|
selectedFiles.value = [];
|
|
selectedFiles.value = [];
|
|
@@ -1808,10 +1758,8 @@ const switchTopCategory = (topCategory) => {
|
|
|
if (topCategory && topCategory.type) {
|
|
if (topCategory && topCategory.type) {
|
|
|
// 按类型过滤(1=图片,2=视频,3=音频,4=文档)
|
|
// 按类型过滤(1=图片,2=视频,3=音频,4=文档)
|
|
|
queryParams.value.categoryType = topCategory.type;
|
|
queryParams.value.categoryType = topCategory.type;
|
|
|
- console.log('switchTopCategory - set categoryType to type:', topCategory.type);
|
|
|
|
|
} else {
|
|
} else {
|
|
|
queryParams.value.categoryType = null;
|
|
queryParams.value.categoryType = null;
|
|
|
- console.log('switchTopCategory - cleared categoryType (show all files)');
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
getList();
|
|
getList();
|
|
@@ -1888,11 +1836,7 @@ const toggleFileSelection = (id, checked = null) => {
|
|
|
|
|
|
|
|
// 根据当前顶级分类过滤子分类
|
|
// 根据当前顶级分类过滤子分类
|
|
|
const filteredCategoryTree = computed(() => {
|
|
const filteredCategoryTree = computed(() => {
|
|
|
- console.log('filteredCategoryTree computed - currentTopCategory:', currentTopCategory.value);
|
|
|
|
|
- console.log('filteredCategoryTree computed - categoryTree:', categoryTree.value);
|
|
|
|
|
-
|
|
|
|
|
if (!currentTopCategory.value || !categoryTree.value || categoryTree.value.length === 0) {
|
|
if (!currentTopCategory.value || !categoryTree.value || categoryTree.value.length === 0) {
|
|
|
- console.log('filteredCategoryTree computed - returning empty array');
|
|
|
|
|
return [];
|
|
return [];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1901,15 +1845,12 @@ const filteredCategoryTree = computed(() => {
|
|
|
// 在顶级分类中查找对应的分类
|
|
// 在顶级分类中查找对应的分类
|
|
|
const parentCategory = categoryTree.value.find((category) => category.id === parentId);
|
|
const parentCategory = categoryTree.value.find((category) => category.id === parentId);
|
|
|
if (parentCategory && parentCategory.children) {
|
|
if (parentCategory && parentCategory.children) {
|
|
|
- console.log('getSubCategories - parentId:', parentId, 'subCategories:', parentCategory.children);
|
|
|
|
|
return parentCategory.children;
|
|
return parentCategory.children;
|
|
|
}
|
|
}
|
|
|
- console.log('getSubCategories - parentId:', parentId, 'subCategories: not found');
|
|
|
|
|
return [];
|
|
return [];
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const result = getSubCategories(currentTopCategory.value.id);
|
|
const result = getSubCategories(currentTopCategory.value.id);
|
|
|
- console.log('filteredCategoryTree computed - result:', result);
|
|
|
|
|
return result;
|
|
return result;
|
|
|
});
|
|
});
|
|
|
|
|
|