From 8ed2afb712c24fe0389eca456630bb85c0875114 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 21 Jul 2024 10:44:15 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E3=80=91=E5=85=A8=E5=B1=80=EF=BC=9A=E5=AF=8C=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=EF=BC=8C=E6=94=AF=E6=8C=81=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E6=96=87=E4=BB=B6=E7=9A=84=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Editor/src/Editor.vue | 58 +++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/src/components/Editor/src/Editor.vue b/src/components/Editor/src/Editor.vue index eff82745..8dd06456 100644 --- a/src/components/Editor/src/Editor.vue +++ b/src/components/Editor/src/Editor.vue @@ -96,11 +96,6 @@ const editorConfig = computed((): IEditorConfig => { // 选择文件时的类型限制,默认为 ['image/*'] 。如不想限制,则设置为 [] allowedFileTypes: ['image/*'], - // 自定义上传参数,例如传递验证的 token 等。参数会被添加到 formData 中,一起上传到服务端。 - meta: { updateSupport: 0 }, - // 将 meta 拼接到 url 参数中,默认 false - metaWithUrl: true, - // 自定义增加 http header headers: { Accept: '*', @@ -108,9 +103,6 @@ const editorConfig = computed((): IEditorConfig => { 'tenant-id': getTenantId() }, - // 跨域是否传递 cookie ,默认为 false - withCredentials: true, - // 超时时间,默认为 10 秒 timeout: 5 * 1000, // 5 秒 @@ -119,7 +111,7 @@ const editorConfig = computed((): IEditorConfig => { // 上传之前触发 onBeforeUpload(file: File) { - console.log(file) + // console.log(file) return file }, // 上传进度的回调函数 @@ -142,6 +134,54 @@ const editorConfig = computed((): IEditorConfig => { customInsert(res: any, insertFn: InsertFnType) { insertFn(res.data, 'image', res.data) } + }, + ['uploadVideo']: { + server: import.meta.env.VITE_UPLOAD_URL, + // 单个文件的最大体积限制,默认为 10M + maxFileSize: 10 * 1024 * 1024, + // 最多可上传几个文件,默认为 100 + maxNumberOfFiles: 10, + // 选择文件时的类型限制,默认为 ['video/*'] 。如不想限制,则设置为 [] + allowedFileTypes: ['video/*'], + + // 自定义增加 http header + headers: { + Accept: '*', + Authorization: 'Bearer ' + getAccessToken(), + 'tenant-id': getTenantId() + }, + + // 超时时间,默认为 30 秒 + timeout: 15 * 1000, // 15 秒 + + // form-data fieldName,后端接口参数名称,默认值wangeditor-uploaded-image + fieldName: 'file', + + // 上传之前触发 + onBeforeUpload(file: File) { + // console.log(file) + return file + }, + // 上传进度的回调函数 + onProgress(progress: number) { + // progress 是 0-100 的数字 + console.log('progress', progress) + }, + onSuccess(file: File, res: any) { + console.log('onSuccess', file, res) + }, + onFailed(file: File, res: any) { + alert(res.message) + console.log('onFailed', file, res) + }, + onError(file: File, err: any, res: any) { + alert(err.message) + console.error('onError', file, err, res) + }, + // 自定义插入图片 + customInsert(res: any, insertFn: InsertFnType) { + insertFn(res.data, 'mp4', res.data) + } } }, uploadImgShowBase64: true