From cc7dba832704e9f650505a9d8285c1d8f2718907 Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Sat, 22 Nov 2025 22:12:20 +0900 Subject: [PATCH 1/8] =?UTF-8?q?ScriptSearchField=20=E5=8D=A1=E9=A1=BF?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../options/routes/ScriptList/ScriptCard.tsx | 46 +++++++++++++------ 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/src/pages/options/routes/ScriptList/ScriptCard.tsx b/src/pages/options/routes/ScriptList/ScriptCard.tsx index f68d3e909..f5969d1b4 100644 --- a/src/pages/options/routes/ScriptList/ScriptCard.tsx +++ b/src/pages/options/routes/ScriptList/ScriptCard.tsx @@ -32,6 +32,7 @@ import { parseTags } from "@App/app/repo/metadata"; import type { ScriptLoading } from "@App/pages/store/features/script"; import { EnableSwitch, HomeCell, MemoizedAvatar, SourceCell, UpdateTimeCell } from "./components"; import { useTranslation } from "react-i18next"; +import { type TFunction } from "i18next"; import { VscLayoutSidebarLeft, VscLayoutSidebarLeftOff } from "react-icons/vsc"; import { FaThList } from "react-icons/fa"; import type { DragEndEvent } from "@dnd-kit/core"; @@ -327,6 +328,36 @@ export const ScriptCardItem = React.memo( ); ScriptCardItem.displayName = "ScriptCard"; +interface ScriptSearchFieldProps { + t: TFunction<"translation", undefined>; + setSearchKeyword: (keyword: string) => void; +} + +export const ScriptSearchField = React.memo( + ({ t, setSearchKeyword }: ScriptSearchFieldProps) => { + const [searchValue, setSearchValue] = useState(""); + return ( + { + setSearchValue(value); + }} + onSearch={(value) => { + setSearchKeyword(value); + }} + /> + ); + }, + (prevProps, nextProps) => { + return prevProps.t === nextProps.t; + } +); +ScriptSearchField.displayName = "ScriptSearchField"; + interface ScriptCardProps { loadingList: boolean; scriptList: ScriptLoading[]; @@ -361,7 +392,6 @@ export const ScriptCard = ({ handleConfig, handleRunStop, }: ScriptCardProps) => { - const [searchValue, setSearchValue] = useState(""); const { t } = useTranslation(); const { guideMode } = useAppContext(); @@ -417,19 +447,7 @@ export const ScriptCard = ({ >
- { - setSearchValue(value); - }} - onSearch={(value) => { - setSearchKeyword(value); - }} - /> +
From f081184735ff66390c889545ba75d7989a3a244e Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Sun, 23 Nov 2025 08:24:08 +0900 Subject: [PATCH 2/8] Update src/pages/options/routes/ScriptList/ScriptCard.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/pages/options/routes/ScriptList/ScriptCard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/options/routes/ScriptList/ScriptCard.tsx b/src/pages/options/routes/ScriptList/ScriptCard.tsx index f5969d1b4..c6c46864f 100644 --- a/src/pages/options/routes/ScriptList/ScriptCard.tsx +++ b/src/pages/options/routes/ScriptList/ScriptCard.tsx @@ -353,7 +353,7 @@ export const ScriptSearchField = React.memo( ); }, (prevProps, nextProps) => { - return prevProps.t === nextProps.t; + return prevProps.t === nextProps.t && prevProps.setSearchKeyword === nextProps.setSearchKeyword; } ); ScriptSearchField.displayName = "ScriptSearchField"; From ea425b3b8a88347bc51b7effb83a420af028ea7b Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Sun, 23 Nov 2025 08:27:19 +0900 Subject: [PATCH 3/8] =?UTF-8?q?=E5=85=88=E8=B7=9FCopliot=E6=8C=87=E7=A4=BA?= =?UTF-8?q?=E6=94=B9=E4=B8=80=E4=B8=8B=E3=80=82=E4=BD=86=E6=9C=80=E7=BB=88?= =?UTF-8?q?=E8=BF=98=E6=98=AF=E8=A6=81=E8=BF=98=E5=8E=9F=E8=87=B3=201.1.2?= =?UTF-8?q?=20=E6=89=80=E4=BB=A5=E8=BF=99=E5=9D=97=E8=A6=81=E9=87=8D?= =?UTF-8?q?=E6=96=B0=E6=90=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/options/routes/ScriptList/ScriptCard.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/pages/options/routes/ScriptList/ScriptCard.tsx b/src/pages/options/routes/ScriptList/ScriptCard.tsx index c6c46864f..85d498c58 100644 --- a/src/pages/options/routes/ScriptList/ScriptCard.tsx +++ b/src/pages/options/routes/ScriptList/ScriptCard.tsx @@ -335,17 +335,12 @@ interface ScriptSearchFieldProps { export const ScriptSearchField = React.memo( ({ t, setSearchKeyword }: ScriptSearchFieldProps) => { - const [searchValue, setSearchValue] = useState(""); return ( { - setSearchValue(value); - }} onSearch={(value) => { setSearchKeyword(value); }} From 0f0501f2ac34e68a2b5b49a59f6a22eb381f66d3 Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Sun, 23 Nov 2025 08:28:37 +0900 Subject: [PATCH 4/8] lint --- src/pages/options/routes/ScriptList/ScriptCard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/options/routes/ScriptList/ScriptCard.tsx b/src/pages/options/routes/ScriptList/ScriptCard.tsx index 85d498c58..23abd5825 100644 --- a/src/pages/options/routes/ScriptList/ScriptCard.tsx +++ b/src/pages/options/routes/ScriptList/ScriptCard.tsx @@ -1,4 +1,4 @@ -import React, { useMemo, useState } from "react"; +import React, { useMemo } from "react"; import { Avatar, Button, From f10caebbb53577a031cb354e053dfc490b436ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=80=E4=B9=8B?= Date: Mon, 24 Nov 2025 10:58:08 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/service/service_worker/client.ts | 4 +- src/app/service/service_worker/script.ts | 3 +- .../options/routes/ScriptList/ScriptCard.tsx | 57 +++------ .../options/routes/ScriptList/ScriptTable.tsx | 112 +++++------------- .../options/routes/ScriptList/components.tsx | 55 ++++++++- src/pages/options/routes/ScriptList/hooks.tsx | 20 ++-- src/pages/options/routes/ScriptList/index.tsx | 9 +- src/pages/store/features/script.ts | 4 +- 8 files changed, 125 insertions(+), 139 deletions(-) diff --git a/src/app/service/service_worker/client.ts b/src/app/service/service_worker/client.ts index 94f2642d2..3e3fd3575 100644 --- a/src/app/service/service_worker/client.ts +++ b/src/app/service/service_worker/client.ts @@ -2,7 +2,7 @@ import type { Script, ScriptCode, ScriptRunResource, TClientPageLoadInfo } from import { type Resource } from "@App/app/repo/resource"; import { type Subscribe } from "@App/app/repo/subscribe"; import { type Permission } from "@App/app/repo/permission"; -import type { InstallSource, ScriptMenu, ScriptMenuItem, SearchType, TBatchUpdateListAction } from "./types"; +import type { InstallSource, ScriptMenu, ScriptMenuItem, TBatchUpdateListAction } from "./types"; import { Client } from "@Packages/message/client"; import type { MessageSend } from "@Packages/message/types"; import type PermissionVerify from "./permission_verify"; @@ -66,7 +66,7 @@ export class ScriptClient extends Client { return this.doThrow("fetchInfo", uuid); } - getFilterResult(req: { type: SearchType; value: string }): Promise { + getFilterResult(req: { value: string }): Promise { return this.do("getFilterResult", req); } diff --git a/src/app/service/service_worker/script.ts b/src/app/service/service_worker/script.ts index 52dfac5ea..b8ed0ecad 100644 --- a/src/app/service/service_worker/script.ts +++ b/src/app/service/service_worker/script.ts @@ -45,7 +45,6 @@ import { BatchUpdateListActionCode, type TBatchUpdateListAction, UpdateStatusCode, - type SearchType, type TBatchUpdateRecord, } from "./types"; import { getSimilarityScore, ScriptUpdateCheck } from "./script_update_check"; @@ -552,7 +551,7 @@ export class ScriptService { return true; } - async getFilterResult(req: { type: SearchType; value: string }) { + async getFilterResult(req: { value: string }) { const OPTION_CASE_INSENSITIVE = true; const scripts = await this.scriptDAO.all(); const scriptCodes = await Promise.all( diff --git a/src/pages/options/routes/ScriptList/ScriptCard.tsx b/src/pages/options/routes/ScriptList/ScriptCard.tsx index 23abd5825..ddeec35ed 100644 --- a/src/pages/options/routes/ScriptList/ScriptCard.tsx +++ b/src/pages/options/routes/ScriptList/ScriptCard.tsx @@ -1,16 +1,5 @@ import React, { useMemo } from "react"; -import { - Avatar, - Button, - Card, - Divider, - Input, - Popconfirm, - Space, - Tag, - Tooltip, - Typography, -} from "@arco-design/web-react"; +import { Avatar, Button, Card, Divider, Popconfirm, Space, Tag, Tooltip, Typography } from "@arco-design/web-react"; import { Link, useNavigate } from "react-router-dom"; import { IconClockCircle, IconDragDotVertical } from "@arco-design/web-react/icon"; import { @@ -30,9 +19,8 @@ import { hashColor, ScriptIcons } from "../utils"; import { getCombinedMeta } from "@App/app/service/service_worker/utils"; import { parseTags } from "@App/app/repo/metadata"; import type { ScriptLoading } from "@App/pages/store/features/script"; -import { EnableSwitch, HomeCell, MemoizedAvatar, SourceCell, UpdateTimeCell } from "./components"; +import { EnableSwitch, HomeCell, MemoizedAvatar, ScriptSearchField, SourceCell, UpdateTimeCell } from "./components"; import { useTranslation } from "react-i18next"; -import { type TFunction } from "i18next"; import { VscLayoutSidebarLeft, VscLayoutSidebarLeftOff } from "react-icons/vsc"; import { FaThList } from "react-icons/fa"; import type { DragEndEvent } from "@dnd-kit/core"; @@ -40,6 +28,8 @@ import { DndContext, KeyboardSensor, PointerSensor, useSensor, useSensors } from import { rectSortingStrategy, SortableContext, sortableKeyboardCoordinates, useSortable } from "@dnd-kit/sortable"; import { CSS } from "@dnd-kit/utilities"; import { useAppContext } from "@App/pages/store/AppContext"; +import type { SetSearchRequest } from "./hooks"; +import type { SearchType } from "@App/app/service/service_worker/types"; const { Text } = Typography; @@ -328,31 +318,6 @@ export const ScriptCardItem = React.memo( ); ScriptCardItem.displayName = "ScriptCard"; -interface ScriptSearchFieldProps { - t: TFunction<"translation", undefined>; - setSearchKeyword: (keyword: string) => void; -} - -export const ScriptSearchField = React.memo( - ({ t, setSearchKeyword }: ScriptSearchFieldProps) => { - return ( - { - setSearchKeyword(value); - }} - /> - ); - }, - (prevProps, nextProps) => { - return prevProps.t === nextProps.t && prevProps.setSearchKeyword === nextProps.setSearchKeyword; - } -); -ScriptSearchField.displayName = "ScriptSearchField"; - interface ScriptCardProps { loadingList: boolean; scriptList: ScriptLoading[]; @@ -363,7 +328,8 @@ interface ScriptCardProps { updateScripts: (uuids: string[], data: Partial