添加了一些log

This commit is contained in:
xu_yanfeng
2024-12-15 19:59:51 +08:00
parent 153a2f66f1
commit 3cdb4db7cf
6 changed files with 34 additions and 10 deletions

View File

@@ -9,6 +9,7 @@ class Content {
private connect: chrome.runtime.Port | null = null;
constructor() {
console.log("init content");
// 接受来自inject.js的消息数据,然后中转到background.js
window.addEventListener("message", (event) => {
let data: PluginEvent = event.data;

View File

@@ -0,0 +1,19 @@
export class Terminal {
color = 'red';
background = 'yellow';
tag = 'terminal';
constructor(tag: string, color: string = 'red', background: string = 'yellow') {
this.color = color;
this.background = background;
this.tag = tag;
}
ok() {
this.log(`ok`);
}
log(message: string) {
console.log(`%c${this.tag}%c${message}`, `color:${this.color};background:${this.background};padding:0 4px`, "color:black;margin-left:5px")
}
connect(msg: string) {
this.log(`[connect] ${msg}`);
}
}