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 >
1535/* metaService: engine.toolbars.preview.Main */
1636import { previewPage } from ' @opentiny/tiny-engine-common/js/preview'
1737import { 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'
1843import meta from ' ../meta'
1944import { ToolbarBase } from ' @opentiny/tiny-engine-common'
45+ const { OPEN_DELAY } = constants
2046
2147export 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 >
0 commit comments