Skip to content

Conversation

@cyfung1031
Copy link
Collaborator

@cyfung1031 cyfung1031 commented Feb 12, 2026

@CodFrm

Drag Drop 修改统一在 FilterList 搞
不要在 FilterList 之后又包一层 memo

虽然 memo 不像 useEffect, 应该是即时生效的

@cyfung1031 cyfung1031 marked this pull request as ready for review February 12, 2026 08:13
@CodFrm CodFrm requested a review from Copilot February 12, 2026 09:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 旨在修复 v1.3 中 ScriptCard(卡片视图)相关的动画/拖拽表现问题,并将“引导模式下无脚本时的演示数据”逻辑从 ScriptCard 下沉到 ScriptList 统一处理,从而让卡片/表格视图共享同一份过滤后的列表数据。

Changes:

  • ScriptList/index.tsx 中引入 guideMode,并在过滤阶段对空列表注入演示脚本数据。
  • 移除 ScriptCard.tsx 内部对引导模式演示数据的 useMemo 包装,改为直接使用父组件传入的 scriptList
  • 调整过滤 effect 依赖项,确保 guideMode 切换会触发过滤结果更新。

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/pages/options/routes/ScriptList/index.tsx 增加 guideMode 演示数据,并在过滤逻辑中选择真实列表/演示列表作为过滤目标
src/pages/options/routes/ScriptList/ScriptCard.tsx 移除 guideMode 演示数据逻辑,统一使用父组件传入的列表,减少额外 memo 包装

Comment on lines +55 to +67
// 一条演示数据
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,
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的演示脚本通过 as ScriptLoading 强行断言,但缺少 Script 必填字段(至少 statusrunStatus)。在表格视图里有 a.status - b.status 这类排序逻辑,statusundefined 会产生 NaN,导致排序/筛选行为异常。建议补齐必填字段并避免类型断言(例如给 demo 设置 status: SCRIPT_STATUS_DISABLErunStatus: SCRIPT_RUN_STATUS_COMPLETE 等)。

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2026-02-12 at 18 22 03

@CodFrm 改成 satisfies 就报错了

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

缺少字段,这里只是满足基本展示的示例,用as没关系

Comment on lines +55 to +68
// 一条演示数据
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,
];
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guideModeScriptList 定义在模块顶层且对象会在拖拽排序时被就地修改(例如后面会写入 s.sort = i)。这会让演示数据在组件卸载/重新进入引导模式后保留上一次的排序等状态,属于隐式的跨渲染共享状态。建议改为在组件内按需创建(例如用工厂函数/useMemo 返回新的数组与对象拷贝),避免被后续逻辑意外污染。

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看你要怎么的示例吧
现在的应该没这么多功能...

Comment on lines +211 to +214
// 如果是引导模式,且没有脚本,则使用演示数据
const targetList = guideMode && scriptList.length === 0 ? guideModeScriptList : scriptList;

const list = targetList.filter((s) => {
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里把演示数据注入到 filterScriptList 后,卡片/表格里的启用、删除、拖拽排序等操作仍会按 uuid 调用后端接口;但 demo 的 uuid 并不在真实脚本列表中,容易造成无效请求/错误提示。建议为 demo 增加明确标记(例如 isDemo)并在相关操作入口处禁用或短路处理,避免引导模式下对不存在的脚本执行写操作。

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

還好吧 ..?

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@cyfung1031
Copy link
Collaborator Author

cyfung1031 commented Feb 12, 2026

@CodFrm ScriptCard好像不加 transition 比较好... ?

Screenshot 2026-02-12 at 18 20 56

你自行试一下哪个较好吧

@CodFrm
Copy link
Member

CodFrm commented Feb 12, 2026

@CodFrm ScriptCard好像不加 transition 比较好... ?

Screenshot 2026-02-12 at 18 20 56 你自行试一下哪个较好吧

明显还是有动画会流畅些呀

@cyfung1031
Copy link
Collaborator Author

@CodFrm ScriptCard好像不加 transition 比较好... ?
Screenshot 2026-02-12 at 18 20 56
你自行试一下哪个较好吧

明显还是有动画会流畅些呀

没 transition 是直接换位。有 transition 是换位时有些特效
(我浏览器试出来是偏向奇怪.. 不过我没所谓)

那我不改这个 transition 了。就这样

@CodFrm CodFrm merged commit e63ce5a into scriptscat:release/v1.3 Feb 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants