Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8ed2afb7
authored
Jul 21, 2024
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【功能新增】全局:富文本编辑器,支持视频文件的上传
parent
5d91131e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
9 deletions
+49
-9
src/components/Editor/src/Editor.vue
+49
-9
No files found.
src/components/Editor/src/Editor.vue
View file @
8ed2afb7
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment