mirror of
https://github.com/YMFE/yapi.git
synced 2025-03-07 14:16:52 +08:00
fix: 修复前的保存
This commit is contained in:
parent
ce65b110a1
commit
746dce76e6
@ -1,36 +1,37 @@
|
||||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Row, Radio, Icon, Input, Select } from 'antd';
|
||||
import common from 'common/power-string.js'
|
||||
// import common from 'common/power-string.js'
|
||||
const Option = Select.Option;
|
||||
|
||||
const RadioButton = Radio.Button;
|
||||
const RadioGroup = Radio.Group;
|
||||
|
||||
|
||||
// const list = METHODS_LIST.slice(0,4);
|
||||
const inputComponent = () => {
|
||||
return <Input size="small" placeholder="small size" />
|
||||
return <Input size="small" placeholder="small size" onChange={handleChange}/>
|
||||
}
|
||||
|
||||
const selectComponent = (value) => {
|
||||
// console.log('props', props);
|
||||
// const subname = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512'];
|
||||
return <Select defaultValue="sha1" style={{ width: 150 }} size="small" >
|
||||
const selectComponent = () => {
|
||||
const subname = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512'];
|
||||
return <Select defaultValue="sha1" style={{ width: 150 }} size="small" onChange={handleChange}>
|
||||
{
|
||||
value.map((item, index) => {
|
||||
subname.map((item, index) => {
|
||||
return <Option value={item} key={index}>{item}</Option>
|
||||
})
|
||||
}
|
||||
</Select>
|
||||
}
|
||||
|
||||
const handleChange =(v)=>{
|
||||
console.log('value',v);
|
||||
}
|
||||
|
||||
const METHODS_LIST = [
|
||||
{ name: 'md5', type: false },
|
||||
{ name: 'lower', type: false },
|
||||
{ name: 'length', type: false },
|
||||
{ name: 'substr', type: true },
|
||||
{ name: 'sha', type: true, component: selectComponent(['sha1', 'sha224', 'sha256', 'sha384', 'sha512']), subname: ['sha1', 'sha224', 'sha256', 'sha384', 'sha512'] },
|
||||
{ name: 'sha', type: true, component: selectComponent(), subname: ['sha1', 'sha224', 'sha256', 'sha384', 'sha512'] },
|
||||
{ name: 'base64', type: false },
|
||||
{ name: 'unbase64', type: false },
|
||||
{ name: 'concat', type: true, component: inputComponent() },
|
||||
@ -39,6 +40,17 @@ const METHODS_LIST = [
|
||||
|
||||
]
|
||||
|
||||
const MethodsListSource = (props) => {
|
||||
console.log('props', props);
|
||||
return <div>
|
||||
{props.component}
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
MethodsListSource.propTypes = {
|
||||
component: PropTypes.any
|
||||
}
|
||||
|
||||
class MethodsList extends Component {
|
||||
static propTypes = {
|
||||
@ -54,19 +66,18 @@ class MethodsList extends Component {
|
||||
list: METHODS_LIST.slice(0, 4),
|
||||
moreFlag: true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
console.log('common', common);
|
||||
}
|
||||
// componentDidMount() {
|
||||
// console.log('common', common);
|
||||
// }
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
// console.log("nextProps",nextProps);
|
||||
if (this.props.show !== nextProps.show) {
|
||||
this.unshowMore();
|
||||
}
|
||||
}
|
||||
// componentWillReceiveProps(nextProps) {
|
||||
// // console.log("nextProps",nextProps);
|
||||
// if (this.props.show !== nextProps.show) {
|
||||
// this.unshowMore();
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@ -79,12 +90,12 @@ class MethodsList extends Component {
|
||||
}
|
||||
|
||||
|
||||
unshowMore = () => {
|
||||
this.setState({
|
||||
list: METHODS_LIST.slice(0, 4),
|
||||
moreFlag: true
|
||||
})
|
||||
}
|
||||
// unshowMore = () => {
|
||||
// this.setState({
|
||||
// list: METHODS_LIST.slice(0, 4),
|
||||
// moreFlag: true
|
||||
// })
|
||||
// }
|
||||
|
||||
render() {
|
||||
const { list, moreFlag } = this.state;
|
||||
@ -99,7 +110,7 @@ class MethodsList extends Component {
|
||||
<RadioButton value={item.name}>
|
||||
<span>{item.name}</span>
|
||||
<span className="input-component">
|
||||
{item.type && item.component}
|
||||
{item.type && <MethodsListSource component={item.component}/>}
|
||||
</span>
|
||||
</RadioButton>
|
||||
|
||||
|
@ -24,7 +24,7 @@ class ModalPostman extends Component {
|
||||
clickValue: [],
|
||||
methodsShow: false,
|
||||
methodsShowMore: false,
|
||||
arr: [],
|
||||
methodsList: [],
|
||||
count: []
|
||||
}
|
||||
|
||||
@ -36,17 +36,21 @@ class ModalPostman extends Component {
|
||||
if (index === 0) {
|
||||
this.setState({
|
||||
clickValue: [].concat([], e.target.value ),
|
||||
arr: []
|
||||
// arr: [{
|
||||
// name: 'substr',
|
||||
// params: []
|
||||
// }]
|
||||
methodsList:[]
|
||||
})
|
||||
this.createArrList([]);
|
||||
} else {
|
||||
let newArr = [].concat(this.state.arr);
|
||||
let newArr = [].concat(this.state.methodsList);
|
||||
let newValue = [].concat(this.state.clickValue);
|
||||
newArr.splice(index + 1, newArr.length - index - 1)
|
||||
newValue.splice(index + 1, newValue.length - index - 1)
|
||||
newArr.splice(index, newArr.length - index)
|
||||
newValue.splice(index, newValue.length - index)
|
||||
this.setState({
|
||||
clickValue: [].concat(newValue, e.target.value ),
|
||||
arr: newArr
|
||||
methodsList: newArr
|
||||
})
|
||||
this.createArrList(newArr)
|
||||
|
||||
@ -67,7 +71,7 @@ class ModalPostman extends Component {
|
||||
}
|
||||
|
||||
this.setState({
|
||||
arr: [].concat(arr, ListSource)
|
||||
methodsList: [].concat(arr, ListSource)
|
||||
})
|
||||
|
||||
}
|
||||
@ -93,7 +97,7 @@ class ModalPostman extends Component {
|
||||
<h3>变量</h3>
|
||||
</Col>
|
||||
{
|
||||
this.state.arr.map((ListSourceComponent, index) => {
|
||||
this.state.methodsList.map((ListSourceComponent, index) => {
|
||||
return <Col span={8} className="modal-postman-col" key={index}>
|
||||
<ListSourceComponent index={index+1} />
|
||||
</Col>
|
||||
|
Loading…
Reference in New Issue
Block a user