yuan_yi
2 years ago
4 changed files with 67 additions and 34 deletions
@ -1,5 +1,6 @@ |
|||
'use strict'; |
|||
import SimpleFileDownButton from './simpleFileDownButton' |
|||
|
|||
export { |
|||
|
|||
SimpleFileDownButton |
|||
}; |
|||
|
@ -0,0 +1,38 @@ |
|||
import React, { useState, useEffect, useRef } from "react"; |
|||
import { connect } from "react-redux"; |
|||
import moment from 'moment' |
|||
import { Button, } from "@douyinfe/semi-ui"; |
|||
|
|||
const SimpleFileDownButton = (props) => { |
|||
const { src, user } = props |
|||
const [downloadUrl, setDownloadUrl] = useState('') |
|||
|
|||
return ( |
|||
<> |
|||
<Button |
|||
style={{ |
|||
width: 65, |
|||
height: 32, |
|||
background: "#FFFFFF", |
|||
borderRadius: 3, |
|||
border: "1px solid #1859C1", |
|||
}} |
|||
onClick={() => { |
|||
setDownloadUrl(`${src}?token=${user.token}×tamp=${moment().valueOf()}`) |
|||
}} |
|||
> |
|||
导出 |
|||
</Button> |
|||
<iframe src={`/_api/${downloadUrl}`} style={{ display: 'none' }} /> |
|||
</> |
|||
) |
|||
} |
|||
|
|||
function mapStateToProps (state) { |
|||
const { auth } = state; |
|||
return { |
|||
user: auth.user, |
|||
}; |
|||
} |
|||
|
|||
export default connect(mapStateToProps)(SimpleFileDownButton); |
Loading…
Reference in new issue