From 062af1ac08b7936b5a869d30954407a95057ac24 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Mon, 7 Apr 2025 10:38:03 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf:=20=E4=BC=98=E5=8C=96=20Web?= =?UTF-8?q?UI=20=E6=97=A5=E5=BF=97=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dashboard/src/stores/common.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/dashboard/src/stores/common.js b/dashboard/src/stores/common.js index 640389ddc..49f55f5db 100644 --- a/dashboard/src/stores/common.js +++ b/dashboard/src/stores/common.js @@ -62,14 +62,23 @@ export const useCommonStore = defineStore({ } const text = decoder.decode(value); - const lines = text.split('\n'); + const lines = text.split('\n\n'); lines.forEach(line => { if (line.startsWith('data:')) { const data = line.substring(5).trim(); - // {"type":"log","data":"[2021-08-01 00:00:00] INFO: Hello, world!"} - - let data_json = JSON.parse(data) + let data_json = {} + try { + data_json = JSON.parse(data); + } catch (e) { + console.error('Invalid JSON:', data); + data_json = { + type: 'log', + data: data, + level: 'INFO', + time: new Date().toISOString(), + } + } if (data_json.type === 'log') { // let log = data_json.data this.log_cache.push(data_json);