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 packages/tiny-engine-portal/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default {
setup() {
const route = useRoute()

const headerShow = computed(() => route.name !== 'applicationVisit')
const headerShow = computed(() => route.name !== 'applicationVisit' && route.name !== 'applicationPlayground')

return {
headerShow,
Expand Down
31 changes: 29 additions & 2 deletions packages/tiny-engine-portal/src/application/ApplicationVisit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,38 @@
<iframe class="tiny-engine-iframe" :src="tinyEngineUrl"></iframe>
</template>
<script>
import { TINY_ENGINE_DEFAULT_URL } from '../controller/utils'
import { TINY_ENGINE_DEFAULT_URL, TINY_ENGINE_DESIGNER_URL } from '../controller/utils'
import { useRoute } from 'vue-router'
import { onMounted, onUnmounted } from 'vue'

export default {
setup() {
const route = useRoute()
const tinyEngineUrl = route.name === 'applicationVisit' ? TINY_ENGINE_DEFAULT_URL : TINY_ENGINE_DESIGNER_URL
//回调函数
const openAppNewTab = ( event ) => {
if(event.data.type === 'openNewTab') {
const href = window.location.href.split('?')[0]
const searchParams = event.data.url.split('?')[1]
window.open(`${href}?${searchParams}`)
}
}
window.addEventListener("message", openAppNewTab, false)

onMounted(() => {
const url = new URL(window.location.href)
const type = url.hash.split('?')[1]
if (url.hash.includes('id')) {
const iframe = document.querySelector('iframe')
iframe.src = `${TINY_ENGINE_DESIGNER_URL}?${type}`
}
})

onUnmounted(() => {
window.removeEventListener('message', openAppNewTab)
})
return {
tinyEngineUrl: TINY_ENGINE_DEFAULT_URL
tinyEngineUrl
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/tiny-engine-portal/src/controller/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export const EXPERIENCE_URL_BDVIEW = `${import.meta.env.VITE_APP_ORIGIN}/platfor
}`

export const TINY_ENGINE_DEFAULT_URL = `${import.meta.env.BASE_URL}tiny-engine-editor/index.html?type=app&id=1&tenant=1`
export const TINY_ENGINE_DESIGNER_URL = `https://res-static.opentiny.design/tiny-engine-designer/latest/index.html`

export const openLowCodeEditor = () => {
window.open(EXPERIENCE_URL, '_blank')
Expand Down
5 changes: 5 additions & 0 deletions packages/tiny-engine-portal/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ const routes = [
name: 'applicationVisit',
component: () => import('../application/ApplicationVisit.vue')
},
{
path: '/tiny-engine-playground',
name: 'applicationPlayground',
component: () => import('../application/ApplicationVisit.vue')
},
{
path: '/component-lib-import',
name: 'componentsLibImport',
Expand Down
2 changes: 1 addition & 1 deletion packages/tiny-engine-portal/src/utils/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function openEditor(router, editorUrl = TINY_ENGINE_DEFAULT_URL) {
window.open(editorUrl, '_blank')
} else {
router.push({
name: 'applicationVisit'
name: 'applicationPlayground'
})
}
}