perf(theme/search): prevent repeated rendering of same page (#2398)

pull/2429/head
烽宁 2 years ago committed by GitHub
parent 86a3c24d2a
commit e7be720ede
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -155,6 +155,9 @@ debouncedWatch(
if (canceled) return
const c = new Map<string, Map<string, string>>()
for (const { id, mod } of mods) {
const mapId = id.slice(0, id.indexOf('#'))
let map = c.get(mapId)
if (map) continue
const comp = mod.default ?? mod
if (comp?.render) {
const app = createApp(comp)
@ -178,8 +181,6 @@ debouncedWatch(
const sections = div.innerHTML.split(headingRegex)
app.unmount()
sections.shift()
const mapId = id.slice(0, id.indexOf('#'))
let map = c.get(mapId)
if (!map) {
map = new Map()
c.set(mapId, map)

Loading…
Cancel
Save