feat(editor): 完善用户代码热更新和环境检测 (#275)

* fix: 更新 bundle-runtime 脚本使用正确的 platform-web 输出文件

原脚本引用的 runtime.browser.js 不存在,改为使用 index.mjs

* feat(editor): 完善用户代码热更新和环境检测

## 热更新改进
- 添加 hotReloadInstances() 方法,通过更新原型链实现真正的热更新
- 组件实例保留数据,仅更新方法
- ComponentRegistry 支持热更新时替换同名组件类

## 环境检测
- 启动时检测 esbuild 可用性
- 在启动页面底部显示环境状态指示器
- 添加 check_environment Rust 命令和前端 API

## esbuild 打包
- 将 esbuild 二进制文件打包到应用中
- 用户无需全局安装 esbuild
- 支持 Windows/macOS/Linux 平台

## 文件监视优化
- 添加 300ms 防抖,避免重复编译
- 修复路径分隔符混合问题

## 资源打包修复
- 修复 Tauri 资源配置,保留 engine 目录结构
- 添加 src-tauri/bin/ 和 src-tauri/engine/ 到 gitignore

* fix: 将热更新模式改为可选,修复测试失败

- ComponentRegistry 添加 hotReloadEnabled 标志,默认禁用
- 只有启用热更新模式时才会替换同名组件类
- 编辑器环境自动启用热更新模式
- reset() 方法中重置热更新标志

* test: 添加热更新模式的测试用例
This commit is contained in:
YHH
2025-12-05 14:24:09 +08:00
committed by GitHub
parent d7454e3ca4
commit 6702f0bfad
12 changed files with 755 additions and 57 deletions

View File

@@ -526,3 +526,92 @@
background: #b91c1c;
border-color: #b91c1c;
}
/* 环境状态指示器样式 | Environment Status Indicator Styles */
.startup-env-status {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
border-radius: 50%;
cursor: pointer;
transition: all 0.15s;
}
.startup-env-status.ready {
color: #4ade80;
}
.startup-env-status.ready:hover {
background: rgba(74, 222, 128, 0.1);
}
.startup-env-status.warning {
color: #f59e0b;
animation: pulse 2s infinite;
}
.startup-env-status.warning:hover {
background: rgba(245, 158, 11, 0.1);
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.6; }
}
.startup-env-tooltip {
position: absolute;
bottom: 100%;
left: 50%;
transform: translateX(-50%);
margin-bottom: 8px;
padding: 12px 16px;
min-width: 200px;
background: #2d2d30;
border: 1px solid #3e3e42;
border-radius: 6px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
z-index: 1000;
}
.startup-env-tooltip::after {
content: '';
position: absolute;
top: 100%;
left: 50%;
transform: translateX(-50%);
border: 6px solid transparent;
border-top-color: #3e3e42;
}
.env-tooltip-title {
margin-bottom: 10px;
padding-bottom: 8px;
border-bottom: 1px solid #3e3e42;
font-size: 12px;
font-weight: 500;
color: #ffffff;
}
.env-tooltip-item {
display: flex;
align-items: center;
gap: 8px;
font-size: 12px;
}
.env-tooltip-item.ok {
color: #4ade80;
}
.env-tooltip-item.error {
color: #f87171;
}
.env-source {
opacity: 0.6;
font-size: 11px;
}