Skip to content

Commit

Permalink
feat(plugins): add meta.js for plugins and replace all hard-coding pl…
Browse files Browse the repository at this point in the history
…ugin id (#506)

* feat(plugins): add meta.js for plugins

* feat(plugins): add generateComment vite plugin for tiny-engine plugins

* feat(plugins): remove metaService comments

* add i18n plugin metaService comment
  • Loading branch information
gene9831 authored May 25, 2024
1 parent 491bda7 commit 9f53dc6
Show file tree
Hide file tree
Showing 57 changed files with 303 additions and 206 deletions.
3 changes: 2 additions & 1 deletion packages/common/component/BindI18n.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ export default {
emit('bind', { ...data, key })
}
const activeI18n = () => useLayout().activePlugin('I18n')
const { PLUGIN_NAME, activePlugin } = useLayout()
const activeI18n = () => activePlugin(PLUGIN_NAME.I18n)
const addBindI18n = () => {
useTranslate().ensureI18n(editForm, true)
Expand Down
19 changes: 13 additions & 6 deletions packages/controller/src/useLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,20 @@ import { constants } from '@opentiny/tiny-engine-utils'
const { PAGE_STATUS } = constants

const PLUGIN_NAME = {
Materials: 'Materials',
AppManage: 'AppManage',
BlockManage: 'BlockManage',
PageController: 'PageController',
Materials: 'engine.plugins.materials',
AppManage: 'engine.plugins.appmanage',
BlockManage: 'engine.plugins.blockmanage',
Bridge: 'engine.plugins.bridge',
DataSource: 'engine.plugins.datasource',
Collections: 'engine.plugins.collections',
EditorHelp: 'engine.plugins.editorhelp',
I18n: 'engine.plugins.i18n',
Robot: 'engine.plugins.robot',
Schema: 'engine.plugins.schema',
PageController: 'engine.plugins.pagecontroller',
OutlineTree: 'engine.plugins.outlinetree',
Tutorial: 'engine.plugins.tutorial',
Lock: 'Lock',
Tutorial: 'Tutorial',
OutlineTree: 'OutlineTree',
save: 'save'
}

Expand Down
10 changes: 5 additions & 5 deletions packages/design-core/src/DesignPlugins.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ export default {
const robotVisible = ref(false)
const robotComponent = ref(null)
const { isTemporaryPage } = usePage()
const HELP_PLUGIN_ID = 'EditorHelp'
const {
PLUGIN_NAME,
pluginState,
registerPluginApi,
layoutState: { plugins: pluginsState }
Expand Down Expand Up @@ -154,7 +154,7 @@ export default {
}
const clickMenu = ({ item, index }) => {
if (item.id === HELP_PLUGIN_ID) return
if (item.id === PLUGIN_NAME.EditorHelp) return
state.prevIdex = index
// 切换插件与关闭插件时确认
Expand All @@ -177,16 +177,16 @@ export default {
}
watch(isTemporaryPage, () => {
if (isTemporaryPage.saved) {
const pagePanel = state.topNavLists?.find((item) => item.id === 'AppManage') || null
const pageIndex = state.topNavLists?.findIndex((item) => item.id === 'AppManage') || -1
const pagePanel = state.topNavLists?.find((item) => item.id === PLUGIN_NAME.AppManage) || null
const pageIndex = state.topNavLists?.findIndex((item) => item.id === PLUGIN_NAME.AppManage) || -1
if (pagePanel !== props.renderPanel) {
clickMenu({ item: pagePanel, index: pageIndex })
}
}
})
const openAIRobot = () => {
robotComponent.value = components.Robot
robotComponent.value = components[PLUGIN_NAME.Robot]
robotVisible.value = !robotVisible.value
}
const close = () => {
Expand Down
26 changes: 12 additions & 14 deletions packages/plugins/block/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

import component, { api } from './src/Main.vue'
import metaData from './meta.js'

export default {
id: 'BlockManage',
title: '区块管理',
icon: 'plugin-icon-symbol',
align: 'top',
...metaData,
api,
component
}
7 changes: 7 additions & 0 deletions packages/plugins/block/meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
id: 'engine.plugins.blockmanage',
title: '区块管理',
type: 'plugins',
align: 'top',
icon: 'plugin-icon-symbol'
}
2 changes: 2 additions & 0 deletions packages/plugins/block/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
"@opentiny/tiny-engine-canvas": "workspace:*",
"@opentiny/tiny-engine-common": "workspace:*",
"@opentiny/tiny-engine-controller": "workspace:*",
"@opentiny/tiny-engine-entry": "workspace:*",
"@opentiny/tiny-engine-http": "workspace:*",
"@opentiny/tiny-engine-utils": "workspace:*",
"html2canvas": "^1.4.1",
"pinyin-pro": "^3.13.0"
},
"devDependencies": {
"@opentiny/vite-plugin-generate-comments": "workspace:*",
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"vite": "^4.3.7"
Expand Down
3 changes: 2 additions & 1 deletion packages/plugins/block/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import { defineConfig } from 'vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import generateComment from '@opentiny/vite-plugin-generate-comments'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), vueJsx()],
plugins: [generateComment(), vue(), vueJsx()],
publicDir: false,
resolve: {},
build: {
Expand Down
26 changes: 12 additions & 14 deletions packages/plugins/bridge/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

import component from './src/Main.vue'
import metaData from './meta.js'

export default {
id: 'Bridge',
title: '资源管理',
icon: 'plugin-icon-sresources',
align: 'top',
...metaData,
component
}
7 changes: 7 additions & 0 deletions packages/plugins/bridge/meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
id: 'engine.plugins.bridge',
title: '资源管理',
type: 'plugins',
align: 'top',
icon: 'plugin-icon-sresources'
}
2 changes: 2 additions & 0 deletions packages/plugins/bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
"@opentiny/tiny-engine-canvas": "workspace:*",
"@opentiny/tiny-engine-common": "workspace:*",
"@opentiny/tiny-engine-controller": "workspace:*",
"@opentiny/tiny-engine-entry": "workspace:*",
"@opentiny/tiny-engine-http": "workspace:*"
},
"devDependencies": {
"@opentiny/vite-plugin-generate-comments": "workspace:*",
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"vite": "^4.3.7"
Expand Down
3 changes: 2 additions & 1 deletion packages/plugins/bridge/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import { defineConfig } from 'vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import generateComment from '@opentiny/vite-plugin-generate-comments'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), vueJsx()],
plugins: [generateComment(), vue(), vueJsx()],
publicDir: false,
resolve: {},
build: {
Expand Down
26 changes: 12 additions & 14 deletions packages/plugins/data/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

import component from './src/Main.vue'
import metaData from './meta.js'

export default {
id: 'DataSource',
title: '状态管理',
icon: 'plugin-icon-var',
align: 'top',
...metaData,
component
}
7 changes: 7 additions & 0 deletions packages/plugins/data/meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
id: 'engine.plugins.datasource',
title: '状态管理',
type: 'plugins',
align: 'top',
icon: 'plugin-icon-var'
}
2 changes: 2 additions & 0 deletions packages/plugins/data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
"@opentiny/tiny-engine-canvas": "workspace:*",
"@opentiny/tiny-engine-common": "workspace:*",
"@opentiny/tiny-engine-controller": "workspace:*",
"@opentiny/tiny-engine-entry": "workspace:*",
"@opentiny/tiny-engine-http": "workspace:*",
"@opentiny/tiny-engine-utils": "workspace:*",
"monaco-editor": "0.33.0"
},
"devDependencies": {
"@opentiny/vite-plugin-generate-comments": "workspace:*",
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"vite": "^4.3.7"
Expand Down
3 changes: 2 additions & 1 deletion packages/plugins/data/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import { defineConfig } from 'vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import generateComment from '@opentiny/vite-plugin-generate-comments'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), vueJsx()],
plugins: [generateComment(), vue(), vueJsx()],
publicDir: false,
resolve: {},
build: {
Expand Down
26 changes: 12 additions & 14 deletions packages/plugins/datasource/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

import { fetchDataSourceList, fetchDataSourceDetail } from './src/js/http'
import component from './src/Main.vue'
import metaData from './meta.js'

export default {
id: 'Collections',
title: '数据源',
icon: 'plugin-icon-data',
align: 'top',
...metaData,
component
}

Expand Down
7 changes: 7 additions & 0 deletions packages/plugins/datasource/meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
id: 'engine.plugins.collections',
title: '数据源',
type: 'plugins',
align: 'top',
icon: 'plugin-icon-data'
}
2 changes: 2 additions & 0 deletions packages/plugins/datasource/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@opentiny/tiny-engine-canvas": "workspace:*",
"@opentiny/tiny-engine-common": "workspace:*",
"@opentiny/tiny-engine-controller": "workspace:*",
"@opentiny/tiny-engine-entry": "workspace:*",
"@opentiny/tiny-engine-http": "workspace:*",
"@opentiny/tiny-engine-utils": "workspace:*",
"@vue/shared": "^3.3.4",
Expand All @@ -35,6 +36,7 @@
"xlsx": "^0.18.5"
},
"devDependencies": {
"@opentiny/vite-plugin-generate-comments": "workspace:*",
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"vite": "^4.3.7"
Expand Down
3 changes: 2 additions & 1 deletion packages/plugins/datasource/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import { defineConfig } from 'vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import generateComment from '@opentiny/vite-plugin-generate-comments'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), vueJsx()],
plugins: [generateComment(), vue(), vueJsx()],
publicDir: false,
resolve: {},
build: {
Expand Down
7 changes: 2 additions & 5 deletions packages/plugins/help/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
*
*/

import HelpIcon from './src/HelpIcon.vue'
import metaData from './meta.js'

export default {
id: 'EditorHelp',
title: '',
icon: HelpIcon,
align: 'bottom'
...metaData
}
9 changes: 9 additions & 0 deletions packages/plugins/help/meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import HelpIcon from './src/HelpIcon.vue'

export default {
id: 'engine.plugins.editorhelp',
title: '',
type: 'plugins',
icon: HelpIcon,
align: 'bottom'
}
2 changes: 2 additions & 0 deletions packages/plugins/help/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
"dependencies": {
"@opentiny/tiny-engine-common": "workspace:*",
"@opentiny/tiny-engine-controller": "workspace:*",
"@opentiny/tiny-engine-entry": "workspace:*",
"@opentiny/tiny-engine-http": "workspace:*"
},
"devDependencies": {
"@opentiny/vite-plugin-generate-comments": "workspace:*",
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"vite": "^4.3.7"
Expand Down
Loading

0 comments on commit 9f53dc6

Please sign in to comment.