From 472f5c9c28b251b9cc6b04a40b91a19a3d6c93ec Mon Sep 17 00:00:00 2001 From: Maiz Date: Tue, 3 May 2016 16:51:15 +0800 Subject: [PATCH 1/2] support window.onerror and line breaks --- dist/vconsole.min.js | 2 +- example/demo1.html | 6 ++++++ src/vconsole.js | 11 +++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/dist/vconsole.min.js b/dist/vconsole.min.js index f5e2fc16..b7cb19a5 100644 --- a/dist/vconsole.min.js +++ b/dist/vconsole.min.js @@ -3,4 +3,4 @@ * Copyright 2016, WechatFE Team * MIT license */ -!function(o,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.vConsole=t():o.vConsole=t()}(this,function(){return function(o){function t(n){if(e[n])return e[n].exports;var i=e[n]={exports:{},id:n,loaded:!1};return o[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var e={};return t.m=o,t.c=e,t.p="",t(0)}([function(o,t,e){"use strict";function n(o){return o&&o.__esModule?o:{"default":o}}function i(){this.html=u["default"],this.$dom=null,this.activedTab="default",this.console={},this.isReady=!1,this.readyCallback=[];var o=this;l(window,"load",function(){o._render(),o._bindEvent(),o._mokeConsole(),o._autoRun()})}function r(o,t){return t?t.querySelector(o):document.querySelector(o)}function c(o,t){var e,n=[];return e=t?t.querySelectorAll(o):document.querySelectorAll(o),e&&e.length>0&&(n=Array.prototype.slice.call(e)),n}function s(o,t){if(o){"[object Array]"!=Object.prototype.toString.call(o)&&(o=[o]);for(var e=0;e0?new Date(o):new Date,e=t.getDay()<10?"0"+t.getDay():t.getDay(),n=t.getMonth()<9?"0"+(t.getMonth()+1):t.getMonth()+1,i=t.getFullYear(),r=t.getHours()<10?"0"+t.getHours():t.getHours(),c=t.getMinutes()<10?"0"+t.getMinutes():t.getMinutes(),s=t.getSeconds()<10?"0"+t.getSeconds():t.getSeconds(),a=t.getMilliseconds()<10?"0"+t.getMilliseconds():t.getMilliseconds();return 100>a&&(a="0"+a),{time:+t,year:i,month:n,day:e,hour:r,minute:c,second:s,millisecond:a}}function f(o){return document.createElement("a").appendChild(document.createTextNode(o)).parentNode.innerHTML}Object.defineProperty(t,"__esModule",{value:!0});var v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol?"symbol":typeof o};e(1);var p=e(5),u=n(p);i.prototype._render=function(){var o="#__vconsole";if(!r(o)){var t=document.createElement("div");t.innerHTML=this.html,document.body.appendChild(t.children[0])}this.$dom=r(o)},i.prototype._bindEvent=function(){var o=this;l(r(".vc-show"),"click",function(){o.show()}),l(r(".vc-hide"),"click",function(){o.hide()}),l(r(".vc-mask"),"click",function(t){return t.target!=r(".vc-mask")?!1:void o.hide()}),l(r(".vc-clear"),"click",function(){o.clearLog(o.activedTab)}),l(c(".vc-tab"),"click",function(t){var e=t.target.dataset.tab;e!=o.activedTab&&o.showTab(e)})},i.prototype._mokeConsole=function(){if(window.console){var o=this;this.console.log=window.console.log,this.console.info=window.console.info,this.console.warn=window.console.warn,this.console.debug=window.console.debug,this.console.error=window.console.error,window.console.log=function(){o._printLog("default","log",arguments)},window.console.info=function(){o._printLog("default","info",arguments)},window.console.warn=function(){o._printLog("default","warn",arguments)},window.console.debug=function(){o._printLog("default","debug",arguments)},window.console.error=function(){o._printLog("default","error",arguments)}}},i.prototype._autoRun=function(){var o=navigator.userAgent,t=[],e=d();this._printLog("system","info",["日志时间:",e.year+"-"+e.month+"-"+e.day+" "+e.hour+":"+e.minute+":"+e.second+" "+e.millisecond]),t=["系统版本:","不明"];var n=o.match(/(ipod).*\s([\d_]+)/i),i=o.match(/(ipad).*\s([\d_]+)/i),r=o.match(/(iphone)\sos\s([\d_]+)/i),c=o.match(/(android)\s([\d\.]+)/i);c?t[1]="Android "+c[2]:r?t[1]="iPhone, iOS "+r[2].replace(/_/g,"."):i?t[1]="iPad, iOS "+i[2].replace(/_/g,"."):n&&(t[1]="iPod, iOS "+n[2].replace(/_/g,".")),this._printLog("system","info",t);var s=o.match(/MicroMessenger\/([\d\.]+)/i);t=["微信版本:","不明"],s&&s[1]&&(t[1]=s[1],this._printLog("system","info",t));var a=o.toLowerCase().match(/ nettype\/([^ ]+)/g);for(t=["网络类型:","不明"],a&&a[0]&&(a=a[0].split("/"),t[1]=a[1],this._printLog("system","info",t)),t=["网址协议:","不明"],"https:"==location.protocol?t[1]="HTTPS":"http:"==location.protocol?t[1]="HTTP":t[1]=location.protocol.replace(":",""),this._printLog("system","info",t),window.addEventListener("load",function(o){var t=window.performance||window.msPerformance||window.webkitPerformance;if(t&&t.timing){var e=t.timing,n=e.navigationStart;this._printLog("system","info",["连接结束点:",e.connectEnd-n+"ms"]),this._printLog("system","info",["回包结束点:",e.responseEnd-n+"ms"]),e.secureConnectionStart>0&&this._printLog("system","info",["ssl耗时:",e.connectEnd-e.secureConnectionStart+"ms"]),this._printLog("system","info",["dom渲染耗时:",e.domComplete-e.domLoading+"ms"])}});this.readyCallback.length>0;){var l=this.readyCallback.shift();l&&l.call(this)}this.isReady=!0},i.prototype._printLog=function(o,t,e){if(e.length){for(var n="",i=0;i=0&&_.splice(t,1)}function s(o){var t=document.createElement("style");return t.type="text/css",r(o,t),t}function a(o){var t=document.createElement("link");return t.rel="stylesheet",r(o,t),t}function l(o,t){var e,n,i;if(t.singleton){var r=m++;e=b||(b=s(t)),n=d.bind(null,e,r,!1),i=d.bind(null,e,r,!0)}else o.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(e=a(t),n=v.bind(null,e),i=function(){c(e),e.href&&URL.revokeObjectURL(e.href)}):(e=s(t),n=f.bind(null,e),i=function(){c(e)});return n(o),function(t){if(t){if(t.css===o.css&&t.media===o.media&&t.sourceMap===o.sourceMap)return;n(o=t)}else i()}}function d(o,t,e,n){var i=e?"":n.css;if(o.styleSheet)o.styleSheet.cssText=y(t,i);else{var r=document.createTextNode(i),c=o.childNodes;c[t]&&o.removeChild(c[t]),c.length?o.insertBefore(r,c[t]):o.appendChild(r)}}function f(o,t){var e=t.css,n=t.media;if(n&&o.setAttribute("media",n),o.styleSheet)o.styleSheet.cssText=e;else{for(;o.firstChild;)o.removeChild(o.firstChild);o.appendChild(document.createTextNode(e))}}function v(o,t){var e=t.css,n=t.sourceMap;n&&(e+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(n))))+" */");var i=new Blob([e],{type:"text/css"}),r=o.href;o.href=URL.createObjectURL(i),r&&URL.revokeObjectURL(r)}var p={},u=function(o){var t;return function(){return"undefined"==typeof t&&(t=o.apply(this,arguments)),t}},h=u(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),g=u(function(){return document.head||document.getElementsByTagName("head")[0]}),b=null,m=0,_=[];o.exports=function(o,t){t=t||{},"undefined"==typeof t.singleton&&(t.singleton=h()),"undefined"==typeof t.insertAt&&(t.insertAt="bottom");var e=i(o);return n(e,t),function(o){for(var r=[],c=0;c
面板
'}])}); \ No newline at end of file +!function(o,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.vConsole=t():o.vConsole=t()}(this,function(){return function(o){function t(n){if(e[n])return e[n].exports;var r=e[n]={exports:{},id:n,loaded:!1};return o[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var e={};return t.m=o,t.c=e,t.p="",t(0)}([function(o,t,e){"use strict";function n(o){return o&&o.__esModule?o:{"default":o}}function r(){this.html=u["default"],this.$dom=null,this.activedTab="default",this.console={},this.isReady=!1,this.readyCallback=[];var o=this;l(window,"load",function(){o._render(),o._bindEvent(),o._mokeConsole(),o._autoRun()})}function i(o,t){return t?t.querySelector(o):document.querySelector(o)}function c(o,t){var e,n=[];return e=t?t.querySelectorAll(o):document.querySelectorAll(o),e&&e.length>0&&(n=Array.prototype.slice.call(e)),n}function s(o,t){if(o){"[object Array]"!=Object.prototype.toString.call(o)&&(o=[o]);for(var e=0;e0?new Date(o):new Date,e=t.getDay()<10?"0"+t.getDay():t.getDay(),n=t.getMonth()<9?"0"+(t.getMonth()+1):t.getMonth()+1,r=t.getFullYear(),i=t.getHours()<10?"0"+t.getHours():t.getHours(),c=t.getMinutes()<10?"0"+t.getMinutes():t.getMinutes(),s=t.getSeconds()<10?"0"+t.getSeconds():t.getSeconds(),a=t.getMilliseconds()<10?"0"+t.getMilliseconds():t.getMilliseconds();return 100>a&&(a="0"+a),{time:+t,year:r,month:n,day:e,hour:i,minute:c,second:s,millisecond:a}}function f(o){return document.createElement("a").appendChild(document.createTextNode(o)).parentNode.innerHTML}Object.defineProperty(t,"__esModule",{value:!0});var v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol?"symbol":typeof o};e(1);var p=e(5),u=n(p);r.prototype._render=function(){var o="#__vconsole";if(!i(o)){var t=document.createElement("div");t.innerHTML=this.html,document.body.appendChild(t.children[0])}this.$dom=i(o)},r.prototype._bindEvent=function(){var o=this;l(i(".vc-show"),"click",function(){o.show()}),l(i(".vc-hide"),"click",function(){o.hide()}),l(i(".vc-mask"),"click",function(t){return t.target!=i(".vc-mask")?!1:void o.hide()}),l(i(".vc-clear"),"click",function(){o.clearLog(o.activedTab)}),l(c(".vc-tab"),"click",function(t){var e=t.target.dataset.tab;e!=o.activedTab&&o.showTab(e)})},r.prototype._mokeConsole=function(){if(window.console){var o=this;this.console.log=window.console.log,this.console.info=window.console.info,this.console.warn=window.console.warn,this.console.debug=window.console.debug,this.console.error=window.console.error,window.console.log=function(){o._printLog("default","log",arguments)},window.console.info=function(){o._printLog("default","info",arguments)},window.console.warn=function(){o._printLog("default","warn",arguments)},window.console.debug=function(){o._printLog("default","debug",arguments)},window.console.error=function(){o._printLog("default","error",arguments)},window.onerror=function(o,t,e,n,r){var i=r.stack.split("at");i=i[0]+" "+i[1],i=i.replace(location.origin,""),console.error(i)}}},r.prototype._autoRun=function(){var o=navigator.userAgent,t=[],e=d();this._printLog("system","info",["日志时间:",e.year+"-"+e.month+"-"+e.day+" "+e.hour+":"+e.minute+":"+e.second+" "+e.millisecond]),t=["系统版本:","不明"];var n=o.match(/(ipod).*\s([\d_]+)/i),r=o.match(/(ipad).*\s([\d_]+)/i),i=o.match(/(iphone)\sos\s([\d_]+)/i),c=o.match(/(android)\s([\d\.]+)/i);c?t[1]="Android "+c[2]:i?t[1]="iPhone, iOS "+i[2].replace(/_/g,"."):r?t[1]="iPad, iOS "+r[2].replace(/_/g,"."):n&&(t[1]="iPod, iOS "+n[2].replace(/_/g,".")),this._printLog("system","info",t);var s=o.match(/MicroMessenger\/([\d\.]+)/i);t=["微信版本:","不明"],s&&s[1]&&(t[1]=s[1],this._printLog("system","info",t));var a=o.toLowerCase().match(/ nettype\/([^ ]+)/g);for(t=["网络类型:","不明"],a&&a[0]&&(a=a[0].split("/"),t[1]=a[1],this._printLog("system","info",t)),t=["网址协议:","不明"],"https:"==location.protocol?t[1]="HTTPS":"http:"==location.protocol?t[1]="HTTP":t[1]=location.protocol.replace(":",""),this._printLog("system","info",t),window.addEventListener("load",function(o){var t=window.performance||window.msPerformance||window.webkitPerformance;if(t&&t.timing){var e=t.timing,n=e.navigationStart;this._printLog("system","info",["连接结束点:",e.connectEnd-n+"ms"]),this._printLog("system","info",["回包结束点:",e.responseEnd-n+"ms"]),e.secureConnectionStart>0&&this._printLog("system","info",["ssl耗时:",e.connectEnd-e.secureConnectionStart+"ms"]),this._printLog("system","info",["dom渲染耗时:",e.domComplete-e.domLoading+"ms"])}});this.readyCallback.length>0;){var l=this.readyCallback.shift();l&&l.call(this)}this.isReady=!0},r.prototype._printLog=function(o,t,e){if(e.length){for(var n="",r=0;r")}catch(c){n+=" ["+v(e[r])+"]"}var s=i("#__vc_log_"+o),a=document.createElement("p");a.className="vc-item vc-item-"+t,a.innerHTML=n,i(".vc-log",s).appendChild(a),i(".vc-content").scrollTop=i(".vc-content").scrollHeight,this.console[t].apply(window.console,e)}},r.prototype.showTab=function(o){var t=i("#__vc_log_"+o);a(c(".vc-tab",this.$dom),"vc-actived"),s(i("#__vc_tab_"+o),"vc-actived"),a(c(".vc-logbox"),"vc-actived"),s(t,"vc-actived"),i(".vc-content").scrollTop=i(".vc-content").scrollHeight,this.activedTab=o},r.prototype.clearLog=function(o){var t=i("#__vc_log_"+o);i(".vc-log",t).innerHTML=""},r.prototype.show=function(){s(this.$dom,"vc-toggle")},r.prototype.hide=function(){a(this.$dom,"vc-toggle")},r.prototype.ready=function(o){this.isReady?o.call(this):this.readyCallback.push(o)},t["default"]=new r,o.exports=t["default"]},function(o,t,e){var n=e(2);"string"==typeof n&&(n=[[o.id,n,""]]);e(4)(n,{});n.locals&&(o.exports=n.locals)},function(o,t,e){t=o.exports=e(3)(),t.push([o.id,'#__vconsole{font-size:13px}#__vconsole .vc-show{display:block;position:fixed;right:10px;bottom:10px;color:#fff;background-color:#04be02;line-height:1;font-size:14px;padding:8px 16px;z-index:10000;border-radius:4px;box-shadow:0 0 8px rgba(0,0,0,.4)}#__vconsole .vc-mask{display:none;position:fixed;top:0;left:0;right:0;bottom:0;background-color:transparent;z-index:10001;transition:background .3s}#__vconsole .vc-panel{position:fixed;min-height:80%;left:0;right:0;bottom:0;z-index:10002;background-color:#efeff4;-webkit-transition:-webkit-transform .3s;transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s;-webkit-transform:translateY(100%);transform:translateY(100%)}#__vconsole .vc-tabbar{border-bottom:1px solid #d9d9d9;overflow:hidden}#__vconsole .vc-tabbar .vc-tab{float:left;line-height:39px;padding:0 15px;border-right:1px solid #d9d9d9;text-decoration:none;color:#000}#__vconsole .vc-tabbar .vc-tab.vc-actived{background-color:#fff}#__vconsole .vc-content{background-color:#fff;overflow-x:hidden;overflow-y:scroll;position:absolute;top:40px;left:0;right:0;bottom:40px;-webkit-overflow-scrolling:touch}#__vconsole .vc-logbox{display:none;position:relative;height:100%}#__vconsole .vc-logbox .vc-log:empty:before{content:"No log";color:#999;position:absolute;top:45%;left:0;right:0;bottom:0;font-size:15px;text-align:center}#__vconsole .vc-logbox .vc-item{margin:0;padding:6px 8px;line-height:1.3;border-bottom:1px solid #eee;word-break:break-word}#__vconsole .vc-logbox .vc-item-info{color:#6a5acd}#__vconsole .vc-logbox .vc-item-debug{color:#daa520}#__vconsole .vc-logbox .vc-item-warn{color:orange;border-color:#ffb930;background-color:#fffacd}#__vconsole .vc-logbox .vc-item-error{color:#dc143c;border-color:#f4a0ab;background-color:#ffe4e1}#__vconsole .vc-logbox.vc-actived{display:block}#__vconsole .vc-toolbar{border-top:1px solid #d9d9d9;line-height:39px;position:absolute;left:0;right:0;bottom:0;overflow:hidden}#__vconsole .vc-toolbar .vc-tool{text-decoration:none;color:#000;width:50%;float:left;text-align:center;position:relative}#__vconsole .vc-toolbar .vc-tool:after{content:" ";position:absolute;top:7px;bottom:7px;right:0;border-left:1px solid #d9d9d9}#__vconsole .vc-toolbar .vc-tool-last:after{border:none}#__vconsole.vc-toggle .vc-show{display:none}#__vconsole.vc-toggle .vc-mask{background:rgba(0,0,0,.6);display:block}#__vconsole.vc-toggle .vc-panel{-webkit-transform:translate(0);transform:translate(0)}',""])},function(o,t){"use strict";o.exports=function(){var o=[];return o.toString=function(){for(var o=[],t=0;t=0&&_.splice(t,1)}function s(o){var t=document.createElement("style");return t.type="text/css",i(o,t),t}function a(o){var t=document.createElement("link");return t.rel="stylesheet",i(o,t),t}function l(o,t){var e,n,r;if(t.singleton){var i=m++;e=b||(b=s(t)),n=d.bind(null,e,i,!1),r=d.bind(null,e,i,!0)}else o.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(e=a(t),n=v.bind(null,e),r=function(){c(e),e.href&&URL.revokeObjectURL(e.href)}):(e=s(t),n=f.bind(null,e),r=function(){c(e)});return n(o),function(t){if(t){if(t.css===o.css&&t.media===o.media&&t.sourceMap===o.sourceMap)return;n(o=t)}else r()}}function d(o,t,e,n){var r=e?"":n.css;if(o.styleSheet)o.styleSheet.cssText=y(t,r);else{var i=document.createTextNode(r),c=o.childNodes;c[t]&&o.removeChild(c[t]),c.length?o.insertBefore(i,c[t]):o.appendChild(i)}}function f(o,t){var e=t.css,n=t.media;if(n&&o.setAttribute("media",n),o.styleSheet)o.styleSheet.cssText=e;else{for(;o.firstChild;)o.removeChild(o.firstChild);o.appendChild(document.createTextNode(e))}}function v(o,t){var e=t.css,n=t.sourceMap;n&&(e+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(n))))+" */");var r=new Blob([e],{type:"text/css"}),i=o.href;o.href=URL.createObjectURL(r),i&&URL.revokeObjectURL(i)}var p={},u=function(o){var t;return function(){return"undefined"==typeof t&&(t=o.apply(this,arguments)),t}},h=u(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),g=u(function(){return document.head||document.getElementsByTagName("head")[0]}),b=null,m=0,_=[];o.exports=function(o,t){t=t||{},"undefined"==typeof t.singleton&&(t.singleton=h()),"undefined"==typeof t.insertAt&&(t.insertAt="bottom");var e=r(o);return n(e,t),function(o){for(var i=[],c=0;c
面板
'}])}); \ No newline at end of file diff --git a/example/demo1.html b/example/demo1.html index b3ed45e0..9caf0688 100644 --- a/example/demo1.html +++ b/example/demo1.html @@ -27,6 +27,7 @@

Demo 1

报错日志(error) 打印Object + 触发JS Error
已打印log
@@ -49,6 +50,11 @@

Demo 1

}); showTips(); }); +$('.js_btn_trigger_error').on('tap', function(e) { + showTips(); + var err = undefined; + err.a = 1; +}); // 用于页面内展示顶部tips var tipsTimer; diff --git a/src/vconsole.js b/src/vconsole.js index f6e1c002..5337c06e 100644 --- a/src/vconsole.js +++ b/src/vconsole.js @@ -83,7 +83,7 @@ vConsole.prototype._bindEvent = function() { }; /** - * replace window.console with vConsole method + * replace window.console & window.onerror with vConsole method * @private */ vConsole.prototype._mokeConsole = function() { @@ -101,6 +101,13 @@ vConsole.prototype._mokeConsole = function() { window.console.warn = function() { that._printLog('default', 'warn', arguments); }; window.console.debug = function() { that._printLog('default', 'debug', arguments); }; window.console.error = function() { that._printLog('default', 'error', arguments); }; + + window.onerror = function(message, source, lineno, colno, error) { + var stack = error.stack.split('at'); + stack = stack[0] + ' ' + stack[1]; + stack = stack.replace(location.origin, ''); + console.error(stack); + }; }; /** @@ -210,7 +217,7 @@ vConsole.prototype._printLog = function(tabName, logType, logs) { } else if (typeof logs[i] == 'object') { line += ' ' + JSON.stringify(logs[i]); } else { - line += ' ' + htmlEncode(logs[i]); + line += ' ' + htmlEncode(logs[i]).replace(/\n/g, '
'); } } catch (e) { line += ' [' + (typeof logs[i]) + ']'; From 6f6489569ce2c606c8c71e5d3255379db2fce076 Mon Sep 17 00:00:00 2001 From: Maiz Date: Tue, 3 May 2016 18:26:54 +0800 Subject: [PATCH 2/2] support [default|system] log format --- dist/vconsole.min.js | 2 +- example/demo1.html | 5 +++++ example/lib/demo.css | 2 +- src/vconsole.js | 26 ++++++++++++++++++++------ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/dist/vconsole.min.js b/dist/vconsole.min.js index b7cb19a5..4371ac59 100644 --- a/dist/vconsole.min.js +++ b/dist/vconsole.min.js @@ -3,4 +3,4 @@ * Copyright 2016, WechatFE Team * MIT license */ -!function(o,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.vConsole=t():o.vConsole=t()}(this,function(){return function(o){function t(n){if(e[n])return e[n].exports;var r=e[n]={exports:{},id:n,loaded:!1};return o[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var e={};return t.m=o,t.c=e,t.p="",t(0)}([function(o,t,e){"use strict";function n(o){return o&&o.__esModule?o:{"default":o}}function r(){this.html=u["default"],this.$dom=null,this.activedTab="default",this.console={},this.isReady=!1,this.readyCallback=[];var o=this;l(window,"load",function(){o._render(),o._bindEvent(),o._mokeConsole(),o._autoRun()})}function i(o,t){return t?t.querySelector(o):document.querySelector(o)}function c(o,t){var e,n=[];return e=t?t.querySelectorAll(o):document.querySelectorAll(o),e&&e.length>0&&(n=Array.prototype.slice.call(e)),n}function s(o,t){if(o){"[object Array]"!=Object.prototype.toString.call(o)&&(o=[o]);for(var e=0;e0?new Date(o):new Date,e=t.getDay()<10?"0"+t.getDay():t.getDay(),n=t.getMonth()<9?"0"+(t.getMonth()+1):t.getMonth()+1,r=t.getFullYear(),i=t.getHours()<10?"0"+t.getHours():t.getHours(),c=t.getMinutes()<10?"0"+t.getMinutes():t.getMinutes(),s=t.getSeconds()<10?"0"+t.getSeconds():t.getSeconds(),a=t.getMilliseconds()<10?"0"+t.getMilliseconds():t.getMilliseconds();return 100>a&&(a="0"+a),{time:+t,year:r,month:n,day:e,hour:i,minute:c,second:s,millisecond:a}}function f(o){return document.createElement("a").appendChild(document.createTextNode(o)).parentNode.innerHTML}Object.defineProperty(t,"__esModule",{value:!0});var v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol?"symbol":typeof o};e(1);var p=e(5),u=n(p);r.prototype._render=function(){var o="#__vconsole";if(!i(o)){var t=document.createElement("div");t.innerHTML=this.html,document.body.appendChild(t.children[0])}this.$dom=i(o)},r.prototype._bindEvent=function(){var o=this;l(i(".vc-show"),"click",function(){o.show()}),l(i(".vc-hide"),"click",function(){o.hide()}),l(i(".vc-mask"),"click",function(t){return t.target!=i(".vc-mask")?!1:void o.hide()}),l(i(".vc-clear"),"click",function(){o.clearLog(o.activedTab)}),l(c(".vc-tab"),"click",function(t){var e=t.target.dataset.tab;e!=o.activedTab&&o.showTab(e)})},r.prototype._mokeConsole=function(){if(window.console){var o=this;this.console.log=window.console.log,this.console.info=window.console.info,this.console.warn=window.console.warn,this.console.debug=window.console.debug,this.console.error=window.console.error,window.console.log=function(){o._printLog("default","log",arguments)},window.console.info=function(){o._printLog("default","info",arguments)},window.console.warn=function(){o._printLog("default","warn",arguments)},window.console.debug=function(){o._printLog("default","debug",arguments)},window.console.error=function(){o._printLog("default","error",arguments)},window.onerror=function(o,t,e,n,r){var i=r.stack.split("at");i=i[0]+" "+i[1],i=i.replace(location.origin,""),console.error(i)}}},r.prototype._autoRun=function(){var o=navigator.userAgent,t=[],e=d();this._printLog("system","info",["日志时间:",e.year+"-"+e.month+"-"+e.day+" "+e.hour+":"+e.minute+":"+e.second+" "+e.millisecond]),t=["系统版本:","不明"];var n=o.match(/(ipod).*\s([\d_]+)/i),r=o.match(/(ipad).*\s([\d_]+)/i),i=o.match(/(iphone)\sos\s([\d_]+)/i),c=o.match(/(android)\s([\d\.]+)/i);c?t[1]="Android "+c[2]:i?t[1]="iPhone, iOS "+i[2].replace(/_/g,"."):r?t[1]="iPad, iOS "+r[2].replace(/_/g,"."):n&&(t[1]="iPod, iOS "+n[2].replace(/_/g,".")),this._printLog("system","info",t);var s=o.match(/MicroMessenger\/([\d\.]+)/i);t=["微信版本:","不明"],s&&s[1]&&(t[1]=s[1],this._printLog("system","info",t));var a=o.toLowerCase().match(/ nettype\/([^ ]+)/g);for(t=["网络类型:","不明"],a&&a[0]&&(a=a[0].split("/"),t[1]=a[1],this._printLog("system","info",t)),t=["网址协议:","不明"],"https:"==location.protocol?t[1]="HTTPS":"http:"==location.protocol?t[1]="HTTP":t[1]=location.protocol.replace(":",""),this._printLog("system","info",t),window.addEventListener("load",function(o){var t=window.performance||window.msPerformance||window.webkitPerformance;if(t&&t.timing){var e=t.timing,n=e.navigationStart;this._printLog("system","info",["连接结束点:",e.connectEnd-n+"ms"]),this._printLog("system","info",["回包结束点:",e.responseEnd-n+"ms"]),e.secureConnectionStart>0&&this._printLog("system","info",["ssl耗时:",e.connectEnd-e.secureConnectionStart+"ms"]),this._printLog("system","info",["dom渲染耗时:",e.domComplete-e.domLoading+"ms"])}});this.readyCallback.length>0;){var l=this.readyCallback.shift();l&&l.call(this)}this.isReady=!0},r.prototype._printLog=function(o,t,e){if(e.length){for(var n="",r=0;r")}catch(c){n+=" ["+v(e[r])+"]"}var s=i("#__vc_log_"+o),a=document.createElement("p");a.className="vc-item vc-item-"+t,a.innerHTML=n,i(".vc-log",s).appendChild(a),i(".vc-content").scrollTop=i(".vc-content").scrollHeight,this.console[t].apply(window.console,e)}},r.prototype.showTab=function(o){var t=i("#__vc_log_"+o);a(c(".vc-tab",this.$dom),"vc-actived"),s(i("#__vc_tab_"+o),"vc-actived"),a(c(".vc-logbox"),"vc-actived"),s(t,"vc-actived"),i(".vc-content").scrollTop=i(".vc-content").scrollHeight,this.activedTab=o},r.prototype.clearLog=function(o){var t=i("#__vc_log_"+o);i(".vc-log",t).innerHTML=""},r.prototype.show=function(){s(this.$dom,"vc-toggle")},r.prototype.hide=function(){a(this.$dom,"vc-toggle")},r.prototype.ready=function(o){this.isReady?o.call(this):this.readyCallback.push(o)},t["default"]=new r,o.exports=t["default"]},function(o,t,e){var n=e(2);"string"==typeof n&&(n=[[o.id,n,""]]);e(4)(n,{});n.locals&&(o.exports=n.locals)},function(o,t,e){t=o.exports=e(3)(),t.push([o.id,'#__vconsole{font-size:13px}#__vconsole .vc-show{display:block;position:fixed;right:10px;bottom:10px;color:#fff;background-color:#04be02;line-height:1;font-size:14px;padding:8px 16px;z-index:10000;border-radius:4px;box-shadow:0 0 8px rgba(0,0,0,.4)}#__vconsole .vc-mask{display:none;position:fixed;top:0;left:0;right:0;bottom:0;background-color:transparent;z-index:10001;transition:background .3s}#__vconsole .vc-panel{position:fixed;min-height:80%;left:0;right:0;bottom:0;z-index:10002;background-color:#efeff4;-webkit-transition:-webkit-transform .3s;transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s;-webkit-transform:translateY(100%);transform:translateY(100%)}#__vconsole .vc-tabbar{border-bottom:1px solid #d9d9d9;overflow:hidden}#__vconsole .vc-tabbar .vc-tab{float:left;line-height:39px;padding:0 15px;border-right:1px solid #d9d9d9;text-decoration:none;color:#000}#__vconsole .vc-tabbar .vc-tab.vc-actived{background-color:#fff}#__vconsole .vc-content{background-color:#fff;overflow-x:hidden;overflow-y:scroll;position:absolute;top:40px;left:0;right:0;bottom:40px;-webkit-overflow-scrolling:touch}#__vconsole .vc-logbox{display:none;position:relative;height:100%}#__vconsole .vc-logbox .vc-log:empty:before{content:"No log";color:#999;position:absolute;top:45%;left:0;right:0;bottom:0;font-size:15px;text-align:center}#__vconsole .vc-logbox .vc-item{margin:0;padding:6px 8px;line-height:1.3;border-bottom:1px solid #eee;word-break:break-word}#__vconsole .vc-logbox .vc-item-info{color:#6a5acd}#__vconsole .vc-logbox .vc-item-debug{color:#daa520}#__vconsole .vc-logbox .vc-item-warn{color:orange;border-color:#ffb930;background-color:#fffacd}#__vconsole .vc-logbox .vc-item-error{color:#dc143c;border-color:#f4a0ab;background-color:#ffe4e1}#__vconsole .vc-logbox.vc-actived{display:block}#__vconsole .vc-toolbar{border-top:1px solid #d9d9d9;line-height:39px;position:absolute;left:0;right:0;bottom:0;overflow:hidden}#__vconsole .vc-toolbar .vc-tool{text-decoration:none;color:#000;width:50%;float:left;text-align:center;position:relative}#__vconsole .vc-toolbar .vc-tool:after{content:" ";position:absolute;top:7px;bottom:7px;right:0;border-left:1px solid #d9d9d9}#__vconsole .vc-toolbar .vc-tool-last:after{border:none}#__vconsole.vc-toggle .vc-show{display:none}#__vconsole.vc-toggle .vc-mask{background:rgba(0,0,0,.6);display:block}#__vconsole.vc-toggle .vc-panel{-webkit-transform:translate(0);transform:translate(0)}',""])},function(o,t){"use strict";o.exports=function(){var o=[];return o.toString=function(){for(var o=[],t=0;t=0&&_.splice(t,1)}function s(o){var t=document.createElement("style");return t.type="text/css",i(o,t),t}function a(o){var t=document.createElement("link");return t.rel="stylesheet",i(o,t),t}function l(o,t){var e,n,r;if(t.singleton){var i=m++;e=b||(b=s(t)),n=d.bind(null,e,i,!1),r=d.bind(null,e,i,!0)}else o.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(e=a(t),n=v.bind(null,e),r=function(){c(e),e.href&&URL.revokeObjectURL(e.href)}):(e=s(t),n=f.bind(null,e),r=function(){c(e)});return n(o),function(t){if(t){if(t.css===o.css&&t.media===o.media&&t.sourceMap===o.sourceMap)return;n(o=t)}else r()}}function d(o,t,e,n){var r=e?"":n.css;if(o.styleSheet)o.styleSheet.cssText=y(t,r);else{var i=document.createTextNode(r),c=o.childNodes;c[t]&&o.removeChild(c[t]),c.length?o.insertBefore(i,c[t]):o.appendChild(i)}}function f(o,t){var e=t.css,n=t.media;if(n&&o.setAttribute("media",n),o.styleSheet)o.styleSheet.cssText=e;else{for(;o.firstChild;)o.removeChild(o.firstChild);o.appendChild(document.createTextNode(e))}}function v(o,t){var e=t.css,n=t.sourceMap;n&&(e+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(n))))+" */");var r=new Blob([e],{type:"text/css"}),i=o.href;o.href=URL.createObjectURL(r),i&&URL.revokeObjectURL(i)}var p={},u=function(o){var t;return function(){return"undefined"==typeof t&&(t=o.apply(this,arguments)),t}},h=u(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),g=u(function(){return document.head||document.getElementsByTagName("head")[0]}),b=null,m=0,_=[];o.exports=function(o,t){t=t||{},"undefined"==typeof t.singleton&&(t.singleton=h()),"undefined"==typeof t.insertAt&&(t.insertAt="bottom");var e=r(o);return n(e,t),function(o){for(var i=[],c=0;c
面板
'}])}); \ No newline at end of file +!function(o,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.vConsole=t():o.vConsole=t()}(this,function(){return function(o){function t(n){if(e[n])return e[n].exports;var i=e[n]={exports:{},id:n,loaded:!1};return o[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var e={};return t.m=o,t.c=e,t.p="",t(0)}([function(o,t,e){"use strict";function n(o){return o&&o.__esModule?o:{"default":o}}function i(){this.html=u["default"],this.$dom=null,this.activedTab="default",this.tabList=["default","system"],this.console={},this.isReady=!1,this.readyCallback=[];var o=this;l(window,"load",function(){o._render(),o._bindEvent(),o._mokeConsole(),o._autoRun()})}function r(o,t){return t?t.querySelector(o):document.querySelector(o)}function c(o,t){var e,n=[];return e=t?t.querySelectorAll(o):document.querySelectorAll(o),e&&e.length>0&&(n=Array.prototype.slice.call(e)),n}function a(o,t){if(o){"[object Array]"!=Object.prototype.toString.call(o)&&(o=[o]);for(var e=0;e0?new Date(o):new Date,e=t.getDay()<10?"0"+t.getDay():t.getDay(),n=t.getMonth()<9?"0"+(t.getMonth()+1):t.getMonth()+1,i=t.getFullYear(),r=t.getHours()<10?"0"+t.getHours():t.getHours(),c=t.getMinutes()<10?"0"+t.getMinutes():t.getMinutes(),a=t.getSeconds()<10?"0"+t.getSeconds():t.getSeconds(),s=t.getMilliseconds()<10?"0"+t.getMilliseconds():t.getMilliseconds();return 100>s&&(s="0"+s),{time:+t,year:i,month:n,day:e,hour:r,minute:c,second:a,millisecond:s}}function f(o){return document.createElement("a").appendChild(document.createTextNode(o)).parentNode.innerHTML}Object.defineProperty(t,"__esModule",{value:!0});var v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol?"symbol":typeof o};e(1);var p=e(5),u=n(p);i.prototype._render=function(){var o="#__vconsole";if(!r(o)){var t=document.createElement("div");t.innerHTML=this.html,document.body.appendChild(t.children[0])}this.$dom=r(o)},i.prototype._bindEvent=function(){var o=this;l(r(".vc-show"),"click",function(){o.show()}),l(r(".vc-hide"),"click",function(){o.hide()}),l(r(".vc-mask"),"click",function(t){return t.target!=r(".vc-mask")?!1:void o.hide()}),l(r(".vc-clear"),"click",function(){o.clearLog(o.activedTab)}),l(c(".vc-tab"),"click",function(t){var e=t.target.dataset.tab;e!=o.activedTab&&o.showTab(e)})},i.prototype._mokeConsole=function(){if(window.console){var o=this;this.console.log=window.console.log,this.console.info=window.console.info,this.console.warn=window.console.warn,this.console.debug=window.console.debug,this.console.error=window.console.error,window.console.log=function(){o._printLog("auto","log",arguments)},window.console.info=function(){o._printLog("auto","info",arguments)},window.console.warn=function(){o._printLog("auto","warn",arguments)},window.console.debug=function(){o._printLog("auto","debug",arguments)},window.console.error=function(){o._printLog("auto","error",arguments)},window.onerror=function(o,t,e,n,i){var r=i.stack.split("at");r=r[0]+" "+r[1],r=r.replace(location.origin,""),console.error(r)}}},i.prototype._autoRun=function(){var o=navigator.userAgent,t=[],e=d();this._printLog("system","info",["日志时间:",e.year+"-"+e.month+"-"+e.day+" "+e.hour+":"+e.minute+":"+e.second+" "+e.millisecond]),t=["系统版本:","不明"];var n=o.match(/(ipod).*\s([\d_]+)/i),i=o.match(/(ipad).*\s([\d_]+)/i),r=o.match(/(iphone)\sos\s([\d_]+)/i),c=o.match(/(android)\s([\d\.]+)/i);c?t[1]="Android "+c[2]:r?t[1]="iPhone, iOS "+r[2].replace(/_/g,"."):i?t[1]="iPad, iOS "+i[2].replace(/_/g,"."):n&&(t[1]="iPod, iOS "+n[2].replace(/_/g,".")),this._printLog("system","info",t);var a=o.match(/MicroMessenger\/([\d\.]+)/i);t=["微信版本:","不明"],a&&a[1]&&(t[1]=a[1],this._printLog("system","info",t));var s=o.toLowerCase().match(/ nettype\/([^ ]+)/g);for(t=["网络类型:","不明"],s&&s[0]&&(s=s[0].split("/"),t[1]=s[1],this._printLog("system","info",t)),t=["网址协议:","不明"],"https:"==location.protocol?t[1]="HTTPS":"http:"==location.protocol?t[1]="HTTP":t[1]=location.protocol.replace(":",""),this._printLog("system","info",t),window.addEventListener("load",function(o){var t=window.performance||window.msPerformance||window.webkitPerformance;if(t&&t.timing){var e=t.timing,n=e.navigationStart;this._printLog("system","info",["连接结束点:",e.connectEnd-n+"ms"]),this._printLog("system","info",["回包结束点:",e.responseEnd-n+"ms"]),e.secureConnectionStart>0&&this._printLog("system","info",["ssl耗时:",e.connectEnd-e.secureConnectionStart+"ms"]),this._printLog("system","info",["dom渲染耗时:",e.domComplete-e.domLoading+"ms"])}});this.readyCallback.length>0;){var l=this.readyCallback.shift();l&&l.call(this)}this.isReady=!0},i.prototype._printLog=function(o,t,e){if(e.length){for(var n="",i=0;i")}catch(c){n+=" ["+v(e[i])+"]"}if("auto"==o){var a=/^ \[(\w+)\]/i,s=n.match(a);null!==s&&s.length>0&&this.tabList.indexOf(s[1])>-1&&(o=s[1],n=n.replace(a,""))}"auto"==o&&(o="default");var l=r("#__vc_log_"+o),d=document.createElement("p");d.className="vc-item vc-item-"+t,d.innerHTML=n,r(".vc-log",l).appendChild(d),r(".vc-content").scrollTop=r(".vc-content").scrollHeight,this.console[t].apply(window.console,e)}},i.prototype.showTab=function(o){var t=r("#__vc_log_"+o);s(c(".vc-tab",this.$dom),"vc-actived"),a(r("#__vc_tab_"+o),"vc-actived"),s(c(".vc-logbox"),"vc-actived"),a(t,"vc-actived"),r(".vc-content").scrollTop=r(".vc-content").scrollHeight,this.activedTab=o},i.prototype.clearLog=function(o){var t=r("#__vc_log_"+o);r(".vc-log",t).innerHTML=""},i.prototype.show=function(){a(this.$dom,"vc-toggle")},i.prototype.hide=function(){s(this.$dom,"vc-toggle")},i.prototype.ready=function(o){this.isReady?o.call(this):this.readyCallback.push(o)},t["default"]=new i,o.exports=t["default"]},function(o,t,e){var n=e(2);"string"==typeof n&&(n=[[o.id,n,""]]);e(4)(n,{});n.locals&&(o.exports=n.locals)},function(o,t,e){t=o.exports=e(3)(),t.push([o.id,'#__vconsole{font-size:13px}#__vconsole .vc-show{display:block;position:fixed;right:10px;bottom:10px;color:#fff;background-color:#04be02;line-height:1;font-size:14px;padding:8px 16px;z-index:10000;border-radius:4px;box-shadow:0 0 8px rgba(0,0,0,.4)}#__vconsole .vc-mask{display:none;position:fixed;top:0;left:0;right:0;bottom:0;background-color:transparent;z-index:10001;transition:background .3s}#__vconsole .vc-panel{position:fixed;min-height:80%;left:0;right:0;bottom:0;z-index:10002;background-color:#efeff4;-webkit-transition:-webkit-transform .3s;transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s;-webkit-transform:translateY(100%);transform:translateY(100%)}#__vconsole .vc-tabbar{border-bottom:1px solid #d9d9d9;overflow:hidden}#__vconsole .vc-tabbar .vc-tab{float:left;line-height:39px;padding:0 15px;border-right:1px solid #d9d9d9;text-decoration:none;color:#000}#__vconsole .vc-tabbar .vc-tab.vc-actived{background-color:#fff}#__vconsole .vc-content{background-color:#fff;overflow-x:hidden;overflow-y:scroll;position:absolute;top:40px;left:0;right:0;bottom:40px;-webkit-overflow-scrolling:touch}#__vconsole .vc-logbox{display:none;position:relative;height:100%}#__vconsole .vc-logbox .vc-log:empty:before{content:"No log";color:#999;position:absolute;top:45%;left:0;right:0;bottom:0;font-size:15px;text-align:center}#__vconsole .vc-logbox .vc-item{margin:0;padding:6px 8px;line-height:1.3;border-bottom:1px solid #eee;word-break:break-word}#__vconsole .vc-logbox .vc-item-info{color:#6a5acd}#__vconsole .vc-logbox .vc-item-debug{color:#daa520}#__vconsole .vc-logbox .vc-item-warn{color:orange;border-color:#ffb930;background-color:#fffacd}#__vconsole .vc-logbox .vc-item-error{color:#dc143c;border-color:#f4a0ab;background-color:#ffe4e1}#__vconsole .vc-logbox.vc-actived{display:block}#__vconsole .vc-toolbar{border-top:1px solid #d9d9d9;line-height:39px;position:absolute;left:0;right:0;bottom:0;overflow:hidden}#__vconsole .vc-toolbar .vc-tool{text-decoration:none;color:#000;width:50%;float:left;text-align:center;position:relative}#__vconsole .vc-toolbar .vc-tool:after{content:" ";position:absolute;top:7px;bottom:7px;right:0;border-left:1px solid #d9d9d9}#__vconsole .vc-toolbar .vc-tool-last:after{border:none}#__vconsole.vc-toggle .vc-show{display:none}#__vconsole.vc-toggle .vc-mask{background:rgba(0,0,0,.6);display:block}#__vconsole.vc-toggle .vc-panel{-webkit-transform:translate(0);transform:translate(0)}',""])},function(o,t){"use strict";o.exports=function(){var o=[];return o.toString=function(){for(var o=[],t=0;t=0&&_.splice(t,1)}function a(o){var t=document.createElement("style");return t.type="text/css",r(o,t),t}function s(o){var t=document.createElement("link");return t.rel="stylesheet",r(o,t),t}function l(o,t){var e,n,i;if(t.singleton){var r=m++;e=b||(b=a(t)),n=d.bind(null,e,r,!1),i=d.bind(null,e,r,!0)}else o.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(e=s(t),n=v.bind(null,e),i=function(){c(e),e.href&&URL.revokeObjectURL(e.href)}):(e=a(t),n=f.bind(null,e),i=function(){c(e)});return n(o),function(t){if(t){if(t.css===o.css&&t.media===o.media&&t.sourceMap===o.sourceMap)return;n(o=t)}else i()}}function d(o,t,e,n){var i=e?"":n.css;if(o.styleSheet)o.styleSheet.cssText=y(t,i);else{var r=document.createTextNode(i),c=o.childNodes;c[t]&&o.removeChild(c[t]),c.length?o.insertBefore(r,c[t]):o.appendChild(r)}}function f(o,t){var e=t.css,n=t.media;if(n&&o.setAttribute("media",n),o.styleSheet)o.styleSheet.cssText=e;else{for(;o.firstChild;)o.removeChild(o.firstChild);o.appendChild(document.createTextNode(e))}}function v(o,t){var e=t.css,n=t.sourceMap;n&&(e+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(n))))+" */");var i=new Blob([e],{type:"text/css"}),r=o.href;o.href=URL.createObjectURL(i),r&&URL.revokeObjectURL(r)}var p={},u=function(o){var t;return function(){return"undefined"==typeof t&&(t=o.apply(this,arguments)),t}},h=u(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),g=u(function(){return document.head||document.getElementsByTagName("head")[0]}),b=null,m=0,_=[];o.exports=function(o,t){t=t||{},"undefined"==typeof t.singleton&&(t.singleton=h()),"undefined"==typeof t.insertAt&&(t.insertAt="bottom");var e=i(o);return n(e,t),function(o){for(var r=[],c=0;c
面板
'}])}); \ No newline at end of file diff --git a/example/demo1.html b/example/demo1.html index 9caf0688..31236ea8 100644 --- a/example/demo1.html +++ b/example/demo1.html @@ -28,6 +28,7 @@

Demo 1

打印Object 触发JS Error + 打印到系统面板
已打印log
@@ -55,6 +56,10 @@

Demo 1

var err = undefined; err.a = 1; }); +$('.js_btn_log_sys').on('tap', function(e) { + console.log('[system] 当前时间戳:', (+new Date())); + showTips(); +}); // 用于页面内展示顶部tips var tipsTimer; diff --git a/example/lib/demo.css b/example/lib/demo.css index 0917e69b..0847d8aa 100644 --- a/example/lib/demo.css +++ b/example/lib/demo.css @@ -2,7 +2,7 @@ html, body { height: 100%; } .page { - padding: 25px 15px 0; + padding: 25px 15px 60px; height: 100%; background-color: #fbf9fe; -webkit-tap-highlight-color: transparent; diff --git a/src/vconsole.js b/src/vconsole.js index 5337c06e..d755be74 100644 --- a/src/vconsole.js +++ b/src/vconsole.js @@ -15,6 +15,7 @@ function vConsole() { this.html = tpl; this.$dom = null; this.activedTab = 'default'; + this.tabList = ['default', 'system']; this.console = {}; // store native console methods this.isReady = false; this.readyCallback = []; @@ -96,11 +97,11 @@ vConsole.prototype._mokeConsole = function() { this.console.warn = window.console.warn; this.console.debug = window.console.debug; this.console.error = window.console.error; - window.console.log = function() { that._printLog('default', 'log', arguments); }; - window.console.info = function() { that._printLog('default', 'info', arguments); }; - window.console.warn = function() { that._printLog('default', 'warn', arguments); }; - window.console.debug = function() { that._printLog('default', 'debug', arguments); }; - window.console.error = function() { that._printLog('default', 'error', arguments); }; + window.console.log = function() { that._printLog('auto', 'log', arguments); }; + window.console.info = function() { that._printLog('auto', 'info', arguments); }; + window.console.warn = function() { that._printLog('auto', 'warn', arguments); }; + window.console.debug = function() { that._printLog('auto', 'debug', arguments); }; + window.console.error = function() { that._printLog('auto', 'error', arguments); }; window.onerror = function(message, source, lineno, colno, error) { var stack = error.stack.split('at'); @@ -199,7 +200,7 @@ vConsole.prototype._autoRun = function() { /** * print a log to log box * @private - * @param string tabName + * @param string tabName auto|default|system * @param string logType log|info|debug|error|warn * @param array logs */ @@ -224,6 +225,19 @@ vConsole.prototype._printLog = function(tabName, logType, logs) { } } + // auto select tab + if (tabName == 'auto') { + var pattern = /^ \[(\w+)\]/i; + var match = line.match(pattern); + if (match !== null && match.length > 0 && this.tabList.indexOf(match[1]) > -1) { + tabName = match[1]; + line = line.replace(pattern, ''); + } + } + if (tabName == 'auto') { + tabName = 'default'; + } + var $logbox = $('#__vc_log_' + tabName); var p = document.createElement('p'); p.className = 'vc-item vc-item-' + logType;