Skip to content

Commit

Permalink
fix: render block by cdn
Browse files Browse the repository at this point in the history
  • Loading branch information
Zephyruso committed Dec 17, 2024
1 parent 8694a3a commit a00a071
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,20 @@
/>
<link
rel="stylesheet"
media="print"
onload="this.media='all'"
href="https://unpkg.com/subsetted-fonts@latest/MiSans-VF/MiSans-VF.css"
/>
<link
rel="stylesheet"
media="print"
onload="this.media='all'"
href="https://unpkg.com/subsetted-fonts@latest/SarasaUiSC-Regular/SarasaUiSC-Regular.css"
/>
<link
rel="stylesheet"
media="print"
onload="this.media='all'"
href="https://unpkg.com/subsetted-fonts@latest/PingFangSC-Regular\PingFangSC-Regular.css"
/>
</head>
Expand Down
33 changes: 22 additions & 11 deletions src/store/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -28,14 +49,6 @@ export const initLogs = () => {
const ws = fetchLogsAPI<Log>({
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
Expand All @@ -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({
Expand Down

0 comments on commit a00a071

Please sign in to comment.