diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3fc79eed..48c8d06f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
* 支持自定义域名邮箱登录
* 测试用例支持导入不同项目接口
+* 完善可视化表达式,可根据焦点编辑表达式
#### Bug Fixed
diff --git a/a.markdown b/a.markdown
index a116bf93..aff80335 100644
--- a/a.markdown
+++ b/a.markdown
@@ -1,4 +1,49 @@
-
eererer
+ test_22(copy_copy)
+
+# %u516C%u5171%u5206%u7C7B
+[TOC]
+
+
+## cluster%0A%3Ca%20id%3Dcluster%3E%20%3C/a%3E
+[TOC]
+
+### 基本信息
+
+**Path:** /cluster
+
+**Method:** POST
+
+**接口描述:**
+
+
+### 请求参数
+**Headers**
+
+| 参数名称 | 参数值 | 是否必须 | 示例 | 备注 |
+| ------------ | ------------ | ------------ | ------------ | ------------ |
+| X-Auth-User | | 是 | | |
+| X-Auth-Project | | 是 | | |
+| X-Auth-token | | 是 | | |
+| Content-Type | multipart/form-data | 是 | | |
+**Query**
+
+| 参数名称 | 是否必须 | 示例 | 备注 |
+| ------------ | ------------ | ------------ | ------------ |
+| qw | 是 | | |
+**Body**
+
+| 参数名称 | 参数类型 | 是否必须 | 示例 | 备注 |
+| ------------ | ------------ | ------------ | ------------ | ------------ |
+| 1 | text | 是 | | |
+| 2 | file | 是 | | |
+
+
+
+### 返回数据
+
+```javascript
+{"type":"object","title":"empty object","properties":{"id":{"type":"object","properties":{"field_1":{"type":"object","properties":{"field_2":{"type":"object","properties":{"field_3":{"type":"object","properties":{"field_4":{"type":"object","properties":{"field_5":{"type":"object","properties":{"field_6":{"type":"object","properties":{"field_7额 u 俄 u 俄 u 茹茹茹茹茹茹茹rrururuueueue ":{"type":"string"}},"required":[]}}}}}}}}}}}}},"msg":{"type":"string"}},"required":[]}
+```
\ No newline at end of file
diff --git a/client/components/Postman/Postman.js b/client/components/Postman/Postman.js
index a9ffa9d9..77b0196f 100755
--- a/client/components/Postman/Postman.js
+++ b/client/components/Postman/Postman.js
@@ -85,6 +85,7 @@ export default class Run extends Component {
test_script: '',
hasPlugin: true,
inputValue: '',
+ cursurPosition: -1,
envModalVisible: false,
test_res_header: null,
test_res_body: null,
@@ -141,21 +142,25 @@ export default class Run extends Component {
const { req_body_other, req_body_type, req_body_is_json_schema } = data;
let body = req_body_other;
// 运行时才会进行转换
- if (this.props.type === 'inter' && req_body_type === 'json' && req_body_other && req_body_is_json_schema) {
-
- let schema = {}
+ if (
+ this.props.type === 'inter' &&
+ req_body_type === 'json' &&
+ req_body_other &&
+ req_body_is_json_schema
+ ) {
+ let schema = {};
try {
schema = json5.parse(req_body_other);
} catch (e) {
- console.log('e',e)
- return ;
+ console.log('e', e);
+ return;
}
let result = await axios.post('/api/interface/schema2json', {
schema: schema,
required: true
});
body = JSON.stringify(result.data);
- console.log('body',body);
+ console.log('body', body);
}
this.setState(
@@ -322,28 +327,67 @@ export default class Run extends Component {
// 模态框的相关操作
showModal = (val, index, type) => {
+ let oTxt1 = document.getElementById(`${type}_${index}`);
+ let cursurPosition = oTxt1.selectionStart;
+
+ let inputValue = this.getInstallValue(val || '', cursurPosition).val
this.setState({
modalVisible: true,
inputIndex: index,
- inputValue: val,
+ inputValue,
+ cursurPosition,
modalType: type
});
};
+ // 点击插入
handleModalOk = val => {
const { inputIndex, modalType } = this.state;
- switch (modalType) {
- case 'req_body_form':
- this.changeBody(val, inputIndex);
- break;
- default:
- this.changeParam(modalType, val, inputIndex);
- break;
- }
+ this.changeInstallParam(modalType, val, inputIndex);
this.setState({ modalVisible: false });
};
+
handleModalCancel = () => {
- this.setState({ modalVisible: false });
+ this.setState({ modalVisible: false, cursurPosition: -1 });
+ };
+
+
+
+ // 获取截取的字符串
+ getInstallValue = (oldValue, cursurPosition) => {
+ let left = oldValue.substr(0, cursurPosition);
+ let right = oldValue.substr(cursurPosition);
+
+ let leftPostion = left.lastIndexOf('{{');
+ let leftPostion2 = left.lastIndexOf('}}');
+ let rightPostion = right.indexOf('}}');
+ // console.log(leftPostion, leftPostion2,rightPostion, rightPostion2);
+ let val = '';
+ // 需要切除原来的变量
+ if (leftPostion !== -1 && rightPostion !==-1 && leftPostion > leftPostion2) {
+ left = left.substr(0, leftPostion);
+ right = right.substr(rightPostion + 2);
+ val = oldValue.substring(leftPostion, cursurPosition+rightPostion+2)
+ }
+ return {
+ left,
+ right,
+ val
+ };
+ }
+
+ // 根据鼠标位置动态插入数据
+ changeInstallParam = (name, v, index, key) => {
+ key = key || 'value';
+ const pathParam = deepCopyJson(this.state[name]);
+ let oldValue = pathParam[index][key] || '';
+ let newValue = this.getInstallValue(oldValue, this.state.cursurPosition)
+ let left = newValue.left;
+ let right = newValue.right;
+ pathParam[index][key] = `${left}${v}${right}`;
+ this.setState({
+ [name]: pathParam
+ });
};
// 环境变量模态框相关操作
@@ -492,6 +536,7 @@ export default class Run extends Component {
className="value"
onChange={e => this.changeParam('req_params', e.target.value, index)}
placeholder="参数值"
+ id={`req_params_${index}`}
addonAfter={
this.changeParam('req_query', e.target.value, index)}
placeholder="参数值"
+ id={`req_query_${index}`}
addonAfter={
this.changeParam('req_headers', e.target.value, index)}
placeholder="参数值"
+ id={`req_headers_${index}`}
addonAfter={
!item.abled && (
this.changeBody(e.target.value, index)}
placeholder="参数值"
+ id={`req_body_form_${index}`}
addonAfter={