Skip to content

Commit 79090d5

Browse files
committed
feat(new-registry): test plugin replace, add, sort & plugin method replace
1 parent 4bd9faa commit 79090d5

10 files changed

Lines changed: 163 additions & 2 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default {
2+
'engine.plugins.appmanage': {
3+
overwrite: {
4+
methods: {
5+
Main: {
6+
createNewPage: (_ctx) => (_event, row) => {
7+
alert(`当前页面是${_ctx().pageState.currentPage.name}, 现在要创建一个新的${_event}页面`)
8+
}
9+
}
10+
}
11+
}
12+
}
13+
}

designer-demo/registry.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
import { META_SERVICE, META_APP } from '@opentiny/tiny-engine-meta-register'
1313
import engineConfig from './engine.config'
1414
import { HttpService } from './src/composable'
15+
import { CustomComponents, Block } from './src/metas'
1516

1617
export default {
1718
[META_SERVICE.Http]: HttpService,
1819
'engine.config': {
1920
...engineConfig
2021
},
22+
[META_APP.BlockManage]: Block,
2123
// 调整插件顺序示例:
2224
[META_APP.Layout]: {
2325
options: {
@@ -29,10 +31,17 @@ export default {
2931
[META_APP.OutlineTree]: {
3032
insertAfter: META_APP.Materials
3133
},
34+
// 调整插件顺序
35+
[META_APP.BlockManage]: {
36+
insertBefore: META_APP.Materials
37+
},
3238
// 调整插件上下位置
3339
[META_APP.Schema]: {
3440
insertBefore: META_APP.Help
3541
},
42+
'engine.plugins.custom-components': {
43+
insertAfter: META_APP.State
44+
},
3645
// 调整工具栏顺序
3746
[META_APP.Save]: {
3847
insertAfter: META_APP.GenerateCode
@@ -43,5 +52,9 @@ export default {
4352
}
4453
}
4554
}
55+
},
56+
'engine.plugins.custom-components': {
57+
...CustomComponents,
58+
id: 'engine.plugins.custom-components'
4659
}
4760
}

designer-demo/src/main.js

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

1516
async function startApp() {
1617
const registry = await import('../registry')
1718
const { init } = await import('@opentiny/tiny-engine')
18-
19+
const hotfixRegistry =
20+
(await initHotfixRegistry({
21+
url: 'http://localhost:8090/hotfixRegistry.js'
22+
})) || {}
1923
init({
2024
// 合并多个注册表
21-
registry: [registry.default],
25+
registry: [registry.default, hotfixRegistry],
2226
configurators,
2327
createAppSignal: ['global_service_init_finish']
2428
})

designer-demo/src/metas/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import CustomComponents from "./plugins/custom-components";
2+
import Block from './plugins/block';
3+
4+
export { CustomComponents, Block }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright (c) 2023 - present TinyEngine Authors.
3+
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
4+
*
5+
* Use of this source code is governed by an MIT-style license.
6+
*
7+
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8+
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9+
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10+
*
11+
*/
12+
13+
import entry from './src/Main.vue'
14+
import metaData from './meta'
15+
16+
export default {
17+
...metaData,
18+
entry,
19+
metas: []
20+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default {
2+
id: 'engine.plugins.blockmanage',
3+
title: '区块管理',
4+
type: 'plugins',
5+
icon: 'plugin-icon-symbol'
6+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<plugin-panel
3+
title="区块管理"
4+
class="plugin-block"
5+
:fixed-name="PLUGIN_NAME.BlockManage"
6+
:fixedPanels="fixedPanels"
7+
:isShowDocsIcon="true"
8+
@close="$emit('close')"
9+
>
10+
<template #header> </template>
11+
<template #content>
12+
<span>这里是替换后的插件:区块管理</span>
13+
</template>
14+
</plugin-panel>
15+
</template>
16+
17+
<script lang="ts">
18+
import { PluginPanel } from '@opentiny/tiny-engine-common'
19+
import { useLayout } from '@opentiny/tiny-engine-meta-register'
20+
export default {
21+
components: {
22+
PluginPanel
23+
},
24+
props: {
25+
fixedPanels: {
26+
type: Array
27+
}
28+
},
29+
setup(props, { emit }) {
30+
const { PLUGIN_NAME } = useLayout()
31+
32+
return {
33+
PLUGIN_NAME
34+
}
35+
}
36+
}
37+
</script>
38+
<style lang="less" scoped></style>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright (c) 2023 - present TinyEngine Authors.
3+
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
4+
*
5+
* Use of this source code is governed by an MIT-style license.
6+
*
7+
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8+
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9+
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10+
*
11+
*/
12+
13+
import entry from './src/Main.vue'
14+
import metaData from './meta'
15+
16+
export default {
17+
...metaData,
18+
entry,
19+
metas: []
20+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default {
2+
id: 'engine.plugins.custom-components',
3+
title: '自定义组件',
4+
type: 'plugins',
5+
icon: 'preview'
6+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<template>
2+
<plugin-panel
3+
title="自定义组件"
4+
class="plugin-datasource"
5+
fixed-name="自定义组件"
6+
:fixedPanels="fixedPanels"
7+
:isShowDocsIcon="true"
8+
@close="$emit('close')"
9+
>
10+
<template #header>
11+
</template>
12+
<template #content>
13+
<span>这里是新增的插件栏,自定义组件</span>
14+
</template>
15+
</plugin-panel>
16+
</template>
17+
18+
<script lang="ts">
19+
import { PluginPanel } from '@opentiny/tiny-engine-common';
20+
21+
export default {
22+
components: {
23+
PluginPanel
24+
},
25+
props: {
26+
fixedPanels: {
27+
type: Array
28+
}
29+
},
30+
setup(props, { emit }) {
31+
32+
}
33+
}
34+
</script>
35+
<style lang="less" scoped>
36+
37+
</style>

0 commit comments

Comments
 (0)