!845 fix: 修复富文本编辑器不能上传同一文件问题、添加存储目录定义

Merge pull request !845 from 半栈幼儿员/hotfix/editor
pull/846/MERGE
芋道源码 2025-12-28 13:22:17 +00:00 committed by Gitee
commit 96fd1f9e4f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 31 additions and 4 deletions

View File

@ -28,7 +28,8 @@ const props = defineProps({
default: () => undefined
},
readonly: propTypes.bool.def(false),
modelValue: propTypes.string.def('')
modelValue: propTypes.string.def(''),
directory: propTypes.string.def('editor-default')
})
const emit = defineEmits(['change', 'update:modelValue'])
@ -115,9 +116,9 @@ const editorConfig = computed((): IEditorConfig => {
['uploadImage']: {
server: getUploadUrl(),
// 2M
maxFileSize: 5 * 1024 * 1024,
maxFileSize: 10 * 1024 * 1024,
// 100
maxNumberOfFiles: 10,
maxNumberOfFiles: 100,
// ['image/*'] []
allowedFileTypes: ['image/*'],
@ -133,6 +134,19 @@ const editorConfig = computed((): IEditorConfig => {
// form-data fieldNamewangeditor-uploaded-image
fieldName: 'file',
//
meta: {
directory: `${props.directory}-image`
},
metaWithUrl: false,
// uppy
uppyConfig: {
onBeforeFileAdded: (newFile: any) => {
newFile.id = `${newFile.id}-${Date.now()}`
return newFile
}
},
//
onBeforeUpload(file: File) {
@ -163,7 +177,7 @@ const editorConfig = computed((): IEditorConfig => {
['uploadVideo']: {
server: getUploadUrl(),
// 10M
maxFileSize: 10 * 1024 * 1024,
maxFileSize: 1024 * 1024 * 1024,
// 100
maxNumberOfFiles: 10,
// ['video/*'] []
@ -181,6 +195,19 @@ const editorConfig = computed((): IEditorConfig => {
// form-data fieldNamewangeditor-uploaded-image
fieldName: 'file',
//
meta: {
directory: `${props.directory}-video`
},
metaWithUrl: false,
// uppy
uppyConfig: {
onBeforeFileAdded: (newFile: any) => {
newFile.id = `${newFile.id}-${Date.now()}`
return newFile
}
},
//
onBeforeUpload(file: File) {