Skip to content

Commit 08778ed

Browse files
committed
⚡️ 优化名称搜索 #262
1 parent bf68abb commit 08778ed

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module.exports = {
2424
},
2525
plugins: ["react", "@typescript-eslint", "prettier"],
2626
rules: {
27+
"no-restricted-syntax": "off",
2728
"react/jsx-filename-extension": [1, { extensions: [".tsx"] }],
2829
"no-unused-expressions": ["error", { allowShortCircuit: true }],
2930
"react/jsx-props-no-spreading": "off",

src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 2,
33
"name": "ScriptCat",
4-
"version": "0.16.0.1010",
4+
"version": "0.16.1",
55
"author": "CodFrm",
66
"description": "脚本猫,一个用户脚本管理器,支持后台脚本、定时脚本、页面脚本,可编写脚本每天帮你自动处理事务.",
77
"options_ui": {

src/pages/options/routes/ScriptList.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,22 @@ function ScriptList() {
202202
</div>
203203
);
204204
},
205-
onFilter: (value, row) =>
206-
value
207-
? row.name.indexOf(value) !== -1 ||
208-
i18nName(row).indexOf(value) !== -1
209-
: true,
205+
onFilter: (value: string, row) => {
206+
if (!value) {
207+
return true;
208+
}
209+
value = value.toLocaleLowerCase();
210+
row.name = row.name.toLocaleLowerCase();
211+
const i18n = i18nName(row).toLocaleLowerCase();
212+
// 空格分开关键字搜索
213+
const keys = value.split(" ");
214+
for (const key of keys) {
215+
if (row.name.includes(key) || i18n.includes(key)) {
216+
return true;
217+
}
218+
}
219+
return false;
220+
},
210221
onFilterDropdownVisibleChange: (visible) => {
211222
if (visible) {
212223
setTimeout(() => inputRef.current!.focus(), 150);

0 commit comments

Comments
 (0)