Compare commits

...

34 Commits

Author SHA1 Message Date
k88936 4df4708ba1 Merge remote-tracking branch 'origin/master' into feat/ui-editor-v3
Project CI / AI game creator shell Rust shard 1/4 (pull_request) Failing after 3m0s
Project CI / AI game creator shell Rust shard 2/4 (pull_request) Failing after 3m4s
Project CI / AI game creator shell Rust shard 3/4 (pull_request) Failing after 3m7s
Project CI / AI game creator shell Rust shard 4/4 (pull_request) Failing after 3m9s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 1m41s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 2m32s
Project CI / Frontend tests (pull_request) Failing after 4m47s
Project CI / Repository checks (pull_request) Failing after 4m39s
Project CI / Native shell tests (pull_request) Successful in 7m14s
Project CI / Backend tests (pull_request) Successful in 8m12s
Project CI / AI game creator shell web tests (pull_request) Failing after 2m54s
# Conflicts:
#	docs/project-memory/shared-memory/pitfalls.md
2026-09-16 14:57:26 +08:00
kdletters b3e9d0a906 发布 AGC 标准版 0.1.45
Project CI / AI game creator shell Rust shard 1/4 (push) Successful in 5m11s
Project CI / AI game creator shell Rust shard 2/4 (push) Successful in 5m39s
Project CI / AI game creator shell Rust smoke (push) Successful in 1m54s
Project CI / AI game creator shell Rust shard 3/4 (push) Successful in 4m35s
Project CI / AI game creator shell Rust shard 4/4 (push) Successful in 4m26s
Project CI / AI game creator shell Rust crates (push) Successful in 3m17s
Project CI / Frontend tests (push) Successful in 4m41s
Project CI / Repository checks (push) Successful in 3m53s
Project CI / Native shell tests (push) Successful in 6m43s
Project CI / Backend tests (push) Successful in 7m26s
Project CI / AI game creator shell web tests (push) Successful in 3m23s
- apps/ai-game-creator-shell/package.json 版本提升到 0.1.45
- apps/ai-game-creator-shell/src-tauri/tauri.conf.json 版本提升到 0.1.45
- apps/ai-game-creator-shell/src-tauri/Cargo.toml 版本提升到 0.1.45
- apps/ai-game-creator-shell/src-tauri/Cargo.lock 同步 genarrative-ai-game-creator-shell 版本
- package-lock.json 同步 apps/ai-game-creator-shell 工作区版本
2026-09-16 11:52:03 +08:00
kdletters a60328623d 调整开发调度管线备份策略
Project CI / AI game creator shell Rust shard 1/4 (push) Successful in 5m30s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m12s
Project CI / AI game creator shell Rust shard 2/4 (push) Successful in 5m36s
Project CI / AI game creator shell Rust shard 3/4 (push) Successful in 5m2s
Project CI / AI game creator shell Rust shard 4/4 (push) Successful in 4m52s
Project CI / AI game creator shell Rust crates (push) Successful in 2m7s
Project CI / Frontend tests (push) Successful in 4m45s
Project CI / Repository checks (push) Successful in 4m42s
Project CI / Backend tests (push) Successful in 6m58s
Project CI / Native shell tests (push) Successful in 8m22s
Project CI / AI game creator shell web tests (push) Successful in 4m5s
恢复 Full Job 备份参数原样透传
开发调度统一传入 skip,默认不上传 OSS
保持 Full 与 AGC 使用同一固定 revision 参数
2026-09-16 11:43:22 +08:00
kdletters 9e63b76991 修正开发环境备份默认映射
Project CI / AI game creator shell Rust shard 1/4 (push) Successful in 5m7s
Project CI / AI game creator shell Rust shard 3/4 (push) Successful in 4m56s
Project CI / AI game creator shell Rust shard 2/4 (push) Successful in 5m37s
Project CI / AI game creator shell Rust shard 4/4 (push) Successful in 4m45s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m18s
Project CI / AI game creator shell Rust crates (push) Successful in 2m48s
Project CI / Repository checks (push) Failing after 1m54s
Project CI / Frontend tests (push) Successful in 5m15s
Project CI / Backend tests (push) Failing after 7m46s
Project CI / AI game creator shell web tests (push) Failing after 4m21s
Project CI / Native shell tests (push) Successful in 8m53s
保留备份参数原有枚举顺序以通过运维门禁
开发目标未显式选择时将 async 映射为 skip
开发环境默认不上传 OSS,release 仍保留显式策略
2026-09-16 11:40:22 +08:00
kdletters a98ebcf68f 调整开发环境默认备份策略
Project CI / AI game creator shell Rust shard 1/4 (push) Successful in 5m30s
Project CI / AI game creator shell Rust shard 3/4 (push) Successful in 5m35s
Project CI / AI game creator shell Rust shard 2/4 (push) Successful in 5m55s
Project CI / AI game creator shell Rust shard 4/4 (push) Successful in 6m0s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m4s
Project CI / AI game creator shell Rust crates (push) Successful in 2m33s
Project CI / Repository checks (push) Failing after 1m16s
Project CI / Frontend tests (push) Successful in 4m59s
Project CI / AI game creator shell web tests (push) Successful in 3m28s
Project CI / Native shell tests (push) Successful in 7m12s
Project CI / Backend tests (push) Successful in 8m33s
开发环境默认跳过 OSS 备份上传
需要冷备时显式选择 async
保持 release 发布的备份策略可配置
2026-09-16 11:37:56 +08:00
kdletters 576ff07a5e 新增定时版本调度管线并收回两条下游管线的定时与去重
Project CI / AI game creator shell Rust shard 3/4 (push) Successful in 5m9s
Project CI / AI game creator shell Rust shard 1/4 (push) Failing after 5m11s
Project CI / AI game creator shell Rust shard 2/4 (push) Successful in 5m34s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m1s
Project CI / AI game creator shell Rust crates (push) Successful in 2m36s
Project CI / AI game creator shell Rust shard 4/4 (push) Successful in 4m20s
Project CI / Frontend tests (push) Successful in 4m23s
Project CI / Repository checks (push) Successful in 4m13s
Project CI / Native shell tests (push) Successful in 6m44s
Project CI / Backend tests (push) Successful in 8m22s
Project CI / AI game creator shell web tests (push) Successful in 3m28s
- 新增 Genarrative-Scheduled-Revision-Trigger:每小时用 git ls-remote 解析分支版本,与上一次触发过的 revision 不同才继续
- 触发时把同一个固定 COMMIT_HASH 同时传给 Full Build 与 AGC Windows Build,保证两条管线构建同一个版本
- Full Build 与 AGC Windows Build 去掉自带定时触发器与管线内版本去重
- 新增 scheduled-revision-trigger Job 配置 XML,使用本机 Git 入口与既有 SSH 凭据,定时器留在 Jenkinsfile
- 生产运维门禁改为校验调度管线约束,并拦住两条下游管线重新加 cron 或自行去重
- 同步开发运维文档、共享开发工作流与踩坑记录
2026-09-16 10:55:16 +08:00
kdletters 5aa616134c 修复 Hook 链继承仓库定位变量导致真实仓库被夹具污染
Project CI / AI game creator shell Rust shard 1/4 (push) Successful in 5m30s
Project CI / AI game creator shell Rust shard 3/4 (push) Successful in 5m47s
Project CI / AI game creator shell Rust shard 4/4 (push) Successful in 5m53s
Project CI / AI game creator shell Rust shard 2/4 (push) Successful in 6m8s
Project CI / AI game creator shell Rust smoke (push) Successful in 1m48s
Project CI / AI game creator shell Rust crates (push) Successful in 2m46s
Project CI / Frontend tests (push) Failing after 4m6s
Project CI / Repository checks (push) Successful in 3m57s
Project CI / Native shell tests (push) Successful in 7m40s
Project CI / Backend tests (push) Successful in 8m27s
Project CI / AI game creator shell web tests (push) Successful in 12m53s
- .husky/pre-commit 与 .husky/pre-push 入口清除 GIT_DIR/GIT_WORK_TREE/GIT_INDEX_FILE 等仓库定位变量

