Skip to content

Commit

Permalink
redis查询结果json格式化显示 hhyo#1376 (hhyo#1382)
Browse files Browse the repository at this point in the history
* redis查询结果json格式化显示 hhyo#1376

redis查询结果json格式化显示 hhyo#1376

* 报错提示

报错提示

* 提示优化

提示优化
  • Loading branch information
nick2wang authored Feb 15, 2022
1 parent be206a4 commit 2a1547f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion sql/templates/sqlquery.html
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ <h4 class="modal-title text-danger">收藏语句</h4>
//初始化查询结果
var isdetail = false
var optgroup = $('#instance_name :selected').parent().attr('label');
if (optgroup == 'Mongo') {
if (optgroup === 'Mongo' || optgroup === 'Redis') {
isdetail = true
}
var showExport = {{can_download}}===1
Expand Down Expand Up @@ -811,6 +811,17 @@ <h4 class="modal-title text-danger">收藏语句</h4>
$.each(row, function (key, value) {
if (key === 0) {//mongodb这里要修改
let rs = value;
if (optgroup === 'Redis') {
try {
rs = JSON.parse(rs);
if (typeof rs == 'object' && rs) {
rs = JSON.stringify(rs, null, 2)
}
} catch (e) {
html.push('<strong>' + "非json格式,无法格式化!" + '</strong>');
return false;
}
}
html.push('<pre>' + highLight(rs) + '</pre>');
}
});
Expand Down

0 comments on commit 2a1547f

Please sign in to comment.