From 3056c24712c629365b91f82a0d412de94028cdbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=80=E4=B9=8B?= Date: Mon, 26 Feb 2024 16:36:15 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E6=90=9C=E7=B4=A2=20#262?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.cjs | 1 + src/manifest.json | 2 +- src/pages/options/routes/ScriptList.tsx | 21 ++++++++++++++++----- src/runtime/background/runtime.ts | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index fbe278a2..f3a2c0c5 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -24,6 +24,7 @@ module.exports = { }, plugins: ["react", "@typescript-eslint", "prettier"], rules: { + "no-restricted-syntax": "off", "react/jsx-filename-extension": [1, { extensions: [".tsx"] }], "no-unused-expressions": ["error", { allowShortCircuit: true }], "react/jsx-props-no-spreading": "off", diff --git a/src/manifest.json b/src/manifest.json index a55f0085..96d8403f 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "ScriptCat", - "version": "0.16.0.1010", + "version": "0.16.1", "author": "CodFrm", "description": "脚本猫,一个用户脚本管理器,支持后台脚本、定时脚本、页面脚本,可编写脚本每天帮你自动处理事务.", "options_ui": { diff --git a/src/pages/options/routes/ScriptList.tsx b/src/pages/options/routes/ScriptList.tsx index 43dd3fae..fe71c852 100644 --- a/src/pages/options/routes/ScriptList.tsx +++ b/src/pages/options/routes/ScriptList.tsx @@ -202,11 +202,22 @@ function ScriptList() { ); }, - onFilter: (value, row) => - value - ? row.name.indexOf(value) !== -1 || - i18nName(row).indexOf(value) !== -1 - : true, + onFilter: (value: string, row) => { + if (!value) { + return true; + } + value = value.toLocaleLowerCase(); + row.name = row.name.toLocaleLowerCase(); + const i18n = i18nName(row).toLocaleLowerCase(); + // 空格分开关键字搜索 + const keys = value.split(" "); + for (const key of keys) { + if (row.name.includes(key) || i18n.includes(key)) { + return true; + } + } + return false; + }, onFilterDropdownVisibleChange: (visible) => { if (visible) { setTimeout(() => inputRef.current!.focus(), 150); diff --git a/src/runtime/background/runtime.ts b/src/runtime/background/runtime.ts index ba5c3e16..90fafe61 100644 --- a/src/runtime/background/runtime.ts +++ b/src/runtime/background/runtime.ts @@ -419,7 +419,7 @@ export default class Runtime extends Manager { addRunScript(sender.tabId!, script, false); return script.status !== SCRIPT_STATUS_ENABLE; } - ); + ).sort((a, b) => a.sort - b.sort); if (!filter.length) { resolve({ scripts: [] });