From 1f126d4877b1309ea6c97f0961ce0cbe4fe415e6 Mon Sep 17 00:00:00 2001 From: redhoodsu Date: Mon, 5 Aug 2019 19:24:59 +0800 Subject: [PATCH] fix: sources json view --- src/Console/stringify.js | 2 +- src/Sources/Sources.js | 15 +++++++++++++-- src/index.js | 2 +- src/lib/logger.js | 4 ++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Console/stringify.js b/src/Console/stringify.js index 0a24de1..6e3b776 100644 --- a/src/Console/stringify.js +++ b/src/Console/stringify.js @@ -9,7 +9,7 @@ let worker if (isWorkerSupported) { tryIt(function() { /* Some browsers like uc mobile doesn't destroy worker properly after refreshing. - * After a few times of visiting, it reaches the maximum number of workers per site. + * After a few times of visiting, it reaches the maximum number of workers per site. */ worker = new StringifyWorker() worker.onmessage = function(e) { diff --git a/src/Sources/Sources.js b/src/Sources/Sources.js index 0b08508..ed7dbbd 100644 --- a/src/Sources/Sources.js +++ b/src/Sources/Sources.js @@ -3,7 +3,15 @@ import beautify from 'js-beautify' import highlight from '../lib/highlight' import JsonViewer from '../lib/JsonViewer' import Settings from '../Settings/Settings' -import { evalCss, ajax, isEmpty, escape, trim, isStr } from '../lib/util' +import { + evalCss, + ajax, + isEmpty, + escape, + trim, + isStr, + stringifyAll +} from '../lib/util' export default class Sources extends Tool { constructor() { @@ -256,7 +264,10 @@ export default class Sources extends Tool { let val = this._data.val try { - if (isStr(val)) val = JSON.parse(val) + if (isStr(val)) { + val = JSON.parse(val) + val = stringifyAll(val) + } /* eslint-disable no-empty */ } catch (e) {} diff --git a/src/index.js b/src/index.js index dbb3be3..aac4fd0 100644 --- a/src/index.js +++ b/src/index.js @@ -32,7 +32,7 @@ import { module.exports = { init({ container, tool, autoScale = true, useShadowDom = true } = {}) { if (this._isInit) return - + this._isInit = true this._scale = 1 diff --git a/src/lib/logger.js b/src/lib/logger.js index 7e00b92..faa17a4 100644 --- a/src/lib/logger.js +++ b/src/lib/logger.js @@ -2,10 +2,10 @@ import { Logger } from './util' let logger -export default (logger = new Logger( +export default logger = new Logger( '[Eruda]', ENV === 'production' ? 'warn' : 'debug' -)) +) logger.formatter = function(type, argList) { argList.unshift(this.name)