fix logging ui

This commit is contained in:
jxxghp
2023-09-03 15:42:01 +08:00
parent 38e74f0c1b
commit 93a2a4a772

View File

@@ -28,7 +28,7 @@ function startSSELogging() {
function extractLogDetailsFromLogs(logs: string[]): { level: string; time: string; program: string; content: string }[] { function extractLogDetailsFromLogs(logs: string[]): { level: string; time: string; program: string; content: string }[] {
const logDetails: { level: string; time: string; program: string; content: string }[] = [] const logDetails: { level: string; time: string; program: string; content: string }[] = []
const logPattern = /^【(.*?)】.*\s(.*?)\s-\s(.*?)\s-\s(.*)$/ const logPattern = /^【(.*?)】[0-9\-:]*\s(.*?)\s-\s(.*?)\s-\s(.*)$/
for (const log of logs) { for (const log of logs) {
const matches = RegExp(logPattern).exec(log) const matches = RegExp(logPattern).exec(log)
@@ -70,7 +70,7 @@ onMounted(() => {
<template> <template>
<div <div
v-if="logs.length === 0" v-if="logs.length === 0"
class="mt-5 w-full text-centerflex flex-col items-center" class="mt-5 w-full text-center flex flex-col items-center"
> >
<VProgressCircular <VProgressCircular
size="48" size="48"
@@ -79,41 +79,43 @@ onMounted(() => {
/> />
<span class="mt-3">正在刷新 ...</span> <span class="mt-3">正在刷新 ...</span>
</div> </div>
<VTable <div>
class="table-rounded" <VTable
hide-default-footer class="table-rounded"
disable-sort hide-default-footer
> disable-sort
<tbody> >
<tr v-for="(log, i) in extractLogDetails" :key="i" class="text-sm"> <tbody>
<td <tr v-for="(log, i) in extractLogDetails" :key="i" class="text-sm">
class="text-sm" <td
> class="text-sm"
<VChip >
size="small" <VChip
:color="getLogColor(log.level)" size="small"
variant="elevated" :color="getLogColor(log.level)"
v-text="log.level" variant="elevated"
v-text="log.level"
/>
</td>
<!-- name -->
<td
class="text-sm"
>
{{ log.time }}
</td>
<td
class="text-sm"
>
<h6 class="text-sm font-weight-medium">
{{ log.program }}
</h6>
</td>
<td
class="text-sm"
v-text="log.content"
/> />
</td> </tr>
<!-- name --> </tbody>
<td </VTable>
class="text-sm" </div>
>
{{ log.time }}
</td>
<td
class="text-sm"
>
<h6 class="text-sm font-weight-medium">
{{ log.program }}
</h6>
</td>
<td
class="text-sm"
v-text="log.content"
/>
</tr>
</tbody>
</VTable>
</template> </template>