Skip to content

✨ 编辑器标签栏「+」支持选择新建脚本类型#1544

Merged
CodFrm merged 1 commit into
scriptscat:mainfrom
cyfung1031:fix/create-script-from-editor
Jul 6, 2026
Merged

✨ 编辑器标签栏「+」支持选择新建脚本类型#1544
CodFrm merged 1 commit into
scriptscat:mainfrom
cyfung1031:fix/create-script-from-editor

Conversation

@cyfung1031

@cyfung1031 cyfung1031 commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Checklist / 检查清单

  • Fixes mentioned issues / 修复已提及的问题
  • Code reviewed by human / 代码通过人工检查
  • Changes tested / 已完成测试

Description / 描述

close #1540

问题:新 UI 中脚本编辑器标签栏的「+」只能按页面默认模板新建脚本,无法像旧 UI 那样选择脚本类型(普通 / 后台 / 定时)。

方案:按 issue 的提案,指向「+」时弹出与脚本列表「新建脚本」一致的类型选择菜单(复用 useHoverMenu + shadcn DropdownMenu 的既有模式),点击菜单项以对应模板(`` / background / `crontab`)新建标签;直接点击「+」保持原行为,沿用 URL 默认模板快速新建,不影响现有工作流。

改动

  • EditorTabs.tsx:「+」按钮外包一层 hover 触发的 DropdownMenu,onNew 增加可选 template 参数;菜单文案复用现有 script: 命名空间 i18n key,无新增翻译。
  • ScriptEditor/index.tsxonNewTab 接受可选 template,未传时沿用 URL 的 template 参数(原行为)。
  • EditorTabs.test.tsx:新增 5 个单元测试(TDD,先写失败测试再实现)。

测试

  • vitest 全量 287 文件 / 3010 用例通过;pnpm run lint(prettier + tsc + eslint)通过。
  • 已按 docs/VERIFICATION.md 用 Playwright 驱动真实构建的扩展验证:hover「+」弹出三个类型项(Create User Script / Create Background Script / Create Scheduled Script),点击「Create Background Script」后新标签载入含 // @background 的后台脚本模板。

Screenshots / 截图

(CLI 无法上传附件,验证截图见上述 Playwright 验证描述;如需可补充。)

🤖 Generated with Claude Code

指向「+」时弹出与「新建脚本」一致的类型选择菜单(普通/后台/定时),
直接点击仍沿用默认模板快速新建。

close scriptscat#1540

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@CodFrm CodFrm merged commit d7b3687 into scriptscat:main Jul 6, 2026
6 of 7 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.

[Proposal] Editor「+」加回脚本类型

2 participants