Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/deploy-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Deploy to GitHub Pages

on:
push:
branches: [develop]

jobs:
deploy-gh-pages:
runs-on: ubuntu-latest
concurrency:
group: deploy-gh-pages
cancel-in-progress: true
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
run_install: false

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: pnpm install

- name: add environment variable
run: |
cat <<'EOF' >> designer-demo/env/.env.alpha
// ---- appended by CI (gh-pages) ----
VITE_ORIGIN=https://agent.opentiny.design/
EOF
- name: change material url
run: |
sed -i "s#material: \['/mock/bundle.json'\]#material: \['https://opentiny.github.io/tiny-engine/mock/bundle.json'\]#g" designer-demo/engine.config.js
echo "Updated material url in designer-demo/engine.config.js"
- name: Run Build
run: |
set -eo pipefail
pnpm run build:plugin 2>&1 | tee /tmp/build-plugin.log
pnpm run build:alpha 2>&1 | tee /tmp/build-alpha.log

- name: Deploy
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./designer-demo/dist/
keep_files: true
force_orphan: false
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
4 changes: 3 additions & 1 deletion designer-demo/engine.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ export default {
theme: 'light',
material: ['/mock/bundle.json'],
scripts: [],
styles: []
styles: [],
// 是否开启 TailWindCSS 特性
enableTailwindCSS: true
}
7 changes: 4 additions & 3 deletions designer-demo/public/mock/bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -4433,18 +4433,19 @@
"bindState": true,
"label": {
"text": {
"zh_CN": "资源"
"zh_CN": "资源选择"
}
},
"cols": 12,
"rules": [],
"widget": {
"component": "InputConfigurator",
"component": "SourceSelectConfigurator",
"props": {}
},
"description": {
"zh_CN": "src路径"
}
},
"labelPosition": "top"
},
{
"property": "attributes3",
Expand Down
10 changes: 10 additions & 0 deletions designer-demo/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import { META_SERVICE, META_APP } from '@opentiny/tiny-engine-meta-register'
import engineConfig from './engine.config'
import { HttpService } from './src/composable'

const baseURL = import.meta.env.BASE_URL || '.'
const baseURLWithoutSlash = baseURL.replace(/\/$/, '')

export default {
[META_SERVICE.Http]: HttpService,
'engine.config': {
Expand Down Expand Up @@ -43,5 +46,12 @@ export default {
}
}
}
},
[META_APP.Preview]: {
options: {
// 配置预览跳转的 url:根据实际业务需求进行配置
// 文档:https://opentiny.design/tiny-engine#/help-center/course/dev/preview-api
previewUrl: ['prod', 'alpha'].includes(import.meta.env.MODE) ? `${baseURLWithoutSlash}/preview.html` : ''
}
}
}
5 changes: 2 additions & 3 deletions designer-demo/src/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*
*/
import { defineEntry } from '@opentiny/tiny-engine-meta-register'
import engineConfig from '../engine.config'
import 'virtual:svg-icons-register'

