mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-02 03:58:33 +08:00
解决${}变量请求体格式化问题
This commit is contained in:
parent
0d037a9165
commit
08b75e5ddb
@ -1 +1 @@
|
||||
Subproject commit f27d1609d77f7d6c988d37d709466e844d350e17
|
||||
Subproject commit 79343a2763b014355f91fc21b2356a95ae437973
|
@ -19,7 +19,7 @@
|
||||
type="body"
|
||||
v-if="body.isKV()"/>
|
||||
<div class="body-raw" v-if="body.type == 'Raw'">
|
||||
<ms-code-edit :mode="body.format" :enable-format="false" :read-only="isReadOnly" :data.sync="body.raw" :modes="modes" ref="codeEdit"/>
|
||||
<ms-code-edit v-if="isCodeEditAlive" :mode="body.format" :read-only="isReadOnly" :data.sync="body.raw" :modes="modes" ref="codeEdit"/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -43,20 +43,26 @@ export default {
|
||||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
type: BODY_TYPE,
|
||||
modes: ['text', 'json', 'xml', 'html']
|
||||
modes: ['text', 'json', 'xml', 'html'],
|
||||
isCodeEditAlive: true
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
modeChange(mode) {
|
||||
this.body.format = mode;
|
||||
}
|
||||
this.reload();
|
||||
},
|
||||
reload() {
|
||||
this.isCodeEditAlive = false;
|
||||
this.$nextTick(() => (this.isCodeEditAlive = true));
|
||||
},
|
||||
},
|
||||
|
||||
created() {
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 7d43154a7c19732407a8e9ace8a7d1ea13c91f36
|
||||
Subproject commit 8cda5c873cd9985c97adb34efacf507167fa4182
|
@ -6,10 +6,21 @@ export function formatJson (json) {
|
||||
indentLevel = 0,
|
||||
inString = false,
|
||||
currentChar = null;
|
||||
let flag = false;
|
||||
for (i = 0, il = json.length; i < il; i += 1) {
|
||||
currentChar = json.charAt(i);
|
||||
switch (currentChar) {
|
||||
case '{':
|
||||
if (i != 0 && json.charAt(i - 1) === '$') {
|
||||
newJson += currentChar;
|
||||
flag = true;
|
||||
} else if (!inString) {
|
||||
newJson += currentChar + "\n" + repeat(tab, indentLevel + 1);
|
||||
indentLevel += 1
|
||||
} else {
|
||||
newJson += currentChar
|
||||
}
|
||||
break;
|
||||
case '[':
|
||||
if (!inString) {
|
||||
newJson += currentChar + "\n" + repeat(tab, indentLevel + 1);
|
||||
@ -19,6 +30,16 @@ export function formatJson (json) {
|
||||
}
|
||||
break;
|
||||
case '}':
|
||||
if (flag) {
|
||||
newJson += currentChar;
|
||||
flag = false;
|
||||
} else if (!inString) {
|
||||
indentLevel -= 1;
|
||||
newJson += "\n" + repeat(tab, indentLevel) + currentChar
|
||||
} else {
|
||||
newJson += currentChar
|
||||
}
|
||||
break;
|
||||
case ']':
|
||||
if (!inString) {
|
||||
indentLevel -= 1;
|
||||
|
Loading…
Reference in New Issue
Block a user