From dcb12453b4915dfd6e6fdaaf0cfd8ae9b67572d8 Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Thu, 21 Dec 2023 12:33:01 +0800 Subject: [PATCH] Improve viewer performance by using v-show --- code/viewer_partial.html | 28 ++++++++++++++++++---------- main.py | 1 + 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/code/viewer_partial.html b/code/viewer_partial.html index db6fa3f2..b22596a5 100644 --- a/code/viewer_partial.html +++ b/code/viewer_partial.html @@ -39,7 +39,7 @@

-
+
{{ intrinsic.name }}
@@ -87,31 +87,39 @@ r.searchParams.set('q', search.value); window.history.pushState({ path: r.href }, '', r.href); - let result = []; + let length = 0; if (search.value === "") { for (let val of allIntrinsics) { if (!groups.value.includes(val.group)) { - continue; + val.display = false; } else if (!extensions.value.includes(val.extension)) { - continue; + val.display = false; + } else { + val.display = true; + length = length + 1; } - result.push(val); } } else { - let candidates = fuse.search(search.value) + for (let val of allIntrinsics) { + val.display = false; + } + + let candidates = fuse.search(search.value); for (let val of candidates) { if (!groups.value.includes(val.item.group)) { continue; } else if (!extensions.value.includes(val.item.extension)) { continue; } - result.push(val.item); + allIntrinsics[val.refIndex].display = true; + length = length + 1; } } - - nextTick(hljs.highlightAll); - return result; + return { + inner: allIntrinsics, + length: length, + }; }); return { diff --git a/main.py b/main.py index 390780c4..30a19df4 100644 --- a/main.py +++ b/main.py @@ -1847,6 +1847,7 @@ def all_intrinsics(render=True): ), "group": title, "extension": extension, + "display": True } ) else: