Skip to content

Commit 1bbadf3

Browse files
committed
docs: update registry code example
1 parent 9147a71 commit 1bbadf3

4 files changed

Lines changed: 36 additions & 46 deletions

File tree

docs/api/frontend-api/preview-api.md

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,14 @@ const registry = {
7474

7575
<pre>
7676
<code>
77-
import { Preview } from '@opentiny/tiny-engine'
77+
// registry.js
78+
import { META_APP } from '@opentiny/tiny-engine-meta-register'
7879
export default {
79-
toolbars: [
80-
[Preview, { options: { ...Preview.options, previewUrl: import.meta<wbr>.env.MODE.includes('prod') ? 'http://tiny-engine-preview.com/customPreview' : '' } }]
81-
]
80+
[META_APP.Preview]: {
81+
options: {
82+
previewUrl: import.meta<wbr>.env.MODE.includes('prod') ? 'http://tiny-engine-preview.com/customPreview' : ''
83+
}
84+
}
8285
}
8386
</code>
8487
</pre>
@@ -91,22 +94,17 @@ export default {
9194

9295
例如:
9396
```javascript
94-
import { Preview } from '@opentiny/tiny-engine'
97+
// registry.js
98+
import { META_APP } from '@opentiny/tiny-engine-meta-register'
9599
export default {
96-
toolbars: [
97-
[
98-
Preview,
99-
{
100-
options: {
101-
...Preview.options,
102-
previewUrl: (originUrl, query) => {
103-
// 这里我们增加了自定义的 query: `test=1`
104-
return `http://tiny-engine-preview.com/customPreview?test=1&${query}`
105-
}
106-
}
107-
}
108-
]
109-
]
100+
[META_APP.Preview]: {
101+
options: {
102+
previewUrl: (originUrl, query) => {
103+
// 这里我们增加了自定义的 query: `test=1`
104+
return `http://tiny-engine-preview.com/customPreview?test=1&${query}`
105+
}
106+
}
107+
}
110108
}
111109
```
112110

@@ -119,7 +117,12 @@ export default {
119117

120118
initPreview({
121119
registry: {
122-
config: { id: 'engine.config', theme: 'light', previewHotReload: false },
120+
'engine.config': {
121+
id: 'engine.config',
122+
theme: 'light',
123+
// 配置 false 关闭热更新
124+
previewHotReload: false
125+
}
123126
// ... other config
124127
}
125128
})

docs/development-getting-started/dev-quick-start.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,7 @@ import engineConfig from './engine.config'
8888

8989
export default {
9090
// ...
91-
-- plugins: [Materials, Tree, Page, Block, Datasource, Bridge, I18n, Script, State, Schema, Help, Robot],
92-
++ plugins: [DemoPlugin, Materials, Tree, Page, Block, Datasource, Bridge, I18n, Script, State, Schema, Help, Robot],
93-
dsls: [{ id: 'engine.dsls.dslvue' }],
94-
settings: [Props, Styles, Events],
95-
canvas: Canvas
91+
++ [DemoPlugin.id]: DemoPlugin
9692
}
9793

9894
```

docs/extension-capabilities-tutorial/customize-page-configured.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
import { handleClickDelete } from './tests/utils'
1919
export default {
2020
// ...
21-
plugins: [
22-
// ...
23-
[Page, { options: { ...Page.options, customPageOperations: [{type: 'delete', label: '删除', action: handleClickDelete}] } }]
24-
// ...
25-
]
21+
[META_APP.AppManage]: {
22+
options: {
23+
customPageOperations: [{type: 'delete', label: '删除', action: handleClickDelete}]
24+
}
25+
}
2626
// ...
2727
}
2828
```

docs/extension-capabilities-tutorial/customize-plugin-ui.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,17 @@
88

99
- `title`。标题
1010
- `icon`。图标,可以为字符串或者组件。如果是字符串,则会使用 tiny-engine 自带的 svg 图标
11-
- `align`。对齐位置,根据插件位置的不同可以为不同的值。如果是顶部工具栏,可以为 `left`, `center`, `right`;如果是左侧插件栏,可以为 `top`, `bottom`
1211

1312
比如替换 Page 插件的图标和对齐位置
1413

1514
```js
1615
// registry.js
1716
export default {
1817
// ...
19-
plugins: [
20-
// ...
21-
{
22-
...Page,
23-
title: '定制页面插件位置',
24-
icon: 'box',
25-
align: 'bottom'
26-
}
27-
// ...
28-
]
18+
[META_APP.AppManage]: {
19+
title: '定制页面插件位置',
20+
icon: 'box'
21+
}
2922
// ...
3023
}
3124
```
@@ -43,11 +36,9 @@ export default {
4336
import CustomPage from './custom-page'
4437
export default {
4538
// ...
46-
plugins: [
47-
// ...
48-
{ ...Page, entry: CustomPage }
49-
// ...
50-
]
39+
[META_APP.AppManage]: {
40+
entry: CustomPage
41+
}
5142
// ...
5243
}
5344
```

0 commit comments

Comments
 (0)