From 8edbaaf35d84246a5c1232b37c825665a3af152d Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Thu, 12 Feb 2026 17:12:57 +0900 Subject: [PATCH 1/2] =?UTF-8?q?v1.3=20=E4=BF=AE=E6=AD=A3=20ScriptCard=20?= =?UTF-8?q?=E5=8A=A8=E7=94=BB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../options/routes/ScriptList/ScriptCard.tsx | 30 +++---------------- src/pages/options/routes/ScriptList/index.tsx | 25 ++++++++++++++-- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/pages/options/routes/ScriptList/ScriptCard.tsx b/src/pages/options/routes/ScriptList/ScriptCard.tsx index df1f02a3f..38c538d2e 100644 --- a/src/pages/options/routes/ScriptList/ScriptCard.tsx +++ b/src/pages/options/routes/ScriptList/ScriptCard.tsx @@ -27,7 +27,6 @@ import type { DragEndEvent } from "@dnd-kit/core"; import { closestCenter, DndContext, KeyboardSensor, PointerSensor, useSensor, useSensors } from "@dnd-kit/core"; import { rectSwappingStrategy, SortableContext, sortableKeyboardCoordinates, useSortable } from "@dnd-kit/sortable"; import { CSS } from "@dnd-kit/utilities"; -import { useAppContext } from "@App/pages/store/AppContext"; import { type SearchFilterRequest } from "./SearchFilter"; import type { SearchType } from "@App/app/service/service_worker/types"; @@ -410,28 +409,7 @@ const ScriptCard = ({ handleRunStop, }: ScriptCardProps) => { const { t } = useTranslation(); - const { guideMode } = useAppContext(); - - // 如果是引导模式,且没有脚本,则创建一条演示数据 - const list = useMemo( - () => - guideMode && scriptList.length === 0 - ? [ - { - uuid: "demo-uuid-1234", - name: "Demo Script", - namespace: "demo", - sort: 0, - createtime: Date.now(), - checktime: Date.now(), - metadata: {}, - type: SCRIPT_TYPE_NORMAL, - favorite: [{ match: "Example", icon: "", website: "https://example.com" }], - } as ScriptLoading, - ] - : scriptList, - [guideMode, scriptList] - ); + // Sensors — move them here (or even higher in parent) so they're stable const sensors = useSensors( useSensor(PointerSensor, { @@ -443,7 +421,7 @@ const ScriptCard = ({ ); // 故意生成一个字串 避免因 list 的参考频繁改动而导致 ctx 的 sortableIds 参考出现非预期更改。 - const sortableIdsString = list?.map((s) => s.uuid).join(",") || ""; + const sortableIdsString = scriptList?.map((s) => s.uuid).join(",") || ""; // sortableIds 应该只包含 ID 字符串数组,而不是对象数组, // 且确保 items 属性接收的是纯 ID 列表,这样 dnd-kit 内部对比更高效。 @@ -529,7 +507,7 @@ const ScriptCard = ({ padding: "16px", }} > - {list.length === 0 ? ( + {scriptList.length === 0 ? ( loadingList ? (