-
Notifications
You must be signed in to change notification settings - Fork 335
ScriptSearchField 卡顿修正 #1014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ScriptSearchField 卡顿修正 #1014
Changes from 1 commit
cc7dba8
f081184
ea425b3
0f0501f
f10caeb
34da2bb
301568c
d114cee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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<string>(""); | ||
| return ( | ||
| <Input.Search | ||
| size="small" | ||
| searchButton | ||
| style={{ maxWidth: 400 }} | ||
| placeholder={t("enter_search_value", { search: `${t("name")}/${t("script_code")}` })!} | ||
| defaultValue={searchValue} | ||
| onChange={(value) => { | ||
| setSearchValue(value); | ||
| }} | ||
|
||
| onSearch={(value) => { | ||
| setSearchKeyword(value); | ||
| }} | ||
| /> | ||
| ); | ||
| }, | ||
| (prevProps, nextProps) => { | ||
| return prevProps.t === nextProps.t; | ||
|
cyfung1031 marked this conversation as resolved.
Outdated
|
||
| } | ||
| ); | ||
| ScriptSearchField.displayName = "ScriptSearchField"; | ||
|
|
||
| interface ScriptCardProps { | ||
| loadingList: boolean; | ||
| scriptList: ScriptLoading[]; | ||
|
|
@@ -361,7 +392,6 @@ export const ScriptCard = ({ | |
| handleConfig, | ||
| handleRunStop, | ||
| }: ScriptCardProps) => { | ||
| const [searchValue, setSearchValue] = useState<string>(""); | ||
| const { t } = useTranslation(); | ||
| const { guideMode } = useAppContext(); | ||
|
|
||
|
|
@@ -417,19 +447,7 @@ export const ScriptCard = ({ | |
| > | ||
| <div className="flex flex-row justify-between items-center" style={{ padding: "8px 0" }}> | ||
| <div className="flex-1"> | ||
| <Input.Search | ||
| size="small" | ||
| searchButton | ||
| style={{ maxWidth: 400 }} | ||
| placeholder={t("enter_search_value", { search: `${t("name")}/${t("script_code")}` })!} | ||
| value={searchValue} | ||
| onChange={(value) => { | ||
| setSearchValue(value); | ||
| }} | ||
| onSearch={(value) => { | ||
| setSearchKeyword(value); | ||
| }} | ||
| /> | ||
| <ScriptSearchField t={t} setSearchKeyword={setSearchKeyword} /> | ||
| </div> | ||
| <Space size={8}> | ||
| <Tooltip content={sidebarOpen ? t("close_sidebar") : t("open_sidebar")}> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不应该是value么?