2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 12:40:25 +08:00

feat: 优化实时日志为500行

This commit is contained in:
耗子
2024-10-26 02:32:57 +08:00
parent 95cf05879d
commit 049f708cae
2 changed files with 6 additions and 6 deletions

View File

@@ -11,15 +11,15 @@ const logRef = ref<LogInst | null>(null)
let logWs: WebSocket | null = null
const init = async () => {
const cmd = `tail -n 200 -f '${props.path}'`
const cmd = `tail -n 100 -f '${props.path}'`
ws.exec(cmd)
.then((ws: WebSocket) => {
logWs = ws
ws.onmessage = (event) => {
log.value += event.data + '\n'
const lines = log.value.split('\n')
if (lines.length > 1000) {
log.value = lines.slice(lines.length - 1000).join('\n')
if (lines.length > 500) {
log.value = lines.slice(lines.length - 500).join('\n')
}
}
})

View File

@@ -12,15 +12,15 @@ const logRef = ref<LogInst | null>(null)
let logWs: WebSocket | null = null
const init = async () => {
const cmd = `tail -n 200 -f '${props.path}'`
const cmd = `tail -n 100 -f '${props.path}'`
ws.exec(cmd)
.then((ws: WebSocket) => {
logWs = ws
ws.onmessage = (event) => {
log.value += event.data + '\n'
const lines = log.value.split('\n')
if (lines.length > 1000) {
log.value = lines.slice(lines.length - 1000).join('\n')
if (lines.length > 500) {
log.value = lines.slice(lines.length - 500).join('\n')
}
}
})