mirror of
https://github.com/liriliri/eruda.git
synced 2026-03-20 09:38:37 +08:00
Add: Auto display if error occurs option
This commit is contained in:
@@ -139,6 +139,12 @@ export default class Console extends Tool
|
||||
{
|
||||
parent.get('sources').set('json', data);
|
||||
parent.showTool('sources');
|
||||
}).on('insert', (log) =>
|
||||
{
|
||||
if (log.type === 'error' && this.config.get('displayIfErr'))
|
||||
{
|
||||
parent.show().showTool('console');
|
||||
}
|
||||
});
|
||||
}
|
||||
_hideInput()
|
||||
@@ -165,7 +171,8 @@ export default class Console extends Tool
|
||||
|
||||
cfg.set(util.defaults(cfg.get(), {
|
||||
catchGlobalErr: true,
|
||||
overrideConsole: true
|
||||
overrideConsole: true,
|
||||
displayIfErr: false
|
||||
}));
|
||||
|
||||
if (cfg.get('catchGlobalErr')) this.catchGlobalErr();
|
||||
|
||||
@@ -195,6 +195,8 @@ export default class Log extends util.Emitter
|
||||
this._lastLog = log;
|
||||
}
|
||||
|
||||
this.emit('insert', log);
|
||||
|
||||
this._isUpdated = true;
|
||||
return this.render();
|
||||
}
|
||||
@@ -276,7 +278,7 @@ var evalJs = jsInput => eval.call(window, jsInput);
|
||||
function errToStr(err)
|
||||
{
|
||||
var lines = err.stack.split('\n'),
|
||||
msg = `${lines[0]}<br/>`,
|
||||
msg = `${err.message || lines[0]}<br/>`,
|
||||
stack = `<div class="eruda-stack">${lines.slice(1).join('<br/>')}</div>`;
|
||||
|
||||
return msg + stack.replace(regJsUrl, match => `<a href="${match}" target="_blank">${match}</a>`);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="eruda-btn eruda-back" ontouchstart>
|
||||
<span class="eruda-icon eruda-icon-chevron-left"></span>
|
||||
</div>
|
||||
<div class="eruda-btn eruda-select">
|
||||
<div class="eruda-btn eruda-select" ontouchstart>
|
||||
<span class="eruda-icon eruda-icon-hand-pointer-o"></span>
|
||||
</div>
|
||||
<div class="eruda-btn eruda-refresh" ontouchstart>
|
||||
|
||||
@@ -104,13 +104,14 @@
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
font-size: 0;
|
||||
.btn {
|
||||
text-align: center;
|
||||
color: $gray;
|
||||
font-size: 14px;
|
||||
line-height: 40px;
|
||||
flex-grow: 1;
|
||||
width: 20%;
|
||||
display: inline-block;
|
||||
&:active, &.active {
|
||||
color: $blue;
|
||||
}
|
||||
|
||||
@@ -242,9 +242,7 @@ export default class Network extends Tool
|
||||
{
|
||||
var cfg = this.config = config.create('eruda-network');
|
||||
|
||||
cfg.set(util.defaults(cfg.get(), {
|
||||
overrideXhr: false
|
||||
}));
|
||||
cfg.set(util.defaults(cfg.get(), {overrideXhr: true}));
|
||||
|
||||
if (cfg.get('overrideXhr')) this.overrideXhr();
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ settings.separator()
|
||||
.separator()
|
||||
.add(consoleTool.config, 'catchGlobalErr', 'Catch Global Errors')
|
||||
.add(consoleTool.config, 'overrideConsole', 'Override Console')
|
||||
.add(consoleTool.config, 'displayIfErr', 'Auto Display If Error Occurs')
|
||||
.separator()
|
||||
.add(network.config, 'overrideXhr', 'Catch Ajax Requests');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user