|
@@ -37,10 +37,11 @@ type Props = {
|
|
myUrl: string //上传的api地址
|
|
myUrl: string //上传的api地址
|
|
isOne?: boolean //只显示单个富文本
|
|
isOne?: boolean //只显示单个富文本
|
|
upAudioBtnNone?: boolean //是否能上传无障碍音频
|
|
upAudioBtnNone?: boolean //是否能上传无障碍音频
|
|
|
|
+ imgOne?: boolean // 只上传图片
|
|
}
|
|
}
|
|
|
|
|
|
function ZRichTexts(
|
|
function ZRichTexts(
|
|
- { check, dirCode, isLook, myUrl, isOne = false, upAudioBtnNone = false }: Props,
|
|
|
|
|
|
+ { check, dirCode, isLook, myUrl, isOne = false, upAudioBtnNone = false, imgOne }: Props,
|
|
ref: any
|
|
ref: any
|
|
) {
|
|
) {
|
|
const [sectionArr, setSectionArr] = useState<SectionArrType[]>([
|
|
const [sectionArr, setSectionArr] = useState<SectionArrType[]>([
|
|
@@ -91,14 +92,17 @@ function ZRichTexts(
|
|
// 拿到files信息
|
|
// 拿到files信息
|
|
const filesInfo = e.target.files[0]
|
|
const filesInfo = e.target.files[0]
|
|
|
|
|
|
- let type = ['image/jpeg', 'image/png', 'video/mp4']
|
|
|
|
|
|
+ let type = ['image/jpeg', 'image/png']
|
|
|
|
+
|
|
|
|
+ if (!imgOne) type.push('video/mp4')
|
|
|
|
+
|
|
let size = 5
|
|
let size = 5
|
|
let txt = '图片只支持png、jpg和jpeg格式!'
|
|
let txt = '图片只支持png、jpg和jpeg格式!'
|
|
let txt2 = '图片最大支持5M!'
|
|
let txt2 = '图片最大支持5M!'
|
|
|
|
|
|
const isVideoFlag = filesInfo.name.endsWith('.mp4') || filesInfo.name.endsWith('.MP4')
|
|
const isVideoFlag = filesInfo.name.endsWith('.mp4') || filesInfo.name.endsWith('.MP4')
|
|
|
|
|
|
- if (isVideoFlag) {
|
|
|
|
|
|
+ if (!isOne && isVideoFlag) {
|
|
// 上传视频
|
|
// 上传视频
|
|
size = 500
|
|
size = 500
|
|
txt = '视频只支持mp4格式!'
|
|
txt = '视频只支持mp4格式!'
|
|
@@ -147,7 +151,7 @@ function ZRichTexts(
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- [dirCode, myUrl, sectionArr]
|
|
|
|
|
|
+ [dirCode, imgOne, isOne, myUrl, sectionArr]
|
|
)
|
|
)
|
|
|
|
|
|
// 让父组件调用的 回显 富文本
|
|
// 让父组件调用的 回显 富文本
|
|
@@ -264,7 +268,7 @@ function ZRichTexts(
|
|
<input
|
|
<input
|
|
id='upInput'
|
|
id='upInput'
|
|
type='file'
|
|
type='file'
|
|
- accept='.png,.jpg,.jpeg,.mp4'
|
|
|
|
|
|
+ accept={`.png,.jpg,.jpeg${imgOne ? '' : ',.mp4'}`}
|
|
ref={myInput}
|
|
ref={myInput}
|
|
onChange={e => handeUpPhoto(e)}
|
|
onChange={e => handeUpPhoto(e)}
|
|
/>
|
|
/>
|
|
@@ -302,7 +306,7 @@ function ZRichTexts(
|
|
myInput.current?.click()
|
|
myInput.current?.click()
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
- 上传图片/视频
|
|
|
|
|
|
+ 上传图片{imgOne ? '' : '/视频'}
|
|
</Button>
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|