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