import React from 'react';
|
|
import { Layout, Card, Button, Icon } from 'antd';
|
import AttachmentDisplay from '../view/AttachmentDisplay';
|
|
export default class Index extends React.Component {
|
constructor(props) {
|
super(props);
|
this.state = {
|
degree: 0
|
};
|
}
|
rotate = degree => {
|
this.setState({ degree: (degree + 360) % 360 });
|
}
|
componentWillReceiveProps(props) {
|
try {
|
if (props.location.state.path
|
!== this.props.location.state.path) {
|
this.setState({ degree: 0 });
|
|
}
|
} catch (e) { }
|
}
|
download = () => {
|
// 接口
|
}
|
|
render() {
|
if (!this.props.location.state) {
|
return null;
|
}
|
const { degree } = this.state;
|
const { path, type, name } = this.props.location.state;
|
if (type === 'online') {
|
return (
|
<iframe src={path} style={{
|
width: '100%',
|
height: '100%',
|
border: 'none',
|
overflow: 'auto'
|
}}
|
/>
|
);
|
}
|
if (type === 'offline') {
|
return (
|
<Card style={{ margin: '8px', textAlign: 'center', width: '100%' }} hoverable bordered>
|
<a href={path} title={`下载${name || ''}`} className="ant-btn ant-btn-primary ant-btn-lg">下载</a>
|
</Card>
|
);
|
}
|
return (
|
<Layout className="h-100" style={{ overflow: 'auto' }}>
|
<div>
|
<div style={{ padding: '16px', zIndex: '1', backgroundColor: 'white' }}>
|
<Button type="primary" onClick={() => this.rotate(degree - 90)}>
|
<Icon type="left" />旋转
|
</Button>
|
{' '}
|
<Button type="primary" onClick={() => this.rotate(degree + 90)}>
|
旋转<Icon type="right" />
|
</Button>
|
{/*{' '}
|
<Button type="primary" onClick={this.download}>
|
一键下载
|
</Button>*/}
|
</div>
|
</div>
|
<AttachmentDisplay key={path} path={path} degree={degree} />
|
</Layout>
|
);
|
}
|
}
|