mirror of
https://github.com/YMFE/yapi.git
synced 2025-04-18 15:20:25 +08:00
fix: 添加以{}包含变量支持与字符串或其他变量拼接
This commit is contained in:
parent
9dbeacc799
commit
880fcd67ed
@ -226,4 +226,4 @@ exports.safeAssign = (Obj, nextObj) => {
|
||||
};
|
||||
|
||||
exports.simpleJsonPathParse = simpleJsonPathParse;
|
||||
exports.handleMockWord = handleMockWord;
|
||||
exports.handleMockWord = handleMockWord;
|
@ -216,8 +216,8 @@ class InterfaceColContent extends Component {
|
||||
}
|
||||
|
||||
const urlObj = URL.parse(URL.resolve(currDomain.domain, '.' + path));
|
||||
urlObj.query && urlObj.query.split('&').forEach(item=>{
|
||||
if(item){
|
||||
urlObj.query && urlObj.query.split('&').forEach(item => {
|
||||
if (item) {
|
||||
item = item.split('=');
|
||||
pathQuery[item[0]] = item[1];
|
||||
}
|
||||
@ -227,7 +227,7 @@ class InterfaceColContent extends Component {
|
||||
protocol: urlObj.protocol || 'http',
|
||||
host: urlObj.host,
|
||||
pathname: urlObj.pathname,
|
||||
query: Object.assign(pathQuery, this.getQueryObj(interfaceData.req_query, requestParams))
|
||||
query: Object.assign(pathQuery, this.getQueryObj(interfaceData.req_query, requestParams))
|
||||
});
|
||||
|
||||
let result = { code: 400, msg: '数据异常', validRes: [] };
|
||||
@ -363,12 +363,22 @@ class InterfaceColContent extends Component {
|
||||
}
|
||||
|
||||
handleValue = (val) => {
|
||||
const regex = /(\{\$\.\d+\..*?\})|(\{\@\w+\})/g;
|
||||
if (!val || typeof val !== 'string') {
|
||||
return val;
|
||||
} else if (val[0] === '@') {
|
||||
return handleMockWord(val);
|
||||
} else if (val.indexOf('$.') === 0) {
|
||||
return simpleJsonPathParse(val, this.records);
|
||||
} else if (val.match(regex) !== null) {
|
||||
val.match(regex).forEach((match) => {
|
||||
if (match.indexOf("{@") === 0) {
|
||||
val = val.replace(match, handleMockWord(match.substr(1, match.length - 2)))
|
||||
} else {
|
||||
val = val.replace(match, simpleJsonPathParse(match.substr(1, match.length - 2), this.records));
|
||||
}
|
||||
});
|
||||
return val;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
window.WEBPACK_ASSETS = {"index.js":{"js":"index@3ea8285572a5ca4441ca.js","css":"index@3ea8285572a5ca4441ca.css"},"lib":{"js":"lib@9521c6250635e5a8893a.js"},"lib2":{"js":"lib2@dbcc326d4fe3e4473316.js"},"manifest":{"js":"manifest@b67af9f8b578904e66c5.js"}}
|
||||
window.WEBPACK_ASSETS = {"index.js":{"js":"index@a415de52976a4723e9c3.js","css":"index@a415de52976a4723e9c3.css"},"lib":{"js":"lib@141ad8d5cb20302cc671.js"},"lib2":{"js":"lib2@f9e5f06eb6179b4b5943.js"},"manifest":{"js":"manifest@b67af9f8b578904e66c5.js"}}
|
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
1
static/prd/index@a415de52976a4723e9c3.css
Normal file
1
static/prd/index@a415de52976a4723e9c3.css
Normal file
File diff suppressed because one or more lines are too long
BIN
static/prd/index@a415de52976a4723e9c3.css.gz
Normal file
BIN
static/prd/index@a415de52976a4723e9c3.css.gz
Normal file
Binary file not shown.
1
static/prd/index@a415de52976a4723e9c3.js
Normal file
1
static/prd/index@a415de52976a4723e9c3.js
Normal file
File diff suppressed because one or more lines are too long
BIN
static/prd/index@a415de52976a4723e9c3.js.gz
Normal file
BIN
static/prd/index@a415de52976a4723e9c3.js.gz
Normal file
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
static/prd/lib2@f9e5f06eb6179b4b5943.js.gz
Normal file
BIN
static/prd/lib2@f9e5f06eb6179b4b5943.js.gz
Normal file
Binary file not shown.
1
static/prd/lib@141ad8d5cb20302cc671.js
Normal file
1
static/prd/lib@141ad8d5cb20302cc671.js
Normal file
File diff suppressed because one or more lines are too long
BIN
static/prd/lib@141ad8d5cb20302cc671.js.gz
Normal file
BIN
static/prd/lib@141ad8d5cb20302cc671.js.gz
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user