refactor(editor): 提取行为树编辑器为独立包并重构编辑器架构 (#216)

* refactor(editor): 提取行为树编辑器为独立包并重构编辑器架构

* feat(editor): 添加插件市场功能

* feat(editor): 重构插件市场以支持版本管理和ZIP打包

* feat(editor): 重构插件发布流程并修复React渲染警告

* fix(plugin): 修复插件发布和市场的路径不一致问题

* feat: 重构插件发布流程并添加插件删除功能

* fix(editor): 完善插件删除功能并修复多个关键问题

* fix(auth): 修复自动登录与手动登录的竞态条件问题

* feat(editor): 重构插件管理流程

* feat(editor): 支持 ZIP 文件直接发布插件

- 新增 PluginSourceParser 解析插件源
- 重构发布流程支持文件夹和 ZIP 两种方式
- 优化发布向导 UI

* feat(editor): 插件市场支持多版本安装

- 插件解压到项目 plugins 目录
- 新增 Tauri 后端安装/卸载命令
- 支持选择任意版本安装
- 修复打包逻辑,保留完整 dist 目录结构

* feat(editor): 个人中心支持多版本管理

- 合并同一插件的不同版本
- 添加版本历史展开/折叠功能
- 禁止有待审核 PR 时更新插件

* fix(editor): 修复 InspectorRegistry 服务注册

- InspectorRegistry 实现 IService 接口
- 注册到 Core.services 供插件使用

* feat(behavior-tree-editor): 完善插件注册和文件操作

- 添加文件创建模板和操作处理器
- 实现右键菜单创建行为树功能
- 修复文件读取权限问题(使用 Tauri 命令)
- 添加 BehaviorTreeEditorPanel 组件
- 修复 rollup 配置支持动态导入

* feat(plugin): 完善插件构建和发布流程

* fix(behavior-tree-editor): 完整恢复编辑器并修复 Toast 集成

* fix(behavior-tree-editor): 修复节点选中、连线跟随和文件加载问题并优化性能

* fix(behavior-tree-editor): 修复端口连接失败问题并优化连线样式

* refactor(behavior-tree-editor): 移除调试面板功能简化代码结构

* refactor(behavior-tree-editor): 清理冗余代码合并重复逻辑

* feat(behavior-tree-editor): 完善编辑器核心功能增强扩展性

* fix(lint): 修复ESLint错误确保CI通过

* refactor(behavior-tree-editor): 优化编辑器工具栏和编译器功能

* refactor(behavior-tree-editor): 清理技术债务,优化代码质量

* fix(editor-app): 修复字符串替换安全问题
This commit is contained in:
YHH
2025-11-18 14:46:51 +08:00
committed by GitHub
parent eac660b1a0
commit bce3a6e253
251 changed files with 26144 additions and 8844 deletions

View File

@@ -0,0 +1,107 @@
/**
* 节点类型值对象
* 封装节点类型的业务逻辑
*/
export class NodeType {
private readonly _value: string;
private constructor(value: string) {
this._value = value;
}
get value(): string {
return this._value;
}
/**
* 是否为根节点
*/
isRoot(): boolean {
return this._value === 'root';
}
/**
* 是否为组合节点(可以有多个子节点)
*/
isComposite(): boolean {
return this._value === 'composite' ||
['sequence', 'selector', 'parallel'].includes(this._value);
}
/**
* 是否为装饰节点(只能有一个子节点)
*/
isDecorator(): boolean {
return this._value === 'decorator' ||
['repeater', 'inverter', 'succeeder', 'failer', 'until-fail', 'until-success'].includes(this._value);
}
/**
* 是否为叶子节点(不能有子节点)
*/
isLeaf(): boolean {
return this._value === 'action' || this._value === 'condition' ||
this._value.includes('action-') || this._value.includes('condition-');
}
/**
* 获取允许的最大子节点数
* @returns 0 表示叶子节点1 表示装饰节点Infinity 表示组合节点
*/
getMaxChildren(): number {
if (this.isLeaf()) {
return 0;
}
if (this.isRoot() || this.isDecorator()) {
return 1;
}
if (this.isComposite()) {
return Infinity;
}
return 0;
}
/**
* 值对象相等性比较
*/
equals(other: NodeType): boolean {
return this._value === other._value;
}
toString(): string {
return this._value;
}
/**
* 预定义的节点类型
*/
static readonly ROOT = new NodeType('root');
static readonly SEQUENCE = new NodeType('sequence');
static readonly SELECTOR = new NodeType('selector');
static readonly PARALLEL = new NodeType('parallel');
static readonly REPEATER = new NodeType('repeater');
static readonly INVERTER = new NodeType('inverter');
static readonly SUCCEEDER = new NodeType('succeeder');
static readonly FAILER = new NodeType('failer');
static readonly UNTIL_FAIL = new NodeType('until-fail');
static readonly UNTIL_SUCCESS = new NodeType('until-success');
/**
* 从字符串创建节点类型
*/
static fromString(value: string): NodeType {
switch (value) {
case 'root': return NodeType.ROOT;
case 'sequence': return NodeType.SEQUENCE;
case 'selector': return NodeType.SELECTOR;
case 'parallel': return NodeType.PARALLEL;
case 'repeater': return NodeType.REPEATER;
case 'inverter': return NodeType.INVERTER;
case 'succeeder': return NodeType.SUCCEEDER;
case 'failer': return NodeType.FAILER;
case 'until-fail': return NodeType.UNTIL_FAIL;
case 'until-success': return NodeType.UNTIL_SUCCESS;
default: return new NodeType(value);
}
}
}

View File

@@ -0,0 +1,72 @@
/**
* 位置值对象
* 表示二维空间中的坐标点
*/
export class Position {
private readonly _x: number;
private readonly _y: number;
constructor(x: number, y: number) {
this._x = x;
this._y = y;
}
get x(): number {
return this._x;
}
get y(): number {
return this._y;
}
/**
* 创建新的位置,加上偏移量
*/
add(offset: Position): Position {
return new Position(this._x + offset._x, this._y + offset._y);
}
/**
* 创建新的位置,减去偏移量
*/
subtract(other: Position): Position {
return new Position(this._x - other._x, this._y - other._y);
}
/**
* 计算到另一个位置的距离
*/
distanceTo(other: Position): number {
const dx = this._x - other._x;
const dy = this._y - other._y;
return Math.sqrt(dx * dx + dy * dy);
}
/**
* 值对象相等性比较
*/
equals(other: Position): boolean {
return this._x === other._x && this._y === other._y;
}
/**
* 转换为普通对象
*/
toObject(): { x: number; y: number } {
return { x: this._x, y: this._y };
}
/**
* 从普通对象创建
*/
static fromObject(obj: { x: number; y: number }): Position {
return new Position(obj.x, obj.y);
}
/**
* 创建零位置
*/
static zero(): Position {
return new Position(0, 0);
}
}

View File

@@ -0,0 +1,59 @@
/**
* 尺寸值对象
* 表示宽度和高度
*/
export class Size {
private readonly _width: number;
private readonly _height: number;
constructor(width: number, height: number) {
if (width < 0 || height < 0) {
throw new Error('Size dimensions must be non-negative');
}
this._width = width;
this._height = height;
}
get width(): number {
return this._width;
}
get height(): number {
return this._height;
}
/**
* 获取面积
*/
get area(): number {
return this._width * this._height;
}
/**
* 缩放尺寸
*/
scale(factor: number): Size {
return new Size(this._width * factor, this._height * factor);
}
/**
* 值对象相等性比较
*/
equals(other: Size): boolean {
return this._width === other._width && this._height === other._height;
}
/**
* 转换为普通对象
*/
toObject(): { width: number; height: number } {
return { width: this._width, height: this._height };
}
/**
* 从普通对象创建
*/
static fromObject(obj: { width: number; height: number }): Size {
return new Size(obj.width, obj.height);
}
}

View File

@@ -0,0 +1,3 @@
export { Position } from './Position';
export { Size } from './Size';
export { NodeType } from './NodeType';