Skip to content
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
2 changes: 1 addition & 1 deletion designer-demo/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "designer-demo",
"private": true,
"version": "2.3.0",
"version": "2.4.0",
"type": "module",
"scripts": {
"dev": "cross-env vite",
Expand Down
2 changes: 1 addition & 1 deletion mockServer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentiny/tiny-engine-mock",
"version": "2.3.0",
"version": "2.4.0",
"publishConfig": {
"access": "public"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/block-compiler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentiny/tiny-engine-block-compiler",
"version": "2.3.0",
"version": "2.4.0",
"publishConfig": {
"access": "public"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/blockToWebComponentTemplate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentiny/tiny-engine-block-build",
"version": "2.3.0",
"version": "2.4.0",
"description": "translate block to webcomponent template",
"main": "./dist/web-components.es.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/build/vite-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentiny/tiny-engine-vite-config",
"version": "2.3.0",
"version": "2.4.0",
"description": "",
"type": "module",
"main": "./index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/build/vite-plugin-meta-comments/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentiny/tiny-engine-vite-plugin-meta-comments",
"version": "2.3.0",
"version": "2.4.0",
"description": "",
"type": "module",
"main": "dist/index.cjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/builtinComponent/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentiny/tiny-engine-builtin-component",
"version": "2.3.0",
"version": "2.4.0",
"description": "",
"main": "dist/index.mjs",
"module": "dist/index.mjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas/DesignCanvas/src/DesignCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export default {
getMaterial: useMaterial().getMaterial,
addHistory: useHistory().addHistory,
request: getMetaApi(META_SERVICE.Http).getHttp(),
getPageById: getMetaApi(META_APP.AppManage).getPageById,
getPageById: getMetaApi(META_APP.AppManage)?.getPageById,
getPageAncestors: usePage().getAncestors,
getBaseInfo: () => getMetaApi(META_SERVICE.GlobalService).getBaseInfo(),
addHistoryDataChangedCallback,
Expand Down
6 changes: 4 additions & 2 deletions packages/canvas/container/src/components/CanvasMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ export default {

// 计算上下文菜单位置,右键时显示,否则关闭

const { PLUGIN_NAME, activeSetting } = useLayout()

const operations = {
del() {
removeNodeById(getCurrent().schema?.id)
Expand All @@ -153,10 +155,10 @@ export default {
copyNode(getCurrent().schema?.id)
},
config() {
useLayout().activeSetting('props')
activeSetting(PLUGIN_NAME.Props)
},
bindEvent() {
useLayout().activeSetting('event')
activeSetting(PLUGIN_NAME.Event)
},
insert({ value }) {
emit('insert', value)
Expand Down
22 changes: 21 additions & 1 deletion packages/canvas/container/src/components/CanvasResize.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</div>
</template>
<script>
import { ref, computed, watch, nextTick } from 'vue'
import { ref, computed, watch, nextTick, onMounted, onUnmounted } from 'vue'
import { useLayout, useCanvas } from '@opentiny/tiny-engine-meta-register'
import { canvasState } from '../container'

Expand Down Expand Up @@ -90,6 +90,9 @@ export default {
})
}

const draggablePanel = ref(null)
watch(() => useLayout().getPluginWidth(draggablePanel.value), setScale, { flush: 'post' })

watch(() => useLayout().getDimension().width, setScale, { flush: 'post', immediate: true })

watch(() => useLayout().leftFixedPanelsStorage.value, setScale, { flush: 'post' })
Expand All @@ -98,6 +101,11 @@ export default {
() => useLayout().getPluginState().render,
(value) => {
const currentFixed = useLayout().getPluginState().fixedPanels.includes(value)
const isPanelResizable = useLayout().isPanelWidthResizable(value)

if (isPanelResizable) {
draggablePanel.value = value
}

if (!value || currentFixed) {
setScale()
Expand Down Expand Up @@ -129,6 +137,18 @@ export default {
}
)

const handleResize = () => {
setScale()
}

onMounted(() => {
window.addEventListener('resize', handleResize)
})

onUnmounted(() => {
window.removeEventListener('resize', handleResize)
})

return {
onMouseDown,
onMouseMove,
Expand Down
14 changes: 12 additions & 2 deletions packages/canvas/container/src/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,18 @@ const handleClipboardPaste = (event) => {
const handleCopyEvent = (event) => {
const selectedNodes = multiSelectedStates.value.map(({ schema }) => copyObject(schema))

const dataToCopy = JSON.stringify(selectedNodes)
setClipboardSchema(event, dataToCopy)
// 如果没有选中任何节点,直接返回
if (!selectedNodes.length) {
return
}

// 验证所有选中的节点是否有效(不为空)
const isValidNodes = selectedNodes.every((node) => node && Object.keys(node).length > 0)

if (isValidNodes) {
const dataToCopy = JSON.stringify(selectedNodes)
setClipboardSchema(event, dataToCopy)
}
}

const eventFiltersMap = new WeakMap()
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentiny/tiny-engine-canvas",
"version": "2.3.0",
"version": "2.4.0",
"publishConfig": {
"access": "public"
},
Expand Down
7 changes: 5 additions & 2 deletions packages/canvas/render/src/RenderMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const {
getDataSourceMap
})
const { getRenderer, setRenderer } = useCustomRenderer()
const { setCondition } = activePageContext
const { setCondition, getConditions } = activePageContext
const updateCanvas = () => {
refreshKey.value++
}
Expand All @@ -75,6 +75,8 @@ setCurrentApi({
// 设置物料配置
setConfigure,
setCondition,
getController,
getConditions,
getRenderer,
setRenderer,
getDesignMode,
Expand All @@ -91,7 +93,6 @@ const throttleUpdateSchema = useThrottleFn(
true
)

const pageRenderer = getRenderer()
const { routerViewSetting } = useRouterViewSetting()

export default defineComponent({
Expand Down Expand Up @@ -275,6 +276,8 @@ export default defineComponent({
)
}

const pageRenderer = getRenderer()

return () =>
pageAncestors.value === null
? h(CanvasEmpty, { placeholderText: '页面分析加载中' })
Expand Down
9 changes: 6 additions & 3 deletions packages/canvas/render/src/canvas-function/canvas-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ import type { IPageContext } from '../page-block-function'
import type { useCustomRenderer } from './custom-renderer'
import type { removeBlockCompsCache, setConfigure } from '../material-function'
import type { getDesignMode, setDesignMode } from './design-mode'
import type { setController } from './controller'
import type { setController, getController } from './controller'

export interface IApplicationFunctionAPI
extends Pick<ReturnType<typeof useUtils>, 'getUtils'>,
Pick<ReturnType<typeof useDataSourceMap>, 'getDataSourceMap'> {}
export type IPageContextAPI = Pick<IPageContext, 'setCondition'>
export interface ICanvasFunctionAPI extends Pick<ReturnType<typeof useCustomRenderer>, 'getRenderer' | 'setRenderer'> {
export type IPageContextAPI = Pick<IPageContext, 'setCondition' | 'getConditions'>
export interface ICanvasFunctionAPI extends ReturnType<typeof useCustomRenderer> {
getDesignMode: typeof getDesignMode
setDesignMode: typeof setDesignMode
setController: typeof setController
getController: typeof getController
setConfigure: typeof setConfigure
updateCanvas: () => void
}
Expand All @@ -31,8 +32,10 @@ export function setCurrentApi(activeApi: IInnerCanvasAPI) {
export const api: IInnerCanvasAPI = {
getUtils: (...args) => currentApi?.getUtils(...args),
setController: (...args) => currentApi?.setController(...args),
getController: (...args) => currentApi?.getController(...args),
setConfigure: (...args) => currentApi?.setConfigure(...args),
setCondition: (...args) => currentApi?.setCondition(...args),
getConditions: (...args) => currentApi?.getConditions(...args),
getDataSourceMap: (...args) => currentApi?.getDataSourceMap(...args),
getRenderer: (...args) => currentApi?.getRenderer(...args),
setRenderer: (...args) => currentApi?.setRenderer(...args),
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas/render/src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const create = async (config) => {
App = createApp(Main).use(TinyI18nHost).provide(I18nInjectionKey, TinyI18nHost)

if (typeof appCreated === 'function') {
await appCreated(App)
await appCreated(App, { api: renderer })
}

App.config.globalProperties.lowcodeConfig = window.parent.TinyGlobalConfig
Expand Down
Loading