Skip to content

Commit c29f2bd

Browse files
authored
fix(saas): increase the demonstration function of screens of different sizes in the training field (#3880)
* fix: increase the demonstration function of screens of different sizes in the training field * fix: layout reversal, horizontal adjustment * fix: update comment
1 parent a2f29f2 commit c29f2bd

File tree

12 files changed

+248
-352
lines changed

12 files changed

+248
-352
lines changed

examples/sites/playground/App.vue

Lines changed: 226 additions & 64 deletions
Large diffs are not rendered by default.
421 Bytes
Loading
331 Bytes
Loading

examples/sites/saas.html

Lines changed: 0 additions & 13 deletions
This file was deleted.

examples/sites/saas/App.vue

Lines changed: 0 additions & 103 deletions
This file was deleted.

examples/sites/saas/main.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

examples/sites/saas/style.css

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/sites/src/assets/custom-block.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
}
3939
p {
4040
font-size: 14px;
41-
line-height: 30px;
42-
margin-bottom: 11px;
41+
line-height: 21px;
42+
margin-bottom: 0px;
4343
}
4444
code {
4545
margin: 0 4px;

examples/sites/src/assets/right-panel.less

Lines changed: 0 additions & 65 deletions
This file was deleted.

examples/sites/src/components/demo.vue

Lines changed: 6 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
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 -->
@@ -47,37 +43,6 @@
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'
11883
import { i18nByKey, getWord } from '@/i18n'
11984
import { $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'
12186
import { AutoTip as vAutoTip } from '@opentiny/vue-directive'
12287
import { languageMap, vueComponents, getWebdocPath, staticDemoPath } from '../views/components-doc/cmp-config'
12388
import { router } from '@/router.js'
12489
import demoConfig from '@demos/config.js'
12590
import { useApiMode, useTemplateMode } from '@/tools'
126-
import { useBreakpoint } from '@opentiny/vue-common'
12791
import useTheme from '@/tools/useTheme'
12892
import AsyncHighlight from './async-highlight.vue'
129-
import '../assets/right-panel.less'
13093
13194
const props = defineProps({
13295
demo: {
@@ -146,10 +109,9 @@ const props = defineProps({
146109
default: false
147110
}
148111
})
112+
149113
const emit = defineEmits(['mounted', 'get-iframe-demo'])
150-
const iframeRef = ref()
151-
const isSmallScreen = computed(() => useBreakpoint().current.value === 'default')
152-
let screenFlag = ref(false)
114+
153115
const { apiModeState, apiModeFn } = useApiMode()
154116
155117
defineOptions({
@@ -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-
186140
watch(
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

Comments
 (0)