index.vue
3.66 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<template>
<!-- 每个小模块的公共样式 -->
<div class="go-content-box" :class="[`bg-depth${depth}`, flex && 'flex']">
<div v-if="showTop" class="top go-mt-0 go-flex-no-wrap">
<n-space class="go-flex-no-wrap" :size="5">
<n-ellipsis>
<n-text>{{ title }}</n-text>
</n-ellipsis>
<div class="mt-1">
<slot name="icon"></slot>
</div>
</n-space>
<n-space class="go-flex-no-wrap" align="center" style="gap: 4px">
<slot name="top-right"></slot>
<n-icon v-show="backIcon" size="20" class="go-cursor-pointer go-d-block" @click="backHandle">
<chevron-back-outline-icon></chevron-back-outline-icon>
</n-icon>
</n-space>
</div>
<div class="content" :class="{
'content-height-show-top-bottom': showBottom || showTop,
'content-height-show-both': showBottom && showTop
}">
<template v-if="disabledScroll">
<slot></slot>
</template>
<template v-else-if="xScroll">
<n-scrollbar x-scrollable>
<n-scrollbar>
<slot></slot>
</n-scrollbar>
</n-scrollbar>
</template>
<template v-else>
<n-scrollbar>
<slot></slot>
</n-scrollbar>
</template>
</div>
<div v-if="showBottom" class="bottom go-mt-0">
<slot name="bottom"></slot>
</div>
<div class="aside">
<slot name="aside"></slot>
</div>
</div>
</template>
<script setup lang="ts">
import { icon } from '@/plugins'
const { ChevronBackOutlineIcon } = icon.ionicons5
const emit = defineEmits(['back'])
defineProps({
title: String,
showTop: {
type: Boolean,
default: true
},
showBottom: {
type: Boolean,
default: false
},
flex: {
type: Boolean,
default: false
},
// back
backIcon: {
type: Boolean,
default: true
},
// 背景深度
depth: {
type: Number,
default: 1
},
// x 轴滚动
xScroll: {
type: Boolean,
default: false
},
disabledScroll: {
type: Boolean,
default: false
},
})
const backHandle = () => {
emit('back')
}
</script>
<style lang="scss" scoped>
$topOrBottomHeight: 40px;
@include go(content-box) {
height: calc(100vh - #{$--header-height});
margin: 1px;
margin-bottom: 0;
&.bg-depth0 {
@include fetch-bg-color('background-color1');
.bottom,
.top {
@include fetch-bg-color('background-color1');
}
}
&.bg-depth1 {
@include fetch-bg-color('background-color1');
.bottom,
.top {
@include fetch-bg-color('background-color2');
}
}
&.bg-depth2 {
@include fetch-bg-color('background-color2');
.bottom,
.top {
@include fetch-bg-color('background-color3');
}
}
&.bg-depth3 {
@include fetch-bg-color('background-color3');
.bottom,
.top {
@include fetch-bg-color('background-color4');
}
}
&.flex {
flex: 1;
}
.top,
.bottom {
display: flex;
justify-content: space-between;
flex-wrap: nowrap;
align-items: center;
height: $topOrBottomHeight;
padding: 0 10px;
border-top: 1px solid;
@include fetch-border-color('hover-border-color');
.mt-1 {
margin-top: 2px;
}
}
.top {
border-bottom: 1px solid;
@include fetch-border-color('background-color1');
}
.content {
height: calc(100vh - #{$--header-height});
overflow: hidden;
}
.aside {
position: relative;
}
.content-height-show-top-bottom {
height: calc(100vh - #{$--header-height} - #{$topOrBottomHeight});
}
.content-height-show-both {
height: calc(100vh - #{$--header-height} - #{$topOrBottomHeight} - #{$topOrBottomHeight});
}
}
</style>