文件上传大小限制相关

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 = {
// 应用标题

View File

@@ -19,7 +19,7 @@
v-for="engineer in availableEngineers"
:key="engineer.userId"
:label="`${engineer.username} (${engineer.statusName || '未知状态'})`"
:value="engineer.userId"
:value="engineer.userId!"
>
<div style="display: flex; justify-content: space-between; align-items: center;">
<span>{{ engineer.username }}</span>
@@ -46,7 +46,7 @@
ref="fileUploadRef"
mode="content"
:max-count="5"
:max-size="10 * 1024 * 1024"
:max-size="FILE_MAX_SIZE"
accept="image/*,.pdf,.doc,.docx,.xls,.xlsx"
:auto-upload="false"
:custom-upload="handleFilesUpload"
@@ -65,12 +65,13 @@
import { ref, computed, watch } from 'vue'
import { ElDialog, ElButton, ElInput, ElSelect, ElOption, ElMessage } from 'element-plus'
import { FileUpload } from 'shared/components'
import { fileAPI } from 'shared/api'
import { fileAPI } from 'shared/api/file'
import { workcaseAPI } from '@/api/workcase'
import { workcaseChatAPI } from '@/api/workcase/workcaseChat'
import type { TbWorkcaseProcessDTO } from '@/types/workcase/workcase'
import type { CustomerServiceVO } from '@/types/workcase/customer'
import type { TbSysFileDTO } from 'shared/types'
import { FILE_MAX_SIZE } from '@/config'
interface Props {
/** 是否显示弹窗 */

View File

@@ -216,6 +216,9 @@ export const FILE_UPLOAD_URL = config.file.uploadUrl;
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 = {
// 应用标题

View File

@@ -8,7 +8,7 @@
:title="'上传文档到:' + currentKnowledgeName"
button-text="上传文档"
accept=".pdf,.doc,.docx,.txt,.md"
:max-size="50 * 1024 * 1024"
:max-size="FILE_MAX_SIZE"
:max-count="10"
:custom-upload="customKnowledgeUpload"
@upload-error="handleUploadError"
@@ -110,7 +110,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'
import { aiKnowledgeAPI } from 'shared/api/ai'
import { FileUpload, FileHistory } from 'shared/components'
import DocumentSegment from 'shared/components/ai/knowledge/DocumentSegment.vue'
import { FILE_DOWNLOAD_URL } from '@/config/index'
import { FILE_DOWNLOAD_URL, FILE_MAX_SIZE } from '@/config/index'
import type { TbKnowledge } from 'shared/types'
// Tab 配置

View File

@@ -280,7 +280,7 @@ import type {
DifyFileInfo,
TbSysFileDTO
} from 'shared/types'
import { AGENT_ID, FILE_DOWNLOAD_URL } from '@/config'
import { AGENT_ID, FILE_DOWNLOAD_URL, FILE_MAX_SIZE } from '@/config'
// 用户信息TODO: 从实际用户store获取
const userId = computed(()=>{
@@ -737,10 +737,9 @@ const uploadFile = async (file: File) => {
return
}
// 文件大小限制 10MB
const maxSize = 10 * 1024 * 1024
if (file.size > maxSize) {
console.error('文件大小超过10MB限制')
// 文件大小限制
if (file.size > FILE_MAX_SIZE) {
console.error(`文件大小超过${FILE_MAX_SIZE / 1024 / 1024}MB限制`)
return
}
@@ -782,7 +781,7 @@ const loadMessagesFilesInfo = async (messageList: TbChatMessage[]) => {
messageList.forEach(msg => {
if (msg.files) {
const filesArray = Array.isArray(msg.files) ? msg.files : [msg.files]
filesArray.forEach(id => {
filesArray.forEach((id: string) => {
if (id && !fileInfoCache.value.has(id)) {
fileIds.push(id)
}

View File

@@ -256,7 +256,7 @@
ref="processFileUploadRef"
mode="content"
:max-count="5"
:max-size="10 * 1024 * 1024"
:max-size="FILE_MAX_SIZE"
accept="image/*,.pdf,.doc,.docx,.xls,.xlsx"
v-model:file-list="processUploadedFiles"
@upload-success="handleProcessUploadSuccess"
@@ -292,7 +292,7 @@ import { workcaseAPI } from '@/api/workcase'
import { fileAPI } from 'shared/api/file'
import { FileUpload } from 'shared/components'
import { WorkcaseAssign } from '@/components'
import { FILE_DOWNLOAD_URL } from '@/config'
import { FILE_DOWNLOAD_URL, FILE_MAX_SIZE } from '@/config'
interface Props {
mode?: 'view' | 'edit' | 'create'