Skip to content

Commit d931ce6

Browse files
committed
Merge branch 'develop' of https://github.com/betterdancing/tiny-engine into feat/resources
1 parent c013b27 commit d931ce6

File tree

126 files changed

+1840
-359
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+1840
-359
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [develop]
6+
7+
jobs:
8+
deploy-gh-pages:
9+
runs-on: ubuntu-latest
10+
concurrency:
11+
group: deploy-gh-pages
12+
cancel-in-progress: true
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Install pnpm
18+
uses: pnpm/action-setup@v4
19+
with:
20+
version: 10
21+
run_install: false
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '20'
27+
registry-url: 'https://registry.npmjs.org'
28+
29+
- name: Install dependencies
30+
run: pnpm install
31+
32+
- name: add environment variable
33+
run: |
34+
cat <<'EOF' >> designer-demo/env/.env.alpha
35+
// ---- appended by CI (gh-pages) ----
36+
VITE_ORIGIN=https://agent.opentiny.design/
37+
EOF
38+
- name: change material url
39+
run: |
40+
sed -i "s#material: \['/mock/bundle.json'\]#material: \['https://opentiny.github.io/tiny-engine/mock/bundle.json'\]#g" designer-demo/engine.config.js
41+
echo "Updated material url in designer-demo/engine.config.js"
42+
- name: Run Build
43+
run: |
44+
set -eo pipefail
45+
pnpm run build:plugin 2>&1 | tee /tmp/build-plugin.log
46+
pnpm run build:alpha 2>&1 | tee /tmp/build-alpha.log
47+
48+
- name: Deploy
49+
uses: peaceiris/actions-gh-pages@v4
50+
with:
51+
github_token: ${{ secrets.GITHUB_TOKEN }}
52+
publish_dir: ./designer-demo/dist/
53+
keep_files: true
54+
force_orphan: false
55+
user_name: 'github-actions[bot]'
56+
user_email: 'github-actions[bot]@users.noreply.github.com'

designer-demo/engine.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ export default {
33
theme: 'light',
44
material: ['/mock/bundle.json'],
55
scripts: [],
6-
styles: []
6+
styles: [],
7+
// 是否开启 TailWindCSS 特性
8+
enableTailwindCSS: true
79
}

designer-demo/registry.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import { META_SERVICE, META_APP } from '@opentiny/tiny-engine-meta-register'
1313
import engineConfig from './engine.config'
1414
import { HttpService } from './src/composable'
1515

16+
const baseURL = import.meta.env.BASE_URL || '.'
17+
const baseURLWithoutSlash = baseURL.replace(/\/$/, '')
18+
1619
export default {
1720
[META_SERVICE.Http]: HttpService,
1821
'engine.config': {
@@ -43,5 +46,12 @@ export default {
4346
}
4447
}
4548
}
49+
},
50+
[META_APP.Preview]: {
51+
options: {
52+
// 配置预览跳转的 url:根据实际业务需求进行配置
53+
// 文档:https://opentiny.design/tiny-engine#/help-center/course/dev/preview-api
54+
previewUrl: ['prod', 'alpha'].includes(import.meta.env.MODE) ? `${baseURLWithoutSlash}/preview.html` : ''
55+
}
4656
}
4757
}

designer-demo/src/preview.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*
1111
*/
1212
import { defineEntry } from '@opentiny/tiny-engine-meta-register'
13+
import engineConfig from '../engine.config'
1314
import 'virtual:svg-icons-register'
1415

