2017-07-26 16:25:34 +08:00
|
|
|
import '../AddInterface.scss'
|
|
|
|
import React, { Component } from 'react'
|
|
|
|
import { Button, message } from 'antd'
|
|
|
|
import Clipboard from 'clipboard'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
|
|
|
const success = () => {
|
|
|
|
message.success('复制成功!')
|
|
|
|
}
|
|
|
|
|
|
|
|
class MockUrl extends Component {
|
|
|
|
static propTypes = {
|
2017-07-27 20:35:19 +08:00
|
|
|
mockURL: PropTypes.string,
|
|
|
|
serverIp: PropTypes.string
|
2017-07-26 16:25:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount () {
|
|
|
|
setTimeout(this.clipboard, 500)
|
|
|
|
}
|
|
|
|
|
|
|
|
clipboard () {
|
|
|
|
const btn = document.querySelector('#mock-clipboard')
|
|
|
|
const txt = document.querySelector('#mock-p').innerHTML
|
2017-07-26 19:07:29 +08:00
|
|
|
|
2017-07-26 16:25:34 +08:00
|
|
|
new Clipboard(btn, {
|
|
|
|
text: () => txt,
|
|
|
|
target () {
|
|
|
|
success()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
2017-07-27 20:35:19 +08:00
|
|
|
const { serverIp } = this.props
|
2017-07-26 16:25:34 +08:00
|
|
|
return (
|
|
|
|
<section className="mock-url-box">
|
2017-07-27 20:06:49 +08:00
|
|
|
<span>mock地址 : </span>
|
2017-07-26 16:25:34 +08:00
|
|
|
<p id="mock-p">{this.props.mockURL}</p>
|
|
|
|
<Button type="primary" id="mock-clipboard">复制</Button>
|
2017-07-27 20:35:19 +08:00
|
|
|
<div className="host">请配置host ***.***.***.*** { serverIp }</div>
|
2017-07-26 16:25:34 +08:00
|
|
|
</section>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MockUrl
|