Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
submodule
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
web_component
submodule
Commits
638cdc29
Commit
638cdc29
authored
Sep 08, 2020
by
zhuyangbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
视频组件
parent
4de6e42a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
6 deletions
+31
-6
fileType.ts
...nents/apolloTable/component/base/extra/upload/fileType.ts
+9
-0
preview.tsx
...nents/apolloTable/component/base/extra/upload/preview.tsx
+21
-5
utils.ts
components/apolloTable/component/base/extra/upload/utils.ts
+1
-1
No files found.
components/apolloTable/component/base/extra/upload/fileType.ts
View file @
638cdc29
...
...
@@ -25,6 +25,15 @@ export const fileType = {
pdf
:
{
thumbUrl
:
`
${
CDN_PATH
}
/pdfIcon.png`
,
},
mp4
:
{
thumbUrl
:
`
${
CDN_PATH
}
/videoIcon.png`
,
},
webm
:
{
thumbUrl
:
`
${
CDN_PATH
}
/videoIcon.png`
,
},
ogg
:
{
thumbUrl
:
`
${
CDN_PATH
}
/videoIcon.png`
,
},
other
:
{
thumbUrl
:
`
${
CDN_PATH
}
/otherIcon.png`
,
},
...
...
components/apolloTable/component/base/extra/upload/preview.tsx
View file @
638cdc29
...
...
@@ -10,6 +10,8 @@ export default class uploadDetail extends React.Component {
};
onPreview
=
(
url
:
string
,
name
:
string
)
=>
{
console
.
log
(
'name: '
,
name
);
console
.
log
(
'url: '
,
url
);
const
nameTypeArr
=
name
.
match
(
/
\.[
a-zA-Z0-9
]
+$/
);
const
urlTypeArr
=
url
.
match
(
/
\.[
a-zA-Z0-9
]
+$/
);
const
typeArr
=
nameTypeArr
||
urlTypeArr
;
...
...
@@ -21,6 +23,8 @@ export default class uploadDetail extends React.Component {
this
.
setState
({
showDialog
:
true
,
type
:
'office'
,
url
});
}
else
if
(
type
===
'pdf'
)
{
this
.
setState
({
showDialog
:
true
,
type
:
'pdf'
,
url
});
}
else
if
([
'mp4'
,
'webm'
,
'ogg'
].
includes
(
type
))
{
this
.
setState
({
showDialog
:
true
,
type
:
'video'
,
url
});
}
else
{
message
.
warn
(
'暂不支持预览'
);
}
...
...
@@ -35,17 +39,29 @@ export default class uploadDetail extends React.Component {
const
{
showDialog
,
type
,
url
}
=
this
.
state
;
return
(
<
div
>
<
Modal
className=
{
styles
.
dialog
}
visible=
{
showDialog
}
onCancel=
{
this
.
handleCancel
}
footer=
{
null
}
>
<
Modal
className=
{
styles
.
dialog
}
visible=
{
showDialog
}
onCancel=
{
this
.
handleCancel
}
footer=
{
null
}
destroyOnClose
>
<
div
>
{
type
===
'image'
?
<
img
alt=
"example"
style=
{
{
width
:
'100%'
}
}
src=
{
url
}
/>
:
null
}
{
type
===
'office'
?
(
{
type
===
'image'
&&
<
img
alt=
"example"
style=
{
{
width
:
'100%'
}
}
src=
{
url
}
/>
}
{
type
===
'office'
&&
(
<
iframe
title=
"office"
width=
"100%"
height=
{
500
}
src=
{
`https://view.officeapps.live.com/op/view.aspx?src=${url}`
}
/>
)
:
null
}
{
type
===
'pdf'
?
<
iframe
width=
"100%"
height=
{
500
}
src=
{
`${url}`
}
/>
:
null
}
)
}
{
type
===
'pdf'
&&
<
iframe
width=
"100%"
height=
{
500
}
src=
{
`${url}`
}
title=
"pdf"
/>
}
{
type
===
'video'
&&
(
<
video
src=
{
url
}
controls
width=
"100%"
>
你的浏览器暂不支持该视频在线播放,请下载后播放
</
video
>
)
}
</
div
>
</
Modal
>
</
div
>
...
...
components/apolloTable/component/base/extra/upload/utils.ts
View file @
638cdc29
import
{
fileType
}
from
'./fileType'
;
export
const
checkoutFileType
=
(
url
=
''
)
=>
{
const
typeArr
=
url
.
match
(
/
\.[
a-zA-Z
]
+$/
);
const
typeArr
=
url
.
match
(
/
\.[
a-zA-Z
0-9
]
+$/
);
let
type
=
typeArr
&&
typeArr
[
0
]
?
typeArr
[
0
].
replace
(
'.'
,
''
)
:
''
;
type
=
type
.
toLowerCase
();
if
(
type
===
'png'
||
type
===
'jpg'
||
type
===
'gif'
||
type
===
'bmp'
||
type
===
'jpeg'
)
{
...
...
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