子标签颜色

This commit is contained in:
xu_yanfeng 2024-12-24 21:23:04 +08:00
parent 27f4884216
commit a0947d6e0b
2 changed files with 23 additions and 6 deletions

View File

@ -24,7 +24,7 @@ class CCInspector {
}
}, 300);
}
private terminal = new Terminal('Inject', 'blue', 'gray');
private terminal = new Terminal('Inject ', 'blue', 'gray');
init() {
console.log(...this.terminal.init());
this.watchIsCocosGame();

View File

@ -3,6 +3,10 @@ export class Terminal {
*
*/
tag = 'terminal';
/**
*
*/
subTag = "";
/**
*
*/
@ -22,33 +26,46 @@ export class Terminal {
this.tag = tag;
}
init(): string[] {
return this.log(`init`);
this.txtColor = 'black';
this.subTag = "init";
return this.log(``);
}
public log(message: string, newline: boolean = false): string[] {
return [`%c${this.tag}%c${newline ? '\n' : ''}${message}`, `color:${this.tagColor};background:${this.tagBackground};padding:0 4px`, `color:${this.txtColor};margin-left:5px`];
return [
`*%c${this.tag}%c${this.subTag}%c${newline ? '\n' : ''}${message}`,
`color:${this.tagColor};background:${this.tagBackground};padding:0 4px`,
`color:white;background:black;padding:0 3px`,
`color:${this.txtColor};background:#e6e6e6;margin-left:5px`
];
}
public blue(message: string): string[] {
this.txtColor = 'blue';
this.subTag = "";
return this.log(message);
}
public green(message: string): string[] {
this.txtColor = 'green';
this.subTag = "";
return this.log(message);
}
public red(message: string): string[] {
this.txtColor = 'red';
this.subTag = "";
return this.log(message);
}
message(msg: string): string[] {
this.txtColor = 'black';
return this.log(`[message] ${msg}`);
this.subTag = 'message';
return this.log(`${msg}`);
}
connect(msg: string): string[] {
this.txtColor = 'black';
return this.log(`[connect] ${msg}`);
this.subTag = 'connect';
return this.log(`${msg}`);
}
disconnect(msg: string): string[] {
this.txtColor = 'black';
return this.log(`[disconnect] ${msg}`);
this.subTag = 'disconnect';
return this.log(`${msg}`);
}
}