Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
center-book
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
center-book
Commits
d32b7616
提交
d32b7616
authored
3月 10, 2026
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: 优化视频上传组件代码格式,统一函数语法并添加视频标题样式
上级
7e2211eb
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
23 行增加
和
12 行删除
+23
-12
video.jsx
src/common/wangeditor-customer/components/video.jsx
+23
-12
没有找到文件。
src/common/wangeditor-customer/components/video.jsx
浏览文件 @
d32b7616
...
@@ -28,7 +28,7 @@ const VideoModal = (props, ref) => {
...
@@ -28,7 +28,7 @@ const VideoModal = (props, ref) => {
useImperativeHandle
(
ref
,
()
=>
{
useImperativeHandle
(
ref
,
()
=>
{
return
{
return
{
setVisible
setVisible
,
}
}
})
})
...
@@ -37,7 +37,7 @@ const VideoModal = (props, ref) => {
...
@@ -37,7 +37,7 @@ const VideoModal = (props, ref) => {
maxCount
:
1
,
maxCount
:
1
,
showUploadList
:
false
,
showUploadList
:
false
,
accept
:
fileAccept
.
join
(
','
),
accept
:
fileAccept
.
join
(
','
),
beforeUpload
:
file
=>
{
beforeUpload
:
(
file
)
=>
{
const
fileExt
=
file
.
name
.
substring
(
file
.
name
.
lastIndexOf
(
'.'
))
const
fileExt
=
file
.
name
.
substring
(
file
.
name
.
lastIndexOf
(
'.'
))
if
(
!
fileAccept
.
includes
(
fileExt
.
toLowerCase
()))
{
if
(
!
fileAccept
.
includes
(
fileExt
.
toLowerCase
()))
{
message
.
error
(
'请上传正确格式的视频'
)
message
.
error
(
'请上传正确格式的视频'
)
...
@@ -53,14 +53,14 @@ const VideoModal = (props, ref) => {
...
@@ -53,14 +53,14 @@ const VideoModal = (props, ref) => {
setVideoUrl
(
url
)
setVideoUrl
(
url
)
form
.
setFieldsValue
({
videoUrl
:
url
})
form
.
setFieldsValue
({
videoUrl
:
url
})
setUploading
(
false
)
setUploading
(
false
)
}
}
,
}
}
const
onFinish
=
values
=>
{
const
onFinish
=
(
values
)
=>
{
editor
.
restoreSelection
()
editor
.
restoreSelection
()
const
nodeEntries
=
SlateEditor
.
nodes
(
editor
,
{
const
nodeEntries
=
SlateEditor
.
nodes
(
editor
,
{
match
:
node
=>
{
match
:
(
node
)
=>
{
// JS syntax
// JS syntax
if
(
SlateElement
.
isElement
(
node
))
{
if
(
SlateElement
.
isElement
(
node
))
{
if
(
node
.
type
===
'paragraph'
)
{
if
(
node
.
type
===
'paragraph'
)
{
...
@@ -69,7 +69,7 @@ const VideoModal = (props, ref) => {
...
@@ -69,7 +69,7 @@ const VideoModal = (props, ref) => {
}
}
return
false
return
false
},
},
universal
:
true
universal
:
true
,
})
})
for
(
let
nodeEntry
of
nodeEntries
)
{
for
(
let
nodeEntry
of
nodeEntries
)
{
const
[
node
]
=
nodeEntry
const
[
node
]
=
nodeEntry
...
@@ -82,12 +82,14 @@ const VideoModal = (props, ref) => {
...
@@ -82,12 +82,14 @@ const VideoModal = (props, ref) => {
{
{
type
:
'video'
,
type
:
'video'
,
src
:
values
.
videoUrl
,
src
:
values
.
videoUrl
,
children
:
[{
text
:
''
}]
children
:
[{
text
:
''
}]
,
},
},
{
{
type
:
'paragraph'
,
type
:
'paragraph'
,
children
:
[{
text
:
values
.
videoTitle
}]
textAlign
:
'center'
,
}
fontSize
:
'14px'
,
children
:
[{
text
:
values
.
videoTitle
}],
},
]
]
SlateTransforms
.
insertNodes
(
editor
,
nodes
)
SlateTransforms
.
insertNodes
(
editor
,
nodes
)
...
@@ -109,13 +111,18 @@ const VideoModal = (props, ref) => {
...
@@ -109,13 +111,18 @@ const VideoModal = (props, ref) => {
classNames=
{
{
classNames=
{
{
header
:
'editor-header-customer'
,
header
:
'editor-header-customer'
,
body
:
'editor-body-customer'
,
body
:
'editor-body-customer'
,
wrapper
:
'editor-wrapper-customer'
wrapper
:
'editor-wrapper-customer'
,
}
}
}
}
maskClosable=
{
false
}
maskClosable=
{
false
}
onCancel=
{
()
=>
setVisible
(
false
)
}
>
onCancel=
{
()
=>
setVisible
(
false
)
}
>
<
Divider
/>
<
Divider
/>
<
div
className=
"editor-content-form"
>
<
div
className=
"editor-content-form"
>
<
Form
layout=
"vertical"
name=
"validate_other"
form=
{
form
}
onFinish=
{
onFinish
}
initialValues=
{
{
videoUrl
:
videoUrl
,
videoTitle
:
''
}
}
>
<
Form
layout=
"vertical"
name=
"validate_other"
form=
{
form
}
onFinish=
{
onFinish
}
initialValues=
{
{
videoUrl
:
videoUrl
,
videoTitle
:
''
}
}
>
<
Form
.
Item
label=
"上传视频"
name=
"videoUrl"
rules=
{
[{
required
:
true
,
message
:
'请上传视频'
}]
}
>
<
Form
.
Item
label=
"上传视频"
name=
"videoUrl"
rules=
{
[{
required
:
true
,
message
:
'请上传视频'
}]
}
>
<
Spin
spinning=
{
uploading
}
tip=
{
`${progress}%`
}
>
<
Spin
spinning=
{
uploading
}
tip=
{
`${progress}%`
}
>
<
div
className=
"editor-dragger"
>
<
div
className=
"editor-dragger"
>
...
@@ -147,7 +154,11 @@ const VideoModal = (props, ref) => {
...
@@ -147,7 +154,11 @@ const VideoModal = (props, ref) => {
</
div
>
</
div
>
</
Spin
>
</
Spin
>
</
Form
.
Item
>
</
Form
.
Item
>
<
Form
.
Item
label=
"视频标题"
name=
"videoTitle"
rules=
{
[{
required
:
true
,
message
:
'请输入视频标题'
}]
}
extra=
"最多输入100字"
>
<
Form
.
Item
label=
"视频标题"
name=
"videoTitle"
rules=
{
[{
required
:
true
,
message
:
'请输入视频标题'
}]
}
extra=
"最多输入100字"
>
<
Input
maxLength=
{
100
}
placeholder=
""
allowClear
/>
<
Input
maxLength=
{
100
}
placeholder=
""
allowClear
/>
</
Form
.
Item
>
</
Form
.
Item
>
<
Form
.
Item
className=
"editor-form-buttons"
>
<
Form
.
Item
className=
"editor-form-buttons"
>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论