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) { 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) { 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 GetModuleUrl = '/project/file-module/tree'; // 查找模块
export const DeleteModuleUrl = '/project/file-module/delete'; // 删除模块 export const DeleteModuleUrl = '/project/file-module/delete'; // 删除模块
export const GetModuleCountUrl = '/project/file/module/count'; // 模块统计文件数量 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"> <div class="ms-thumbnail-card-more">
<MsTableMoreAction v-if="props.moreActions" :list="props.moreActions" @select="handleMoreActionSelect" /> <MsTableMoreAction v-if="props.moreActions" :list="props.moreActions" @select="handleMoreActionSelect" />
</div> </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 <MsIcon
v-else v-else
:type="FileIconMap[fileType][UploadStatus.done]" :type="FileIconMap[fileType][UploadStatus.done]"

View File

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

View File

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

View File

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