debug
This commit is contained in:
91
domain-web/src/views/logs/LogsView.vue
Normal file
91
domain-web/src/views/logs/LogsView.vue
Normal file
@@ -0,0 +1,91 @@
|
||||
<template>
|
||||
<PageCard title="日志诊断" description="查看最近日志摘要,并直接下载诊断包。">
|
||||
<template #header-extra>
|
||||
<div class="toolbar">
|
||||
<el-link :href="bundleUrl" target="_blank" type="primary">下载诊断包</el-link>
|
||||
<el-button plain :loading="loading" @click="loadLogs">刷新</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-row :gutter="16">
|
||||
<el-col :xs="24" :lg="12">
|
||||
<div class="log-block">
|
||||
<h3>API 标准输出</h3>
|
||||
<pre>{{ apiStdout }}</pre>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :xs="24" :lg="12">
|
||||
<div class="log-block">
|
||||
<h3>Worker 日志</h3>
|
||||
<pre>{{ workerLog }}</pre>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</PageCard>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import PageCard from "@/components/PageCard.vue";
|
||||
import { logsApi } from "@/api/modules";
|
||||
|
||||
const loading = ref(false);
|
||||
const apiStdout = ref("暂无日志");
|
||||
const workerLog = ref("暂无日志");
|
||||
const bundleUrl = logsApi.bundleUrl();
|
||||
|
||||
const normalizeLines = (value: unknown) => {
|
||||
if (Array.isArray(value)) {
|
||||
return value.join("\n") || "暂无日志";
|
||||
}
|
||||
return typeof value === "string" && value.trim() ? value : "暂无日志";
|
||||
};
|
||||
|
||||
const loadLogs = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const response = await logsApi.latest();
|
||||
apiStdout.value = normalizeLines(response.data?.api_stdout);
|
||||
workerLog.value = normalizeLines(response.data?.worker_log);
|
||||
} catch {
|
||||
ElMessage.error("读取日志失败");
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(loadLogs);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.toolbar {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.log-block {
|
||||
height: 100%;
|
||||
padding: 18px;
|
||||
border-radius: 16px;
|
||||
background: #0f172a;
|
||||
color: #e2e8f0;
|
||||
}
|
||||
|
||||
.log-block h3 {
|
||||
margin: 0 0 12px;
|
||||
color: #f8fafc;
|
||||
}
|
||||
|
||||
.log-block pre {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
font-family: Consolas, Monaco, monospace;
|
||||
max-height: 520px;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user