删除log导出
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import { createApp, defineComponent, h } from "vue";
|
import { createApp, defineComponent, h } from "vue";
|
||||||
import "./tool/consoleExport.js";
|
|
||||||
import App from "./App.vue";
|
import App from "./App.vue";
|
||||||
import router from "./router";
|
import router from "./router";
|
||||||
import store from "./store";
|
import store from "./store";
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
if (import.meta.env.VITE_USER_NODE_ENVh === "production") {
|
|
||||||
const log = console.log;
|
|
||||||
const error = console.error;
|
|
||||||
const warn = console.warn;
|
|
||||||
const info = console.info;
|
|
||||||
const list = [];
|
|
||||||
|
|
||||||
class Item {
|
|
||||||
constructor(type, arrs) {
|
|
||||||
this.type = type
|
|
||||||
this.time = FormatDate()
|
|
||||||
this.content = arrs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log = function () {
|
|
||||||
log(...arguments)
|
|
||||||
list.push(new Item('log', [...arguments]))
|
|
||||||
}
|
|
||||||
console.error = function () {
|
|
||||||
error(...arguments)
|
|
||||||
list.push(new Item('error', [...arguments]))
|
|
||||||
}
|
|
||||||
console.warn = function () {
|
|
||||||
warn(...arguments)
|
|
||||||
list.push(new Item('warn', [...arguments]))
|
|
||||||
}
|
|
||||||
console.info = function () {
|
|
||||||
info(...arguments)
|
|
||||||
list.push(new Item('info', [...arguments]))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 导出列表-json
|
|
||||||
const exportListJson = function () {
|
|
||||||
const json = JSON.stringify(list, null, 2)
|
|
||||||
const blob = new Blob([json], { type: 'application/json' })
|
|
||||||
const url = URL.createObjectURL(blob)
|
|
||||||
const a = document.createElement('a')
|
|
||||||
a.href = url
|
|
||||||
a.download = `console_${FormatDate("yyyyMMddHHmmss")}.json`
|
|
||||||
a.click()
|
|
||||||
URL.revokeObjectURL(url)
|
|
||||||
}
|
|
||||||
|
|
||||||
const keys = [];
|
|
||||||
document.addEventListener("keydown", (e) => {
|
|
||||||
if (e.key === "Control") return;
|
|
||||||
if (e.ctrlKey) {
|
|
||||||
keys.push(e.key)
|
|
||||||
const str = keys.join('');
|
|
||||||
if (/m{5}/i.test(str)) {
|
|
||||||
exportListJson()
|
|
||||||
keys.splice(0, keys.length)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
keys.splice(0, keys.length)
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 时间格式化-自定义格式
|
|
||||||
* @param format 格式化字符串,默认值为 'yyyy-MM-dd HH:mm:ss'
|
|
||||||
* @returns 格式化后的时间字符串
|
|
||||||
*/
|
|
||||||
function FormatDate(format = 'yyyy-MM-dd HH:mm:ss') {
|
|
||||||
const date = new Date();
|
|
||||||
const yyyy = String(date.getFullYear());
|
|
||||||
const yy = String(date.getFullYear()).slice(-2);
|
|
||||||
const MM = String(date.getMonth() + 1).padStart(2, '0');
|
|
||||||
const M = String(date.getMonth() + 1);
|
|
||||||
const dd = String(date.getDate()).padStart(2, '0');
|
|
||||||
const d = String(date.getDate());
|
|
||||||
const HH = String(date.getHours()).padStart(2, '0');
|
|
||||||
const H = String(date.getHours());
|
|
||||||
const mm = String(date.getMinutes()).padStart(2, '0');
|
|
||||||
const m = String(date.getMinutes());
|
|
||||||
const ss = String(date.getSeconds()).padStart(2, '0');
|
|
||||||
const s = String(date.getSeconds());
|
|
||||||
const str = format.replaceAll('yyyy', yyyy)
|
|
||||||
.replaceAll('yy', yy)
|
|
||||||
.replaceAll('MM', MM)
|
|
||||||
.replaceAll('M', M)
|
|
||||||
.replaceAll('dd', dd)
|
|
||||||
.replaceAll('d', d)
|
|
||||||
.replaceAll('HH', HH)
|
|
||||||
.replaceAll('H', H)
|
|
||||||
.replaceAll('mm', mm)
|
|
||||||
.replaceAll('m', m)
|
|
||||||
.replaceAll('ss', ss)
|
|
||||||
.replaceAll('s', s);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user