|
@@ -18,7 +18,14 @@ import { API_upFile } from '@/store/action/layout'
|
|
|
import { forwardRef, useImperativeHandle } from 'react'
|
|
|
import MyPopconfirm from '../MyPopconfirm'
|
|
|
|
|
|
-type MyTypeType = 'thumb' | 'video' | 'audio' | 'model' | 'pdf' | 'epub'
|
|
|
+type MyTypeType =
|
|
|
+ | 'thumb'
|
|
|
+ | 'video'
|
|
|
+ | 'audio'
|
|
|
+ | 'model'
|
|
|
+ | 'pdf'
|
|
|
+ | 'epub'
|
|
|
+ | 'pdf、doc、docx'
|
|
|
|
|
|
// 这个组件 只处理 上传 一张图片或者 视频 音频 模型 pdf 的情况
|
|
|
|
|
@@ -72,8 +79,12 @@ function ZupOne(
|
|
|
|
|
|
// 校验格式
|
|
|
const type = format
|
|
|
-
|
|
|
- if (myType === 'pdf') {
|
|
|
+ if (myType === 'pdf、doc、docx') {
|
|
|
+ if (!filesInfo.type.includes('pdf') && !filesInfo.type.includes('doc')) {
|
|
|
+ e.target.value = ''
|
|
|
+ return MessageFu.warning(`只支持${formatTxt}格式!`)
|
|
|
+ }
|
|
|
+ } else if (myType === 'pdf') {
|
|
|
if (!filesInfo.type.includes('pdf')) {
|
|
|
e.target.value = ''
|
|
|
return MessageFu.warning(`只支持${formatTxt}格式!`)
|
|
@@ -99,7 +110,7 @@ function ZupOne(
|
|
|
const fd = new FormData()
|
|
|
// 把files添加进FormData对象(‘photo’为后端需要的字段)
|
|
|
let myTypeRes: string = myType
|
|
|
- if (['pdf', 'epub'].includes(myTypeRes)) myTypeRes = 'doc'
|
|
|
+ if (['pdf', 'epub', 'pdf、doc、docx'].includes(myTypeRes)) myTypeRes = 'doc'
|
|
|
fd.append('type', myTypeRes)
|
|
|
fd.append('dirCode', dirCode)
|
|
|
fd.append('file', filesInfo)
|
|
@@ -153,7 +164,8 @@ function ZupOne(
|
|
|
|
|
|
const acceptRes = useMemo(() => {
|
|
|
let accept = '.png,.jpg,.jpeg'
|
|
|
- if (myType === 'video') accept = '.mp4'
|
|
|
+ if (myType === 'pdf、doc、docx') accept = '.pdf,.doc,.docx'
|
|
|
+ else if (myType === 'video') accept = '.mp4'
|
|
|
else if (myType === 'audio') accept = '.mp3'
|
|
|
else if (myType === 'model') accept = '.4dage'
|
|
|
else if (myType === 'pdf') accept = '.pdf'
|
|
@@ -164,7 +176,7 @@ function ZupOne(
|
|
|
// 点击 预览(除了图片)
|
|
|
const lookFileNoImgFu = useCallback(
|
|
|
(type: MyTypeType) => {
|
|
|
- if (type === 'pdf' || type === 'thumb') {
|
|
|
+ if (type === 'pdf' || type === 'thumb' || type === 'pdf、doc、docx') {
|
|
|
// 新窗口打开
|
|
|
window.open(baseURL + fileUrl.filePath)
|
|
|
} else if (type !== 'epub') {
|
|
@@ -241,7 +253,12 @@ function ZupOne(
|
|
|
}
|
|
|
rev={undefined}
|
|
|
/>
|
|
|
- <a href={baseURL + fileUrl.filePath} download target='_blank' rel='noreferrer'>
|
|
|
+ <a
|
|
|
+ href={baseURL + fileUrl.filePath}
|
|
|
+ download
|
|
|
+ target='_blank'
|
|
|
+ rel='noreferrer'
|
|
|
+ >
|
|
|
<DownloadOutlined rev={undefined} />
|
|
|
</a>
|
|
|
</div>
|
|
@@ -283,7 +300,10 @@ function ZupOne(
|
|
|
格式要求:支持{formatTxt}格式;最大支持{size}M。{upTxt}
|
|
|
<br />
|
|
|
<div
|
|
|
- className={classNames('noUpThumb', !fileUrl.filePath && fileCheck ? 'noUpThumbAc' : '')}
|
|
|
+ className={classNames(
|
|
|
+ 'noUpThumb',
|
|
|
+ !fileUrl.filePath && fileCheck ? 'noUpThumbAc' : ''
|
|
|
+ )}
|
|
|
>
|
|
|
{checkTxt}
|
|
|
</div>
|