149 lines
3.1 KiB
Vue
Raw Normal View History

2022-01-06 13:45:51 +08:00
<template>
<!-- 每个小模块的公共样式 -->
2022-01-06 13:45:51 +08:00
<div class="go-content-box" :class="[`bg-depth${depth}`, flex && 'flex']">
2022-01-08 21:01:52 +08:00
<div v-if="showTop" class="top go-mt-0 go-flex-no-wrap">
<n-space class="go-flex-no-wrap" :size="5">
2022-01-08 21:01:52 +08:00
<n-ellipsis>
<n-text>{{ title }}</n-text>
</n-ellipsis>
<div class="mt-1">
<slot name="icon"></slot>
</div>
</n-space>
2022-01-06 13:45:51 +08:00
<n-space>
<slot name="top-right"></slot>
<n-icon v-show="backIcon" size="20" class="go-cursor-pointer" @click="backHandle">
2022-03-14 19:52:01 +08:00
<chevron-back-outline-icon></chevron-back-outline-icon>
2022-01-06 13:45:51 +08:00
</n-icon>
</n-space>
</div>
2022-01-20 22:13:51 +08:00
<aside class="content" :class="{'content-height-show-top': showTop}">
2022-01-28 21:05:07 +08:00
<template v-if="xScroll">
<n-scrollbar x-scrollable>
<n-scrollbar>
<slot></slot>
</n-scrollbar>
</n-scrollbar>
</template>
<template v-else>
2022-01-20 21:25:35 +08:00
<n-scrollbar>
<slot></slot>
</n-scrollbar>
2022-01-28 21:05:07 +08:00
</template>
2022-01-06 13:45:51 +08:00
</aside>
2022-01-20 22:13:51 +08:00
2022-01-06 13:45:51 +08:00
<div v-if="showBottom" class="bottom go-mt-0">
<slot name="bottom"></slot>
</div>
</div>
</template>
<script setup lang="ts">
import { icon } from '@/plugins'
const { ChevronBackOutlineIcon } = icon.ionicons5
2022-01-20 22:13:51 +08:00
2022-01-08 21:01:52 +08:00
const emit = defineEmits(['back'])
2022-01-06 13:45:51 +08:00
defineProps({
title: String,
showTop: {
type: Boolean,
default: true
},
showBottom: {
type: Boolean,
default: false
},
flex: {
type: Boolean,
default: false
},
2022-01-08 21:01:52 +08:00
// back
backIcon: {
type: Boolean,
default: true
},
2022-01-06 13:45:51 +08:00
// 背景深度
depth: {
type: Number,
default: 1
2022-01-28 21:05:07 +08:00
},
// x 轴滚动
xScroll: {
type: Boolean,
default: false
2022-01-06 13:45:51 +08:00
}
})
2022-01-08 21:01:52 +08:00
const backHandle = () => {
emit('back')
}
2022-01-06 13:45:51 +08:00
</script>
<style lang="scss" scoped>
2022-01-21 17:55:35 +08:00
$topHeight: 40px;
2022-01-06 13:45:51 +08:00
@include go(content-box) {
height: calc(100vh - #{$--header-height});
margin: 1px;
margin-bottom: 0;
&.bg-depth0 {
@include filter-bg-color("background-color1");
2022-01-06 13:45:51 +08:00
.bottom,
.top {
@include filter-bg-color("background-color1");
2022-01-06 13:45:51 +08:00
}
}
&.bg-depth1 {
@include filter-bg-color("background-color1");
2022-01-06 13:45:51 +08:00
.bottom,
.top {
@include filter-bg-color("background-color2");
2022-01-06 13:45:51 +08:00
}
}
&.bg-depth2 {
@include filter-bg-color("background-color2");
2022-01-06 13:45:51 +08:00
.bottom,
.top {
@include filter-bg-color("background-color3");
2022-01-06 13:45:51 +08:00
}
}
&.bg-depth3 {
@include filter-bg-color("background-color3");
2022-01-06 13:45:51 +08:00
.bottom,
.top {
@include filter-bg-color("background-color4");
2022-01-06 13:45:51 +08:00
}
}
&.flex {
flex: 1;
}
.top,
.bottom {
display: flex;
justify-content: space-between;
2022-01-08 21:01:52 +08:00
flex-wrap: nowrap;
2022-01-06 13:45:51 +08:00
align-items: center;
2022-01-21 17:55:35 +08:00
height: $topHeight;
2022-01-06 13:45:51 +08:00
padding: 0 10px;
border-top: 1px solid;
@include filter-border-color("hover-border-color");
2022-01-08 21:01:52 +08:00
.mt-1 {
margin-top: 2px;
}
2022-01-06 13:45:51 +08:00
}
2022-01-11 20:56:19 +08:00
.top {
border-bottom: 1px solid;
@include filter-border-color("background-color1");
2022-01-11 20:56:19 +08:00
}
2022-01-06 13:45:51 +08:00
.content {
height: calc(100vh - #{$--header-height});
2022-01-06 13:45:51 +08:00
overflow: hidden;
&.content-height-show-top {
height: calc(100vh - #{$--header-height} - #{$topHeight});
}
2022-01-06 13:45:51 +08:00
}
}
</style>