- scripts/check-repository-ci.sh 增加同样的清理,保证本地门禁与 CI 走同一套隔离

- scripts/git-hooks.test.mjs 夹具 Git 调用前自检仓库归属并禁用 Hook,命令落到外部仓库时直接失败

- 守卫用例的子进程必须真的继承 GIT_DIR,避免隔离断言空转

- 更新开发运维文档与 shared-memory/pitfalls.md,记录链接工作树注入形态与配置修复步骤
2026-09-16 10:35:07 +08:00
kdletters 187b66c3b1 Jenkins 定时构建增加版本未变化去重
- Full Build 改为每小时触发,并按已解析 commit 与全部构建参数判断是否重复
- AGC Windows Build 增加每小时触发与同一套去重逻辑,跳过时不再安装依赖、构建和上传
- 跳过记录为 NOT_BUILT,越过跳过记录后最近一次实际构建成功才允许跳过,失败或中断可重试
- 生产运维门禁补充两个 Job 的去重约束与各阶段跳过检查
- 同步开发运维文档与共享开发工作流说明
2026-09-16 10:32:03 +08:00
k88936 1e992bcdf8 扩大未知 JavaScript 异常上报原则
Project CI / AI game creator shell Rust smoke (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
Project CI / AI game creator shell Rust shard 1/4 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust shard 2/4 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust shard 3/4 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust shard 4/4 (pull_request) Has been cancelled
明确所有未解决和非契约化 JS 异常必须继续抛出

说明用户 fallback 不得替代全局 error report 链路
2026-09-14 19:47:08 +08:00
k88936 8368aa262c 补充剪贴板异常上报约定
记录 UI fallback 后仍需抛出原始原生错误

明确未知异常必须进入 error report 链路
2026-09-14 19:43:08 +08:00
k88936 e9ddbf16da 重构预览网格步长计算
提取预览网格自适应步长到独立模块

补充缩放网格计算与背景样式测试

同步预览画布缩放交互文档
2026-09-14 19:40:13 +08:00
k88936 22ac1f4c0b 修复 UI 编辑器剪贴板写入权限
为主窗口补充 clipboard-manager 写文本权限

保留手动复制提示并继续抛出原始 Tauri 剪贴板错误
2026-09-14 19:39:34 +08:00
k88936 9910a0eec0 优化 UI 编辑器复制反馈布局
将复制失败提示与操作按钮分离排列
2026-09-14 19:06:15 +08:00
k88936 70981b9ca9 完善 UI 编辑器结果弹窗覆盖
增加普通保存成功与保存后生成失败的场景断言

验证路径弹窗和失败重试按钮的可见行为
2026-09-14 19:01:44 +08:00
k88936 8a0d5600b3 拆分 UI 编辑器路径复制按钮
Project CI / AI game creator shell Rust shard 1/4 (pull_request) Failing after 2m27s
Project CI / AI game creator shell Rust shard 2/4 (pull_request) Failing after 2m23s
Project CI / AI game creator shell Rust shard 3/4 (pull_request) Failing after 2m5s
Project CI / AI game creator shell Rust shard 4/4 (pull_request) Failing after 2m8s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m57s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 2m15s
Project CI / Frontend tests (pull_request) Failing after 3m22s
Project CI / Repository checks (pull_request) Successful in 3m38s
Project CI / Native shell tests (pull_request) Successful in 6m42s
Project CI / AI game creator shell web tests (pull_request) Failing after 3m12s
Project CI / Backend tests (pull_request) Successful in 8m24s
将剪贴板状态与写入逻辑提取为独立小组件

保持保存结果弹窗只负责结果布局与动作编排
2026-09-14 18:59:51 +08:00
k88936 184d88dbb8 修复多树预览受左侧选中图片限制
移除 activeImageId 对预览拖动和缩放手势的门控

按树 wrapper 提供几何上下文并允许任意树操作

保留 activeImageId 仅用于左侧图片与图片级检查
2026-09-14 18:59:51 +08:00
k88936 791794c0a6 记录 UI 编辑器保存结果弹窗约定
补充保存与代码生成结果弹窗及相对路径复制行为

记录复制失败、重试和保存并返回边界
2026-09-14 18:59:51 +08:00
k88936 9cfb47d945 补充 UI 编辑器保存结果测试
覆盖保存和生成成功弹窗与项目相对路径复制

覆盖保存失败、冲突和剪贴板失败反馈
2026-09-14 18:59:51 +08:00
k88936 27859d3e19 接入 UI 编辑器保存结果弹窗
让普通保存和保存并生成流程返回结构化结果

将成功与失败反馈接入独立弹窗并保留保存并返回直返行为
2026-09-14 18:59:51 +08:00
k88936 43f3780a38 新增 UI 编辑器保存结果弹窗
新增保存成功、代码生成成功和失败状态弹窗

提供项目相对路径复制按钮及复制失败提示
2026-09-14 18:59:51 +08:00
k88936 a1f9149c27 UI编辑器移除预览模式残留类型
完成三开关替代 render mode 的类型清理
2026-09-14 18:59:51 +08:00
k88936 f0bba18841 UI编辑器收口多树上下文菜单目标
预览菜单携带所属树 ID

避免非当前图片树的结构操作写错目标
2026-09-14 18:59:51 +08:00
k88936 f679cfa179 UI编辑器完善多树创建与文档契约
统一识别和合并结果的 createTree 流程

按选中节点所属树驱动 Inspector 编辑

补充多树预览与树级偏移权威文档
2026-09-14 18:59:50 +08:00
k88936 f68ffcfecd UI编辑器补充合并树偏移构造
为合并产出的节点补齐 NodeOffset
2026-09-14 18:59:50 +08:00
k88936 ec94a4fe00 UI编辑器重构多树预览与独立开关
预览画布同时渲染全部界面树并支持树级拖动

拆分显示框线、原图和组件开关

预览节点选择与左侧当前图片解耦
2026-09-14 18:59:50 +08:00
k88936 46f8592375 UI编辑器补充树级偏移模型
新增 Node offset min/max 数据结构

统一新树默认横向布局入口

增加树级偏移状态更新操作与实施计划
2026-09-14 18:59:50 +08:00
k88936 cdf2882302 补齐自动切分概览字体属性
向 SeparationOverview 传入 fonts 数据

修复 UI 编辑器 TS2741 类型错误
2026-09-14 18:59:50 +08:00
k88936 d156113e71 修复 UI 编辑器待办循环高亮动画
修复受控树选中回调清除 Inspector 高亮的问题

循环游标同时使用界面树与节点 ID

补充多节点循环和动画重启回归测试
2026-09-14 18:59:50 +08:00
k88936 a8f2ac17be 注释掉 InspectorSidebar 中的 LayoutEditor 组件以暂时禁用布局编辑功能 2026-09-14 18:59:50 +08:00
k88936 43ac9a5761 补充 UI 编辑器交互回归测试
从实际节点事件目标验证删除快捷键

验证 portal 右键菜单启用后会执行操作并关闭
2026-09-14 18:59:50 +08:00
k88936 e992e0b35c 压缩 UI 编辑器概览布局
将识别概览指标改为四列横向排列

将素材切分概览改为四列网格以减少纵向高度
2026-09-14 18:59:50 +08:00
k88936 e389b54a3a 修复 UI 预览画布交互
为无限视口添加跟随平移和缩放的点阵背景

恢复画布快捷缩放与初始适配比例控制

保留节点平移选择并屏蔽浏览器原生拖拽选择
2026-09-14 18:59:50 +08:00
k88936 84c780a6f8 重构 UI 编辑器全屏外壳
通过 portal 将资源编辑器挂载到 body 并覆盖标题栏以下区域

移除外层 FocusTrap,保留内部确认对话框的模态行为

统一左右浮动面板的顶部与底部留白
2026-09-14 18:59:50 +08:00
k88936 03f900fbe5 布局重构:
- 预览改为全区域背景层。
  - 左右面板、顶部流程条改为覆盖层,可遮挡预览。
  - 左右面板开合状态仅保存在当前 React 会话。
  - 增加左右面板“收起/展开”入口。
  - 编辑器关闭入口改为单独的 ×,继续通过 onBack 注入关闭逻辑。
  - 保留全局顶部栏与现有快捷键、业务状态、保存流程。
  - 底层页面仍由现有父级路由控制,不新增 URL 状态。
2026-09-14 18:59:50 +08:00
47 changed files with 1755 additions and 402 deletions
+3
View File
@@ -1 +1,4 @@
# Git 在链接工作树里执行 Hook 时会注入 GIT_DIR 等仓库定位变量,优先级高于 cwd;
# 子进程(npm、lint-staged、测试夹具)会继承它们并写到真实仓库,故在入口统一清除。
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_COMMON_DIR GIT_PREFIX GIT_CONFIG_PARAMETERS GIT_CEILING_DIRECTORIES
npm run format:staged npm run format:staged
+3
View File
@@ -1 +1,4 @@
# Git 在链接工作树里执行 Hook 时会注入 GIT_DIR 等仓库定位变量,优先级高于 cwd;
# 钩子链(npm → check:repository-ci → 测试夹具)会继承它们并写到真实仓库,故在入口统一清除。
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_COMMON_DIR GIT_PREFIX GIT_CONFIG_PARAMETERS GIT_CEILING_DIRECTORIES
npm run check:pre-push-master -- "$@" npm run check:pre-push-master -- "$@"
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "@genarrative/ai-game-creator-shell", "name": "@genarrative/ai-game-creator-shell",
"private": true, "private": true,
"version": "0.1.29", "version": "0.1.45",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "node scripts/start-tauri-dev.mjs", "dev": "node scripts/start-tauri-dev.mjs",
+1 -1
View File
@@ -1725,7 +1725,7 @@ dependencies = [
[[package]] [[package]]
name = "genarrative-ai-game-creator-shell" name = "genarrative-ai-game-creator-shell"
version = "0.1.29" version = "0.1.45"
dependencies = [ dependencies = [
"agent-runtime-core", "agent-runtime-core",
"axum", "axum",
@@ -1,6 +1,6 @@
[package] [package]
name = "genarrative-ai-game-creator-shell" name = "genarrative-ai-game-creator-shell"
version = "0.1.29" version = "0.1.45"
edition = "2021" edition = "2021"
publish = false publish = false
@@ -1,11 +1,12 @@
{ {
"$schema": "../gen/schemas/desktop-schema.json", "$schema": "../gen/schemas/desktop-schema.json",
"identifier": "main", "identifier": "main",
"description": "AI 游戏创作主窗口允许读系统剪贴板图片,用于粘贴素材附件;允许弹出原生打开/保存对话框用于素材上传与导出。", "description": "AI 游戏创作主窗口允许读系统剪贴板,用于粘贴素材附件和复制生成文件路径;允许弹出原生打开/保存对话框用于素材上传与导出。",
"windows": ["client"], "windows": ["client"],
"permissions": [ "permissions": [
"clipboard-manager:allow-read-image", "clipboard-manager:allow-read-image",
"clipboard-manager:allow-read-text", "clipboard-manager:allow-read-text",
"clipboard-manager:allow-write-text",
"core:image:allow-rgba", "core:image:allow-rgba",
"core:image:allow-size", "core:image:allow-size",
"core:resources:allow-close", "core:resources:allow-close",
@@ -172,6 +172,7 @@ mod materialize {
use crate::ui_editor::layout::node::{ use crate::ui_editor::layout::node::{
Node as LayoutNode, NodeMetadata, NodeSource, StageStatus, Node as LayoutNode, NodeMetadata, NodeSource, StageStatus,
}; };
use crate::ui_editor::layout::offset::NodeOffset;
use crate::ui_editor::layout::transform::Transform; use crate::ui_editor::layout::transform::Transform;
use crate::ui_editor::state::{State, UITree}; use crate::ui_editor::state::{State, UITree};
use crate::ui_editor::utils::{random_node_id, NodeId, UIDesignImageId}; use crate::ui_editor::utils::{random_node_id, NodeId, UIDesignImageId};
@@ -302,6 +303,7 @@ mod materialize {
component: None, component: None,
children_display_mode: ChildrenDisplayMode::Exclusive, children_display_mode: ChildrenDisplayMode::Exclusive,
children: members.into_iter().map(|member| member.node).collect(), children: members.into_iter().map(|member| member.node).collect(),
offset: NodeOffset::default(),
}, },
priority, priority,
src_ui_design, src_ui_design,
@@ -9,6 +9,7 @@ use crate::ui_editor::layout::children_display_mode::ChildrenDisplayMode;
use crate::ui_editor::layout::control_layout::ControlLayout; use crate::ui_editor::layout::control_layout::ControlLayout;
use crate::ui_editor::layout::dimension::UIRect; use crate::ui_editor::layout::dimension::UIRect;
use crate::ui_editor::layout::node::{Node as LayoutNode, NodeMetadata, NodeSource, StageStatus}; use crate::ui_editor::layout::node::{Node as LayoutNode, NodeMetadata, NodeSource, StageStatus};
use crate::ui_editor::layout::offset::NodeOffset;
use crate::ui_editor::layout::transform::Transform; use crate::ui_editor::layout::transform::Transform;
use crate::ui_editor::resource::ui_design_image::UIDesignImage; use crate::ui_editor::resource::ui_design_image::UIDesignImage;
use crate::ui_editor::state::{State, UITree}; use crate::ui_editor::state::{State, UITree};
@@ -322,6 +323,7 @@ fn convert_node(
component: source.component.clone().into_option(), component: source.component.clone().into_option(),
children_display_mode: ChildrenDisplayMode::Stack, children_display_mode: ChildrenDisplayMode::Stack,
children, children,
offset: NodeOffset::default(),
}) })
} }
@@ -858,6 +860,7 @@ pub(crate) async fn recognize_ui_impl_with_provider(
component: recognition_root.component.into_option(), component: recognition_root.component.into_option(),
children_display_mode: ChildrenDisplayMode::Stack, children_display_mode: ChildrenDisplayMode::Stack,
children, children,
offset: NodeOffset::default(),
}; };
// Tree identity and root identity are assigned by Rust, never chosen by the model. // Tree identity and root identity are assigned by Rust, never chosen by the model.
ui_trees.push(UITree { ui_trees.push(UITree {
@@ -2,4 +2,5 @@ pub mod children_display_mode;
pub mod control_layout; pub mod control_layout;
pub mod dimension; pub mod dimension;
pub mod node; pub mod node;
pub mod offset;
pub mod transform; pub mod transform;
@@ -1,6 +1,7 @@
use crate::ui_editor::component::Component; use crate::ui_editor::component::Component;
use crate::ui_editor::layout::children_display_mode::ChildrenDisplayMode; use crate::ui_editor::layout::children_display_mode::ChildrenDisplayMode;
use crate::ui_editor::layout::control_layout::ControlLayout; use crate::ui_editor::layout::control_layout::ControlLayout;
use crate::ui_editor::layout::offset::NodeOffset;
use crate::ui_editor::utils::NodeId; use crate::ui_editor::utils::NodeId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use ts_rs::TS; use ts_rs::TS;
@@ -14,6 +15,7 @@ pub struct Node {
pub component: Option<Component>, pub component: Option<Component>,
pub children_display_mode: ChildrenDisplayMode, pub children_display_mode: ChildrenDisplayMode,
pub children: Vec<Node>, pub children: Vec<Node>,
pub offset: NodeOffset,
} }
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, TS)] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize, TS)]
@@ -0,0 +1,18 @@
use serde::{Deserialize, Serialize};
use ts_rs::TS;
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, TS)]
#[ts(export, export_to = concat!(env!("CARGO_MANIFEST_DIR"), "/../src/features/ui-editor/types/"))]
pub struct NodeOffset {
pub min: [f32; 2],
pub max: [f32; 2],
}
impl Default for NodeOffset {
fn default() -> Self {
Self {
min: [0.0, 0.0],
max: [0.0, 0.0],
}
}
}
@@ -1,7 +1,7 @@
{ {
"$schema": "https://schema.tauri.app/config/2", "$schema": "https://schema.tauri.app/config/2",
"productName": "陶泥儿", "productName": "陶泥儿",
"version": "0.1.29", "version": "0.1.45",
"identifier": "world.genarrative.ai-game-creator", "identifier": "world.genarrative.ai-game-creator",
"build": { "build": {
"beforeDevCommand": "npm --prefix ../.. run agc:serve", "beforeDevCommand": "npm --prefix ../.. run agc:serve",
@@ -1,4 +1,5 @@
import type { Node as UiNode } from './types/Node'; import type { Node as UiNode } from './types/Node';
import type { NodeId } from './types/NodeId';
import type { NodeMetadata } from './types/NodeMetadata'; import type { NodeMetadata } from './types/NodeMetadata';
import type { StageStatus } from './types/StageStatus'; import type { StageStatus } from './types/StageStatus';
import type { UIDesignImageId } from './types/UIDesignImageId'; import type { UIDesignImageId } from './types/UIDesignImageId';
@@ -14,6 +15,11 @@ export type UiTreeNodeTarget = {
node: UiNode; node: UiNode;
}; };
export type UiTreeNodeCursor = {
treeId: UIDesignImageId;
nodeId: NodeId;
};
export type StageStatusOverview = { export type StageStatusOverview = {
total: number; total: number;
needsAttention: number; needsAttention: number;
@@ -79,22 +85,28 @@ export function getStageStatusTargets(
export function getNextUiTreeNodeTarget( export function getNextUiTreeNodeTarget(
targets: UiTreeNodeTarget[], targets: UiTreeNodeTarget[],
previousNodeId: string | null, previous: string | UiTreeNodeCursor | null,
): UiTreeNodeTarget | null { ): UiTreeNodeTarget | null {
if (targets.length === 0) return null; if (targets.length === 0) return null;
const previousIndex = targets.findIndex( const previousIndex =
({ node }) => node.id === previousNodeId, typeof previous === 'string'
); ? targets.findIndex(({ node }) => node.id === previous)
: previous
? targets.findIndex(
({ treeId, node }) =>
treeId === previous.treeId && node.id === previous.nodeId,
)
: -1;
return targets[(previousIndex + 1) % targets.length] ?? null; return targets[(previousIndex + 1) % targets.length] ?? null;
} }
export function getNextMatchingUiTreeNodeTarget( export function getNextMatchingUiTreeNodeTarget(
uiTrees: UITree[], uiTrees: UITree[],
previousNodeId: string | null, previous: string | UiTreeNodeCursor | null,
matches: (target: UiTreeNodeTarget) => boolean, matches: (target: UiTreeNodeTarget) => boolean,
): UiTreeNodeTarget | null { ): UiTreeNodeTarget | null {
return getNextUiTreeNodeTarget( return getNextUiTreeNodeTarget(
collectUiTreeNodeTargets(uiTrees).filter(matches), collectUiTreeNodeTargets(uiTrees).filter(matches),
previousNodeId, previous,
); );
} }
@@ -4,5 +4,6 @@ import type { Component } from "./Component";
import type { ControlLayout } from "./ControlLayout"; import type { ControlLayout } from "./ControlLayout";
import type { NodeId } from "./NodeId"; import type { NodeId } from "./NodeId";
import type { NodeMetadata } from "./NodeMetadata"; import type { NodeMetadata } from "./NodeMetadata";
import type { NodeOffset } from "./NodeOffset";
export type Node = { id: NodeId, layout: ControlLayout, metadata: NodeMetadata, component: Component | null, children_display_mode: ChildrenDisplayMode, children: Array<Node>, }; export type Node = { id: NodeId, layout: ControlLayout, metadata: NodeMetadata, component: Component | null, children_display_mode: ChildrenDisplayMode, children: Array<Node>, offset: NodeOffset };
@@ -0,0 +1,4 @@
export type NodeOffset = {
min: [number, number];
max: [number, number];
};
@@ -17,6 +17,7 @@ import type { FontAssetId } from './types/FontAssetId';
import type { Node } from './types/Node'; import type { Node } from './types/Node';
import type { NodeId } from './types/NodeId'; import type { NodeId } from './types/NodeId';
import type { NodeMetadata } from './types/NodeMetadata'; import type { NodeMetadata } from './types/NodeMetadata';
import type { NodeOffset } from './types/NodeOffset';
import type { SpriteAsset } from './types/SpriteAsset'; import type { SpriteAsset } from './types/SpriteAsset';
import type { SpriteAssetId } from './types/SpriteAssetId'; import type { SpriteAssetId } from './types/SpriteAssetId';
import type { SpriteBorder } from './types/SpriteBorder'; import type { SpriteBorder } from './types/SpriteBorder';
@@ -34,6 +35,7 @@ export const EMPTY_UI_EDITOR_STATE: State = {
}; };
const MAX_HISTORY_LENGTH = 100; const MAX_HISTORY_LENGTH = 100;
export const UI_TREE_PADDING = 48;
export type UiEditorOperationFailureReason = export type UiEditorOperationFailureReason =
| 'locked' | 'locked'
@@ -156,6 +158,7 @@ function createPageRoot(state: State): Node {
component: null, component: null,
children_display_mode: 'Stack', children_display_mode: 'Stack',
children: [], children: [],
offset: { min: [0, 0], max: [0, 0] },
}; };
} }
@@ -187,9 +190,53 @@ function createHumanNode(state: State): Node {
component: null, component: null,
children_display_mode: 'Stack', children_display_mode: 'Stack',
children: [], children: [],
offset: { min: [0, 0], max: [0, 0] },
}; };
} }
function treeSize(state: State, treeId: UIDesignImageId): [number, number] {
const image = state.ui_design_images[treeId];
if (
!image ||
!Number.isFinite(image.pixels_per_unit) ||
image.pixels_per_unit <= 0
) {
throw new Error(`界面图 ${treeId} 缺少合法尺寸`);
}
return [
image.pixel_size[0] / image.pixels_per_unit,
image.pixel_size[1] / image.pixels_per_unit,
];
}
function deriveTreeOffset(state: State, treeId: UIDesignImageId): NodeOffset {
const [width, height] = treeSize(state, treeId);
const existing = state.ui_trees.filter(
(tree) => tree.src_ui_design !== treeId,
);
if (existing.length === 0) return { min: [0, 0], max: [width, height] };
const maxX = Math.max(
...existing.map(
(tree) =>
tree.root.offset.min[0] + treeSize(state, tree.src_ui_design)[0],
),
);
const minY = Math.min(...existing.map((tree) => tree.root.offset.min[1]));
return {
min: [maxX + UI_TREE_PADDING, minY],
max: [maxX + UI_TREE_PADDING + width, minY + height],
};
}
export function createTree(
state: State,
treeId: UIDesignImageId,
root = createPageRoot(state),
) {
root.offset = deriveTreeOffset(state, treeId);
return { src_ui_design: treeId, root };
}
function synchronizeDesignImageTrees(state: State): void { function synchronizeDesignImageTrees(state: State): void {
const imageIds = new Set(Object.keys(state.ui_design_images)); const imageIds = new Set(Object.keys(state.ui_design_images));
state.ui_trees = state.ui_trees.filter((tree) => state.ui_trees = state.ui_trees.filter((tree) =>
@@ -197,7 +244,7 @@ function synchronizeDesignImageTrees(state: State): void {
); );
for (const [id] of Object.entries(state.ui_design_images)) { for (const [id] of Object.entries(state.ui_design_images)) {
if (!state.ui_trees.some((tree) => tree.src_ui_design === id)) { if (!state.ui_trees.some((tree) => tree.src_ui_design === id)) {
state.ui_trees.push({ src_ui_design: id, root: createPageRoot(state) }); state.ui_trees.push(createTree(state, id));
} }
} }
} }
@@ -951,6 +998,34 @@ export function useUiEditorState(initialState: State = EMPTY_UI_EDITOR_STATE) {
[commit, guard], [commit, guard],
); );
const setTreeOffset = useCallback(
(
treeId: UIDesignImageId,
min: [number, number],
): UiEditorOperationResult => {
const blocked = guard();
if (blocked) return blocked;
if (!min.every(Number.isFinite)) return { ok: false, reason: 'invalid' };
const current = stateRef.current;
const tree = current.ui_trees.find(
(candidate) => candidate.src_ui_design === treeId,
);
if (!tree) return { ok: false, reason: 'missing' };
const size = treeSize(current, treeId);
const next = cloneState(current);
const nextTree = next.ui_trees.find(
(candidate) => candidate.src_ui_design === treeId,
)!;
nextTree.root.offset = {
min: [...min],
max: [min[0] + size[0], min[1] + size[1]],
};
commit(next);
return { ok: true, value: undefined };
},
[commit, guard],
);
const insertNodeAfter = useCallback( const insertNodeAfter = useCallback(
( (
treeId: UIDesignImageId, treeId: UIDesignImageId,
@@ -1464,6 +1539,7 @@ export function useUiEditorState(initialState: State = EMPTY_UI_EDITOR_STATE) {
setSpriteBorder, setSpriteBorder,
insertNode, insertNode,
insertNodeAfter, insertNodeAfter,
setTreeOffset,
deleteNode, deleteNode,
setNodeTransform, setNodeTransform,
setNodeLayout, setNodeLayout,
@@ -70,6 +70,7 @@ export function InputSidebar({ input }: { input: UiEditorInputProjection }) {
component: null, component: null,
children_display_mode: 'Stack', children_display_mode: 'Stack',
children: uiTrees.map((tree) => tree.root), children: uiTrees.map((tree) => tree.root),
offset: { min: [0, 0], max: [0, 0] },
}; };
}, [uiTrees]); }, [uiTrees]);
@@ -83,8 +84,14 @@ export function InputSidebar({ input }: { input: UiEditorInputProjection }) {
treeIdForNode={(nodeId) => treeIdByNodeId.get(nodeId) ?? null} treeIdForNode={(nodeId) => treeIdByNodeId.get(nodeId) ?? null}
isNodePreviewVisible={input.isNodePreviewVisible} isNodePreviewVisible={input.isNodePreviewVisible}
onSelectNode={(treeId, nodeId) => { onSelectNode={(treeId, nodeId) => {
input.selectDesignImage(treeId); // react-arborist emits `onSelect` when its controlled `selection`
input.selectNode(nodeId); // prop is updated. Overview navigation updates the selection and
// the status highlight in the same render, so treating that
// programmatic notification as a fresh user selection would clear
// the highlight before it can be painted. Only mutate selection
// state when the target actually differs from the current one.
const sameNode = input.selectedNodeId === nodeId;
if (!sameNode) input.selectNode(nodeId);
}} }}
onToggleNodeVisibility={(nodeId) => onToggleNodeVisibility={(nodeId) =>
input.toggleNodePreviewVisibility(nodeId) input.toggleNodePreviewVisibility(nodeId)
@@ -284,7 +284,7 @@ function NodeInspector({
onMetadataChange, onMetadataChange,
highlightedStatusField, highlightedStatusField,
onTransformChange, onTransformChange,
onLayoutChange, // onLayoutChange,
sprites, sprites,
previewUrls, previewUrls,
fonts, fonts,
@@ -483,11 +483,11 @@ function NodeInspector({
readOnly={transformReadOnly || isReadOnly} readOnly={transformReadOnly || isReadOnly}
onChange={onTransformChange} onChange={onTransformChange}
/> />
<LayoutEditor {/*<LayoutEditor*/}
node={node} {/* node={node}*/}
readOnly={isReadOnly} {/* readOnly={isReadOnly}*/}
onChange={onLayoutChange} {/* onChange={onLayoutChange}*/}
/> {/*/>*/}
<ComponentPanel <ComponentPanel
key={node.id} key={node.id}
component={node.component} component={node.component}
@@ -511,6 +511,7 @@ function NodeInspector({
); );
} }
// eslint-disable-next-line unused-imports/no-unused-vars
function LayoutEditor({ function LayoutEditor({
node, node,
readOnly, readOnly,
@@ -826,11 +827,26 @@ function NodeStageSelect({
const attentionTone = kind === 'Blocked' ? 'blocked' : 'review'; const attentionTone = kind === 'Blocked' ? 'blocked' : 'review';
useEffect(() => { useEffect(() => {
if (!highlight) return; const statusRow = statusRowRef.current;
statusRowRef.current?.scrollIntoView({ if (!highlight || !statusRow) return;
statusRow.scrollIntoView({
block: 'nearest', block: 'nearest',
behavior: 'smooth', behavior: 'smooth',
}); });
// 强制制造一次样式边界,避免 A → B → A 时浏览器复用已完成的动画。
statusRow.classList.remove('ui-editor-status-attention');
void statusRow.offsetWidth;
statusRow.classList.add('ui-editor-status-attention');
// 多节点切换会复用 Inspector 树,显式重启动画,确保回到已查看节点时
// 仍能再次播放提示,而不是依赖 class/key 的重协调行为。
if (typeof statusRow.getAnimations === 'function') {
for (const animation of statusRow.getAnimations()) {
animation.cancel();
animation.play();
}
}
}, [highlight]); }, [highlight]);
return ( return (
@@ -44,7 +44,7 @@ export function RecognitionOverview({
Overview Overview
</span> </span>
<h2 className="m-0 text-sm font-semibold"></h2> <h2 className="m-0 text-sm font-semibold"></h2>
<div className="mt-3 grid grid-cols-2 gap-2"> <div className="mt-3 grid grid-cols-4 gap-2">
<OverviewValue label="已识别 Node" value={overview.total} /> <OverviewValue label="已识别 Node" value={overview.total} />
<OverviewAction <OverviewAction
label="待用户检查" label="待用户检查"
@@ -47,7 +47,7 @@ export function SeparationOverview({
Overview Overview
</span> </span>
<h2 className="m-0 text-sm font-semibold"></h2> <h2 className="m-0 text-sm font-semibold"></h2>
<div className="mt-3 grid grid-cols-2 gap-2"> <div className="mt-3 grid grid-cols-4 gap-2">
<OverviewValue <OverviewValue
label="需要切分素材的组件" label="需要切分素材的组件"
value={overview.componentsNeedingAssets} value={overview.componentsNeedingAssets}
@@ -0,0 +1,44 @@
import { writeText } from '@tauri-apps/plugin-clipboard-manager';
import { Copy } from 'lucide-react';
import { useEffect, useState } from 'react';
export function UiEditorCopyPathButton({
relativePath,
}: {
relativePath: string;
}) {
const [copyState, setCopyState] = useState<'idle' | 'copied' | 'failed'>(
'idle',
);
useEffect(() => setCopyState('idle'), [relativePath]);
async function copyPath() {
setCopyState('idle');
try {
await writeText(relativePath);
setCopyState('copied');
} catch (error) {
setCopyState('failed');
throw error;
}
}
return (
<>
{copyState === 'failed' ? (
<p className="mt-2 text-xs text-red-600" role="alert">
</p>
) : null}
<button
type="button"
className="inline-flex items-center gap-1.5 rounded-lg border border-(--platform-subpanel-border) px-3 py-2 text-xs"
onClick={() => void copyPath()}
>
<Copy size={14} aria-hidden="true" />
{copyState === 'copied' ? '已复制' : '复制路径'}
</button>
</>
);
}
@@ -0,0 +1,140 @@
import { ThemedModal } from '../../../components/modal/ThemedModal';
import { UiEditorCopyPathButton } from './UiEditorCopyPathButton';
export type UiEditorSaveResultNotice =
| {
kind: 'saved';
}
| {
kind: 'generated';
relativePath: string;
}
| {
kind: 'failure';
message: string;
retryLabel?: string;
onRetry?: () => void;
};
export function UiEditorSaveResultModal({
notice,
onClose,
}: {
notice: UiEditorSaveResultNotice | null;
onClose: () => void;
}) {
return (
<ThemedModal
open={notice !== null}
onClose={onClose}
ariaLabel={ariaLabelForNotice(notice)}
panelClassName="w-[min(460px,calc(100vw-2rem))] rounded-2xl p-5"
>
{notice?.kind === 'generated' ? (
<GeneratedNotice relativePath={notice.relativePath} onClose={onClose} />
) : notice?.kind === 'saved' ? (
<SimpleNotice title="保存成功" onClose={onClose} />
) : notice?.kind === 'failure' ? (
<FailureNotice notice={notice} onClose={onClose} />
) : null}
</ThemedModal>
);
}
function GeneratedNotice({
relativePath,
onClose,
}: {
relativePath: string;
onClose: () => void;
}) {
return (
<>
<h2 className="m-0 text-base font-semibold"></h2>
<p className="mt-3 text-sm text-(--platform-text-soft)"></p>
<code className="mt-2 block select-text break-all rounded-lg bg-black/5 px-3 py-2 text-xs leading-5">
{relativePath}
</code>
<div className="mt-5">
<UiEditorCopyPathButton relativePath={relativePath} />
<div className="mt-3 flex justify-end">
<button
type="button"
className="rounded-lg bg-orange-600 px-3 py-2 text-xs font-semibold text-white"
onClick={onClose}
>
</button>
</div>
</div>
</>
);
}
function SimpleNotice({
title,
onClose,
}: {
title: string;
onClose: () => void;
}) {
return (
<>
<h2 className="m-0 text-base font-semibold">{title}</h2>
<div className="mt-5 flex justify-end">
<button
type="button"
className="rounded-lg bg-orange-600 px-3 py-2 text-xs font-semibold text-white"
onClick={onClose}
>
</button>
</div>
</>
);
}
function FailureNotice({
notice,
onClose,
}: {
notice: Extract<UiEditorSaveResultNotice, { kind: 'failure' }>;
onClose: () => void;
}) {
return (
<>
<h2 className="m-0 text-base font-semibold"></h2>
<p className="mt-3 whitespace-pre-line text-sm leading-6 text-red-700">
{notice.message}
</p>
<div className="mt-5 flex flex-wrap justify-end gap-2">
<button
type="button"
className="rounded-lg border border-(--platform-subpanel-border) px-3 py-2 text-xs"
onClick={onClose}
>
</button>
{notice.onRetry ? (
<button
type="button"
className="rounded-lg bg-orange-600 px-3 py-2 text-xs font-semibold text-white"
onClick={() => {
onClose();
notice.onRetry?.();
}}
>
{notice.retryLabel ?? '重试'}
</button>
) : null}
</div>
</>
);
}
function ariaLabelForNotice(notice: UiEditorSaveResultNotice | null) {
if (notice?.kind === 'generated') return '代码已生成';
if (notice?.kind === 'saved') return '保存成功';
if (notice?.kind === 'failure') return '操作失败';
return '保存结果';
}
File diff suppressed because it is too large Load Diff
@@ -20,17 +20,17 @@ import { resolveExclusiveVisibleChildId } from './exclusiveVisibility';
export type { ResizeHandle } from '../../../../features/ui-editor/nodeTransformGeometry'; export type { ResizeHandle } from '../../../../features/ui-editor/nodeTransformGeometry';
export type UiEditorRenderMode = 'editor-overlay' | 'final-preview';
type NodePointerDown = ( type NodePointerDown = (
event: ReactPointerEvent<HTMLDivElement>, event: ReactPointerEvent<HTMLDivElement>,
node: UiNode, node: UiNode,
treeId?: string,
) => void; ) => void;
type UiTreeRendererProps = { type UiTreeRendererProps = {
tree: UITree | null; tree: UITree | null;
renderMode: UiEditorRenderMode; treeId?: string;
showFrame: boolean; showFrame: boolean;
showComponent: boolean;
hiddenNodeIds: ReadonlySet<NodeId>; hiddenNodeIds: ReadonlySet<NodeId>;
previewTransforms?: ReadonlyMap<NodeId, UiNode['layout']['transform']>; previewTransforms?: ReadonlyMap<NodeId, UiNode['layout']['transform']>;
selectedNodeId: NodeId | null; selectedNodeId: NodeId | null;
@@ -41,6 +41,7 @@ type UiTreeRendererProps = {
event: ReactMouseEvent<HTMLDivElement>, event: ReactMouseEvent<HTMLDivElement>,
node: UiNode, node: UiNode,
isPageRoot: boolean, isPageRoot: boolean,
treeId?: string,
) => void; ) => void;
onNodePointerDown: NodePointerDown; onNodePointerDown: NodePointerDown;
onNodePointerMove: (event: ReactPointerEvent<HTMLDivElement>) => void; onNodePointerMove: (event: ReactPointerEvent<HTMLDivElement>) => void;
@@ -50,6 +51,7 @@ type UiTreeRendererProps = {
event: ReactPointerEvent<HTMLDivElement>, event: ReactPointerEvent<HTMLDivElement>,
node: UiNode, node: UiNode,
handle: ResizeHandle, handle: ResizeHandle,
treeId?: string,
) => void; ) => void;
onNodeResizePointerMove: (event: ReactPointerEvent<HTMLDivElement>) => void; onNodeResizePointerMove: (event: ReactPointerEvent<HTMLDivElement>) => void;
onNodeResizePointerUp: (event: ReactPointerEvent<HTMLDivElement>) => void; onNodeResizePointerUp: (event: ReactPointerEvent<HTMLDivElement>) => void;
@@ -81,10 +83,11 @@ const EMPTY_PREVIEW_TRANSFORMS: ReadonlyMap<
function RenderNode({ function RenderNode({
node, node,
treeId,
isRoot, isRoot,
parentContainer, parentContainer,
renderMode,
showFrame, showFrame,
showComponent,
hiddenNodeIds, hiddenNodeIds,
previewTransforms, previewTransforms,
selectedNodeId, selectedNodeId,
@@ -124,8 +127,8 @@ function RenderNode({
return null; return null;
} }
const isEditorOverlay = renderMode === 'editor-overlay'; const isSelected = selectedNodeId === node.id;
const isFrameVisible = isEditorOverlay || showFrame; const isFrameVisible = showFrame || isSelected;
const receivesPointerGesture = parentContainer === undefined; const receivesPointerGesture = parentContainer === undefined;
const hasDirectPointerGesture = receivesPointerGesture && !isRoot; const hasDirectPointerGesture = receivesPointerGesture && !isRoot;
const exclusiveVisibleChildId = const exclusiveVisibleChildId =
@@ -170,15 +173,14 @@ function RenderNode({
} }
} }
onContextMenu={(event) => { onContextMenu={(event) => {
if (!isEditorOverlay) return;
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
onSelectNode(node.id); onSelectNode(node.id);
onNodeContextMenu(event, node, Boolean(isRoot)); onNodeContextMenu(event, node, Boolean(isRoot), treeId);
}} }}
onPointerDown={ onPointerDown={
receivesPointerGesture receivesPointerGesture
? (event) => onNodePointerDown(event, node) ? (event) => onNodePointerDown(event, node, treeId)
: undefined : undefined
} }
onPointerMove={receivesPointerGesture ? onNodePointerMove : undefined} onPointerMove={receivesPointerGesture ? onNodePointerMove : undefined}
@@ -191,10 +193,10 @@ function RenderNode({
{node.metadata.name} {node.metadata.name}
</span> </span>
) : null} ) : null}
{node.component ? ( {showComponent && node.component ? (
<ComponentView component={node.component} resources={resources} /> <ComponentView component={node.component} resources={resources} />
) : null} ) : null}
{renderMode === 'final-preview' && selectedNodeId === node.id ? ( {isSelected ? (
<ExclusiveChildrenTabs <ExclusiveChildrenTabs
parent={node} parent={node}
isChildVisible={(nodeId) => nodeId === exclusiveVisibleChildId} isChildVisible={(nodeId) => nodeId === exclusiveVisibleChildId}
@@ -207,13 +209,14 @@ function RenderNode({
<RenderNode <RenderNode
key={child.id} key={child.id}
node={child} node={child}
treeId={treeId}
parentContainer={ parentContainer={
isContainer(node.layout.container) isContainer(node.layout.container)
? node.layout.container ? node.layout.container
: undefined : undefined
} }
renderMode={renderMode}
showFrame={showFrame} showFrame={showFrame}
showComponent={showComponent}
hiddenNodeIds={hiddenNodeIds} hiddenNodeIds={hiddenNodeIds}
previewTransforms={activePreviewTransforms} previewTransforms={activePreviewTransforms}
selectedNodeId={selectedNodeId} selectedNodeId={selectedNodeId}
@@ -254,7 +257,7 @@ function RenderNode({
touchAction: 'none', touchAction: 'none',
}} }}
onPointerDown={(event) => onPointerDown={(event) =>
onNodeResizePointerDown(event, node, handle.id) onNodeResizePointerDown(event, node, handle.id, treeId)
} }
onPointerMove={onNodeResizePointerMove} onPointerMove={onNodeResizePointerMove}
onPointerUp={onNodeResizePointerUp} onPointerUp={onNodeResizePointerUp}
@@ -0,0 +1,26 @@
/** 背景网格的基础世界步长;缩放时按 2 倍档位调整屏幕密度。 */
export const PREVIEW_GRID_BASE_STEP = 28;
const PREVIEW_GRID_MIN_SCREEN_SPACING = 20;
const PREVIEW_GRID_MAX_SCREEN_SPACING = 40;
/**
* 选择一个离散的世界步长,让网格圆点在屏幕上保持可读密度。
* 背景位置仍使用 viewport 的屏幕平移量,因此切档不会破坏世界原点对齐。
*/
export function resolvePreviewGridStep(viewportScale: number): number {
if (!Number.isFinite(viewportScale) || viewportScale <= 0) {
return PREVIEW_GRID_BASE_STEP;
}
let step = PREVIEW_GRID_BASE_STEP;
let screenSpacing = step * viewportScale;
while (screenSpacing < PREVIEW_GRID_MIN_SCREEN_SPACING) {
step *= 2;
screenSpacing *= 2;
}
while (screenSpacing >= PREVIEW_GRID_MAX_SCREEN_SPACING) {
step /= 2;
screenSpacing /= 2;
}
return step;
}

Some files were not shown because too many files have changed in this diff Show More