mirror of
https://github.com/YMFE/yapi.git
synced 2024-11-27 04:40:08 +08:00
feat: pathname 允许只有一个 /
This commit is contained in:
parent
e8c95ee139
commit
290f8c5505
@ -4,6 +4,7 @@
|
||||
|
||||
1. Api 路径兼容 postman {varible}
|
||||
2. View Response Height 问题
|
||||
3. pathname 允许只有一个 /
|
||||
|
||||
### v1.2.8
|
||||
|
||||
|
@ -3,6 +3,8 @@ import PropTypes from 'prop-types'
|
||||
import { Tree } from 'antd';
|
||||
import { connect } from 'react-redux';
|
||||
import { fetchVariableParamsList } from '../../reducer/modules/interfaceCol.js'
|
||||
|
||||
|
||||
const TreeNode = Tree.TreeNode;
|
||||
const CanSelectPathPrefix = 'CanSelectPath-';
|
||||
|
||||
@ -29,26 +31,42 @@ class VariablesSelect extends Component {
|
||||
static propTypes = {
|
||||
click: PropTypes.func,
|
||||
currColId: PropTypes.number,
|
||||
fetchVariableParamsList: PropTypes.func
|
||||
|
||||
fetchVariableParamsList: PropTypes.func,
|
||||
id: PropTypes.number
|
||||
}
|
||||
state = {
|
||||
records: [],
|
||||
expandedKeys: []
|
||||
}
|
||||
|
||||
handleRecordsData(id){
|
||||
let newRecords = [];
|
||||
this.id = id;
|
||||
for(let i=0; i< this.records.length; i++){
|
||||
if(this.records[i]._id === id){
|
||||
break;
|
||||
}
|
||||
newRecords.push(this.records[i])
|
||||
}
|
||||
this.setState({
|
||||
records: newRecords
|
||||
})
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
const { currColId, fetchVariableParamsList } = this.props
|
||||
let result = await fetchVariableParamsList(currColId);
|
||||
let result = await fetchVariableParamsList(currColId);
|
||||
let records = result.payload.data.data;
|
||||
records = records.sort((a, b)=>{
|
||||
this.records = records.sort((a, b)=>{
|
||||
return a.index - b.index
|
||||
})
|
||||
this.setState({
|
||||
records
|
||||
})
|
||||
|
||||
this.handleRecordsData(this.props.id)
|
||||
}
|
||||
|
||||
async componentWillReceiveProps(nextProps){
|
||||
if(this.records && nextProps.id &&this.id !== nextProps.id ){
|
||||
this.handleRecordsData(nextProps.id)
|
||||
}
|
||||
}
|
||||
|
||||
handleSelect = (key) => {
|
||||
|
@ -37,7 +37,8 @@ class ModalPostman extends Component {
|
||||
handleCancel: PropTypes.func,
|
||||
handleOk: PropTypes.func,
|
||||
inputValue: PropTypes.any,
|
||||
envType: PropTypes.string
|
||||
envType: PropTypes.string,
|
||||
id: PropTypes.number
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
@ -191,7 +192,7 @@ class ModalPostman extends Component {
|
||||
envType === 'case' && <Panel
|
||||
header={<h3 className="mock-title">变量 <Tooltip placement="top" title="YApi 提供了强大的变量参数功能,你可以在测试的时候使用前面接口的 参数 或 返回值 作为 后面接口的参数,即使接口之间存在依赖,也可以轻松 一键测试~"><Icon type="question-circle-o" /></Tooltip></h3>}
|
||||
key="3">
|
||||
<VariablesSelect click={this.mockClick(index)} />
|
||||
<VariablesSelect id={this.props.id} click={this.mockClick(index)} />
|
||||
</Panel>
|
||||
}
|
||||
</Collapse>
|
||||
|
@ -248,6 +248,7 @@ export default class Run extends Component {
|
||||
handleOk={this.handleModalOk}
|
||||
inputValue={inputValue}
|
||||
envType={this.props.type}
|
||||
id={+this.state._id}
|
||||
>
|
||||
</ModalPostman>
|
||||
<CheckCrossInstall hasPlugin={hasPlugin} />
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yapi",
|
||||
"version": "1.2.8",
|
||||
"version": "1.2.9",
|
||||
"description": "YAPI",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -192,7 +192,7 @@ exports.handleVarPath = (pathname, params)=>{
|
||||
* path第一位必需为 /, path 只允许由 字母数字-/_:.{}= 组成
|
||||
*/
|
||||
exports.verifyPath = (path) => {
|
||||
if (/^\/[a-zA-Z0-9\-\/_:\.\{\}\=]+$/.test(path)) {
|
||||
if (/^\/[a-zA-Z0-9\-\/_:\.\{\}\=]*$/.test(path)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user