feat: add logs ansi render

This commit is contained in:
engigu
2026-03-11 11:59:03 +08:00
parent db2bbd5d4d
commit b7522bc47c
7 changed files with 74 additions and 12 deletions
+7 -1
View File
@@ -133,6 +133,12 @@ async function uninstallPackage() {
}
}
import { ansiToHtml } from '@/utils/ansi'
const renderedLog = computed(() => {
return ansiToHtml(logContent.value)
})
function showLog(dep: Dependency) {
logPkgName.value = dep.name
logContent.value = dep.log || '暂无日志'
@@ -357,7 +363,7 @@ onMounted(async () => {
<DialogDescription class="sr-only">查看依赖包的详细安装输出日志</DialogDescription>
</DialogHeader>
<div class="max-h-[400px] overflow-y-auto">
<pre class="text-xs bg-muted p-3 rounded-lg whitespace-pre-wrap break-all font-mono">{{ logContent }}</pre>
<pre class="text-xs bg-muted p-3 rounded-lg whitespace-pre-wrap break-all font-mono" v-html="renderedLog"></pre>
</div>
<DialogFooter>
<Button variant="outline" @click="showLogDialog = false">关闭</Button>