Dev: Cache render result

This commit is contained in:
surunzi
2016-05-21 14:54:17 +08:00
parent 6cbda313fb
commit 6d26c7434f
8 changed files with 56 additions and 11 deletions

View File

@@ -241,9 +241,15 @@ export default class Log extends util.Emitter
var logs = this._renderLogs = this._filterLogs(this._logs);
this._$el.html(this._tpl({logs: logs}));
this._renderHtml(this._tpl({logs: logs}));
this._scrollToBottom();
}
_renderHtml(html)
{
if (html === this._lastHtml) return;
this._lastHtml = html;
this._$el.html(html);
}
_filterLogs(logs)
{
var filter = this._filter;

View File

@@ -221,7 +221,13 @@ export default class Elements extends Tool
if (!isElExist(this._curEl)) return this._back();
this._highlight[this._highlightElement ? 'show' : 'hide']();
this._$showArea.html(this._tpl(this._getData()));
this._renderHtml(this._tpl(this._getData()));
}
_renderHtml(html)
{
if (html === this._lastHtml) return;
this._lastHtml = html;
this._$showArea.html(html);
}
_initConfig()
{

View File

@@ -34,6 +34,12 @@ export default class Info extends Tool
}
_render()
{
this._$el.html(this._tpl({messages: this._msgs}));
this._renderHtml(this._tpl({messages: this._msgs}));
}
_renderHtml(html)
{
if (html === this._lastHtml) return;
this._lastHtml = html;
this._$el.html(html);
}
}

View File

@@ -270,12 +270,18 @@ export default class Network extends Tool
{
if (!this.active) return;
this._$el.html(this._tpl({
this._renderHtml(this._tpl({
data: this._performanceTimingData,
timing: this._performanceTiming,
requests: this._requests
}));
}
_renderHtml(html)
{
if (html === this._lastHtml) return;
this._lastHtml = html;
this._$el.html(html);
}
}
function formatTime(time)

View File

@@ -219,7 +219,7 @@ export default class Resources extends Tool
stylesheetData = this._stylesheetData,
imageData = this._imageData;
this._$el.html(this._tpl({
this._renderHtml(this._tpl({
localStoreData: localStoreData,
localStoreState: getState('localStore', localStoreData.length),
cookieData: cookieData,
@@ -241,6 +241,12 @@ export default class Resources extends Tool
$li.css({height: $li.get(0).offsetWidth});
}, 150);
}
_renderHtml(html)
{
if (html === this._lastHtml) return;
this._lastHtml = html;
this._$el.html(html);
}
}
function getState(type, len)

View File

@@ -39,6 +39,9 @@
border-radius: 50%;
font-size: 12px;
cursor: pointer;
&:active {
color: $gray-light;
}
}
}
.link-list {

View File

@@ -56,8 +56,14 @@ export default class Snippets extends Tool
}
_render()
{
this._$el.html(this._tpl({
this._renderHtml(this._tpl({
snippets: this._snippets
}));
}
_renderHtml(html)
{
if (html === this._lastHtml) return;
this._lastHtml = html;
this._$el.html(html);
}
}

View File

@@ -144,7 +144,7 @@ export default class Sources extends Tool
}
_renderImg()
{
this._$el.html(this._imgTpl(this._data.val));
this._renderHtml(this._imgTpl(this._data.val));
}
_renderHttp()
{
@@ -152,7 +152,7 @@ export default class Sources extends Tool
val.hasResTxt = (val.resTxt.trim() !== '');
this._$el.html(this._httpTpl(this._data.val));
this._renderHtml(this._httpTpl(this._data.val));
}
_renderCode()
{
@@ -182,11 +182,11 @@ export default class Sources extends Tool
code = util.escape(code);
}
this._$el.html(this._codeTpl({code: code}));
this._renderHtml(this._codeTpl({code: code}));
}
_renderJson()
{
this._$el.html(this._jsonTpl());
this._renderHtml(this._jsonTpl());
var val = this._data.val;
@@ -197,6 +197,12 @@ export default class Sources extends Tool
}
_renderRaw()
{
this._$el.html(this._rawTpl({val: this._data.val}));
this._renderHtml(this._rawTpl({val: this._data.val}));
}
_renderHtml(html)
{
if (html === this._lastHtml) return;
this._lastHtml = html;
this._$el.html(html);
}
}