Skip to content

Commit 50d15e9

Browse files
authored
fix: Modify tiny-engine-designer path (#65)
1 parent 458ffe1 commit 50d15e9

File tree

5 files changed

+37
-4
lines changed

5 files changed

+37
-4
lines changed

packages/tiny-engine-portal/src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default {
2929
setup() {
3030
const route = useRoute()
3131
32-
const headerShow = computed(() => route.name !== 'applicationVisit')
32+
const headerShow = computed(() => route.name !== 'applicationVisit' && route.name !== 'applicationPlayground')
3333
3434
return {
3535
headerShow,

packages/tiny-engine-portal/src/application/ApplicationVisit.vue

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,38 @@
22
<iframe class="tiny-engine-iframe" :src="tinyEngineUrl"></iframe>
33
</template>
44
<script>
5-
import { TINY_ENGINE_DEFAULT_URL } from '../controller/utils'
5+
import { TINY_ENGINE_DEFAULT_URL, TINY_ENGINE_DESIGNER_URL } from '../controller/utils'
6+
import { useRoute } from 'vue-router'
7+
import { onMounted, onUnmounted } from 'vue'
8+
69
export default {
710
setup() {
11+
const route = useRoute()
12+
const tinyEngineUrl = route.name === 'applicationVisit' ? TINY_ENGINE_DEFAULT_URL : TINY_ENGINE_DESIGNER_URL
13+
//回调函数
14+
const openAppNewTab = ( event ) => {
15+
if(event.data.type === 'openNewTab') {
16+
const href = window.location.href.split('?')[0]
17+
const searchParams = event.data.url.split('?')[1]
18+
window.open(`${href}?${searchParams}`)
19+
}
20+
}
21+
window.addEventListener("message", openAppNewTab, false)
22+
23+
onMounted(() => {
24+
const url = new URL(window.location.href)
25+
const type = url.hash.split('?')[1]
26+
if (url.hash.includes('id')) {
27+
const iframe = document.querySelector('iframe')
28+
iframe.src = `${TINY_ENGINE_DESIGNER_URL}?${type}`
29+
}
30+
})
31+
32+
onUnmounted(() => {
33+
window.removeEventListener('message', openAppNewTab)
34+
})
835
return {
9-
tinyEngineUrl: TINY_ENGINE_DEFAULT_URL
36+
tinyEngineUrl
1037
}
1138
}
1239
}

packages/tiny-engine-portal/src/controller/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ export const EXPERIENCE_URL_BDVIEW = `${import.meta.env.VITE_APP_ORIGIN}/platfor
138138
}`
139139

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

142143
export const openLowCodeEditor = () => {
143144
window.open(EXPERIENCE_URL, '_blank')

packages/tiny-engine-portal/src/router/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ const routes = [
103103
name: 'applicationVisit',
104104
component: () => import('../application/ApplicationVisit.vue')
105105
},
106+
{
107+
path: '/tiny-engine-playground',
108+
name: 'applicationPlayground',
109+
component: () => import('../application/ApplicationVisit.vue')
110+
},
106111
{
107112
path: '/component-lib-import',
108113
name: 'componentsLibImport',

packages/tiny-engine-portal/src/utils/editor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function openEditor(router, editorUrl = TINY_ENGINE_DEFAULT_URL) {
66
window.open(editorUrl, '_blank')
77
} else {
88
router.push({
9-
name: 'applicationVisit'
9+
name: 'applicationPlayground'
1010
})
1111
}
1212
}

0 commit comments

Comments
 (0)