Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: merge lowcodeconfig with registry, migrate alias config to demo #551

Merged
Merged
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
5 changes: 5 additions & 0 deletions designer-demo/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
*/

export default {
config: {
id: 'engine.config',
theme: 'light',
material: [],
},
layout: { id: 'engine.layout' },
toolbars: [
{
Expand Down
59 changes: 59 additions & 0 deletions designer-demo/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,70 @@
import path from 'node:path'
import { defineConfig, mergeConfig } from 'vite'
import getDefaultConfig from '@opentiny/tiny-engine/vite.config.js'

export default defineConfig((options) => {
const defaultConfig = getDefaultConfig(options)

const devAlias = {
'@opentiny/tiny-engine-controller/js': path.resolve(__dirname, '../packages/controller/js'),
'@opentiny/tiny-engine-common/component': path.resolve(__dirname, '../packages/common/component'),
'@opentiny/tiny-engine-common': path.resolve(__dirname, '../packages/common/index.js'),
'@opentiny/tiny-engine-controller/utils': path.resolve(__dirname, '../packages/controller/utils.js'),
'@opentiny/tiny-engine-controller/adapter': path.resolve(__dirname, '../packages/controller/adapter.js'),
'@opentiny/tiny-engine-controller': path.resolve(__dirname, '../packages/controller/src/index.js'),
'@opentiny/tiny-engine-plugin-materials': path.resolve(__dirname, '../packages/plugins/materials/index.js'),
'@opentiny/tiny-engine-plugin-block': path.resolve(__dirname, '../packages/plugins/block/index.js'),
'@opentiny/tiny-engine-plugin-data': path.resolve(__dirname, '../packages/plugins/data/index.js'),
'@opentiny/tiny-engine-plugin-datasource': path.resolve(__dirname, '../packages/plugins/datasource/index.js'),
'@opentiny/tiny-engine-plugin-script': path.resolve(__dirname, '../packages/plugins/script/index.js'),
'@opentiny/tiny-engine-plugin-tree': path.resolve(__dirname, '../packages/plugins/tree/index.js'),
'@opentiny/tiny-engine-plugin-help': path.resolve(__dirname, '../packages/plugins/help/index.js'),
'@opentiny/tiny-engine-plugin-schema': path.resolve(__dirname, '../packages/plugins/schema/index.js'),
'@opentiny/tiny-engine-plugin-page': path.resolve(__dirname, '../packages/plugins/page/index.js'),
'@opentiny/tiny-engine-plugin-i18n': path.resolve(__dirname, '../packages/plugins/i18n/index.js'),
'@opentiny/tiny-engine-plugin-bridge': path.resolve(__dirname, '../packages/plugins/bridge/index.js'),
'@opentiny/tiny-engine-plugin-tutorial': path.resolve(__dirname, '../packages/plugins/tutorial/index.js'),
'@opentiny/tiny-engine-plugin-robot': path.resolve(__dirname, '../packages/plugins/robot/index.js'),
'@opentiny/tiny-engine-settings-panel': path.resolve(__dirname, '../packages/settings/panel/index.js'),
'@opentiny/tiny-engine-setting-events': path.resolve(__dirname, '../packages/settings/events/index.js'),
'@opentiny/tiny-engine-setting-props': path.resolve(__dirname, '../packages/settings/props/index.js'),
'@opentiny/tiny-engine-setting-styles': path.resolve(__dirname, '../packages/settings/styles/index.js'),
'@opentiny/tiny-engine-toolbar-breadcrumb': path.resolve(__dirname, '../packages/toolbars/breadcrumb/index.js'),
'@opentiny/tiny-engine-toolbar-fullscreen': path.resolve(__dirname, '../packages/toolbars/fullscreen/index.js'),
'@opentiny/tiny-engine-toolbar-lang': path.resolve(__dirname, '../packages/toolbars/lang/index.js'),
'@opentiny/tiny-engine-toolbar-layout': path.resolve(__dirname, '../packages/toolbars/layout/index.js'),
'@opentiny/tiny-engine-toolbar-checkinout': path.resolve(__dirname, '../packages/toolbars/lock/index.js'),
'@opentiny/tiny-engine-toolbar-logo': path.resolve(__dirname, '../packages/toolbars/logo/index.js'),
'@opentiny/tiny-engine-toolbar-logout': path.resolve(__dirname, '../packages/toolbars/logout/index.js'),
'@opentiny/tiny-engine-toolbar-media': path.resolve(__dirname, '../packages/toolbars/media/index.js'),
'@opentiny/tiny-engine-toolbar-preview': path.resolve(__dirname, '../packages/toolbars/preview/index.js'),
'@opentiny/tiny-engine-toolbar-generate-vue': path.resolve(__dirname, '../packages/toolbars/generate-vue/index.js'),
'@opentiny/tiny-engine-toolbar-refresh': path.resolve(__dirname, '../packages/toolbars/refresh/index.js'),
'@opentiny/tiny-engine-toolbar-redoundo': path.resolve(__dirname, '../packages/toolbars/redoundo/index.js'),
'@opentiny/tiny-engine-toolbar-clean': path.resolve(__dirname, '../packages/toolbars/clean/index.js'),
'@opentiny/tiny-engine-toolbar-save': path.resolve(__dirname, '../packages/toolbars/save/index.js'),
'@opentiny/tiny-engine-toolbar-setting': path.resolve(__dirname, '../packages/toolbars/setting/index.js'),
'@opentiny/tiny-engine-toolbar-collaboration': path.resolve(__dirname, '../packages/toolbars/collaboration/index.js'),
'@opentiny/tiny-engine-theme-dark': path.resolve(__dirname, '../packages/theme/dark/index.less'),
'@opentiny/tiny-engine-theme-light': path.resolve(__dirname, '../packages/theme/light/index.less'),
'@opentiny/tiny-engine-svgs': path.resolve(__dirname, '../packages/svgs/index.js'),
'@opentiny/tiny-engine-http': path.resolve(__dirname, '../packages/http/src/index.js'),
'@opentiny/tiny-engine-canvas': path.resolve(__dirname, '../packages/canvas/src/index.js'),
'@opentiny/tiny-engine-utils': path.resolve(__dirname, '../packages/utils/src/index.js'),
'@opentiny/tiny-engine-webcomponent-core': path.resolve(__dirname, '../packages/webcomponent/src/lib.js'),
'@opentiny/tiny-engine-i18n-host': path.resolve(__dirname, '../packages/i18n/src/lib.js'),
'@opentiny/tiny-engine-builtin-component': path.resolve(__dirname, '../packages/builtinComponent/index.js'),
'@opentiny/tiny-engine-entry': path.resolve(__dirname, '../packages/entry/src/index.js'),
'@opentiny/tiny-engine-layout': path.resolve(__dirname, '../packages/layout/index.js'),
'@opentiny/tiny-engine-configurator': path.resolve(__dirname, '../packages/configurator/src/index.js')
}

const config = {
server: {
port: 8090
},
resolve: {
alias: devAlias
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/canvas/src/components/render/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ const create = () => {

export const createRender = (config) => {
initRenderContext()
const { dslMode, canvasOptions } = config
const { styles = [], scripts = [] } = canvasOptions[dslMode]

const { styles = [], scripts = [] } = config.canvasDependencies
const { styles: thirdStyles = [], scripts: thirdScripts = [] } = window.thirdPartyDeps || {}

Promise.all([
Expand Down
7 changes: 4 additions & 3 deletions packages/common/component/LifeCycles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
<script lang="jsx">
import { reactive, ref, watchEffect, onBeforeUnmount } from 'vue'
import { Button, DialogBox, Popover, Search, Alert } from '@opentiny/vue'
import { getGlobalConfig, useModal, usePage, useNotify, useCanvas } from '@opentiny/tiny-engine-controller'
import { useModal, usePage, useNotify, useCanvas } from '@opentiny/tiny-engine-controller'
import { getMergeMeta } from '@opentiny/tiny-engine-entry'
import { theme } from '@opentiny/tiny-engine-controller/adapter'
import MetaListItems from './MetaListItems.vue'
import { iconYes } from '@opentiny/vue-icon'
Expand Down Expand Up @@ -112,9 +113,9 @@ export default {
const { confirm } = useModal()
const { getPageContent } = usePage()

const lifeCycles = getGlobalConfig()?.lifeCyclesOptions[getGlobalConfig()?.dslMode]
const lifeCycles = getMergeMeta('engine.config')?.lifeCyclesOptions[getMergeMeta('engine.config')?.dslMode]

const lifeCycleTips = getGlobalConfig()?.lifeCycleTips[getGlobalConfig()?.dslMode]
const lifeCycleTips = getMergeMeta('engine.config')?.lifeCycleTips[getMergeMeta('engine.config')?.dslMode]

const state = reactive({
showPopover: true,
Expand Down
4 changes: 2 additions & 2 deletions packages/controller/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import { toRaw } from 'vue'
import { getGlobalConfig } from './src/globalConfig'
import { getMergeMeta } from '@opentiny/tiny-engine-entry'

/**
* 将画布pageSchema对象转换成编辑器中的string
Expand Down Expand Up @@ -55,7 +55,7 @@ export const string2Obj = (string) => {
*/

export const theme = () => {
const theme = getGlobalConfig()?.theme?.includes('dark') ? 'vs-dark' : 'vs'
const theme = getMergeMeta('engine.config').theme?.includes('dark') ? 'vs-dark' : 'vs'

return theme
}
19 changes: 0 additions & 19 deletions packages/controller/src/globalConfig.js

This file was deleted.

6 changes: 3 additions & 3 deletions packages/controller/src/hooks/useBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import { extend, copyArray } from '@opentiny/vue-renderless/common/object'
import { format } from '@opentiny/vue-renderless/common/date'
import { remove } from '@opentiny/vue-renderless/common/array'
import { constants } from '@opentiny/tiny-engine-utils'
import { getMergeMeta } from '@opentiny/tiny-engine-entry'
import { getCanvasStatus } from '../../js/canvas'
import { ast2String, parseExpression } from '../../js/ast'
import { getCssObjectFromStyleStr } from '../../js/css'
import { getGlobalConfig } from '../globalConfig'
import {
HOOK_NAME,
initHook,
Expand Down Expand Up @@ -332,7 +332,7 @@ const createBlock = ({ name_cn, label, path, categories }) => {
histories: [],
categories,
public: BLOCK_OPENNESS.Open,
framework: getGlobalConfig()?.dslMode,
framework: getMergeMeta('engine.config')?.dslMode,
content: {
...extend(true, {}, DEFAULT_BLOCK),
fileName: label,
Expand All @@ -354,7 +354,7 @@ const createEmptyBlock = ({ name_cn, label, path, categories }) => {
label,
categories,
public: BLOCK_OPENNESS.Open,
framework: getGlobalConfig()?.dslMode,
framework: getMergeMeta('engine.config')?.dslMode,
content: {
...extend(true, {}, DEFAULT_BLOCK),
fileName: label
Expand Down
5 changes: 2 additions & 3 deletions packages/controller/src/hooks/useResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
*/

import { reactive } from 'vue'
import { getGlobalConfig } from '../globalConfig'
import { useHttp } from '@opentiny/tiny-engine-http'
import { utils, constants } from '@opentiny/tiny-engine-utils'
import { meta as BuiltinComponentMaterials } from '@opentiny/tiny-engine-builtin-component'
import { getMergeMeta } from '@opentiny/tiny-engine-entry'
import { getCanvasStatus } from '../../js/canvas'
import useNotify from '../components/useNotify'
import {
Expand Down Expand Up @@ -250,8 +250,7 @@ const getConfigureMap = () => {
}

const fetchMaterial = async () => {
const { dslMode, canvasOptions } = getGlobalConfig()
const bundleUrls = canvasOptions[dslMode].material
const bundleUrls = getMergeMeta('engine.config')?.material || []
const materials = await Promise.allSettled(bundleUrls.map((url) => http.get(url)))

materials.forEach((response) => {
Expand Down
7 changes: 3 additions & 4 deletions packages/controller/src/hooks/useSaveLocal.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
*/

import { Modal } from '@opentiny/vue'
import { HOOK_NAME, initHook, useCanvas, getMergeMeta } from '@opentiny/tiny-engine-entry'
import { VITE_ORIGIN } from '../../js/environments'
import { getGlobalConfig } from '../globalConfig'
import { HOOK_NAME, initHook, useCanvas } from '@opentiny/tiny-engine-entry'

// 获取当前页面的全量信息

Expand All @@ -28,7 +27,7 @@ const confirmSaveLocal = async () => {
api: `${VITE_ORIGIN}/app-service/api/pages/code/${currentPageId}`,
pageName: currentPageName,
pageId: currentPageId,
platformId: getGlobalConfig()?.platformId
platformId: getMergeMeta('engine.config')?.platformId
})

if (savePage.error) {
Expand All @@ -53,7 +52,7 @@ const savePageLocal = async () => {
const fileExistRes = await bridge.callHandler('page-is-exist', {
pageName: currentPageName || currentPage.name,
pageId: currentPageId || currentPage.id,
platformId: getGlobalConfig()?.platformId
platformId: getMergeMeta('engine.config')?.platformId
})

// 查询本地文件失败:存在同名文件 / 接口报错
Expand Down
3 changes: 1 addition & 2 deletions packages/controller/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import './hooks/mountHooks'
import useMessage from './useMessage'
import { getGlobalConfig, setGlobalConfig } from './globalConfig'
import useData from './useData'
export { default as metaData } from '../meta'
import example from './example'
Expand Down Expand Up @@ -42,4 +41,4 @@ export {
useCustom
} from '@opentiny/tiny-engine-entry'

export { getGlobalConfig, setGlobalConfig, useNotify, useData, useMessage, useModal }
export { useNotify, useData, useMessage, useModal }
97 changes: 0 additions & 97 deletions packages/design-core/config/lowcode.config.js

This file was deleted.

Loading