Explorar o código

!845 fix: 修复富文本编辑器不能上传同一文件问题、添加存储目录定义
Merge pull request !845 from 半栈幼儿员/hotfix/editor

芋道源码 hai 1 mes
pai
achega
96fd1f9e4f
Modificáronse 1 ficheiros con 31 adicións e 4 borrados
  1. 31 4
      src/components/Editor/src/Editor.vue

+ 31 - 4
src/components/Editor/src/Editor.vue

@@ -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 fieldName,后端接口参数名称,默认值wangeditor-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 fieldName,后端接口参数名称,默认值wangeditor-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) {