feat(文件管理): 文件管理页面部分接口

This commit is contained in:
baiqi 2023-10-27 11:09:47 +08:00 committed by 建国
parent e9ac9d34e9
commit 0da79cbe4f
6 changed files with 20 additions and 12 deletions

View File

@ -62,12 +62,12 @@ export function deleteFile(data: BatchFileApiParams) {
// 下载文件
export function downloadFile(id: string) {
return MSR.get({ url: DownloadFileUrl, params: id }, { isTransformResponse: false });
return MSR.get({ url: DownloadFileUrl, params: id, responseType: 'blob' }, { isTransformResponse: false });
}
// 批量下载文件
export function batchDownloadFile(data: BatchFileApiParams) {
return MSR.post({ url: BatchDownloadFileUrl, data }, { isTransformResponse: false });
return MSR.post({ url: BatchDownloadFileUrl, data, responseType: 'blob' }, { isTransformResponse: false });
}
// 更新模块

View File

@ -11,3 +11,4 @@ export const AddModuleUrl = '/project/file-module/add'; // 添加模块
export const GetModuleUrl = '/project/file-module/tree'; // 查找模块
export const DeleteModuleUrl = '/project/file-module/delete'; // 删除模块
export const GetModuleCountUrl = '/project/file/module/count'; // 模块统计文件数量
export const PreviewImgUrl = '/project/file/download/preview-img'; // 预览图片文件接口

View File

@ -4,7 +4,13 @@
<div class="ms-thumbnail-card-more">
<MsTableMoreAction v-if="props.moreActions" :list="props.moreActions" @select="handleMoreActionSelect" />
</div>
<a-image v-if="fileType === 'image'" :src="props.url" class="absolute top-0 h-full w-full" :preview="false" />
<a-image
v-if="fileType === 'image'"
:src="props.url"
class="absolute top-0 h-full w-full"
:preview="false"
hide-footer
/>
<MsIcon
v-else
:type="FileIconMap[fileType][UploadStatus.done]"

View File

@ -16,13 +16,7 @@
<a-list-item-meta>
<template #avatar>
<a-avatar shape="square" class="rounded-[var(--border-radius-mini)] bg-[var(--color-text-n9)]">
<a-image
v-if="item.file.type.includes('image/')"
:src="item.url"
:alt="item.file.name"
width="40"
height="40"
/>
<a-image v-if="item.file.type.includes('image/')" :src="item.url" width="40" height="40" hide-footer />
<MsIcon
v-else
:type="getFileIcon(item)"

View File

@ -2,7 +2,11 @@
<a-upload
v-bind="{ ...props }"
v-model:file-list="fileList"
:accept="UploadAcceptEnum[props.accept]"
:accept="
[UploadAcceptEnum.none, UploadAcceptEnum.unknown].includes(UploadAcceptEnum[props.accept])
? '*'
: UploadAcceptEnum[props.accept]
"
:multiple="props.multiple"
:disabled="props.disabled"
@change="handleChange"
@ -75,6 +79,7 @@
maxSize: number; // MB
sizeUnit: 'MB' | 'KB'; //
isLimit: boolean; //
draggable: boolean; //
}> & {
accept: UploadType;
fileList: MsFileItem[];

View File

@ -84,7 +84,7 @@
<template #item="{ item, index }">
<MsThumbnailCard
:type="item.fileType"
:url="`http://172.16.200.18:8081${item.previewSrc}.${item.fileType}`"
:url="item.url || `${PreviewImgUrl}/${item.id}`"
:footer-text="item.name"
:more-actions="item.fileType === 'JAR' ? jarFileActions : normalFileActions"
@click="openFileDetail(item.id, index)"
@ -129,6 +129,7 @@
:auto-upload="false"
:sub-text="acceptType === 'jar' ? '' : t('project.fileManagement.normalFileSubText', { size: 50 })"
multiple
draggable
size-unit="MB"
class="mb-[16px] w-full"
@change="handleFileChange"
@ -292,6 +293,7 @@
updateFile,
uploadFile,
} from '@/api/modules/project-management/fileManagement';
import { PreviewImgUrl } from '@/api/requrls/project-management/fileManagement';
import { useI18n } from '@/hooks/useI18n';
import useModal from '@/hooks/useModal';
import useAppStore from '@/store/modules/app';