-
Notifications
You must be signed in to change notification settings - Fork 317
v1.3 修正 ScriptCard 动画问题 #1234
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
v1.3 修正 ScriptCard 动画问题 #1234
Changes from all commits
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 |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ | |
| import type { ScriptLoading } from "@App/pages/store/features/script"; | ||
|
|
||
| import { type TSelectFilter, useScriptDataManagement, useScriptFilters } from "./hooks"; | ||
| import { useAppContext } from "@App/pages/store/AppContext"; | ||
|
|
||
| type TableProps = React.ComponentProps<typeof ScriptTable>; | ||
| type CardProps = React.ComponentProps<typeof ScriptCard>; | ||
|
|
@@ -51,12 +52,28 @@ | |
|
|
||
| MainContent.displayName = "MainContent"; | ||
|
|
||
| // 一条演示数据 | ||
| const guideModeScriptList = [ | ||
| { | ||
| 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, | ||
| ]; | ||
|
Comment on lines
+55
to
+68
|
||
|
|
||
| /** | ||
| * 主组件 | ||
| */ | ||
| function ScriptList() { | ||
| const { t } = useTranslation(); | ||
| const [usp] = useSearchParams(); | ||
| const { guideMode } = useAppContext(); | ||
|
|
||
| // 1. 基础 UI 状态 | ||
| const [sidebarOpen, setSidebarOpen] = useState(() => localStorage.getItem("script-list-sidebar") === "1"); | ||
|
|
@@ -190,7 +207,11 @@ | |
| // 6. 执行过滤逻辑 | ||
| useEffect(() => { | ||
| const { status, type, tags, source } = selectedFilters; | ||
| const list = scriptList.filter((s) => { | ||
|
|
||
| // 如果是引导模式,且没有脚本,则使用演示数据 | ||
| const targetList = guideMode && scriptList.length === 0 ? guideModeScriptList : scriptList; | ||
|
|
||
| const list = targetList.filter((s) => { | ||
|
Comment on lines
+211
to
+214
|
||
| if (status !== null) { | ||
| if (status === SCRIPT_STATUS_ENABLE || status === SCRIPT_STATUS_DISABLE) { | ||
| if (s.status !== status) return false; | ||
|
|
@@ -221,7 +242,7 @@ | |
| return () => { | ||
| enableKeywordSearch = false; | ||
| }; | ||
| }, [scriptList, selectedFilters, stats, searchRequest]); | ||
| }, [guideMode, scriptList, selectedFilters, stats, searchRequest]); | ||
|
|
||
| // 处理 URL 传参打开配置 | ||
| useEffect(() => { | ||
|
|
@@ -235,7 +256,7 @@ | |
| } | ||
| }); | ||
| } | ||
| }, []); | ||
|
|
||
| return ( | ||
| <Card id="script-list" className="script-list" style={{ height: "100%", overflowY: "auto" }}> | ||
|
|
||
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.
这里的演示脚本通过
as ScriptLoading强行断言,但缺少Script必填字段(至少status、runStatus)。在表格视图里有a.status - b.status这类排序逻辑,status为undefined会产生NaN,导致排序/筛选行为异常。建议补齐必填字段并避免类型断言(例如给 demo 设置status: SCRIPT_STATUS_DISABLE、runStatus: SCRIPT_RUN_STATUS_COMPLETE等)。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.
@CodFrm 改成 satisfies 就报错了
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.
缺少字段,这里只是满足基本展示的示例,用as没关系