UNPKG

pabala-biu

Version:

Changelogs

58 lines (52 loc) 1.29 kB
const log:any = { }; function typeColor (type = 'default') { let color = '' switch (type) { case 'primary': color = '#2d8cf0' break case 'success': color = '#19be6b' break case 'info': color = '#909399' break case 'warning': color = '#ff9900' break case 'danger': color = '#f03f14' break case 'default': color = '#35495E' break default: color = type break } return color } log['print'] = function (text:string, type = 'default', back = false) { if (typeof text === 'object') { // 如果是对象则调用打印对象方式 console.dir(text) return } if (back) { // 如果是打印带背景图的 console.log( `%c ${text} `, `background:${typeColor(type)}; padding: 2px; border-radius: 4px;color: #fff;` ) } else { console.log( `%c ${text} `, `color: ${typeColor(type)};` ) } } log.pretty = function (title:string, text:string, type = 'primary') { console.log(`${title} ${text} `) } log.error = function () { } export default log