185 lines
3.7 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>
2023-03-16 11:51:45 +08:00
<n-space class="go-flex-no-wrap" align="center" style="gap: 4px">
2022-01-06 13:45:51 +08:00
<slot name="top-right"></slot>
2022-09-27 20:14:00 +08:00
<n-icon v-show="backIcon" size="20" class="go-cursor-pointer go-d-block" @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
2022-12-16 19:08:34 +08:00
<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">
2022-01-28 21:05:07 +08:00
<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>
</div>
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 class="aside">
<slot name="aside"></slot>
</div>
2022-01-06 13:45:51 +08:00
</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-12-16 19:08:34 +08:00
},
disabledScroll: {
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-04-07 19:33:14 +08:00
$topOrBottomHeight: 40px;
2022-12-16 19:08:34 +08:00
2022-01-06 13:45:51 +08:00
@include go(content-box) {
height: calc(100vh - #{$--header-height});
margin: 1px;
margin-bottom: 0;
2022-12-16 19:08:34 +08:00
2022-01-06 13:45:51 +08:00
&.bg-depth0 {
2022-05-02 17:18:18 +08:00
@include fetch-bg-color('background-color1');
2022-12-16 19:08:34 +08:00
2022-01-06 13:45:51 +08:00
.bottom,
.top {
2022-05-02 17:18:18 +08:00
@include fetch-bg-color('background-color1');
2022-01-06 13:45:51 +08:00
}
}
2022-12-16 19:08:34 +08:00
2022-01-06 13:45:51 +08:00
&.bg-depth1 {
2022-05-02 17:18:18 +08:00
@include fetch-bg-color('background-color1');
2022-12-16 19:08:34 +08:00
2022-01-06 13:45:51 +08:00
.bottom,
.top {
2022-05-02 17:18:18 +08:00
@include fetch-bg-color('background-color2');
2022-01-06 13:45:51 +08:00
}
}
2022-12-16 19:08:34 +08:00
2022-01-06 13:45:51 +08:00
&.bg-depth2 {
2022-05-02 17:18:18 +08:00
@include fetch-bg-color('background-color2');
2022-12-16 19:08:34 +08:00
2022-01-06 13:45:51 +08:00
.bottom,
.top {
2022-05-02 17:18:18 +08:00
@include fetch-bg-color('background-color3');
2022-01-06 13:45:51 +08:00
}
}
2022-12-16 19:08:34 +08:00
2022-01-06 13:45:51 +08:00
&.bg-depth3 {
2022-05-02 17:18:18 +08:00
@include fetch-bg-color('background-color3');
2022-12-16 19:08:34 +08:00
2022-01-06 13:45:51 +08:00
.bottom,
.top {
2022-05-02 17:18:18 +08:00
@include fetch-bg-color('background-color4');
2022-01-06 13:45:51 +08:00
}
}
2022-12-16 19:08:34 +08:00
2022-01-06 13:45:51 +08:00
&.flex {
flex: 1;
}
2022-12-16 19:08:34 +08:00
2022-01-06 13:45:51 +08:00
.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-04-07 19:33:14 +08:00
height: $topOrBottomHeight;
2022-01-06 13:45:51 +08:00
padding: 0 10px;
border-top: 1px solid;
2022-05-02 17:18:18 +08:00
@include fetch-border-color('hover-border-color');
2022-12-16 19:08:34 +08:00
2022-01-08 21:01:52 +08:00
.mt-1 {
margin-top: 2px;
}
2022-01-06 13:45:51 +08:00
}
2022-12-16 19:08:34 +08:00
2022-01-11 20:56:19 +08:00
.top {
border-bottom: 1px solid;
2022-05-02 17:18:18 +08:00
@include fetch-border-color('background-color1');
2022-01-11 20:56:19 +08:00
}
2022-09-27 20:14:00 +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;
2022-04-07 19:33:14 +08:00
}
2022-04-09 23:55:09 +08:00
.aside {
position: relative;
}
2022-04-07 19:33:14 +08:00
.content-height-show-top-bottom {
height: calc(100vh - #{$--header-height} - #{$topOrBottomHeight});
}
2022-12-16 19:08:34 +08:00
2022-04-07 19:33:14 +08:00
.content-height-show-both {
2022-09-27 20:14:00 +08:00
height: calc(100vh - #{$--header-height} - #{$topOrBottomHeight} - #{$topOrBottomHeight});
2022-01-06 13:45:51 +08:00
}
}
</style>