mirror of
https://github.com/liriliri/eruda.git
synced 2026-03-24 09:48:37 +08:00
Dev: Dynamic info content support #51
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import Tool from '../DevTools/Tool';
|
||||
import defInfo from './defInfo';
|
||||
import {evalCss, each} from '../lib/util';
|
||||
import {evalCss, each, isFn} from '../lib/util';
|
||||
|
||||
export default class Info extends Tool
|
||||
{
|
||||
@@ -20,6 +20,12 @@ export default class Info extends Tool
|
||||
|
||||
this._addDefInfo();
|
||||
}
|
||||
show()
|
||||
{
|
||||
this._render();
|
||||
|
||||
super.show();
|
||||
}
|
||||
destroy()
|
||||
{
|
||||
super.destroy();
|
||||
@@ -61,7 +67,16 @@ export default class Info extends Tool
|
||||
}
|
||||
_render()
|
||||
{
|
||||
this._renderHtml(this._tpl({messages: this._msgs}));
|
||||
let messages = [];
|
||||
|
||||
each(this._msgs, ({name, val}) =>
|
||||
{
|
||||
if (isFn(val)) val = val();
|
||||
|
||||
messages.push({name, val});
|
||||
});
|
||||
|
||||
this._renderHtml(this._tpl({messages}));
|
||||
}
|
||||
_renderHtml(html)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,10 @@ let browser = detectBrowser();
|
||||
export default [
|
||||
{
|
||||
name: 'Location',
|
||||
val: location.href
|
||||
val()
|
||||
{
|
||||
return location.href;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'User Agent',
|
||||
|
||||
Reference in New Issue
Block a user