reader-header.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <view class="header" v-if="show" :style="headerStyle">
  3. <view class="header-left">
  4. <view class="back-btn" @tap="onBack">
  5. <text class="iconfont icon-left"></text>
  6. </view>
  7. </view>
  8. <view class="header-right">
  9. <view class="icon-btn" @tap="onSearch">
  10. <text class="iconfont icon-search"></text>
  11. <text class="icon-text">搜索</text>
  12. </view>
  13. <view class="icon-btn" @tap="onAddToShelf">
  14. <text class="iconfont icon-bookshelf"></text>
  15. <text class="icon-text">加入书架</text>
  16. </view>
  17. <view class="icon-btn" @tap="onAddBookmark">
  18. <text class="iconfont icon-bookmark"></text>
  19. <text class="icon-text">添加书签</text>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. name: 'ReaderHeader',
  27. props: {
  28. show: {
  29. type: Boolean,
  30. default: false
  31. },
  32. capsuleInfo: {
  33. type: Object,
  34. default: () => ({
  35. height: 0,
  36. top: 0,
  37. right: 0,
  38. statusBarHeight: 0
  39. })
  40. },
  41. headerHeight: {
  42. type: Number,
  43. default: 90
  44. }
  45. },
  46. computed: {
  47. headerStyle() {
  48. return {
  49. height: `${this.headerHeight}rpx`,
  50. paddingTop: `${this.capsuleInfo.statusBarHeight}px`
  51. }
  52. }
  53. },
  54. methods: {
  55. onBack() {
  56. this.$emit('back')
  57. },
  58. onSearch() {
  59. this.$emit('search')
  60. },
  61. onAddToShelf() {
  62. this.$emit('add-to-shelf')
  63. },
  64. onAddBookmark() {
  65. this.$emit('add-bookmark')
  66. }
  67. }
  68. }
  69. </script>
  70. <style scoped>
  71. .header {
  72. position: fixed;
  73. top: 0;
  74. left: 0;
  75. right: 0;
  76. display: flex;
  77. justify-content: space-between;
  78. align-items: center;
  79. padding-left: 20rpx;
  80. padding-right: 20rpx;
  81. background-color: #ffffff;
  82. z-index: 100;
  83. }
  84. .header-left,
  85. .header-right {
  86. display: flex;
  87. align-items: center;
  88. }
  89. .header-right {
  90. gap: 30rpx;
  91. }
  92. .back-btn,
  93. .icon-btn {
  94. display: flex;
  95. flex-direction: column;
  96. align-items: center;
  97. color: #000000;
  98. }
  99. .icon {
  100. font-family: "iconfont";
  101. font-size: 40rpx;
  102. }
  103. .icon-text {
  104. font-size: 20rpx;
  105. margin-top: 4rpx;
  106. }
  107. </style>