| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <template>
- <view class="header" v-if="show" :style="headerStyle">
- <view class="header-left">
- <view class="back-btn" @tap="onBack">
- <text class="iconfont icon-left"></text>
- </view>
- </view>
- <view class="header-right">
- <view class="icon-btn" @tap="onSearch">
- <text class="iconfont icon-search"></text>
- <text class="icon-text">搜索</text>
- </view>
- <view class="icon-btn" @tap="onAddToShelf">
- <text class="iconfont icon-bookshelf"></text>
- <text class="icon-text">加入书架</text>
- </view>
- <view class="icon-btn" @tap="onAddBookmark">
- <text class="iconfont icon-bookmark"></text>
- <text class="icon-text">添加书签</text>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: 'ReaderHeader',
- props: {
- show: {
- type: Boolean,
- default: false
- },
- capsuleInfo: {
- type: Object,
- default: () => ({
- height: 0,
- top: 0,
- right: 0,
- statusBarHeight: 0
- })
- },
- headerHeight: {
- type: Number,
- default: 90
- }
- },
- computed: {
- headerStyle() {
- return {
- height: `${this.headerHeight}rpx`,
- paddingTop: `${this.capsuleInfo.statusBarHeight}px`
- }
- }
- },
- methods: {
- onBack() {
- this.$emit('back')
- },
- onSearch() {
- this.$emit('search')
- },
- onAddToShelf() {
- this.$emit('add-to-shelf')
- },
- onAddBookmark() {
- this.$emit('add-bookmark')
- }
- }
- }
- </script>
- <style scoped>
- .header {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding-left: 20rpx;
- padding-right: 20rpx;
- background-color: #ffffff;
- z-index: 100;
- }
- .header-left,
- .header-right {
- display: flex;
- align-items: center;
- }
- .header-right {
- gap: 30rpx;
- }
- .back-btn,
- .icon-btn {
- display: flex;
- flex-direction: column;
- align-items: center;
- color: #000000;
- }
- .icon {
- font-family: "iconfont";
- font-size: 40rpx;
- }
- .icon-text {
- font-size: 20rpx;
- margin-top: 4rpx;
- }
- </style>
|