提交 9747e764 编写于 作者: M mxd

优化执行结果显示,保持`JSON`原样输出

上级 5abb726e
......@@ -719,7 +719,8 @@ export default {
reader.readAsText(data)
reader.onload = function() {
try{
resolve(JSON.parse(this.result))
JSON.parse(this.result)
resolve(this.result)
}catch(e){
resolve(data)
}
......
import request from "@/api/request";
const Beautifier = require('./beautifier/javascript/beautifier').Beautifier
const replaceURL = (url) => url.replace(/:?\/+/g, e => e.indexOf(':') > -1 ? e : '/');
const isVisible = (elem) => elem && !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length);
const formatJson = (val, defaultVal) => {
if (val) {
if (typeof val == 'string') {
try {
val = JSON.parse(val);
} catch (ignored) {
return val;
}
return new Beautifier(val).beautify()
}
if (val) {
return JSON.stringify(val, null, 4);
......@@ -104,8 +100,8 @@ const goToAnchor = (dom) => {
/**
* 获取url中的参数
* @param {String} variable
* @returns
* @param {String} variable
* @returns
*/
const getQueryVariable = (variable) => {
var query = window.location.search.substring(1)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册