Skip to content

Commit 315138e

Browse files
feat(preview): Modify the style to be consistent with toolbar save. (#1709)
1 parent a214cba commit 315138e

File tree

8 files changed

+93
-26
lines changed

8 files changed

+93
-26
lines changed

packages/common/component/ToolbarBase.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<span class="toolbar-item-wrap" @click="click">
2+
<span class="toolbar-item-wrap" @click="click($event)">
33
<component :is="getRender()" v-bind="state">
44
<template #default>
55
<slot name="button"></slot>
@@ -47,8 +47,9 @@ export default {
4747
trigger: computed(() => props.trigger)
4848
})
4949
50-
const click = () => {
50+
const click = (e: any) => {
5151
emit('click-api')
52+
e.stopPropagation()
5253
}
5354
5455
const getRender = () => {

packages/common/component/toolbar-built-in/ToolbarBaseButton.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<span v-if="options?.showDots" class="dot"></span>
44
<tiny-button class="toolbar-button">
55
<svg-icon v-if="icon" :name="icon"></svg-icon>
6-
<span class="save-title">{{ content }}</span>
6+
<span v-if="options?.showTitle !== false" class="save-title">{{ content }}</span>
77
<slot></slot>
88
</tiny-button>
99
</div>
@@ -36,12 +36,15 @@ export default {
3636
.toolbar-button {
3737
background-color: var(--te-component-toolbar-base-button-bg-color) !important;
3838
border: none !important;
39-
min-width: 70px;
39+
min-width: 60px;
4040
height: 26px;
4141
line-height: 24px;
4242
padding: 0 8px;
4343
border-radius: 4px;
4444
margin-right: 4px;
45+
.svg-icon {
46+
color: var(--te-component-common-icon-color-primary) !important;
47+
}
4548
}
4649
4750
.svg-wrap {
@@ -57,8 +60,8 @@ export default {
5760
right: 2px;
5861
z-index: 100;
5962
}
60-
.svg-icon.svg-icon.svg-icon {
61-
color: var(--te-component-common-icon-color-primary);
62-
}
63+
}
64+
.tiny-popover.no-arrow {
65+
margin-top: 12px;
6366
}
6467
</style>

packages/design-core/registry.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
Fullscreen,
1818
Lang,
1919
ViewSetting,
20-
Logo,
20+
// Logo,
2121
Lock,
2222
Media,
2323
Redoundo,
@@ -138,7 +138,7 @@ export default {
138138
layout: __TINY_ENGINE_REMOVED_REGISTRY['engine.layout'] === false ? null : Layout,
139139
toolbars: [
140140
__TINY_ENGINE_REMOVED_REGISTRY['engine.toolbars.themeSwitch'] === false ? null : ThemeSwitch,
141-
__TINY_ENGINE_REMOVED_REGISTRY['engine.toolbars.logo'] === false ? null : Logo,
141+
//__TINY_ENGINE_REMOVED_REGISTRY['engine.toolbars.logo'] === false ? null : Logo,
142142
__TINY_ENGINE_REMOVED_REGISTRY['engine.toolbars.breadcrumb'] === false ? null : Breadcrumb,
143143
__TINY_ENGINE_REMOVED_REGISTRY['engine.toolbars.lock'] === false ? null : Lock,
144144
__TINY_ENGINE_REMOVED_REGISTRY['engine.toolbars.media'] === false ? null : Media,

packages/toolbars/preview/meta.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export default {
66
icon: {
77
default: 'preview'
88
},
9-
renderType: 'icon',
9+
renderType: 'button',
10+
showTitle: false,
1011
previewUrl: ''
1112
}
1213
}

packages/toolbars/preview/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"homepage": "https://opentiny.design/tiny-engine",
2727
"dependencies": {
2828
"@opentiny/tiny-engine-common": "workspace:*",
29-
"@opentiny/tiny-engine-meta-register": "workspace:*"
29+
"@opentiny/tiny-engine-meta-register": "workspace:*",
30+
"@opentiny/tiny-engine-utils": "workspace:*"
3031
},
3132
"devDependencies": {
3233
"@opentiny/tiny-engine-vite-plugin-meta-comments": "workspace:*",
@@ -36,6 +37,7 @@
3637
},
3738
"peerDependencies": {
3839
"@opentiny/vue": "^3.20.0",
40+
"@opentiny/vue-icon": "^3.20.0",
3941
"vue": "^3.4.15"
4042
}
4143
}

packages/toolbars/preview/src/Main.vue

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
<template>
2-
<div class="toolbar-save toolbar-helpGuid">
3-
<toolbar-base content="预览页面" :icon="options.icon?.default || options?.icon" :options="options" trigger="hover">
2+
<div class="toolbar-preview">
3+
<toolbar-base
4+
content="预览"
5+
:icon="options.icon?.default || options?.icon"
6+
:options="options"
7+
trigger="hover"
8+
@click-api="preview('page')"
9+
>
410
<template #button>
5-
<div class="toolbar-preview-item">
6-
<span @click="preview('page')">页面预览</span>
7-
<span @click="preview('app')">应用预览</span>
8-
</div>
11+
<tiny-popover
12+
:visible-arrow="false"
13+
width="85"
14+
trigger="manual"
15+
:open-delay="OPEN_DELAY.Default"
16+
v-model="poperVisible"
17+
>
18+
<template #reference>
19+
<span @click.stop="clickPopover">
20+
<tiny-icon-up-ward v-if="poperVisible"></tiny-icon-up-ward>
21+
<tiny-icon-down-ward v-else></tiny-icon-down-ward>
22+
</span>
23+
</template>
24+
<div class="toolbar-preview-item">
25+
<span @click="preview('page')">页面预览</span>
26+
<span @click="preview('app')">应用预览</span>
27+
</div>
28+
</tiny-popover>
929
</template>
1030
</toolbar-base>
1131
</div>
@@ -15,11 +35,20 @@
1535
/* metaService: engine.toolbars.preview.Main */
1636
import { previewPage } from '@opentiny/tiny-engine-common/js/preview'
1737
import { useLayout, useNotify, getOptions } from '@opentiny/tiny-engine-meta-register'
38+
import { constants } from '@opentiny/tiny-engine-utils'
39+
import { ref } from 'vue'
40+
import type { Component } from 'vue'
41+
import { Popover } from '@opentiny/vue'
42+
import { iconUpWard, iconDownWard } from '@opentiny/vue-icon'
1843
import meta from '../meta'
1944
import { ToolbarBase } from '@opentiny/tiny-engine-common'
45+
const { OPEN_DELAY } = constants
2046
2147
export default {
2248
components: {
49+
TinyPopover: Popover as Component,
50+
TinyIconUpWard: iconUpWard(),
51+
TinyIconDownWard: iconDownWard(),
2352
ToolbarBase
2453
},
2554
props: {
@@ -29,6 +58,14 @@ export default {
2958
}
3059
},
3160
setup() {
61+
const poperVisible = ref(false)
62+
const clickPopover = () => {
63+
poperVisible.value = !poperVisible.value
64+
}
65+
66+
const closePopover = () => {
67+
poperVisible.value = false
68+
}
3269
const preview = async (previewType: string) => {
3370
const { beforePreview, previewMethod, afterPreview } = getOptions(meta.id)
3471
@@ -60,7 +97,7 @@ export default {
6097
}
6198
6299
previewPage({ previewType })
63-
100+
closePopover()
64101
if (typeof afterPreview === 'function') {
65102
try {
66103
await afterPreview()
@@ -74,7 +111,10 @@ export default {
74111
}
75112
76113
return {
77-
preview
114+
poperVisible,
115+
clickPopover,
116+
preview,
117+
OPEN_DELAY
78118
}
79119
}
80120
}
@@ -84,10 +124,14 @@ export default {
84124
display: flex;
85125
justify-content: center;
86126
flex-direction: column;
87-
gap: 8px;
88127
89128
span {
90129
cursor: pointer;
130+
line-height: 28px;
131+
padding: 0 2px;
132+
&:first-child {
133+
border-bottom: 1px solid var(--te-common-border-divider);
134+
}
91135
}
92136
}
93137
</style>

packages/toolbars/save/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
},
3838
"peerDependencies": {
3939
"@opentiny/vue": "^3.20.0",
40+
"@opentiny/vue-icon": "^3.20.0",
4041
"vue": "^3.4.15"
4142
}
4243
}

packages/toolbars/save/src/Main.vue

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,18 @@
77
@click-api="openApi"
88
>
99
<template #button>
10-
<tiny-popover :visible-arrow="false" width="203" trigger="click" :open-delay="OPEN_DELAY.Default">
10+
<tiny-popover
11+
:visible-arrow="false"
12+
width="203"
13+
trigger="manual"
14+
:open-delay="OPEN_DELAY.Default"
15+
v-model="poperVisible"
16+
>
1117
<template #reference>
12-
<svg-icon :name="iconExpand"></svg-icon>
18+
<span @click.stop="clickPopover">
19+
<tiny-icon-up-ward v-if="poperVisible"></tiny-icon-up-ward>
20+
<tiny-icon-down-ward v-else></tiny-icon-down-ward>
21+
</span>
1322
</template>
1423
<div class="save-style">
1524
<div class="save-setting">保存设置</div>
@@ -60,6 +69,7 @@ import { reactive, ref, onUnmounted, onMounted } from 'vue'
6069
import type { Component } from 'vue'
6170
import { VueMonaco } from '@opentiny/tiny-engine-common'
6271
import { Button, Popover, DialogBox, Checkbox, Select } from '@opentiny/vue'
72+
import { iconUpWard, iconDownWard } from '@opentiny/vue-icon'
6373
import { useCanvas, useMessage } from '@opentiny/tiny-engine-meta-register'
6474
import { ToolbarBase } from '@opentiny/tiny-engine-common'
6575
import { openCommon, saveCommon } from './js/index'
@@ -79,13 +89,11 @@ export default {
7989
TinyDialogBox: DialogBox,
8090
TinyCheckbox: Checkbox as Component,
8191
TinySelect: Select,
92+
TinyIconUpWard: iconUpWard(),
93+
TinyIconDownWard: iconDownWard(),
8294
ToolbarBase
8395
},
8496
props: {
85-
iconExpand: {
86-
type: String,
87-
default: 'down-arrow'
88-
},
8997
options: {
9098
type: Object,
9199
default: () => ({})
@@ -107,6 +115,7 @@ export default {
107115
})
108116
109117
const editor = ref(null)
118+
const poperVisible = ref(false)
110119
111120
const { isSaved, setSaved, getSchema } = useCanvas()
112121
@@ -115,6 +124,10 @@ export default {
115124
116125
const originSchema = ref(null)
117126
127+
const clickPopover = () => {
128+
poperVisible.value = !poperVisible.value
129+
}
130+
118131
onMounted(() => {
119132
// 订阅页面/区块初始化事件
120133
subscribe({
@@ -207,9 +220,11 @@ export default {
207220
return {
208221
state,
209222
editor,
223+
poperVisible,
210224
editorOptions,
211225
isLoading,
212226
isSaved,
227+
clickPopover,
213228
close,
214229
openApi,
215230
saveApi,

0 commit comments

Comments
 (0)