Skip to content

Commit 062af1a

Browse files
committed
🎈 perf: δΌ˜εŒ– WebUI ζ—₯志错误倄理
1 parent 79d38f9 commit 062af1a

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

β€Ždashboard/src/stores/common.jsβ€Ž

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,23 @@ export const useCommonStore = defineStore({
6262
}
6363

6464
const text = decoder.decode(value);
65-
const lines = text.split('\n');
65+
const lines = text.split('\n\n');
6666
lines.forEach(line => {
6767
if (line.startsWith('data:')) {
6868
const data = line.substring(5).trim();
69-
7069
// {"type":"log","data":"[2021-08-01 00:00:00] INFO: Hello, world!"}
71-
72-
let data_json = JSON.parse(data)
70+
let data_json = {}
71+
try {
72+
data_json = JSON.parse(data);
73+
} catch (e) {
74+
console.error('Invalid JSON:', data);
75+
data_json = {
76+
type: 'log',
77+
data: data,
78+
level: 'INFO',
79+
time: new Date().toISOString(),
80+
}
81+
}
7382
if (data_json.type === 'log') {
7483
// let log = data_json.data
7584
this.log_cache.push(data_json);

0 commit comments

Comments
Β (0)