Comparing version 1.0.1 to 1.0.2
@@ -1,840 +0,1 @@ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(); | ||
else if(typeof define === 'function' && define.amd) | ||
define([], factory); | ||
else if(typeof exports === 'object') | ||
exports["vConsole"] = factory(); | ||
else | ||
root["vConsole"] = factory(); | ||
})(this, function() { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ }; | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/** | ||
* A Front-End Console Panel for Mobile Webpage | ||
* | ||
* @version 1.0.0 | ||
* @author WeChat | ||
*/ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
__webpack_require__(1); | ||
/** | ||
* initial | ||
* @constructor | ||
*/ | ||
function vConsole() { | ||
this.html = __webpack_require__(5); | ||
this.$dom = null; | ||
this.activedTab = 'default'; | ||
this.console = {}; // store native console methods | ||
this.isReady = false; | ||
this.readyCallback = []; | ||
var self = this; | ||
bind(window, 'load', function () { | ||
self._render(); | ||
self._bindEvent(); | ||
self._mokeConsole(); | ||
self._autoRun(); | ||
}); | ||
} | ||
/** | ||
* render panel DOM | ||
* @private | ||
*/ | ||
vConsole.prototype._render = function () { | ||
var id = '#__vconsole'; | ||
if (!$(id)) { | ||
var e = document.createElement('div'); | ||
e.innerHTML = this.html; | ||
document.body.appendChild(e.children[0]); | ||
} | ||
this.$dom = $(id); | ||
}; | ||
/** | ||
* bind DOM events | ||
* @private | ||
*/ | ||
vConsole.prototype._bindEvent = function () { | ||
var self = this; | ||
// show console panel | ||
bind($('.vc-show'), 'click', function () { | ||
self.show(); | ||
}); | ||
// hide console panel | ||
bind($('.vc-hide'), 'click', function () { | ||
self.hide(); | ||
}); | ||
// hide console panel when tap background mask | ||
bind($('.vc-mask'), 'click', function (e) { | ||
if (e.target != $('.vc-mask')) { | ||
return false; | ||
} | ||
self.hide(); | ||
}); | ||
// clear a log box | ||
bind($('.vc-clear'), 'click', function () { | ||
self.clearLog(self.activedTab); | ||
}); | ||
// show a log box | ||
bind($$('.vc-tab'), 'click', function (e) { | ||
var tabName = e.target.dataset.tab; | ||
if (tabName == self.activedTab) { | ||
return; | ||
} | ||
self.showTab(tabName); | ||
}); | ||
}; | ||
/** | ||
* replace window.console with vConsole method | ||
* @private | ||
*/ | ||
vConsole.prototype._mokeConsole = function () { | ||
if (!window.console) { | ||
return; | ||
} | ||
var self = 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 () { | ||
self._printLog('default', 'log', arguments); | ||
}; | ||
window.console.info = function () { | ||
self._printLog('default', 'info', arguments); | ||
}; | ||
window.console.warn = function () { | ||
self._printLog('default', 'warn', arguments); | ||
}; | ||
window.console.debug = function () { | ||
self._printLog('default', 'debug', arguments); | ||
}; | ||
window.console.error = function () { | ||
self._printLog('default', 'error', arguments); | ||
}; | ||
}; | ||
/** | ||
* auto run after initial | ||
* @private | ||
*/ | ||
vConsole.prototype._autoRun = function () { | ||
// print system info | ||
var ua = navigator.userAgent, | ||
logMsg = []; | ||
// current time | ||
var d = getDate(); | ||
this._printLog('system', 'info', ['日志时间:', d.year + '-' + d.month + '-' + d.day + ' ' + d.hour + ':' + d.minute + ':' + d.second + ' ' + d.millisecond]); | ||
// device & system | ||
logMsg = ['系统版本:', '不明']; | ||
var ipod = ua.match(/(ipod).*\s([\d_]+)/i), | ||
ipad = ua.match(/(ipad).*\s([\d_]+)/i), | ||
iphone = ua.match(/(iphone)\sos\s([\d_]+)/i), | ||
android = ua.match(/(android)\s([\d\.]+)/i); | ||
if (android) { | ||
logMsg[1] = 'Android ' + android[2]; | ||
} else if (iphone) { | ||
logMsg[1] = 'iPhone, iOS ' + iphone[2].replace(/_/g, '.'); | ||
} else if (ipad) { | ||
logMsg[1] = 'iPad, iOS ' + ipad[2].replace(/_/g, '.'); | ||
} else if (ipod) { | ||
logMsg[1] = 'iPod, iOS ' + ipod[2].replace(/_/g, '.'); | ||
} | ||
this._printLog('system', 'info', logMsg); | ||
// wechat app version | ||
var version = ua.match(/MicroMessenger\/([\d\.]+)/i); | ||
logMsg = ['微信版本:', '不明']; | ||
if (version && version[1]) { | ||
logMsg[1] = version[1]; | ||
this._printLog('system', 'info', logMsg); | ||
} | ||
// network type | ||
var network = ua.toLowerCase().match(/ nettype\/([^ ]+)/g); | ||
logMsg = ['网络类型:', '不明']; | ||
if (network && network[0]) { | ||
network = network[0].split('/'); | ||
logMsg[1] = network[1]; | ||
this._printLog('system', 'info', logMsg); | ||
} | ||
// HTTP protocol | ||
logMsg = ['网址协议:', '不明']; | ||
if (location.protocol == 'https:') { | ||
logMsg[1] = 'HTTPS'; | ||
} else if (location.protocol == 'http:') { | ||
logMsg[1] = 'HTTP'; | ||
} else { | ||
logMsg[1] = location.protocol.replace(':', ''); | ||
} | ||
this._printLog('system', 'info', logMsg); | ||
// performance related | ||
window.addEventListener('load', function (e) { | ||
var performance = window.performance || window.msPerformance || window.webkitPerformance; | ||
// timing | ||
if (performance && performance.timing) { | ||
var t = performance.timing, | ||
start = t.navigationStart; | ||
// this._printLog('system', 'debug', ['domainLookupEnd:', (t.domainLookupEnd - start)+'ms']); | ||
this._printLog('system', 'info', ['连接结束点:', t.connectEnd - start + 'ms']); | ||
this._printLog('system', 'info', ['回包结束点:', t.responseEnd - start + 'ms']); | ||
// this._printLog('system', 'debug', ['domComplete:', (t.domComplete - start)+'ms']); | ||
// this._printLog('system', 'info', ['beforeReqTime:', (t.requestStart - start)+'ms']); | ||
if (t.secureConnectionStart > 0) { | ||
this._printLog('system', 'info', ['ssl耗时:', t.connectEnd - t.secureConnectionStart + 'ms']); | ||
} | ||
// this._printLog('system', 'info', ['req&RespTime:', (t.responseEnd - t.requestStart)+'ms']); | ||
this._printLog('system', 'info', ['dom渲染耗时:', t.domComplete - t.domLoading + 'ms']); | ||
} | ||
}); | ||
while (this.readyCallback.length > 0) { | ||
var callback = this.readyCallback.shift(); | ||
callback && callback.call(this); | ||
} | ||
this.isReady = true; | ||
}; | ||
/** | ||
* print a log to log box | ||
* @private | ||
* @param string tabName | ||
* @param string logType log|info|debug|error|warn | ||
* @param array logs | ||
*/ | ||
vConsole.prototype._printLog = function (tabName, logType, logs) { | ||
if (!logs.length) { | ||
return; | ||
} | ||
// generate plain text for a line | ||
var line = ''; | ||
for (var i = 0; i < logs.length; i++) { | ||
try { | ||
if (typeof logs[i] == 'function') { | ||
line += ' ' + logs[i].toString(); | ||
} else if (typeof logs[i] == 'object') { | ||
line += ' ' + JSON.stringify(logs[i]); | ||
} else { | ||
line += ' ' + logs[i]; | ||
} | ||
} catch (e) { | ||
line += ' [' + typeof logs[i] + ']'; | ||
} | ||
} | ||
var $logbox = $('#__vc_log_' + tabName); | ||
var p = document.createElement('p'); | ||
p.className = 'vc-item vc-item-' + logType; | ||
p.innerHTML = line; | ||
$('.vc-log', $logbox).appendChild(p); | ||
$('.vc-content').scrollTop = $('.vc-content').scrollHeight; | ||
// print to traditional console | ||
this.console[logType].apply(window.console, logs); | ||
}; | ||
/** | ||
* show a log box by tab name | ||
* @public | ||
*/ | ||
vConsole.prototype.showTab = function (tabName) { | ||
var $logbox = $('#__vc_log_' + tabName); | ||
// set actived status | ||
removeClass($$('.vc-tab', this.$dom), 'vc-actived'); | ||
addClass($('#__vc_tab_' + tabName), 'vc-actived'); | ||
removeClass($$('.vc-logbox'), 'vc-actived'); | ||
addClass($logbox, 'vc-actived'); | ||
// scroll to bottom | ||
$('.vc-content').scrollTop = $('.vc-content').scrollHeight; | ||
this.activedTab = tabName; | ||
}; | ||
/** | ||
* clear a log box by tab name | ||
* @public | ||
*/ | ||
vConsole.prototype.clearLog = function (tabName) { | ||
var $logbox = $('#__vc_log_' + tabName); | ||
$('.vc-log', $logbox).innerHTML = ''; | ||
}; | ||
/** | ||
* show console panel | ||
* @public | ||
*/ | ||
vConsole.prototype.show = function () { | ||
addClass(this.$dom, 'vc-toggle'); | ||
}; | ||
/** | ||
* hide console panel | ||
* @public | ||
*/ | ||
vConsole.prototype.hide = function () { | ||
removeClass(this.$dom, 'vc-toggle'); | ||
}; | ||
/** | ||
* | ||
* @public | ||
*/ | ||
vConsole.prototype.ready = function (callback) { | ||
if (!this.isReady) { | ||
this.readyCallback.push(callback); | ||
} else { | ||
callback.call(this); | ||
} | ||
}; | ||
/**************************************************************** | ||
Utility Functions | ||
****************************************************************/ | ||
/** | ||
* get single element | ||
* @private | ||
*/ | ||
function $(selector, contextElement) { | ||
if (contextElement) { | ||
return contextElement.querySelector(selector); | ||
} | ||
return document.querySelector(selector); | ||
} | ||
/** | ||
* get multiple elements | ||
* @private | ||
*/ | ||
function $$(selector, contextElement) { | ||
var nodeList, | ||
list = []; | ||
if (contextElement) { | ||
nodeList = contextElement.querySelectorAll(selector); | ||
} else { | ||
nodeList = document.querySelectorAll(selector); | ||
} | ||
if (nodeList && nodeList.length > 0) { | ||
list = Array.prototype.slice.call(nodeList); | ||
} | ||
return list; | ||
} | ||
/** | ||
* add className to an element | ||
* @private | ||
*/ | ||
function addClass($el, className) { | ||
if (!$el) { | ||
return; | ||
} | ||
if (Object.prototype.toString.call($el) != '[object Array]') { | ||
$el = [$el]; | ||
} | ||
for (var i = 0; i < $el.length; i++) { | ||
$el[i].className += ' ' + className; | ||
} | ||
} | ||
/** | ||
* remove className from an element | ||
* @private | ||
*/ | ||
function removeClass($el, className) { | ||
if (!$el) { | ||
return; | ||
} | ||
if (Object.prototype.toString.call($el) != '[object Array]') { | ||
$el = [$el]; | ||
} | ||
for (var i = 0; i < $el.length; i++) { | ||
var arr = $el[i].className.split(' '); | ||
for (var j = 0; j < arr.length; j++) { | ||
if (arr[j] == className) { | ||
arr[j] = ''; | ||
} | ||
} | ||
$el[i].className = arr.join(' '); | ||
} | ||
} | ||
/** | ||
* bind an event to element(s) | ||
* @private | ||
* @param array $el element object or array | ||
* @param string eventType name of the event | ||
* @param function fn | ||
* @param boolean useCapture | ||
*/ | ||
function bind($el, eventType, fn, useCapture) { | ||
if (!$el) { | ||
return; | ||
} | ||
if (useCapture === undefined) { | ||
useCapture = false; | ||
} | ||
if (Object.prototype.toString.call($el) != '[object Array]') { | ||
$el = [$el]; | ||
} | ||
for (var i = 0; i < $el.length; i++) { | ||
$el[i].addEventListener(eventType, fn, useCapture); | ||
} | ||
} | ||
/** | ||
* get formatted date by timestamp | ||
* @param int time | ||
* @return object | ||
*/ | ||
function getDate(time) { | ||
var d = time > 0 ? new Date(time) : new Date(); | ||
var day = d.getDay() < 10 ? '0' + d.getDay() : d.getDay(), | ||
month = d.getMonth() < 9 ? '0' + (d.getMonth() + 1) : d.getMonth() + 1, | ||
year = d.getFullYear(), | ||
hour = d.getHours() < 10 ? '0' + d.getHours() : d.getHours(), | ||
minute = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes(), | ||
second = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds(), | ||
millisecond = d.getMilliseconds() < 10 ? '0' + d.getMilliseconds() : d.getMilliseconds(); | ||
if (millisecond < 100) { | ||
millisecond = '0' + millisecond; | ||
} | ||
return { | ||
time: +d, | ||
year: year, | ||
month: month, | ||
day: day, | ||
hour: hour, | ||
minute: minute, | ||
second: second, | ||
millisecond: millisecond | ||
}; | ||
} | ||
/** | ||
* export | ||
*/ | ||
exports['default'] = new vConsole(); | ||
module.exports = exports['default']; | ||
/***/ }, | ||
/* 1 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
// style-loader: Adds some css to the DOM by adding a <style> tag | ||
// load the styles | ||
var content = __webpack_require__(2); | ||
if(typeof content === 'string') content = [[module.id, content, '']]; | ||
// add the styles to the DOM | ||
var update = __webpack_require__(4)(content, {}); | ||
if(content.locals) module.exports = content.locals; | ||
// Hot Module Replacement | ||
if(false) { | ||
// When the styles change, update the <style> tags | ||
if(!content.locals) { | ||
module.hot.accept("!!./../node_modules/css-loader/index.js!./../node_modules/less-loader/index.js!./vconsole.less", function() { | ||
var newContent = require("!!./../node_modules/css-loader/index.js!./../node_modules/less-loader/index.js!./vconsole.less"); | ||
if(typeof newContent === 'string') newContent = [[module.id, newContent, '']]; | ||
update(newContent); | ||
}); | ||
} | ||
// When the module is disposed, remove the <style> tags | ||
module.hot.dispose(function() { update(); }); | ||
} | ||
/***/ }, | ||
/* 2 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
exports = module.exports = __webpack_require__(3)(); | ||
// imports | ||
// module | ||
exports.push([module.id, "#__vconsole {\n font-size: 13px;\n}\n#__vconsole .vc-show {\n display: block;\n position: fixed;\n right: 10px;\n bottom: 10px;\n color: #FFF;\n background-color: #04BE02;\n line-height: 1;\n font-size: 14px;\n padding: 8px 16px;\n z-index: 10000;\n border-radius: 4px;\n box-shadow: 0 0 8px rgba(0, 0, 0, 0.4);\n}\n#__vconsole .vc-mask {\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: rgba(0, 0, 0, 0);\n z-index: 10001;\n transition: background .3s;\n}\n#__vconsole .vc-panel {\n position: fixed;\n min-height: 80%;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 10002;\n background-color: #EFEFF4;\n -webkit-transition: -webkit-transform 0.3s;\n transition: -webkit-transform 0.3s;\n transition: transform .3s;\n transition: transform 0.3s, -webkit-transform 0.3s;\n -webkit-transform: translate(0, 100%);\n transform: translate(0, 100%);\n}\n#__vconsole .vc-tabbar {\n border-bottom: 1px solid #D9D9D9;\n overflow: hidden;\n}\n#__vconsole .vc-tabbar .vc-tab {\n float: left;\n line-height: 39px;\n padding: 0 15px;\n border-right: 1px solid #D9D9D9;\n text-decoration: none;\n color: #000;\n}\n#__vconsole .vc-tabbar .vc-tab.vc-actived {\n background-color: #FFF;\n}\n#__vconsole .vc-content {\n background-color: #FFF;\n overflow-x: hidden;\n overflow-y: scroll;\n position: absolute;\n top: 40px;\n left: 0;\n right: 0;\n bottom: 40px;\n -webkit-overflow-scrolling: touch;\n}\n#__vconsole .vc-logbox {\n display: none;\n position: relative;\n height: 100%;\n}\n#__vconsole .vc-logbox .vc-log:empty:before {\n content: \"No log\";\n color: #999;\n position: absolute;\n top: 45%;\n left: 0;\n right: 0;\n bottom: 0;\n font-size: 15px;\n text-align: center;\n}\n#__vconsole .vc-logbox .vc-item {\n margin: 0;\n padding: 6px 8px;\n line-height: 1.3;\n border-bottom: 1px solid #EEE;\n word-break: break-word;\n}\n#__vconsole .vc-logbox .vc-item-info {\n color: #6A5ACD;\n}\n#__vconsole .vc-logbox .vc-item-debug {\n color: #DAA520;\n}\n#__vconsole .vc-logbox .vc-item-warn {\n color: #FFA500;\n border-color: #FFB930;\n background-color: #FFFACD;\n}\n#__vconsole .vc-logbox .vc-item-error {\n color: #DC143C;\n border-color: #F4A0AB;\n background-color: #FFE4E1;\n}\n#__vconsole .vc-logbox.vc-actived {\n display: block;\n}\n#__vconsole .vc-toolbar {\n border-top: 1px solid #D9D9D9;\n line-height: 39px;\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n}\n#__vconsole .vc-toolbar .vc-tool {\n text-decoration: none;\n color: #000;\n width: 50%;\n float: left;\n text-align: center;\n position: relative;\n}\n#__vconsole .vc-toolbar .vc-tool:after {\n content: \" \";\n position: absolute;\n top: 7px;\n bottom: 7px;\n right: 0;\n border-left: 1px solid #D9D9D9;\n}\n#__vconsole .vc-toolbar .vc-tool-last:after {\n border: none;\n}\n#__vconsole.vc-toggle .vc-show {\n display: none;\n}\n#__vconsole.vc-toggle .vc-mask {\n background: rgba(0, 0, 0, 0.6);\n display: block;\n}\n#__vconsole.vc-toggle .vc-panel {\n -webkit-transform: translate(0, 0);\n transform: translate(0, 0);\n}\n", ""]); | ||
// exports | ||
/***/ }, | ||
/* 3 */ | ||
/***/ function(module, exports) { | ||
/* | ||
MIT License http://www.opensource.org/licenses/mit-license.php | ||
Author Tobias Koppers @sokra | ||
*/ | ||
// css base code, injected by the css-loader | ||
"use strict"; | ||
module.exports = function () { | ||
var list = []; | ||
// return the list of modules as css string | ||
list.toString = function toString() { | ||
var result = []; | ||
for (var i = 0; i < this.length; i++) { | ||
var item = this[i]; | ||
if (item[2]) { | ||
result.push("@media " + item[2] + "{" + item[1] + "}"); | ||
} else { | ||
result.push(item[1]); | ||
} | ||
} | ||
return result.join(""); | ||
}; | ||
// import a list of modules into the list | ||
list.i = function (modules, mediaQuery) { | ||
if (typeof modules === "string") modules = [[null, modules, ""]]; | ||
var alreadyImportedModules = {}; | ||
for (var i = 0; i < this.length; i++) { | ||
var id = this[i][0]; | ||
if (typeof id === "number") alreadyImportedModules[id] = true; | ||
} | ||
for (i = 0; i < modules.length; i++) { | ||
var item = modules[i]; | ||
// skip already imported module | ||
// this implementation is not 100% perfect for weird media query combinations | ||
// when a module is imported multiple times with different media queries. | ||
// I hope this will never occur (Hey this way we have smaller bundles) | ||
if (typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) { | ||
if (mediaQuery && !item[2]) { | ||
item[2] = mediaQuery; | ||
} else if (mediaQuery) { | ||
item[2] = "(" + item[2] + ") and (" + mediaQuery + ")"; | ||
} | ||
list.push(item); | ||
} | ||
} | ||
}; | ||
return list; | ||
}; | ||
/***/ }, | ||
/* 4 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/* | ||
MIT License http://www.opensource.org/licenses/mit-license.php | ||
Author Tobias Koppers @sokra | ||
*/ | ||
var stylesInDom = {}, | ||
memoize = function(fn) { | ||
var memo; | ||
return function () { | ||
if (typeof memo === "undefined") memo = fn.apply(this, arguments); | ||
return memo; | ||
}; | ||
}, | ||
isOldIE = memoize(function() { | ||
return /msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase()); | ||
}), | ||
getHeadElement = memoize(function () { | ||
return document.head || document.getElementsByTagName("head")[0]; | ||
}), | ||
singletonElement = null, | ||
singletonCounter = 0, | ||
styleElementsInsertedAtTop = []; | ||
module.exports = function(list, options) { | ||
if(false) { | ||
if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment"); | ||
} | ||
options = options || {}; | ||
// Force single-tag solution on IE6-9, which has a hard limit on the # of <style> | ||
// tags it will allow on a page | ||
if (typeof options.singleton === "undefined") options.singleton = isOldIE(); | ||
// By default, add <style> tags to the bottom of <head>. | ||
if (typeof options.insertAt === "undefined") options.insertAt = "bottom"; | ||
var styles = listToStyles(list); | ||
addStylesToDom(styles, options); | ||
return function update(newList) { | ||
var mayRemove = []; | ||
for(var i = 0; i < styles.length; i++) { | ||
var item = styles[i]; | ||
var domStyle = stylesInDom[item.id]; | ||
domStyle.refs--; | ||
mayRemove.push(domStyle); | ||
} | ||
if(newList) { | ||
var newStyles = listToStyles(newList); | ||
addStylesToDom(newStyles, options); | ||
} | ||
for(var i = 0; i < mayRemove.length; i++) { | ||
var domStyle = mayRemove[i]; | ||
if(domStyle.refs === 0) { | ||
for(var j = 0; j < domStyle.parts.length; j++) | ||
domStyle.parts[j](); | ||
delete stylesInDom[domStyle.id]; | ||
} | ||
} | ||
}; | ||
} | ||
function addStylesToDom(styles, options) { | ||
for(var i = 0; i < styles.length; i++) { | ||
var item = styles[i]; | ||
var domStyle = stylesInDom[item.id]; | ||
if(domStyle) { | ||
domStyle.refs++; | ||
for(var j = 0; j < domStyle.parts.length; j++) { | ||
domStyle.parts[j](item.parts[j]); | ||
} | ||
for(; j < item.parts.length; j++) { | ||
domStyle.parts.push(addStyle(item.parts[j], options)); | ||
} | ||
} else { | ||
var parts = []; | ||
for(var j = 0; j < item.parts.length; j++) { | ||
parts.push(addStyle(item.parts[j], options)); | ||
} | ||
stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts}; | ||
} | ||
} | ||
} | ||
function listToStyles(list) { | ||
var styles = []; | ||
var newStyles = {}; | ||
for(var i = 0; i < list.length; i++) { | ||
var item = list[i]; | ||
var id = item[0]; | ||
var css = item[1]; | ||
var media = item[2]; | ||
var sourceMap = item[3]; | ||
var part = {css: css, media: media, sourceMap: sourceMap}; | ||
if(!newStyles[id]) | ||
styles.push(newStyles[id] = {id: id, parts: [part]}); | ||
else | ||
newStyles[id].parts.push(part); | ||
} | ||
return styles; | ||
} | ||
function insertStyleElement(options, styleElement) { | ||
var head = getHeadElement(); | ||
var lastStyleElementInsertedAtTop = styleElementsInsertedAtTop[styleElementsInsertedAtTop.length - 1]; | ||
if (options.insertAt === "top") { | ||
if(!lastStyleElementInsertedAtTop) { | ||
head.insertBefore(styleElement, head.firstChild); | ||
} else if(lastStyleElementInsertedAtTop.nextSibling) { | ||
head.insertBefore(styleElement, lastStyleElementInsertedAtTop.nextSibling); | ||
} else { | ||
head.appendChild(styleElement); | ||
} | ||
styleElementsInsertedAtTop.push(styleElement); | ||
} else if (options.insertAt === "bottom") { | ||
head.appendChild(styleElement); | ||
} else { | ||
throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'."); | ||
} | ||
} | ||
function removeStyleElement(styleElement) { | ||
styleElement.parentNode.removeChild(styleElement); | ||
var idx = styleElementsInsertedAtTop.indexOf(styleElement); | ||
if(idx >= 0) { | ||
styleElementsInsertedAtTop.splice(idx, 1); | ||
} | ||
} | ||
function createStyleElement(options) { | ||
var styleElement = document.createElement("style"); | ||
styleElement.type = "text/css"; | ||
insertStyleElement(options, styleElement); | ||
return styleElement; | ||
} | ||
function createLinkElement(options) { | ||
var linkElement = document.createElement("link"); | ||
linkElement.rel = "stylesheet"; | ||
insertStyleElement(options, linkElement); | ||
return linkElement; | ||
} | ||
function addStyle(obj, options) { | ||
var styleElement, update, remove; | ||
if (options.singleton) { | ||
var styleIndex = singletonCounter++; | ||
styleElement = singletonElement || (singletonElement = createStyleElement(options)); | ||
update = applyToSingletonTag.bind(null, styleElement, styleIndex, false); | ||
remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true); | ||
} else if(obj.sourceMap && | ||
typeof URL === "function" && | ||
typeof URL.createObjectURL === "function" && | ||
typeof URL.revokeObjectURL === "function" && | ||
typeof Blob === "function" && | ||
typeof btoa === "function") { | ||
styleElement = createLinkElement(options); | ||
update = updateLink.bind(null, styleElement); | ||
remove = function() { | ||
removeStyleElement(styleElement); | ||
if(styleElement.href) | ||
URL.revokeObjectURL(styleElement.href); | ||
}; | ||
} else { | ||
styleElement = createStyleElement(options); | ||
update = applyToTag.bind(null, styleElement); | ||
remove = function() { | ||
removeStyleElement(styleElement); | ||
}; | ||
} | ||
update(obj); | ||
return function updateStyle(newObj) { | ||
if(newObj) { | ||
if(newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) | ||
return; | ||
update(obj = newObj); | ||
} else { | ||
remove(); | ||
} | ||
}; | ||
} | ||
var replaceText = (function () { | ||
var textStore = []; | ||
return function (index, replacement) { | ||
textStore[index] = replacement; | ||
return textStore.filter(Boolean).join('\n'); | ||
}; | ||
})(); | ||
function applyToSingletonTag(styleElement, index, remove, obj) { | ||
var css = remove ? "" : obj.css; | ||
if (styleElement.styleSheet) { | ||
styleElement.styleSheet.cssText = replaceText(index, css); | ||
} else { | ||
var cssNode = document.createTextNode(css); | ||
var childNodes = styleElement.childNodes; | ||
if (childNodes[index]) styleElement.removeChild(childNodes[index]); | ||
if (childNodes.length) { | ||
styleElement.insertBefore(cssNode, childNodes[index]); | ||
} else { | ||
styleElement.appendChild(cssNode); | ||
} | ||
} | ||
} | ||
function applyToTag(styleElement, obj) { | ||
var css = obj.css; | ||
var media = obj.media; | ||
if(media) { | ||
styleElement.setAttribute("media", media) | ||
} | ||
if(styleElement.styleSheet) { | ||
styleElement.styleSheet.cssText = css; | ||
} else { | ||
while(styleElement.firstChild) { | ||
styleElement.removeChild(styleElement.firstChild); | ||
} | ||
styleElement.appendChild(document.createTextNode(css)); | ||
} | ||
} | ||
function updateLink(linkElement, obj) { | ||
var css = obj.css; | ||
var sourceMap = obj.sourceMap; | ||
if(sourceMap) { | ||
// http://stackoverflow.com/a/26603875 | ||
css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */"; | ||
} | ||
var blob = new Blob([css], { type: "text/css" }); | ||
var oldSrc = linkElement.href; | ||
linkElement.href = URL.createObjectURL(blob); | ||
if(oldSrc) | ||
URL.revokeObjectURL(oldSrc); | ||
} | ||
/***/ }, | ||
/* 5 */ | ||
/***/ function(module, exports) { | ||
module.exports = "<!-- vConsole -->\n<div id=\"__vconsole\" class=\"\">\n\t<div class=\"vc-show\">面板</div>\n\t<div class=\"vc-mask\">\n\t</div>\n\t<div class=\"vc-panel\">\n\t\t<div class=\"vc-tabbar\">\n\t\t\t<a class=\"vc-tab vc-actived\" data-tab=\"default\" id=\"__vc_tab_default\" href=\"javascript:;\">日志</a>\n\t\t\t<a class=\"vc-tab\" data-tab=\"system\" id=\"__vc_tab_system\" href=\"javascript:;\">系统</a>\n\t\t</div>\n\t\t<div class=\"vc-content\">\n\t\t\t<div class=\"vc-logbox vc-actived\" id=\"__vc_log_default\">\n\t\t\t\t<div class=\"vc-log\"></div>\n\t\t\t</div>\n\t\t\t<div class=\"vc-logbox\" id=\"__vc_log_system\">\n\t\t\t\t<div class=\"vc-log\"></div>\n\t\t\t</div>\n\t\t</div>\n\t\t<div class=\"vc-toolbar\">\n\t\t\t<a href=\"javascript:;\" class=\"vc-tool vc-clear\">清空</a>\n\t\t\t<a href=\"javascript:;\" class=\"vc-tool vc-tool-last vc-hide\">隐藏</a>\n\t\t</div>\n\t</div>\n</div>\n<!-- /vConsole -->"; | ||
/***/ } | ||
/******/ ]) | ||
}); | ||
; | ||
!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=v["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;e<o.length;e++)o[e].className+=" "+t}}function a(o,t){if(o){"[object Array]"!=Object.prototype.toString.call(o)&&(o=[o]);for(var e=0;e<o.length;e++){for(var n=o[e].className.split(" "),i=0;i<n.length;i++)n[i]==t&&(n[i]="");o[e].className=n.join(" ")}}}function l(o,t,e,n){if(o){void 0===n&&(n=!1),"[object Array]"!=Object.prototype.toString.call(o)&&(o=[o]);for(var i=0;i<o.length;i++)o[i].addEventListener(t,e,n)}}function d(o){var t=o>0?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}}Object.defineProperty(t,"__esModule",{value:!0}),e(1);var f=e(5),v=n(f);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<e.length;i++)try{n+="function"==typeof e[i]?" "+e[i].toString():"object"==typeof e[i]?" "+JSON.stringify(e[i]):" "+e[i]}catch(c){n+=" ["+typeof e[i]+"]"}var s=r("#__vc_log_"+o),a=document.createElement("p");a.className="vc-item vc-item-"+t,a.innerHTML=n,r(".vc-log",s).appendChild(a),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);a(c(".vc-tab",this.$dom),"vc-actived"),s(r("#__vc_tab_"+o),"vc-actived"),a(c(".vc-logbox"),"vc-actived"),s(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(){s(this.$dom,"vc-toggle")},i.prototype.hide=function(){a(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<this.length;t++){var e=this[t];e[2]?o.push("@media "+e[2]+"{"+e[1]+"}"):o.push(e[1])}return o.join("")},o.i=function(t,e){"string"==typeof t&&(t=[[null,t,""]]);for(var n={},i=0;i<this.length;i++){var r=this[i][0];"number"==typeof r&&(n[r]=!0)}for(i=0;i<t.length;i++){var c=t[i];"number"==typeof c[0]&&n[c[0]]||(e&&!c[2]?c[2]=e:e&&(c[2]="("+c[2]+") and ("+e+")"),o.push(c))}},o}},function(o,t,e){function n(o,t){for(var e=0;e<o.length;e++){var n=o[e],i=p[n.id];if(i){i.refs++;for(var r=0;r<i.parts.length;r++)i.parts[r](n.parts[r]);for(;r<n.parts.length;r++)i.parts.push(l(n.parts[r],t))}else{for(var c=[],r=0;r<n.parts.length;r++)c.push(l(n.parts[r],t));p[n.id]={id:n.id,refs:1,parts:c}}}}function i(o){for(var t=[],e={},n=0;n<o.length;n++){var i=o[n],r=i[0],c=i[1],s=i[2],a=i[3],l={css:c,media:s,sourceMap:a};e[r]?e[r].parts.push(l):t.push(e[r]={id:r,parts:[l]})}return t}function r(o,t){var e=g(),n=_[_.length-1];if("top"===o.insertAt)n?n.nextSibling?e.insertBefore(t,n.nextSibling):e.appendChild(t):e.insertBefore(t,e.firstChild),_.push(t);else{if("bottom"!==o.insertAt)throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");e.appendChild(t)}}function c(o){o.parentNode.removeChild(o);var t=_.indexOf(o);t>=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<e.length;c++){var s=e[c],a=p[s.id];a.refs--,r.push(a)}if(o){var l=i(o);n(l,t)}for(var c=0;c<r.length;c++){var a=r[c];if(0===a.refs){for(var d=0;d<a.parts.length;d++)a.parts[d]();delete p[a.id]}}}};var y=function(){var o=[];return function(t,e){return o[t]=e,o.filter(Boolean).join("\n")}}()},function(o,t){o.exports='<div id=__vconsole class=""> <div class=vc-show>面板</div> <div class=vc-mask> </div> <div class=vc-panel> <div class=vc-tabbar> <a class="vc-tab vc-actived" data-tab=default id=__vc_tab_default href=javascript:;>日志</a> <a class=vc-tab data-tab=system id=__vc_tab_system href=javascript:;>系统</a> </div> <div class=vc-content> <div class="vc-logbox vc-actived" id=__vc_log_default> <div class=vc-log></div> </div> <div class=vc-logbox id=__vc_log_system> <div class=vc-log></div> </div> </div> <div class=vc-toolbar> <a href=javascript:; class="vc-tool vc-clear">清空</a> <a href=javascript:; class="vc-tool vc-tool-last vc-hide">隐藏</a> </div> </div> </div>'}])}); |
{ | ||
"name": "vconsole", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A virtual console panel for mobile page", | ||
@@ -5,0 +5,0 @@ "main": "./dist/vconsole.js", |
/** | ||
* A Front-End Console Panel for Mobile Webpage | ||
* | ||
* @version 1.0.1 | ||
* @author WeChat | ||
* @version 1.0.2 | ||
* @author WechatFE | ||
*/ | ||
require('./vconsole.less'); | ||
import './vconsole.less'; | ||
import tpl from './tpl.html'; | ||
@@ -15,16 +16,16 @@ /** | ||
function vConsole() { | ||
this.html = require('./tpl.html'); | ||
this.$dom = null; | ||
this.activedTab = 'default'; | ||
this.console = {}; // store native console methods | ||
this.isReady = false; | ||
this.readyCallback = []; | ||
this.html = tpl; | ||
this.$dom = null; | ||
this.activedTab = 'default'; | ||
this.console = {}; // store native console methods | ||
this.isReady = false; | ||
this.readyCallback = []; | ||
var self = this; | ||
bind(window, 'load', function() { | ||
self._render(); | ||
self._bindEvent(); | ||
self._mokeConsole(); | ||
self._autoRun(); | ||
}); | ||
var self = this; | ||
bind(window, 'load', function() { | ||
self._render(); | ||
self._bindEvent(); | ||
self._mokeConsole(); | ||
self._autoRun(); | ||
}); | ||
} | ||
@@ -37,9 +38,9 @@ | ||
vConsole.prototype._render = function() { | ||
var id = '#__vconsole'; | ||
if (! $(id)) { | ||
var e = document.createElement('div'); | ||
e.innerHTML = this.html; | ||
document.body.appendChild(e.children[0]); | ||
} | ||
this.$dom = $(id); | ||
var id = '#__vconsole'; | ||
if (! $(id)) { | ||
var e = document.createElement('div'); | ||
e.innerHTML = this.html; | ||
document.body.appendChild(e.children[0]); | ||
} | ||
this.$dom = $(id); | ||
}; | ||
@@ -52,35 +53,35 @@ | ||
vConsole.prototype._bindEvent = function() { | ||
var self = this; | ||
var self = this; | ||
// show console panel | ||
bind($('.vc-show'), 'click', function() { | ||
self.show(); | ||
}) | ||
// show console panel | ||
bind($('.vc-show'), 'click', function() { | ||
self.show(); | ||
}) | ||
// hide console panel | ||
bind($('.vc-hide'), 'click', function() { | ||
self.hide(); | ||
}); | ||
// hide console panel | ||
bind($('.vc-hide'), 'click', function() { | ||
self.hide(); | ||
}); | ||
// hide console panel when tap background mask | ||
bind($('.vc-mask'), 'click', function(e) { | ||
if (e.target != $('.vc-mask')) { | ||
return false; | ||
} | ||
self.hide(); | ||
}); | ||
// hide console panel when tap background mask | ||
bind($('.vc-mask'), 'click', function(e) { | ||
if (e.target != $('.vc-mask')) { | ||
return false; | ||
} | ||
self.hide(); | ||
}); | ||
// clear a log box | ||
bind($('.vc-clear'), 'click', function() { | ||
self.clearLog(self.activedTab); | ||
}); | ||
// clear a log box | ||
bind($('.vc-clear'), 'click', function() { | ||
self.clearLog(self.activedTab); | ||
}); | ||
// show a log box | ||
bind($$('.vc-tab'), 'click', function(e) { | ||
var tabName = e.target.dataset.tab; | ||
if (tabName == self.activedTab) { | ||
return; | ||
} | ||
self.showTab(tabName); | ||
}); | ||
// show a log box | ||
bind($$('.vc-tab'), 'click', function(e) { | ||
var tabName = e.target.dataset.tab; | ||
if (tabName == self.activedTab) { | ||
return; | ||
} | ||
self.showTab(tabName); | ||
}); | ||
}; | ||
@@ -93,102 +94,102 @@ | ||
vConsole.prototype._mokeConsole = function() { | ||
if (!window.console) { | ||
return; | ||
} | ||
var self = 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() { self._printLog('default', 'log', arguments); }; | ||
window.console.info = function() { self._printLog('default', 'info', arguments); }; | ||
window.console.warn = function() { self._printLog('default', 'warn', arguments); }; | ||
window.console.debug = function() { self._printLog('default', 'debug', arguments); }; | ||
window.console.error = function() { self._printLog('default', 'error', arguments); }; | ||
if (!window.console) { | ||
return; | ||
} | ||
var self = 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() { self._printLog('default', 'log', arguments); }; | ||
window.console.info = function() { self._printLog('default', 'info', arguments); }; | ||
window.console.warn = function() { self._printLog('default', 'warn', arguments); }; | ||
window.console.debug = function() { self._printLog('default', 'debug', arguments); }; | ||
window.console.error = function() { self._printLog('default', 'error', arguments); }; | ||
}; | ||
/** | ||
* auto run after initial | ||
* auto run after initialization | ||
* @private | ||
*/ | ||
vConsole.prototype._autoRun = function() { | ||
// print system info | ||
var ua = navigator.userAgent, | ||
logMsg = []; | ||
// current time | ||
var d = getDate(); | ||
this._printLog('system', 'info', ['日志时间:', d.year+'-'+d.month+'-'+d.day+' '+d.hour+':'+d.minute+':'+d.second+' '+d.millisecond]); | ||
// print system info | ||
var ua = navigator.userAgent, | ||
logMsg = []; | ||
// current time | ||
var d = getDate(); | ||
this._printLog('system', 'info', ['日志时间:', d.year+'-'+d.month+'-'+d.day+' '+d.hour+':'+d.minute+':'+d.second+' '+d.millisecond]); | ||
// device & system | ||
logMsg = ['系统版本:', '不明']; | ||
var ipod = ua.match(/(ipod).*\s([\d_]+)/i), | ||
ipad = ua.match(/(ipad).*\s([\d_]+)/i), | ||
iphone = ua.match(/(iphone)\sos\s([\d_]+)/i), | ||
android = ua.match(/(android)\s([\d\.]+)/i); | ||
if (android) { | ||
logMsg[1] = 'Android ' + android[2]; | ||
} else if (iphone) { | ||
logMsg[1] = 'iPhone, iOS ' + iphone[2].replace(/_/g,'.'); | ||
} else if (ipad) { | ||
logMsg[1] = 'iPad, iOS ' + ipad[2].replace(/_/g, '.'); | ||
} else if (ipod) { | ||
logMsg[1] = 'iPod, iOS ' + ipod[2].replace(/_/g, '.'); | ||
} | ||
this._printLog('system', 'info', logMsg); | ||
// device & system | ||
logMsg = ['系统版本:', '不明']; | ||
var ipod = ua.match(/(ipod).*\s([\d_]+)/i), | ||
ipad = ua.match(/(ipad).*\s([\d_]+)/i), | ||
iphone = ua.match(/(iphone)\sos\s([\d_]+)/i), | ||
android = ua.match(/(android)\s([\d\.]+)/i); | ||
if (android) { | ||
logMsg[1] = 'Android ' + android[2]; | ||
} else if (iphone) { | ||
logMsg[1] = 'iPhone, iOS ' + iphone[2].replace(/_/g,'.'); | ||
} else if (ipad) { | ||
logMsg[1] = 'iPad, iOS ' + ipad[2].replace(/_/g, '.'); | ||
} else if (ipod) { | ||
logMsg[1] = 'iPod, iOS ' + ipod[2].replace(/_/g, '.'); | ||
} | ||
this._printLog('system', 'info', logMsg); | ||
// wechat app version | ||
var version = ua.match(/MicroMessenger\/([\d\.]+)/i); | ||
logMsg = ['微信版本:', '不明']; | ||
if (version && version[1]) { | ||
logMsg[1] = version[1]; | ||
this._printLog('system', 'info', logMsg); | ||
} | ||
// wechat app version | ||
var version = ua.match(/MicroMessenger\/([\d\.]+)/i); | ||
logMsg = ['微信版本:', '不明']; | ||
if (version && version[1]) { | ||
logMsg[1] = version[1]; | ||
this._printLog('system', 'info', logMsg); | ||
} | ||
// network type | ||
var network = ua.toLowerCase().match(/ nettype\/([^ ]+)/g); | ||
logMsg = ['网络类型:', '不明']; | ||
if (network && network[0]) { | ||
network = network[0].split('/'); | ||
logMsg[1] = network[1]; | ||
this._printLog('system', 'info', logMsg); | ||
} | ||
// network type | ||
var network = ua.toLowerCase().match(/ nettype\/([^ ]+)/g); | ||
logMsg = ['网络类型:', '不明']; | ||
if (network && network[0]) { | ||
network = network[0].split('/'); | ||
logMsg[1] = network[1]; | ||
this._printLog('system', 'info', logMsg); | ||
} | ||
// HTTP protocol | ||
logMsg = ['网址协议:', '不明']; | ||
if (location.protocol == 'https:') { | ||
logMsg[1] = 'HTTPS'; | ||
} else if (location.protocol == 'http:') { | ||
logMsg[1] = 'HTTP'; | ||
} else { | ||
logMsg[1] = location.protocol.replace(':', ''); | ||
} | ||
this._printLog('system', 'info', logMsg); | ||
// HTTP protocol | ||
logMsg = ['网址协议:', '不明']; | ||
if (location.protocol == 'https:') { | ||
logMsg[1] = 'HTTPS'; | ||
} else if (location.protocol == 'http:') { | ||
logMsg[1] = 'HTTP'; | ||
} else { | ||
logMsg[1] = location.protocol.replace(':', ''); | ||
} | ||
this._printLog('system', 'info', logMsg); | ||
// performance related | ||
window.addEventListener('load', function(e) { | ||
var performance = window.performance || window.msPerformance || window.webkitPerformance; | ||
// performance related | ||
window.addEventListener('load', function(e) { | ||
var performance = window.performance || window.msPerformance || window.webkitPerformance; | ||
// timing | ||
if (performance && performance.timing) { | ||
var t = performance.timing, | ||
start = t.navigationStart; | ||
// this._printLog('system', 'debug', ['domainLookupEnd:', (t.domainLookupEnd - start)+'ms']); | ||
this._printLog('system', 'info', ['连接结束点:', (t.connectEnd - start)+'ms']); | ||
this._printLog('system', 'info', ['回包结束点:', (t.responseEnd - start)+'ms']); | ||
// this._printLog('system', 'debug', ['domComplete:', (t.domComplete - start)+'ms']); | ||
// this._printLog('system', 'info', ['beforeReqTime:', (t.requestStart - start)+'ms']); | ||
if (t.secureConnectionStart > 0) { | ||
this._printLog('system', 'info', ['ssl耗时:', (t.connectEnd - t.secureConnectionStart)+'ms']); | ||
} | ||
// this._printLog('system', 'info', ['req&RespTime:', (t.responseEnd - t.requestStart)+'ms']); | ||
this._printLog('system', 'info', ['dom渲染耗时:', (t.domComplete - t.domLoading)+'ms']); | ||
} | ||
}); | ||
// timing | ||
if (performance && performance.timing) { | ||
var t = performance.timing, | ||
start = t.navigationStart; | ||
// this._printLog('system', 'debug', ['domainLookupEnd:', (t.domainLookupEnd - start)+'ms']); | ||
this._printLog('system', 'info', ['连接结束点:', (t.connectEnd - start)+'ms']); | ||
this._printLog('system', 'info', ['回包结束点:', (t.responseEnd - start)+'ms']); | ||
// this._printLog('system', 'debug', ['domComplete:', (t.domComplete - start)+'ms']); | ||
// this._printLog('system', 'info', ['beforeReqTime:', (t.requestStart - start)+'ms']); | ||
if (t.secureConnectionStart > 0) { | ||
this._printLog('system', 'info', ['ssl耗时:', (t.connectEnd - t.secureConnectionStart)+'ms']); | ||
} | ||
// this._printLog('system', 'info', ['req&RespTime:', (t.responseEnd - t.requestStart)+'ms']); | ||
this._printLog('system', 'info', ['dom渲染耗时:', (t.domComplete - t.domLoading)+'ms']); | ||
} | ||
}); | ||
while (this.readyCallback.length > 0) { | ||
var callback = this.readyCallback.shift(); | ||
callback && callback.call(this); | ||
} | ||
this.isReady = true; | ||
while (this.readyCallback.length > 0) { | ||
var callback = this.readyCallback.shift(); | ||
callback && callback.call(this); | ||
} | ||
this.isReady = true; | ||
}; | ||
@@ -199,36 +200,36 @@ | ||
* @private | ||
* @param string tabName | ||
* @param string logType log|info|debug|error|warn | ||
* @param array logs | ||
* @param string tabName | ||
* @param string logType log|info|debug|error|warn | ||
* @param array logs | ||
*/ | ||
vConsole.prototype._printLog = function(tabName, logType, logs) { | ||
if (!logs.length) { | ||
return; | ||
} | ||
if (!logs.length) { | ||
return; | ||
} | ||
// generate plain text for a line | ||
var line = ''; | ||
for (var i=0; i<logs.length; i++) { | ||
try { | ||
if (typeof logs[i] == 'function') { | ||
line += ' ' + logs[i].toString(); | ||
} else if (typeof logs[i] == 'object') { | ||
line += ' ' + JSON.stringify(logs[i]); | ||
} else { | ||
line += ' ' + logs[i]; | ||
} | ||
} catch (e) { | ||
line += ' [' + (typeof logs[i]) + ']'; | ||
} | ||
} | ||
// generate plain text for a line | ||
var line = ''; | ||
for (var i=0; i<logs.length; i++) { | ||
try { | ||
if (typeof logs[i] == 'function') { | ||
line += ' ' + logs[i].toString(); | ||
} else if (typeof logs[i] == 'object') { | ||
line += ' ' + JSON.stringify(logs[i]); | ||
} else { | ||
line += ' ' + logs[i]; | ||
} | ||
} catch (e) { | ||
line += ' [' + (typeof logs[i]) + ']'; | ||
} | ||
} | ||
var $logbox = $('#__vc_log_' + tabName); | ||
var p = document.createElement('p'); | ||
p.className = 'vc-item vc-item-' + logType; | ||
p.innerHTML = line; | ||
$('.vc-log', $logbox).appendChild(p); | ||
$('.vc-content').scrollTop = $('.vc-content').scrollHeight; | ||
var $logbox = $('#__vc_log_' + tabName); | ||
var p = document.createElement('p'); | ||
p.className = 'vc-item vc-item-' + logType; | ||
p.innerHTML = line; | ||
$('.vc-log', $logbox).appendChild(p); | ||
$('.vc-content').scrollTop = $('.vc-content').scrollHeight; | ||
// print to traditional console | ||
this.console[logType].apply(window.console, logs); | ||
// print to traditional console | ||
this.console[logType].apply(window.console, logs); | ||
}; | ||
@@ -241,11 +242,11 @@ | ||
vConsole.prototype.showTab = function(tabName) { | ||
var $logbox = $('#__vc_log_' + tabName); | ||
// set actived status | ||
removeClass($$('.vc-tab', this.$dom), 'vc-actived'); | ||
addClass($('#__vc_tab_' + tabName), 'vc-actived'); | ||
removeClass($$('.vc-logbox'), 'vc-actived'); | ||
addClass($logbox, 'vc-actived'); | ||
// scroll to bottom | ||
$('.vc-content').scrollTop = $('.vc-content').scrollHeight; | ||
this.activedTab = tabName; | ||
var $logbox = $('#__vc_log_' + tabName); | ||
// set actived status | ||
removeClass($$('.vc-tab', this.$dom), 'vc-actived'); | ||
addClass($('#__vc_tab_' + tabName), 'vc-actived'); | ||
removeClass($$('.vc-logbox'), 'vc-actived'); | ||
addClass($logbox, 'vc-actived'); | ||
// scroll to bottom | ||
$('.vc-content').scrollTop = $('.vc-content').scrollHeight; | ||
this.activedTab = tabName; | ||
}; | ||
@@ -258,4 +259,4 @@ | ||
vConsole.prototype.clearLog = function(tabName) { | ||
var $logbox = $('#__vc_log_' + tabName); | ||
$('.vc-log', $logbox).innerHTML = ''; | ||
var $logbox = $('#__vc_log_' + tabName); | ||
$('.vc-log', $logbox).innerHTML = ''; | ||
}; | ||
@@ -268,3 +269,3 @@ | ||
vConsole.prototype.show = function() { | ||
addClass(this.$dom, 'vc-toggle'); | ||
addClass(this.$dom, 'vc-toggle'); | ||
}; | ||
@@ -277,15 +278,16 @@ | ||
vConsole.prototype.hide = function() { | ||
removeClass(this.$dom, 'vc-toggle'); | ||
removeClass(this.$dom, 'vc-toggle'); | ||
}; | ||
/** | ||
* | ||
* when vConsole is ready, callback() will be called | ||
* @public | ||
* @param function callback | ||
*/ | ||
vConsole.prototype.ready = function(callback) { | ||
if (!this.isReady) { | ||
this.readyCallback.push(callback); | ||
} else { | ||
callback.call(this); | ||
} | ||
if (!this.isReady) { | ||
this.readyCallback.push(callback); | ||
} else { | ||
callback.call(this); | ||
} | ||
}; | ||
@@ -303,6 +305,6 @@ | ||
function $(selector, contextElement) { | ||
if (contextElement) { | ||
return contextElement.querySelector(selector); | ||
} | ||
return document.querySelector(selector); | ||
if (contextElement) { | ||
return contextElement.querySelector(selector); | ||
} | ||
return document.querySelector(selector); | ||
} | ||
@@ -315,13 +317,13 @@ | ||
function $$(selector, contextElement) { | ||
var nodeList, | ||
list = []; | ||
if (contextElement) { | ||
nodeList = contextElement.querySelectorAll(selector); | ||
} else { | ||
nodeList = document.querySelectorAll(selector); | ||
} | ||
if (nodeList && nodeList.length > 0) { | ||
list = Array.prototype.slice.call(nodeList); | ||
} | ||
return list; | ||
var nodeList, | ||
list = []; | ||
if (contextElement) { | ||
nodeList = contextElement.querySelectorAll(selector); | ||
} else { | ||
nodeList = document.querySelectorAll(selector); | ||
} | ||
if (nodeList && nodeList.length > 0) { | ||
list = Array.prototype.slice.call(nodeList); | ||
} | ||
return list; | ||
} | ||
@@ -334,11 +336,11 @@ | ||
function addClass($el, className) { | ||
if (!$el) { | ||
return; | ||
} | ||
if (Object.prototype.toString.call($el) != '[object Array]') { | ||
$el = [$el]; | ||
} | ||
for (var i=0; i<$el.length; i++) { | ||
$el[i].className += ' ' + className; | ||
} | ||
if (!$el) { | ||
return; | ||
} | ||
if (Object.prototype.toString.call($el) != '[object Array]') { | ||
$el = [$el]; | ||
} | ||
for (var i=0; i<$el.length; i++) { | ||
$el[i].className += ' ' + className; | ||
} | ||
} | ||
@@ -351,17 +353,17 @@ | ||
function removeClass($el, className) { | ||
if (!$el) { | ||
return; | ||
} | ||
if (Object.prototype.toString.call($el) != '[object Array]') { | ||
$el = [$el]; | ||
} | ||
for (var i=0; i<$el.length; i++) { | ||
var arr = $el[i].className.split(' '); | ||
for (var j=0; j<arr.length; j++) { | ||
if (arr[j] == className) { | ||
arr[j] = ''; | ||
} | ||
} | ||
$el[i].className = arr.join(' '); | ||
} | ||
if (!$el) { | ||
return; | ||
} | ||
if (Object.prototype.toString.call($el) != '[object Array]') { | ||
$el = [$el]; | ||
} | ||
for (var i=0; i<$el.length; i++) { | ||
var arr = $el[i].className.split(' '); | ||
for (var j=0; j<arr.length; j++) { | ||
if (arr[j] == className) { | ||
arr[j] = ''; | ||
} | ||
} | ||
$el[i].className = arr.join(' '); | ||
} | ||
} | ||
@@ -372,20 +374,20 @@ | ||
* @private | ||
* @param array $el element object or array | ||
* @param string eventType name of the event | ||
* @param function fn | ||
* @param boolean useCapture | ||
* @param array $el element object or array | ||
* @param string eventType name of the event | ||
* @param function fn | ||
* @param boolean useCapture | ||
*/ | ||
function bind($el, eventType, fn, useCapture) { | ||
if (!$el) { | ||
return; | ||
} | ||
if (useCapture === undefined) { | ||
useCapture = false; | ||
} | ||
if (Object.prototype.toString.call($el) != '[object Array]') { | ||
$el = [$el]; | ||
} | ||
for (var i=0; i<$el.length; i++) { | ||
$el[i].addEventListener(eventType, fn, useCapture); | ||
} | ||
if (!$el) { | ||
return; | ||
} | ||
if (useCapture === undefined) { | ||
useCapture = false; | ||
} | ||
if (Object.prototype.toString.call($el) != '[object Array]') { | ||
$el = [$el]; | ||
} | ||
for (var i=0; i<$el.length; i++) { | ||
$el[i].addEventListener(eventType, fn, useCapture); | ||
} | ||
} | ||
@@ -395,25 +397,25 @@ | ||
* get formatted date by timestamp | ||
* @param int time | ||
* @return object | ||
* @param int time | ||
* @return object | ||
*/ | ||
function getDate(time) { | ||
var d = time>0 ? new Date(time) : new Date(); | ||
var day = d.getDay()<10 ? '0'+d.getDay() : d.getDay(), | ||
month = d.getMonth()<9 ? '0'+(d.getMonth()+1) : (d.getMonth()+1), | ||
year = d.getFullYear(), | ||
hour = d.getHours()<10 ? '0'+d.getHours() : d.getHours(), | ||
minute = d.getMinutes()<10 ? '0'+d.getMinutes() : d.getMinutes(), | ||
second = d.getSeconds()<10 ? '0'+d.getSeconds() : d.getSeconds(), | ||
millisecond = d.getMilliseconds()<10 ? '0'+d.getMilliseconds() : d.getMilliseconds(); | ||
if (millisecond<100) { millisecond = '0' + millisecond; } | ||
return { | ||
time: (+d), | ||
year: year, | ||
month: month, | ||
day: day, | ||
hour: hour, | ||
minute: minute, | ||
second: second, | ||
millisecond: millisecond | ||
}; | ||
var d = time>0 ? new Date(time) : new Date(); | ||
var day = d.getDay()<10 ? '0'+d.getDay() : d.getDay(), | ||
month = d.getMonth()<9 ? '0'+(d.getMonth()+1) : (d.getMonth()+1), | ||
year = d.getFullYear(), | ||
hour = d.getHours()<10 ? '0'+d.getHours() : d.getHours(), | ||
minute = d.getMinutes()<10 ? '0'+d.getMinutes() : d.getMinutes(), | ||
second = d.getSeconds()<10 ? '0'+d.getSeconds() : d.getSeconds(), | ||
millisecond = d.getMilliseconds()<10 ? '0'+d.getMilliseconds() : d.getMilliseconds(); | ||
if (millisecond<100) { millisecond = '0' + millisecond; } | ||
return { | ||
time: (+d), | ||
year: year, | ||
month: month, | ||
day: day, | ||
hour: hour, | ||
minute: minute, | ||
second: second, | ||
millisecond: millisecond | ||
}; | ||
} | ||
@@ -420,0 +422,0 @@ |
@@ -5,37 +5,37 @@ var webpack = require('webpack'); | ||
module.exports = { | ||
devtool: false, | ||
entry: { | ||
"vconsole" : "./src/vconsole.js" | ||
}, | ||
output: { | ||
path: "./dist", | ||
filename: "[name].min.js", | ||
library: 'vConsole', | ||
libraryTarget: 'umd', | ||
umdNameDefine: true | ||
}, | ||
module: { | ||
loaders: [ | ||
{ | ||
test: /\.html$/, loader: "html" | ||
}, | ||
{ | ||
test: /\.js$/, loader: "babel" | ||
}, | ||
{ | ||
test: /\.less$/, | ||
loader: "style!css!less" | ||
// loader: ExtractTextPlugin.extract("style-loader", "css-loader!less-loader") // 将css独立打包 | ||
} | ||
] | ||
}, | ||
plugins: [ | ||
// new webpack.optimize.UglifyJsPlugin({ | ||
// compress: { | ||
// warnings: false | ||
// } | ||
// }) | ||
// ,new ExtractTextPlugin("[name].min.css") // 将css独立打包 | ||
] | ||
devtool: false, | ||
entry: { | ||
"vconsole" : "./src/vconsole.js" | ||
}, | ||
output: { | ||
path: "./dist", | ||
filename: "[name].min.js", | ||
library: 'vConsole', | ||
libraryTarget: 'umd', | ||
umdNameDefine: true | ||
}, | ||
module: { | ||
loaders: [ | ||
{ | ||
test: /\.html$/, loader: "html" | ||
}, | ||
{ | ||
test: /\.js$/, loader: "babel" | ||
}, | ||
{ | ||
test: /\.less$/, | ||
loader: "style!css!less" | ||
// loader: ExtractTextPlugin.extract("style-loader", "css-loader!less-loader") // 将css独立打包 | ||
} | ||
] | ||
}, | ||
plugins: [ | ||
new webpack.optimize.UglifyJsPlugin({ | ||
compress: { | ||
warnings: false | ||
} | ||
}) | ||
// ,new ExtractTextPlugin("[name].min.css") // 将css独立打包 | ||
] | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
0
0
249069
1505