async function startApp() {
Expand All @@ -23,9 +24,7 @@ async function startApp() {
const registry = {
[META_SERVICE.Http]: HttpService,
'engine.config': {
id: 'engine.config',
theme: 'light',
material: ['/mock/bundle.json']
...engineConfig
}
}

Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
- [更新日志](./changelog/changelog.md)
- [v2.7升级指南](./changelog/v2.7-upgrade-guide.md)
- 解决方案
- [前端及Java服务端docker部署](./solutions/front-backend-docker-deployment.md)
- [Java服务端部署](./solutions/server-deployment-solution-java.md)
- [Node.js服务端部署](./solutions/server-deployment-solution.md)
- [区块发布方案(Node.js服务端)](./solutions/block-release-solution.md)
Expand Down
1 change: 1 addition & 0 deletions docs/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"title": "解决方案",
"name": "solutions",
"articles": [
{"title": "前端及Java服务端docker部署", "name": "front-backend-docker-deployment.md"},
{ "title": "Java服务端部署", "name": "server-deployment-solution-java.md" },
{ "title": "Node.js服务端部署", "name": "server-deployment-solution.md" },
{ "title": "区块发布方案(Node.js服务端)", "name": "block-release-solution.md" },
Expand Down
89 changes: 89 additions & 0 deletions docs/changelog/v2.7-upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,95 @@ const register = {
}
```

#### 3.3 仅支持在第一层声明(子层声明不会生效)

自 v2.7 起,我们只读取注册表对象的“第一层”。只有第一层的键会被注册进 `metaHashMap`。

也就是说:把插件/配置项写在子层(无论是把唯一 ID 放到某个插件的子属性里,还是通过 `metas` 往里塞)都不会被注册,`getMergeMeta`/`getMergeMetaByType`/`getAllMergeMeta` 也就找不到它们。

简而言之:请把所有需要生效的插件/配置项,都放到注册表的第一层来声明。

错误示例(不会生效):
```javascript
import { META_APP } from '@opentiny/tiny-engine'
import testMeta from './testMeta'

export default {
// 1) 在子层直接再次声明插件/配置项(无效,不会注册到 metaHashMap)
[META_APP.Materials]: {
'engine.plugins.test': testMeta
},

// 2) 通过 metas 在子层注入(无效,不会注册到 metaHashMap)
[META_APP.Materials]: {
options: {
displayComponentIds: ['engine.plugins.test'],
metas: [testMeta]
}
}
}
```

正确示例(第一层声明 + 通过 ID 引用):
```javascript
import { META_APP } from '@opentiny/tiny-engine'
import testMeta from './testMeta' // testMeta.id = 'engine.plugins.test'

export default {
// 作为第一层键单独注册
[testMeta.id]: testMeta,

// 在需要的插件或布局中通过 ID 引用
[META_APP.Materials]: {
options: {
displayComponentIds: ['engine.plugins.test']
}
}
}
```

适用范围:所有插件与配置项都遵循该规则。用户注册表只支持:
- 把已有的插件/配置项设为 `false`(删除默认);
- 在第一层新增插件/配置项;
- 在第一层用相同 ID 覆盖默认配置。

##### 物料插件(Materials 插件)迁移建议

如果你旧版本是在 `Materials` 插件内部(例如 `Materials.metas` 或把自定义 ID 放到 `Materials` 的子属性里)扩展物料插件,请按下面方式迁移:

错误示例(不会生效):
```javascript
import { META_APP } from '@opentiny/tiny-engine'
import MyMaterial from './MyMaterial' // MyMaterial.id = 'engine.plugins.myMaterial'

export default {
[META_APP.Materials]: {
// 通过 metas 向物料插件塞入物料项(无效)
options: {
metas: [MyMaterial]
}
}
}
```

正确示例(第一层声明 + 在物料插件中引用):
```javascript
import { META_APP } from '@opentiny/tiny-engine'
import MyMaterial from './MyMaterial' // MyMaterial.id = 'engine.plugins.myMaterial'

export default {
// 1) 物料项作为第一层键单独注册
[MyMaterial.id]: MyMaterial,

// 2) 在 Materials 插件中通过 ID Tab 组件显示
[META_APP.Materials]: {
options: {
displayComponentIds: ['engine.plugins.myMaterial']
}
}
}
```

### 4. 注册表热修复功能

v2.7 版本新增了注册表热修复(hotfix)功能,可以通过覆盖官方插件的特定函数或模板,实现紧急 bug 修复,而不需要等待官方版本发布。
Expand Down
41 changes: 41 additions & 0 deletions docs/extension-capabilities-overview/new-registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,47 @@ export default {
更多高级特性,请参考 [注册表高级配置](./new-registry-advanced.md)。


## Tailwind CSS 支持

TinyEngine 自 v2.9 起支持在注册表中通过 `engine.config.enableTailwindCSS` 开关启用 Tailwind CSS(默认开启)。

### 开关配置

```javascript
// registry.js
export default {
'engine.config': {
// ...其他配置
enableTailwindCSS: true // 开启(默认即为 true);设为 false 可关闭
}
}
```

### 启用后的行为

- 预览态:自动按需加载 `@tailwindcss/browser`,使画布/预览中可直接使用 Tailwind 原子类。
- 出码生成:生成的应用将自动完成以下配置(基于 Tailwind CSS v4 零配置方案):
- 在依赖中添加 `tailwindcss`,并在开发依赖中添加 `@tailwindcss/vite`;
- 在 Vite 配置中注册 `tailwindcss()` 插件;
- 生成 `src/style.css`,内容包含 `@import "tailwindcss";`;
- 在 `src/main.js` 自动引入 `./style.css`。

以上步骤由引擎/出码器自动完成,无需手动干预。

### 关闭 Tailwind

当配置为 `enableTailwindCSS: false` 时:

- 预览态不会加载 `@tailwindcss/browser`;
- 出码时不会注入与 Tailwind 相关的依赖、Vite 插件及样式文件导入。

### 注意事项

- 预览依赖解析:内置 import-map 已包含 `@tailwindcss/browser` 映射;如使用自定义 CDN/离线环境,请确保该映射可用。
- 自定义样式:可在生成的 `src/style.css` 中追加自定义样式,或在项目中新增样式文件后自行引入。
- 运行时渲染:如果您自定义了运行时渲染引擎,请确保在运行时渲染中增加对 Tailwind CSS 的支持。


## Vite 配置要求

**重要说明⚠️**:为了使注册表的 tree-shaking 功能正常工作,您需要在 `vite.config.js` 中配置 `registryPath` 参数,指向您的注册表文件路径。
Expand Down
10 changes: 6 additions & 4 deletions docs/extension-capabilities-tutorial/mcpService.md
Original file line number Diff line number Diff line change
Expand Up @@ -430,20 +430,22 @@ mcpService.setOptions(remoteConfig)

### 高级配置

```typescript
<pre>
<code>
import { getMetaApi } from '@opentiny/tiny-engine-meta-register'

const mcpService = getMetaApi('engine.service.mcp')

const advancedConfig = {
proxyUrl: process.env.MCP_PROXY_URL || 'http://localhost:3000/mcp',
connectToAgentServer: process.env.NODE_ENV === 'production',
proxyUrl: process<wbr>.env.MCP_PROXY_URL || 'http://localhost:3000/mcp',
connectToAgentServer: process<wbr>.env.NODE_ENV === 'production',
reconnectAttempts: 5,
reconnectInterval: 2000
}

mcpService.setOptions(advancedConfig)
```
</code>
</pre>

## 最佳实践

Expand Down
57 changes: 57 additions & 0 deletions docs/solutions/front-backend-docker-deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# 前端及Java服务端docker部署

## 1、环境准备
- **工具安装**

根据自己的linux操作系统安装docker,配置国内镜像加速,编辑/etc/docker/daemon.json文件镜像地址,如图

```sh
{
"registry-mirrors": [
"https://docker.m.daocloud.io",
"https://mirror.iscas.ac.cn",
"https://docker.rainbond.cc",
"https://dockerproxy.cn",
"https://docker.udayun.com"
]
}
```

![](./imgs/daemon.png)

编辑完成后重载配置重启docker
```sh
sudo systemctl daemon-reload
sudo systemctl restart docker
```
docker-compose安装
```sh
sudo curl -L "https://ghproxy.com/https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
```
- **拉取代码**
```sh
git clone -b develop https://github.com/opentiny/tiny-engine.git
git clone -b develop https://github.com/opentiny/tiny-engine-backend-java.git
```
## 2、配置修改
- **nginx配置修改**

修改 Java 项目 /tiny-engine-backend-java/docker-deploy-data/nginx.conf 文件,如图所示将ip改为自己服务器ip或域名
![](./imgs/nginxcof.png)

## 3、服务启动与停止

- **服务启动**

在 Java 项目根目录 docker-compose.yml 文件同级执行命令
```sh
docker-compose up -d
```
- **服务停止**

```sh
docker-compose stop
```
## 4、视频讲解
- [TinyEngine实操教程(4)——前后端部署](https://www.bilibili.com/video/BV1gGgcz8Eek/?spm_id_from=333.1387.homepage.video_card.click&vd_source=ea0e34d0a465d263673f7f36dcae0edf)
Binary file added docs/solutions/imgs/daemon.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/solutions/imgs/nginxcof.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const getDevAlias = (useSourceAlias) => {
'@opentiny/tiny-engine-plugin-bridge': path.resolve(basePath, 'packages/plugins/bridge/index.ts'),
'@opentiny/tiny-engine-plugin-tutorial': path.resolve(basePath, 'packages/plugins/tutorial/index.ts'),
'@opentiny/tiny-engine-plugin-robot': path.resolve(basePath, 'packages/plugins/robot/index.ts'),
'@opentiny/tiny-engine-plugin-resource': path.resolve(basePath, 'packages/plugins/resource/index.ts'),
'@opentiny/tiny-engine-settings-panel': path.resolve(basePath, 'packages/settings/panel/index.ts'),
'@opentiny/tiny-engine-setting-events': path.resolve(basePath, 'packages/settings/events/index.ts'),
'@opentiny/tiny-engine-setting-props': path.resolve(basePath, 'packages/settings/props/index.ts'),
Expand Down
4 changes: 2 additions & 2 deletions packages/canvas/DesignCanvas/src/DesignCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export default {
return
}

const { importMap, importStyles } = getImportMapData(deps)
const { importMap, importStyles, importScripts } = getImportMapData(deps)

canvasSrcDoc.value = initCanvas(importMap, importStyles).html
canvasSrcDoc.value = initCanvas(importMap, importStyles, importScripts).html
}
})

Expand Down
Loading