log color

This commit is contained in:
wxiaoguang
2022-09-30 12:26:59 +08:00
committed by Jason Song
parent 3e9022c9f0
commit 0abbc2b50f
3 changed files with 70 additions and 2 deletions

View File

@ -68,6 +68,7 @@
<script>
import {SvgIcon} from '../svg.js';
import Vue from 'vue';
import AnsiToHTML from `ansi-to-html`;
const sfc = {
name: 'RepoBuildView',
@ -89,6 +90,10 @@ const sfc = {
};
},
created() {
this.ansiToHTML = new AnsiToHTML({escapeXML: true});
},
mounted() {
// TODO: the parent element's full height doesn't work well now
const elBodyDiv = document.querySelector('body > div.full.height');
@ -144,7 +149,7 @@ const sfc = {
el.appendChild(elLogTime);
const elLogMsg = document.createElement('log-msg');
elLogMsg.innerText = line.m;
elLogMsg.innerHTML = this.ansiToHTML.toHtml(line.m);
el.appendChild(elLogMsg);
return el;
@ -191,7 +196,7 @@ const sfc = {
for (let i = 0; i < 110; i++) {
lines.push({
ln: cursor, // demo only, use cursor for line number
m: `hello world ${Date.now()}, cursor: ${cursor}`,
m: ' '.repeat(i % 4) + `\x1B[1;3;31mDemo Log\x1B[0m, tag test <br>, hello world ${Date.now()}, cursor: ${cursor}`,
t: Date.now(),
});
cursor++;
@ -369,6 +374,7 @@ export function initRepositoryBuildView() {
}
log-msg {
flex: 1;
white-space: pre;
margin-left: 16px;
}
}