preview.js
1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import React, { Component } from 'react'
import shareHide from "../../utils/shareHide";
import css from './databank.less';
shareHide();
class Preview extends Component {
constructor(){
super()
this.state={ }
}
render() {
const { state } = this.props.location;
let fileType = '';
if (state) {
const i = state.url.lastIndexOf('.');
fileType = state.url.substring(i+1, state.url.length);
fileType = fileType.toLocaleLowerCase();
}
return (
<div className={css.preview}>
{/* {fileType==='pdf' && <embed width="100%" height="100%" name="plugin" id="plugin" src={state && state.url} type="application/pdf" internalinstanceid="8" />} */}
{
(fileType==='png' || fileType ==='jpg' || fileType==='gif') && <div style={{textAlign:'center'}}> <img src={state.url} alt="" /></div>
}
{
// (/doc|docx|xls|xlsx|ppt|pptx/i.test(fileType)) && <iframe src={'https://view.officeapps.live.com/op/view.aspx?src='+state.url} width='100%' height='100%' frameBorder='1' title="docPreview">
// </iframe>
}
{
(fileType==='mp4') && <video width="100%" autoPlay src={state.url}></video>
}
</div>
)
}
}
export default Preview