Skip to content

Commit

Permalink
fix:canvasSrc
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoyun8 committed Sep 30, 2024
1 parent a246398 commit fb0798d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
20 changes: 14 additions & 6 deletions packages/canvas/DesignCanvas/src/DesignCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
:is="CanvasContainer.entry"
:controller="controller"
:materials-panel="materialsPanel"
:canvas-src="canvasUrl"
:canvas-src="canvasSrc"
:canvas-src-doc="canvasSrcDoc"
@remove="removeNode"
@selected="nodeSelected"
></component>
Expand All @@ -26,13 +27,15 @@ import {
useHistory,
useModal,
getMergeRegistry,
getMergeMeta
getMergeMeta,
getOptions
} from '@opentiny/tiny-engine-meta-register'
import { useHttp } from '@opentiny/tiny-engine-http'
import { constants } from '@opentiny/tiny-engine-utils'
import * as ast from '@opentiny/tiny-engine-common/js/ast'
import { initCanvas } from '../../init-canvas/init-canvas'
import { getImportMapData } from './importMap'
import meta from '../meta'
const { PAGE_STATUS } = constants
Expand All @@ -52,6 +55,13 @@ export default {
const showMask = ref(true)
const canvasRef = ref(null)
let showModal = false // 弹窗标识
const { canvasSrc = '' } = getOptions(meta.id) || {}
let canvasSrcDoc = ''
if (!canvasSrc) {
const { importMap, importStyles } = getImportMapData(getMergeMeta('engine.config')?.importMapVersion)
canvasSrcDoc = initCanvas(importMap, importStyles)
}
const removeNode = (node) => {
const { pageState } = useCanvas()
Expand Down Expand Up @@ -158,12 +168,10 @@ export default {
canvasResizeObserver?.disconnect?.()
})
const { importMap, importStyles } = getImportMapData(getMergeMeta('engine.config')?.importMapVersion)
const { html: canvasUrl } = initCanvas(importMap, importStyles)
return {
removeNode,
canvasUrl,
canvasSrc,
canvasSrcDoc,
nodeSelected,
footData,
materialsPanel,
Expand Down
24 changes: 17 additions & 7 deletions packages/canvas/container/src/CanvasContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@
<canvas-divider :selectState="selectState"></canvas-divider>
<canvas-resize-border :iframe="iframe"></canvas-resize-border>
<canvas-resize>
<iframe
v-if="!loading"
id="canvas"
ref="iframe"
:srcdoc="canvasSrc"
style="border: none; width: 100%; height: 100%"
></iframe>
<template v-if="!loading">
<iframe
v-if="canvasSrc"
id="canvas"
ref="iframe"
:src="canvasSrc"
style="border: none; width: 100%; height: 100%"
></iframe>
<iframe
v-else
id="canvas"
ref="iframe"
:srcdoc="canvasSrcDoc"
style="border: none; width: 100%; height: 100%"
></iframe>
</template>
<div v-else class="datainit-tip">应用数据初始化中...</div>
</canvas-resize>
<canvas-menu @insert="insertComponent"></canvas-menu>
Expand Down Expand Up @@ -63,6 +72,7 @@ export default {
props: {
controller: Object,
canvasSrc: String,
canvasSrcDoc: String,
materialsPanel: Object
},
emits: ['selected', 'remove'],
Expand Down
3 changes: 2 additions & 1 deletion packages/canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import { CanvasBreadcrumb } from './breadcrumb'
import CanvasContainer from './container'
import CanvasLayout from './layout'
import DesignCanvas from './DesignCanvas'
import { createRender } from './render'

export { CanvasContainer, CanvasLayout, DesignCanvas }
export { CanvasContainer, CanvasLayout, DesignCanvas, createRender }

export default {
...DesignCanvas,
Expand Down

0 comments on commit fb0798d

Please sign in to comment.