mirror of
https://github.com/patarapolw/cjdic2.git
synced 2026-11-09 17:39:35 +00:00
(refractor) timer and warm up query
This commit is contained in:
1 parent
1b2ee0f691
commit
d6f2b145c3
13 files changed
+294
-47
No files matched your search
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user