11<template >
2- <div ref =" demoContainer" :id =" demo.demoId" : class =" !isMobileFirst ? ' demo-container' : 'demo-mobile-first-container' " >
2+ <div ref =" demoContainer" :id =" demo.demoId" class =" demo-container" >
33 <div
44 v-if =" isIntersecting"
55 class =" ti-br-sm ti-wp100"
6- :class =" {
7- 'b-a-success': currDemoId === demo.demoId,
8- 'is-current': currDemoId === demo.demoId,
9- 'is-mobile-first': isMobileFirst
10- }"
6+ :class =" currDemoId === demo.demoId ? 'b-a-success is-current' : ''"
117 >
128 <div class =" demo-content" >
139 <!-- DEMO 的标题 + 说明desc + 示例wcTag -->
4743 <tiny-button @click =" openIframe(demo)" >{{ i18nByKey('yan-shi') }}</tiny-button >
4844 </div >
4945 </div >
50- <div v-else-if =" isMobileFirst" class =" mobile-first-demo-container" >
51- <div class =" right-side-panel" >
52- <div class =" panel-header" >
53- <h3 class =" panel-title" >{{ demo.name[state.langKey] }}</h3 >
54- <div class =" screen-switch-wrapper" v-if =" !isSmallScreen" >
55- <!-- 添加 Switch 控件 -->
56- <span class =" switch-label" >{{ screenFlag ? '小屏' : '大屏' }}</span >
57- <tiny-switch v-model =" screenFlag" size =" small" > </tiny-switch >
58- </div >
59- </div >
60- <div class =" panel-body" >
61- <div class =" panel-cmp-box" >
62- <!-- 小屏幕 -->
63- <div v-if =" screenFlag && !isSmallScreen" key =" mobile-iframe-wrapper" >
64- <iframe
65- ref =" iframeRef"
66- style =" height : 300px ; max-width : 639px "
67- sandbox =" allow-scripts allow-same-origin"
68- :src =" `/saas.html?component=${router.currentRoute.value.params.cmpId}&demo=${demo.codeFiles[0]}`"
69- frameborder =" 0"
70- importance =" high"
71- loading =" lazy"
72- >
73- </iframe >
74- </div >
75- <!-- 大屏 -->
76- <component v-else :is =" cmp" />
77- </div >
78- </div >
79- </div >
80- </div >
8146 <div v-else class =" pc-demo-container" >
8247 <div class =" pc-demo" >
8348 <component :is =" cmp" />
@@ -117,16 +82,14 @@ import {
11782} from ' vue'
11883import { i18nByKey , getWord } from ' @/i18n'
11984import { $split , fetchDemosFile } from ' @/tools'
120- import { Tabs as TinyTabs , TabItem as TinyTabItem , Button as TinyButton , Switch as TinySwitch } from ' @opentiny/vue'
85+ import { Tabs as TinyTabs , TabItem as TinyTabItem , Button as TinyButton } from ' @opentiny/vue'
12186import { AutoTip as vAutoTip } from ' @opentiny/vue-directive'
12287import { languageMap , vueComponents , getWebdocPath , staticDemoPath } from ' ../views/components-doc/cmp-config'
12388import { router } from ' @/router.js'
12489import demoConfig from ' @demos/config.js'
12590import { useApiMode , useTemplateMode } from ' @/tools'
126- import { useBreakpoint } from ' @opentiny/vue-common'
12791import useTheme from ' @/tools/useTheme'
12892import AsyncHighlight from ' ./async-highlight.vue'
129- import ' ../assets/right-panel.less'
13093
13194const props = defineProps ({
13295 demo: {
@@ -146,10 +109,9 @@ const props = defineProps({
146109 default: false
147110 }
148111})
112+
149113const emit = defineEmits ([' mounted' , ' get-iframe-demo' ])
150- const iframeRef = ref ()
151- const isSmallScreen = computed (() => useBreakpoint ().current .value === ' default' )
152- let screenFlag = ref (false )
114+
153115const { apiModeState, apiModeFn } = useApiMode ()
154116
155117defineOptions ({
@@ -175,14 +137,6 @@ const state = reactive({
175137 copyIcon: ' i-ti-copy'
176138})
177139
178- watch (
179- isSmallScreen ,
180- (val ) => {
181- if (val ) screenFlag .value = true
182- },
183- { immediate: true }
184- )
185-
186140watch (
187141 () => props .isIntersecting ,
188142 async () => {
@@ -299,7 +253,7 @@ const openPlayground = (demo, open = true) => {
299253 const tinyTheme = templateModeState .isSaas ? ' saas' : currentThemeKey .value .split (' -' )[0 ]
300254 const openModeQuery = open ? ' ' : ' &openMode=preview'
301255 // TODO: 目前mf只有Options写法,后续再放开compositon
302- const url = ` ${import .meta .env .VITE_PLAYGROUND_URL }?cmpId=${cmpId }&fileName=${props . demo .codeFiles [0 ]}&apiMode=${
256+ const url = ` ${import .meta .env .VITE_PLAYGROUND_URL }?cmpId=${cmpId }&fileName=${demo .codeFiles [0 ]}&apiMode=${
303257 isMobileFirst .value ? ' Options' : apiModeState .apiMode
304258 }&mode=${templateModeState .mode }&theme=${tinyTheme }${openModeQuery } `
305259
@@ -342,11 +296,6 @@ onBeforeUnmount(() => {
342296 padding : 20px 24px ;
343297}
344298
345- .is-mobile-first {
346- padding : 20px ;
347- border : 1px solid #dcdfe6 ;
348- }
349-
350299.demo-desc {
351300 font-size : 16px ;
352301 line-height : 1.7em ;
@@ -399,23 +348,6 @@ onBeforeUnmount(() => {
399348 .pc-demo-container {
400349 overflow : auto ;
401350 }
402- .demo-mobile-first-container {
403- cursor : pointer ;
404- width : 100% ;
405- .is-mobile-first {
406- .demo-title {
407- width : 200px ;
408- font-size : 18px ;
409- white-space : nowrap ;
410- overflow : hidden ;
411- text-overflow : ellipsis ;
412- }
413- .demo-options {
414- top : 0px ;
415- right : 0px ;
416- }
417- }
418- }
419351}
420352
421353.pc-demo-container {
0 commit comments