mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 12:40:25 +08:00
feat: 优化实时日志为500行
This commit is contained in:
@@ -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')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user