Skip to content

Commit 397c5eb

Browse files
committed
update claude
1 parent 23ef2f2 commit 397c5eb

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

CLAUDE.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,20 @@ packages/script-engine/src/
5050
├── components/ ← 所有 UI 子组件(每个组件一个文件)
5151
│ ├── index.ts ← barrel 导出
5252
│ ├── theme-colors.ts ← 共享配色 themes + ThemeColors + ensureScrollbarStyle
53-
│ ├── toolbar.tsx ← 工具栏(标题 + 主题切换 + 编译验证)
53+
│ ├── toolbar.tsx ← 工具栏(标题 + 脚本说明 + 主题切换 + 编译验证 + 全屏
5454
│ ├── toolbar-button.tsx ← 工具栏按钮(通用)
5555
│ ├── format-icon.tsx ← 格式化按钮图标
5656
│ ├── fullscreen-icon.tsx ← 全屏按钮图标
5757
│ ├── expand-sidebar-button.tsx ← 展开侧边栏按钮
5858
│ ├── drag-handle.tsx ← 属性面板拖拽手柄
5959
│ ├── panel-header.tsx ← 属性面板头部
60-
│ ├── section-header.tsx ← 通用区块标题(复用 3 处)
61-
│ ├── variable-row.tsx ← 变量行(binds/requests 复用
60+
│ ├── section-header.tsx ← 通用区块标题(支持 extra 插槽,复用 3 处)
61+
│ ├── variable-row.tsx ← 变量行(函数入参/绑定参数复用
6262
│ ├── field-row.tsx ← 字段行
6363
│ ├── function-row.tsx ← 方法行
6464
│ ├── type-section.tsx ← 类型展开区块
65-
│ ├── main-function-section.tsx ← 主函数展示区
66-
│ ├── variables-section.tsx ← 变量列表区
65+
│ ├── main-function-section.tsx ← 主函数展示区(签名展示)
66+
│ ├── variables-section.tsx ← 函数入参 + 绑定参数列表区(分两个 SectionHeader 展示)
6767
│ └── data-types-section.tsx ← 数据类型列表区
6868
├── autocomplete/ ← 自动补全逻辑
6969
│ ├── index.ts
@@ -80,7 +80,7 @@ packages/script-engine/src/
8080
└── index.ts ← 库入口
8181
```
8282

83-
**组件拆分原则**:每个子组件一个文件,导出组件和 Props 接口。`theme-colors.ts` 存放共享配色和全局样式注入函数。
83+
**组件拆分原则**:每个子组件一个文件,导出组件和 Props 接口。`theme-colors.ts` 存放共享配色和全局样式注入函数。`SectionHeader` 支持 `extra?: ReactNode` 插槽用于在标题右侧放置操作按钮。
8484

8585
## 关键架构
8686

@@ -131,6 +131,7 @@ packages/script-engine/src/
131131
- 展示 metadata 中**所有**类型(包括 Integer/String 等基础类型)
132132
- 滚动容器必须设置 `minHeight: 0`(flex 布局关键修复)
133133
- 所有列表按 name 字母序排序(`localeCompare`
134+
- **变量区域拆分为两个独立 SectionHeader**:"函数入参"(`sortedRequests`)和"绑定参数"(`sortedBinds`),各自为空时不显示
134135

135136
### ScriptMetadata Schema (`src/types/index.ts`)
136137

@@ -139,9 +140,9 @@ packages/script-engine/src/
139140
```ts
140141
ScriptMetadata {
141142
mainMethod?: string // 主函数名(如 "run",可选)
142-
description?: string // 主函数描述信息(可选)
143+
description?: string // 脚本说明(可选,显示在工具栏"脚本说明"按钮弹框中
143144
binds: ScriptBindInfo[] // 注入变量,如 $request(name 含 $ 前缀)
144-
requests: ScriptRequestInfo[] // 主函数参数,如 request
145+
requests: ScriptRequestInfo[] // 主函数参数(函数入参),如 request
145146
returnType?: string // 主函数返回类型
146147
types: Record<string, ScriptTypeInfo> // 所有可用类型(含基础类型)
147148
}
@@ -156,6 +157,16 @@ ScriptParameterInfo { dataType, name, description? }
156157

157158
`metadata` 是动态的(不同脚本有不同 schema),但结构固定。`metadata` 必须是**解析后的对象**(不能是 JSON 字符串),否则面板无数据。
158159

160+
### 工具栏脚本说明 (`src/components/toolbar.tsx`)
161+
162+
当 `metadata.description` 存在时,工具栏显示"脚本说明"按钮(带问号图标):
163+
164+
- 点击切换弹框显示/隐藏(非 hover 触发,便于复制内容)
165+
- 弹框使用 `fixed` 定位 + `calcTooltipPos()` 智能翻转(与属性面板 tooltip 共享定位逻辑)
166+
- 描述内容按 `\n` 分行渲染,自动识别 `key: value` 格式并高亮 key(使用 `colors.accent`
167+
- `description` 消失时自动关闭弹框并重置位置
168+
- 兼容字面 `\n` 和真实换行符(通过 `.replace(/\\n/g, '\n')` 处理)
169+
159170
## 类型导出
160171
161172
`src/index.ts` 必须同时导出组件和类型:

0 commit comments

Comments
 (0)