From a00a07152f2d05ca1019c96bb92d767524d7ffe9 Mon Sep 17 00:00:00 2001
From: Zephyruso <176294927+Zephyruso@users.noreply.github.com>
Date: Tue, 17 Dec 2024 11:43:45 +0800
Subject: [PATCH] fix: render block by cdn
---
index.html | 6 ++++++
src/store/logs.ts | 33 ++++++++++++++++++++++-----------
2 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/index.html b/index.html
index 6904f491..c4786057 100644
--- a/index.html
+++ b/index.html
@@ -32,14 +32,20 @@
/>
diff --git a/src/store/logs.ts b/src/store/logs.ts
index 82cc8bbb..d1f23f9f 100644
--- a/src/store/logs.ts
+++ b/src/store/logs.ts
@@ -19,6 +19,27 @@ const sliceLogs = throttle(() => {
logsTemp = []
}, 500)
+const ipSourceMatchs: [RegExp, string][] = []
+const restructMatchs = () => {
+ ipSourceMatchs.length = 0
+ for (const ip in sourceIPLabelMap.value) {
+ if (ip.startsWith('/')) continue
+ const regex = new RegExp(ip + ':', 'ig')
+
+ ipSourceMatchs.push([regex, `${ip} (${sourceIPLabelMap.value[ip]}) :`])
+ }
+}
+
+watch(
+ sourceIPLabelMap,
+ () => {
+ restructMatchs()
+ },
+ {
+ immediate: true,
+ },
+)
+
export const initLogs = () => {
cancel?.()
logs.value = []
@@ -28,14 +49,6 @@ export const initLogs = () => {
const ws = fetchLogsAPI({
level: logLevel.value,
})
- const ipSourceMatchs: [RegExp, string][] = []
-
- for (const ip in sourceIPLabelMap.value) {
- if (ip.startsWith('/')) continue
- const regex = new RegExp(ip + ':', 'ig')
-
- ipSourceMatchs.push([regex, `${ip} (${sourceIPLabelMap.value[ip]}) :`])
- }
const unwatch = watch(ws.data, (data) => {
if (!data) return
@@ -46,9 +59,7 @@ export const initLogs = () => {
}
for (const [regex, label] of ipSourceMatchs) {
- if (regex.test(data.payload)) {
- data.payload = data.payload.replace(regex, label)
- }
+ data.payload = data.payload.replace(regex, label)
}
logsTemp.unshift({