This commit is contained in:
Peter Dave Hello 2025-04-21 01:21:46 +00:00 committed by GitHub
commit 71d4abefd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -159,10 +159,10 @@ export const usePromptStore = createPersistStore(
fetch(PROMPT_URL)
.then((res) => res.json())
.then((res) => {
let fetchPrompts = [res.en, res.tw, res.cn];
if (getLang() === "cn") {
fetchPrompts = fetchPrompts.reverse();
}
const lang = getLang();
const fetchPrompts = [res[lang], res.en, res.tw, res.cn].filter(
Boolean,
);
const builtinPrompts = fetchPrompts.map((promptList: PromptList) => {
return promptList.map(
([title, content]) =>
@ -180,8 +180,9 @@ export const usePromptStore = createPersistStore(
const allPromptsForSearch = builtinPrompts
.reduce((pre, cur) => pre.concat(cur), [])
.filter((v) => !!v.title && !!v.content);
SearchService.count.builtin =
res.en.length + res.cn.length + res.tw.length;
SearchService.count.builtin = Object.values(res)
.filter(Array.isArray)
.reduce((total, promptList) => total + promptList.length, 0);
SearchService.init(allPromptsForSearch, userPrompts);
});
},