var res = `
__ __ ____ _ __ __ __
/ / / /__ / / /___ | | / /___ _____/ /___/ /
/ /_/ / _ \\/ / / __ \\ | | /| / / __ \\/ ___/ / __ /
/ __ / __/ / / /_/ / | |/ |/ / /_/ / / / / /_/ /
/_/ /_/\\___/_/_/\\____/ |__/|__/\\____/_/ /_/\\__,_/
`
console.log(res);
function onlyFormat() {
var date = new Date(); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
var Y = date.getFullYear() + '-';
var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
return Y + M + D + ' ' + h + m + s; //时分秒可以根据自己的需求加上
};
function change(factory) {
return (...args) => factory(`控制台 %c${onlyFormat()}%c [localhost] %cINFO: `,'color:#F56C6C;','color:green;','color:#1A73E8;background:white;','', ...args)
}
console.log = change(console.log)
let a = 1
let b = 23
let c = 'ccc'
console.log(a,b,c);
js采用高级工厂 模仿spring控制台 封装console对象方法
最新推荐文章于 2023-06-05 14:55:29 发布