Commit f0c5caf
committed
refactor(ui): 重构变量管理系统和编辑器代码结构
**架构重构**
- 从集中式变量管理迁移到分层架构(临时/全局/预定义)
- 废弃 ContextEditorState.variables,保持向后兼容
- 移除组件间不必要的 services prop 传递
- 添加 VariableManager 工厂函数和异步初始化机制
- 完善国际化支持,统一术语("上下文变量" → "临时变量")
**补全逻辑优化**
- 移除预定义变量的自动补全功能,简化补全列表
- 调整补全优先级:临时变量 (boost: 3) > 全局变量 (boost: 2) > 预定义变量 (boost: 1)
- 修改 global-variables 传递为仅自定义变量
- 新增 createVariableCompletionOption 函数,统一处理补全逻辑
- 智能检测光标后已有的右括号数量,动态计算需要插入的右括号数量
**UI 和代码结构优化**
- 新增 useContextEditorUIState composable 统一管理编辑器 UI 状态
- 消除 extension/web App.vue 中约 40 行重复代码
- 使用配置驱动方式简化标签页可见性逻辑
- 移除 watch(props.visible) 中的冗余 else 分支
- 合并重复的 CSS 规则
- 将卡片标题从"变量值设置"更改为"临时变量",更准确地反映功能定位
- 移除重复的"管理变量"按钮,避免与上方"全局变量"按钮功能重复
**代码清理和测试增强**
- 清理未使用的 handleOpenVariableManager 函数
- 消除重复的补全选项构建逻辑,提高代码可维护性
- 新增右括号补齐测试用例,增强现有测试使用实际编辑器视图模拟
- 更新所有相关测试用例,所有测试通过
- 提升整体代码可维护性和简洁性
影响范围:core, ui, web, extension1 parent d47f162 commit f0c5caf
File tree
28 files changed
+1306
-515
lines changed- packages
- core/src/types
- extension/src
- ui
- src
- components
- context-mode
- image-mode
- variable-extraction
- variable
- composables
- context
- prompt
- variable
- i18n/locales
- services
- types
- tests
- e2e
- integration
- unit
- components
- variable-extraction
- web/src
28 files changed
+1306
-515
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
145 | 148 | | |
146 | 149 | | |
147 | 150 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
165 | 164 | | |
166 | 165 | | |
167 | 166 | | |
| |||
202 | 201 | | |
203 | 202 | | |
204 | 203 | | |
205 | | - | |
| 204 | + | |
206 | 205 | | |
207 | 206 | | |
208 | 207 | | |
209 | 208 | | |
210 | 209 | | |
211 | 210 | | |
212 | 211 | | |
213 | | - | |
214 | 212 | | |
215 | 213 | | |
216 | 214 | | |
| |||
258 | 256 | | |
259 | 257 | | |
260 | 258 | | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | 259 | | |
266 | 260 | | |
267 | 261 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | 117 | | |
124 | 118 | | |
125 | 119 | | |
| |||
635 | 629 | | |
636 | 630 | | |
637 | 631 | | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | | - | |
642 | | - | |
643 | | - | |
644 | 632 | | |
645 | 633 | | |
646 | 634 | | |
| |||
0 commit comments