index.vue
2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<template>
<div class="go-apple-control-btn">
<template v-for="item in filterBtnList" :key="item.key">
<div class="btn" :class="[item.key, disabled && 'disabled', mini && 'mini']" @click.stop="handleClick(item.key)">
<n-tooltip trigger="hover">
<template #trigger>
<n-icon size="10" class="icon-base" :class="{ hover: !disabled }">
<component :is="item.icon"></component>
</n-icon>
</template>
{{ item.title }}
</n-tooltip>
</div>
</template>
</div>
</template>
<script lang="ts" setup>
import { icon } from '@/plugins'
import { computed } from 'vue'
import { screenfullFn } from '@/utils'
const emit = defineEmits(['close', 'remove', 'resize', 'fullResize'])
const props = defineProps({
// mini 版本
mini: {
request: false,
type: Boolean,
default: false
},
// 禁用所有按钮
disabled: {
request: false,
type: Boolean,
default: false
},
// 要隐藏的按钮
hidden: {
request: false,
type: Array,
default() {
return []
}
},
// 使用全屏功能
narrow: {
request: false,
type: Boolean,
default: false
}
})
const t = window['$t']
const { CloseIcon, RemoveIcon, BrowsersOutlineIcon } = icon.ionicons5
const filterBtnList = computed(() => {
const res = btnList.filter(e => {
return props.hidden.findIndex(p => e.key == p) === -1
})
return res
})
const isFull = computed(() => {
return props.narrow && screenfullFn(true)
})
const btnList: {
title: string
key: 'close' | 'remove' | 'resize' | 'fullResize'
icon: any
}[] = [
{
title: t('common.delText'),
key: 'close',
icon: CloseIcon
},
{
title: t('common.reduceText'),
key: 'remove',
icon: RemoveIcon
},
{
title: isFull.value ? t('common.loadThreeModel') : t('common.loadThreeModel'),
key: props.narrow ? 'fullResize' : 'resize',
icon: BrowsersOutlineIcon
}
]
const handleClick = (key: 'close' | 'remove' | 'resize' | 'fullResize') => {
if (key === 'fullResize') screenfullFn()
// 缩小并关闭全屏
if (key === 'remove') screenfullFn(true) && screenfullFn()
emit(key)
}
</script>
<style lang="scss" scoped>
@include go('apple-control-btn') {
display: flex;
&:hover {
.btn {
.hover {
cursor: pointer;
opacity: 1;
}
}
}
.btn {
display: flex;
align-items: center;
justify-content: center;
width: 14px;
height: 14px;
margin: 0 4px;
color: $--color-text;
font-weight: bold;
border-radius: 50%;
&.mini {
width: 8px;
height: 8px;
margin: 0 2px;
}
&.disabled {
pointer-events: none;
}
.icon-base {
opacity: 0;
}
.hover {
@extend .go-transition;
}
}
.close {
background-color: $--color-red;
}
.remove {
background-color: $--color-warn;
}
.resize,
.fullResize {
background-color: $--color-success;
}
}
</style>