1516
async function startApp() {
@@ -23,9 +24,7 @@ async function startApp() {
2324
const registry = {
2425
[META_SERVICE.Http]: HttpService,
2526
'engine.config': {
26-
id: 'engine.config',
27-
theme: 'light',
28-
material: ['/mock/bundle.json']
27+
...engineConfig
2928
}
3029
}
3130

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
- [更新日志](./changelog/changelog.md)
5151
- [v2.7升级指南](./changelog/v2.7-upgrade-guide.md)
5252
- 解决方案
53+
- [前端及Java服务端docker部署](./solutions/front-backend-docker-deployment.md)
5354
- [Java服务端部署](./solutions/server-deployment-solution-java.md)
5455
- [Node.js服务端部署](./solutions/server-deployment-solution.md)
5556
- [区块发布方案(Node.js服务端)](./solutions/block-release-solution.md)

docs/catalog.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"title": "解决方案",
9696
"name": "solutions",
9797
"articles": [
98+
{"title": "前端及Java服务端docker部署", "name": "front-backend-docker-deployment.md"},
9899
{ "title": "Java服务端部署", "name": "server-deployment-solution-java.md" },
99100
{ "title": "Node.js服务端部署", "name": "server-deployment-solution.md" },
100101
{ "title": "区块发布方案(Node.js服务端)", "name": "block-release-solution.md" },

docs/changelog/v2.7-upgrade-guide.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,95 @@ const register = {
361361
}
362362
```
363363

364+
#### 3.3 仅支持在第一层声明(子层声明不会生效)
365+
366+
自 v2.7 起,我们只读取注册表对象的“第一层”。只有第一层的键会被注册进 `metaHashMap`
367+
368+
也就是说:把插件/配置项写在子层(无论是把唯一 ID 放到某个插件的子属性里,还是通过 `metas` 往里塞)都不会被注册,`getMergeMeta`/`getMergeMetaByType`/`getAllMergeMeta` 也就找不到它们。
369+
370+
简而言之:请把所有需要生效的插件/配置项,都放到注册表的第一层来声明。
371+
372+
错误示例(不会生效):
373+
```javascript
374+
import { META_APP } from '@opentiny/tiny-engine'
375+
import testMeta from './testMeta'
376+
377+
export default {
378+
// 1) 在子层直接再次声明插件/配置项(无效,不会注册到 metaHashMap)
379+
[META_APP.Materials]: {
380+
'engine.plugins.test': testMeta
381+
},
382+
383+
// 2) 通过 metas 在子层注入(无效,不会注册到 metaHashMap)
384+
[META_APP.Materials]: {
385+
options: {
386+
displayComponentIds: ['engine.plugins.test'],
387+
metas: [testMeta]
388+
}
389+
}
390+
}
391+
```
392+
393+
正确示例(第一层声明 + 通过 ID 引用):
394+
```javascript
395+
import { META_APP } from '@opentiny/tiny-engine'
396+
import testMeta from './testMeta' // testMeta.id = 'engine.plugins.test'
397+
398+
export default {
399+
// 作为第一层键单独注册
400+
[testMeta.id]: testMeta,
401+
402+
// 在需要的插件或布局中通过 ID 引用
403+
[META_APP.Materials]: {
404+
options: {
405+
displayComponentIds: ['engine.plugins.test']
406+
}
407+
}
408+
}
409+
```
410+
411+
适用范围:所有插件与配置项都遵循该规则。用户注册表只支持:
412+
- 把已有的插件/配置项设为 `false`(删除默认);
413+
- 在第一层新增插件/配置项;
414+
- 在第一层用相同 ID 覆盖默认配置。
415+
416+
##### 物料插件(Materials 插件)迁移建议
417+
418+
如果你旧版本是在 `Materials` 插件内部(例如 `Materials.metas` 或把自定义 ID 放到 `Materials` 的子属性里)扩展物料插件,请按下面方式迁移:
419+
420+
错误示例(不会生效):
421+
```javascript
422+
import { META_APP } from '@opentiny/tiny-engine'
423+
import MyMaterial from './MyMaterial' // MyMaterial.id = 'engine.plugins.myMaterial'
424+
425+
export default {
426+
[META_APP.Materials]: {
427+
// 通过 metas 向物料插件塞入物料项(无效)
428+
options: {
429+
metas: [MyMaterial]
430+
}
431+
}
432+
}
433+
```
434+
435+
正确示例(第一层声明 + 在物料插件中引用):
436+
```javascript
437+
import { META_APP } from '@opentiny/tiny-engine'
438+
import MyMaterial from './MyMaterial' // MyMaterial.id = 'engine.plugins.myMaterial'
439+
440+
export default {
441+
// 1) 物料项作为第一层键单独注册
442+
[MyMaterial.id]: MyMaterial,
443+
444+
// 2) 在 Materials 插件中通过 ID Tab 组件显示
445+
[META_APP.Materials]: {
446+
options: {
447+
displayComponentIds: ['engine.plugins.myMaterial']
448+
}
449+
}
450+
}
451+
```
452+
364453
### 4. 注册表热修复功能
365454

366455
v2.7 版本新增了注册表热修复(hotfix)功能,可以通过覆盖官方插件的特定函数或模板,实现紧急 bug 修复,而不需要等待官方版本发布。

docs/extension-capabilities-overview/new-registry.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,47 @@ export default {
271271
更多高级特性,请参考 [注册表高级配置](./new-registry-advanced.md)。
272272
273273
274+
## Tailwind CSS 支持
275+
276+
TinyEngine 自 v2.9 起支持在注册表中通过 `engine.config.enableTailwindCSS` 开关启用 Tailwind CSS(默认开启)。
277+
278+
### 开关配置
279+
280+
```javascript
281+
// registry.js
282+
export default {
283+
'engine.config': {
284+
// ...其他配置
285+
enableTailwindCSS: true // 开启(默认即为 true);设为 false 可关闭
286+
}
287+
}
288+
```
289+
290+
### 启用后的行为
291+
292+
- 预览态:自动按需加载 `@tailwindcss/browser`,使画布/预览中可直接使用 Tailwind 原子类。
293+
- 出码生成:生成的应用将自动完成以下配置(基于 Tailwind CSS v4 零配置方案):
294+
- 在依赖中添加 `tailwindcss`,并在开发依赖中添加 `@tailwindcss/vite`
295+
- 在 Vite 配置中注册 `tailwindcss()` 插件;
296+
- 生成 `src/style.css`,内容包含 `@import "tailwindcss";`
297+
- 在 `src/main.js` 自动引入 `./style.css`
298+
299+
以上步骤由引擎/出码器自动完成,无需手动干预。
300+
301+
### 关闭 Tailwind
302+
303+
当配置为 `enableTailwindCSS: false` 时:
304+
305+
- 预览态不会加载 `@tailwindcss/browser`
306+
- 出码时不会注入与 Tailwind 相关的依赖、Vite 插件及样式文件导入。
307+
308+
### 注意事项
309+
310+
- 预览依赖解析:内置 import-map 已包含 `@tailwindcss/browser` 映射;如使用自定义 CDN/离线环境,请确保该映射可用。
311+
- 自定义样式:可在生成的 `src/style.css` 中追加自定义样式,或在项目中新增样式文件后自行引入。
312+
- 运行时渲染:如果您自定义了运行时渲染引擎,请确保在运行时渲染中增加对 Tailwind CSS 的支持。
313+
314+
274315
## Vite 配置要求
275316
276317
**重要说明⚠️**:为了使注册表的 tree-shaking 功能正常工作,您需要在 `vite.config.js` 中配置 `registryPath` 参数,指向您的注册表文件路径。

docs/extension-capabilities-tutorial/mcpService.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,20 +430,22 @@ mcpService.setOptions(remoteConfig)
430430

431431
### 高级配置
432432

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

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

438439
const advancedConfig = {
439-
proxyUrl: process.env.MCP_PROXY_URL || 'http://localhost:3000/mcp',
440-
connectToAgentServer: process.env.NODE_ENV === 'production',
440+
proxyUrl: process<wbr>.env.MCP_PROXY_URL || 'http://localhost:3000/mcp',
441+
connectToAgentServer: process<wbr>.env.NODE_ENV === 'production',
441442
reconnectAttempts: 5,
442443
reconnectInterval: 2000
443444
}
444445

445446
mcpService.setOptions(advancedConfig)
446-
```
447+
</code>
448+
</pre>
447449

448450
## 最佳实践
449451

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# 前端及Java服务端docker部署
2+
3+
## 1、环境准备
4+
- **工具安装**
5+
6+
根据自己的linux操作系统安装docker,配置国内镜像加速,编辑/etc/docker/daemon.json文件镜像地址,如图
7+
8+
```sh
9+
{
10+
"registry-mirrors": [
11+
"https://docker.m.daocloud.io",
12+
"https://mirror.iscas.ac.cn",
13+
"https://docker.rainbond.cc",
14+
"https://dockerproxy.cn",
15+
"https://docker.udayun.com"
16+
]
17+
}
18+
```
19+
20+
![](./imgs/daemon.png)
21+
22+
编辑完成后重载配置重启docker
23+
```sh
24+
sudo systemctl daemon-reload
25+
sudo systemctl restart docker
26+
```
27+
docker-compose安装
28+
```sh
29+
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
30+
sudo chmod +x /usr/local/bin/docker-compose
31+
```
32+
- **拉取代码**
33+
```sh
34+
git clone -b develop https://github.com/opentiny/tiny-engine.git
35+
git clone -b develop https://github.com/opentiny/tiny-engine-backend-java.git
36+
```
37+
## 2、配置修改
38+
- **nginx配置修改**
39+
40+
修改 Java 项目 /tiny-engine-backend-java/docker-deploy-data/nginx.conf 文件,如图所示将ip改为自己服务器ip或域名
41+
![](./imgs/nginxcof.png)
42+
43+
## 3、服务启动与停止
44+
45+
- **服务启动**
46+
47+
在 Java 项目根目录 docker-compose.yml 文件同级执行命令
48+
```sh
49+
docker-compose up -d
50+
```
51+
- **服务停止**
52+
53+
```sh
54+
docker-compose stop
55+
```
56+
## 4、视频讲解
57+
- [TinyEngine实操教程(4)——前后端部署](https://www.bilibili.com/video/BV1gGgcz8Eek/?spm_id_from=333.1387.homepage.video_card.click&vd_source=ea0e34d0a465d263673f7f36dcae0edf)

0 commit comments

Comments
 (0)