mirror of
https://gitee.com/yudaocode/yudao-ui-admin-vue3.git
synced 2025-12-30 09:32:26 +00:00
!845 fix: 修复富文本编辑器不能上传同一文件问题、添加存储目录定义
Merge pull request !845 from 半栈幼儿员/hotfix/editor
This commit is contained in:
@@ -28,7 +28,8 @@ const props = defineProps({
|
|||||||
default: () => undefined
|
default: () => undefined
|
||||||
},
|
},
|
||||||
readonly: propTypes.bool.def(false),
|
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'])
|
const emit = defineEmits(['change', 'update:modelValue'])
|
||||||
@@ -115,9 +116,9 @@ const editorConfig = computed((): IEditorConfig => {
|
|||||||
['uploadImage']: {
|
['uploadImage']: {
|
||||||
server: getUploadUrl(),
|
server: getUploadUrl(),
|
||||||
// 单个文件的最大体积限制,默认为 2M
|
// 单个文件的最大体积限制,默认为 2M
|
||||||
maxFileSize: 5 * 1024 * 1024,
|
maxFileSize: 10 * 1024 * 1024,
|
||||||
// 最多可上传几个文件,默认为 100
|
// 最多可上传几个文件,默认为 100
|
||||||
maxNumberOfFiles: 10,
|
maxNumberOfFiles: 100,
|
||||||
// 选择文件时的类型限制,默认为 ['image/*'] 。如不想限制,则设置为 []
|
// 选择文件时的类型限制,默认为 ['image/*'] 。如不想限制,则设置为 []
|
||||||
allowedFileTypes: ['image/*'],
|
allowedFileTypes: ['image/*'],
|
||||||
|
|
||||||
@@ -133,6 +134,19 @@ const editorConfig = computed((): IEditorConfig => {
|
|||||||
|
|
||||||
// form-data fieldName,后端接口参数名称,默认值wangeditor-uploaded-image
|
// form-data fieldName,后端接口参数名称,默认值wangeditor-uploaded-image
|
||||||
fieldName: 'file',
|
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) {
|
onBeforeUpload(file: File) {
|
||||||
@@ -163,7 +177,7 @@ const editorConfig = computed((): IEditorConfig => {
|
|||||||
['uploadVideo']: {
|
['uploadVideo']: {
|
||||||
server: getUploadUrl(),
|
server: getUploadUrl(),
|
||||||
// 单个文件的最大体积限制,默认为 10M
|
// 单个文件的最大体积限制,默认为 10M
|
||||||
maxFileSize: 10 * 1024 * 1024,
|
maxFileSize: 1024 * 1024 * 1024,
|
||||||
// 最多可上传几个文件,默认为 100
|
// 最多可上传几个文件,默认为 100
|
||||||
maxNumberOfFiles: 10,
|
maxNumberOfFiles: 10,
|
||||||
// 选择文件时的类型限制,默认为 ['video/*'] 。如不想限制,则设置为 []
|
// 选择文件时的类型限制,默认为 ['video/*'] 。如不想限制,则设置为 []
|
||||||
@@ -181,6 +195,19 @@ const editorConfig = computed((): IEditorConfig => {
|
|||||||
|
|
||||||
// form-data fieldName,后端接口参数名称,默认值wangeditor-uploaded-image
|
// form-data fieldName,后端接口参数名称,默认值wangeditor-uploaded-image
|
||||||
fieldName: 'file',
|
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) {
|
onBeforeUpload(file: File) {
|
||||||
|
|||||||
Reference in New Issue
Block a user