chore(plugin-search): make the search case-insensitive

This commit is contained in:
pacmandoh 2024-02-05 17:38:20 +08:00 committed by Hk-Gosuto
parent 666c80456a
commit 5893795d59
1 changed files with 8 additions and 4 deletions

View File

@ -163,11 +163,13 @@ export function PluginPage() {
const chatStore = useChatStore();
const currentLang = getLang();
const supportedLangs = ['cn', 'ru'];
const supportedLangs = ["cn", "ru"];
const allPlugins = pluginStore
.getAll()
.filter(
(m) => supportedLangs.includes(currentLang) ? m.lang === currentLang : m.lang === 'en'
.filter((m) =>
supportedLangs.includes(currentLang)
? m.lang === currentLang
: m.lang === "en",
);
const [searchPlugins, setSearchPlugins] = useState<Plugin[]>([]);
@ -178,7 +180,9 @@ export function PluginPage() {
const onSearch = (text: string) => {
setSearchText(text);
if (text.length > 0) {
const result = allPlugins.filter((m) => m.name.includes(text));
const result = allPlugins.filter((m) =>
m.name.toLowerCase().includes(text.toLowerCase()),
);
setSearchPlugins(result);
} else {
setSearchPlugins(allPlugins);