(refractor) timer and warm up query

This commit is contained in:
polv committed 2026-03-03 12:44:54 +07:00
1 parent 1b2ee0f691
commit d6f2b145c3
13 files changed
+294 -47

No files matched your search

+19 -5
View File
@@ -45,6 +45,19 @@ function SearchPage() {
const lang = "ja-JP";
const isInit = useRef(false);
useEffect(() => {
if (isInit.current) return;
isInit.current = true;
invoke("search_yomitan", {
qTerm: "",
qReading: "",
limit: 1,
offset: 0,
});
});
useEffect(() => {
trySearch();
}, [q]);
@@ -72,6 +85,12 @@ function SearchPage() {
}
async function runSearch(isNew = true) {
let norm_q = q.trim();
if (isAutoKana) {
norm_q = norm_q.replace(/n$/i, "ん").replace(/[a-z]$/i, "");
}
if (!norm_q) return;
const ender = /\p{Z}$/u.test(q) ? "" : "*";
const re = /\<(.+?)\>\[(.+?)\]/g;
@@ -79,11 +98,6 @@ function SearchPage() {
let qTerm = "";
let qReading = "";
let norm_q = q.trim();
if (isAutoKana) {
norm_q = norm_q.replace(/n$/i, "ん").replace(/[a-z]$/i, "");
}
norm_q.split(re).map((s, i) => {
switch (i % 3) {
case 1: