feat(file): 优化文件管理页面功能
- 新增MinIO存储服务选项支持 - 集成CoiImageViewer组件替换原生图片预览功能 - 移除冗余的图片预览弹框代码,提升代码简洁性 - 优化图片文件的展示效果和预览体验 - 统一存储服务类型的标签显示样式
This commit is contained in:
parent
0d54a2d119
commit
a6dc2f90ae
@ -217,6 +217,7 @@
|
|||||||
:options="[
|
:options="[
|
||||||
{ label: 'LOCAL', value: 'LOCAL' },
|
{ label: 'LOCAL', value: 'LOCAL' },
|
||||||
{ label: 'OSS', value: 'OSS' },
|
{ label: 'OSS', value: 'OSS' },
|
||||||
|
{ label: 'MINIO', value: 'MINIO' },
|
||||||
]"
|
]"
|
||||||
/>
|
/>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
@ -271,36 +272,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</CoiDialog>
|
</CoiDialog>
|
||||||
|
|
||||||
<!-- 图片预览弹框 -->
|
|
||||||
<n-modal
|
|
||||||
v-model:show="imagePreviewVisible"
|
|
||||||
preset="card"
|
|
||||||
title="图片预览"
|
|
||||||
:style="{ width: '80%', maxWidth: '800px' }"
|
|
||||||
:mask-closable="true"
|
|
||||||
>
|
|
||||||
<div class="text-center">
|
|
||||||
<img
|
|
||||||
v-if="previewImageUrl"
|
|
||||||
:src="previewImageUrl"
|
|
||||||
:alt="previewImageName"
|
|
||||||
class="max-w-full max-h-96 mx-auto"
|
|
||||||
>
|
|
||||||
<div class="mt-2 text-sm text-gray-500">
|
|
||||||
{{ previewImageName }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</n-modal>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { h, onMounted, ref } from 'vue'
|
import { h, onMounted, ref } from 'vue'
|
||||||
import { NButton, NIcon, NImage, NP, NPopconfirm, NSpace, NTag, NText, NUpload, NUploadDragger } from 'naive-ui'
|
import { NButton, NIcon, NP, NPopconfirm, NSpace, NTag, NText, NUpload, NUploadDragger } from 'naive-ui'
|
||||||
import type { DataTableColumns, DataTableInst, FormInst, UploadFileInfo, UploadInst } from 'naive-ui'
|
import type { DataTableColumns, DataTableInst, FormInst, UploadFileInfo, UploadInst } from 'naive-ui'
|
||||||
import CoiEmpty from '@/components/common/CoiEmpty.vue'
|
import CoiEmpty from '@/components/common/CoiEmpty.vue'
|
||||||
import CoiPagination from '@/components/common/CoiPagination.vue'
|
import CoiPagination from '@/components/common/CoiPagination.vue'
|
||||||
|
import CoiImageViewer from '@/components/common/CoiImageViewer.vue'
|
||||||
import { coiMsgBox, coiMsgError, coiMsgSuccess, coiMsgWarning } from '@/utils/coi'
|
import { coiMsgBox, coiMsgError, coiMsgSuccess, coiMsgWarning } from '@/utils/coi'
|
||||||
import { usePermission } from '@/hooks/usePermission'
|
import { usePermission } from '@/hooks/usePermission'
|
||||||
import { PERMISSIONS } from '@/constants/permissions'
|
import { PERMISSIONS } from '@/constants/permissions'
|
||||||
@ -360,11 +341,6 @@ const searchForm = ref<SysFileSearchForm>({
|
|||||||
fileType: '0', // 默认全部
|
fileType: '0', // 默认全部
|
||||||
})
|
})
|
||||||
|
|
||||||
// 图片预览相关
|
|
||||||
const imagePreviewVisible = ref(false)
|
|
||||||
const previewImageUrl = ref('')
|
|
||||||
const previewImageName = ref('')
|
|
||||||
|
|
||||||
// 文件上传相关
|
// 文件上传相关
|
||||||
const uploadFileList = ref<UploadFileInfo[]>([])
|
const uploadFileList = ref<UploadFileInfo[]>([])
|
||||||
const uploading = ref(false)
|
const uploading = ref(false)
|
||||||
@ -458,14 +434,13 @@ const columns: DataTableColumns<SysFileVo> = [
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (isImage && row.filePath) {
|
if (isImage && row.filePath) {
|
||||||
return h(NImage, {
|
return h(CoiImageViewer, {
|
||||||
src: row.filePath,
|
src: row.filePath,
|
||||||
width: 45,
|
alt: row.fileName,
|
||||||
height: 30,
|
width: 50,
|
||||||
objectFit: 'cover',
|
height: 40,
|
||||||
previewDisabled: true,
|
previewable: true,
|
||||||
onClick: () => handleImagePreview(row.filePath!, row.fileName),
|
title: `文件预览 - ${row.fileName}`,
|
||||||
class: 'cursor-pointer rounded border',
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,6 +456,7 @@ const columns: DataTableColumns<SysFileVo> = [
|
|||||||
render: (row) => {
|
render: (row) => {
|
||||||
const serviceMap: Record<string, { type: 'success' | 'info' | 'warning', text: string }> = {
|
const serviceMap: Record<string, { type: 'success' | 'info' | 'warning', text: string }> = {
|
||||||
1: { type: 'success', text: '本地存储' },
|
1: { type: 'success', text: '本地存储' },
|
||||||
|
2: { type: 'info', text: 'MinIO存储' },
|
||||||
3: { type: 'warning', text: '阿里云OSS' },
|
3: { type: 'warning', text: '阿里云OSS' },
|
||||||
}
|
}
|
||||||
const config = serviceMap[row.fileService] || { type: 'info', text: '未知' }
|
const config = serviceMap[row.fileService] || { type: 'info', text: '未知' }
|
||||||
@ -676,13 +652,6 @@ function handleDownload(row: SysFileVo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 图片预览
|
|
||||||
function handleImagePreview(url: string, name: string) {
|
|
||||||
previewImageUrl.value = url
|
|
||||||
previewImageName.value = name
|
|
||||||
imagePreviewVisible.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// 文件上传相关函数
|
// 文件上传相关函数
|
||||||
|
|
||||||
// 打开上传弹框
|
// 打开上传弹框
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user