文件上传大小限制相关

This commit is contained in:
2025-12-31 15:43:02 +08:00
parent 4f0eeede37
commit 1bb1dba4d6
7 changed files with 24 additions and 18 deletions

View File

@@ -130,7 +130,7 @@
</div>
<div class="info">
<div class="name">{{ file.name || file.fileName || '未知文件' }}</div>
<div class="name">{{ file.name || '未知文件' }}</div>
<div class="size">{{ file.size ? formatFileSize(file.size) : '' }}</div>
</div>
@@ -148,7 +148,7 @@
<script setup lang="ts">
import { ref, computed } from 'vue'
import { FILE_DOWNLOAD_URL } from '@/config'
import { FILE_DOWNLOAD_URL, FILE_MAX_SIZE } from '@/config'
import { fileAPI } from '@/api/file/file'
import type { TbSysFileDTO } from '@/types/file/file'
import { ElButton, ElDialog } from 'element-plus'
@@ -179,7 +179,7 @@ const props = withDefaults(defineProps<Props>(), {
coverImg: '',
fileList: () => [],
accept: '',
maxSize: 10 * 1024 * 1024,
maxSize: FILE_MAX_SIZE,
maxCount: 10,
title: '文件上传',
buttonText: '上传文件',
@@ -226,7 +226,7 @@ const currentFileList = computed(() => {
// 判断已上传文件是否为图片
const isUploadedImageFile = (file: InternalFile): boolean => {
if (file.localPreviewUrl) return true // 有本地预览说明是图片
const mimeType = file.mimeType || file.extension || ''
const mimeType = file.mimeType || ''
return mimeType.includes('image') || /\.(jpg|jpeg|png|gif|webp|bmp)$/i.test(file.name || '')
}
@@ -240,7 +240,7 @@ const getUploadedFileUrl = (file: InternalFile): string => {
// 获取已上传文件的类型图标
const getUploadedFileTypeIcon = (file: InternalFile): string => {
const ext = file.extension || file.name?.split('.').pop() || ''
const ext = file.type || file.name?.split('.').pop() || ''
const iconMap: Record<string, string> = {
pdf: '📄',
doc: '📝',

View File

@@ -205,6 +205,9 @@ export const FILE_DOWNLOAD_URL = config.file.downloadUrl;
export const PUBLIC_IMG_PATH = config.publicImgPath;
export const PUBLIC_WEB_PATH = config.publicWebPath;
// 文件上传大小限制100MB
export const FILE_MAX_SIZE = 100 * 1024 * 1024;
// 导出完整配置对象
export const APP_CONFIG = {
// 应用标题