settingMenu.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <view>
  3. <uni-popup @touchstart="maskStart" @touchmove="maskTouch" :animation="false" mask-background-color="rgba(0,0,0,0)" ref="menu" background-color="#fff" @change="change">
  4. <view v-if="showSettingFontSizeMode==false" class="selects-box">
  5. <view @click="emit('clickPreChapter')">上一章</view>
  6. <view @click="emit('clickNextChapter')">下一章</view>
  7. </view>
  8. <view v-if="showSettingFontSizeMode==false" class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }">
  9. <view class="items-box">
  10. <view class="item-box" @click="emit('clickCatalog')">
  11. 目录
  12. </view>
  13. <view class="item-box" v-if="mode === config.read_config.readMode.Bright" @click="emit('clickMode',config.read_config.readMode.Dark)">
  14. 夜间
  15. </view>
  16. <view class="item-box" v-if="mode === config.read_config.readMode.Dark" @click="emit('clickMode',config.read_config.readMode.Bright)">
  17. 日间
  18. </view>
  19. <view class="item-box" @click="emit('clickOpenSetting')">
  20. 设置
  21. </view>
  22. </view>
  23. </view>
  24. <view v-if="showSettingFontSizeMode==true" class="fontSelect" >
  25. <view>字体大小</view>
  26. <view> |</view>
  27. <view></view>
  28. </view>
  29. </uni-popup>
  30. </view>
  31. </template>
  32. <script setup lang="ts">
  33. import {ref, onMounted,defineProps,defineEmits} from 'vue'
  34. import { config } from '../../config/config';
  35. import { ReadSetting } from '../../stores/readSetting';
  36. const emit = defineEmits(['clickCatalog','clickPreChapter','clickNextChapter','clickMode','clickOpenSetting','Close'])
  37. // const { windowWidth, windowHeight, statusBarHeight, platform, pixelRatio } = uni.getSystemInfoSync();
  38. let menu = ref(null)
  39. function change(e){
  40. if(e.show==false){
  41. emit('Close')
  42. }
  43. console.log('当前模式:' + e.type + ',状态:' + e.show);
  44. }
  45. onMounted(()=>{
  46. const type = 'bottom'
  47. // open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
  48. menu.value.open(type)
  49. })
  50. let mode = ref(ReadSetting().getReadSetting().readMode)
  51. let startPosY = ref(-1)
  52. function maskTouch(e){
  53. if(Math.abs(e.changedTouches[0].pageY-startPosY.value)>10){
  54. startPosY.value = -1
  55. emit('Close')
  56. }
  57. }
  58. function maskStart(e){
  59. startPosY.value = e.changedTouches[0].pageY
  60. }
  61. let showSettingFontSizeMode = ref(false)
  62. function showSettingFont(){
  63. showSettingFontSizeMode.value = true
  64. }
  65. defineExpose({showSettingFont})
  66. </script>
  67. <style lang="scss" scoped>
  68. .selects-box{
  69. display: flex;
  70. justify-content: space-around;
  71. align-items: center;
  72. height: 80px;
  73. width: 100%;
  74. .item-box {
  75. display: flex;
  76. flex-flow: column;
  77. justify-content: center;
  78. align-items: center;
  79. height: 100%;
  80. }
  81. }
  82. .items-box {
  83. display: flex;
  84. justify-content: space-around;
  85. align-items: center;
  86. height: 80px;
  87. width: 100%;
  88. margin-bottom: 5%;
  89. .item-box {
  90. display: flex;
  91. flex-flow: column;
  92. justify-content: center;
  93. align-items: center;
  94. height: 100%;
  95. }
  96. }
  97. .fontSelect {
  98. display: flex;
  99. justify-content: space-around;
  100. align-items: center;
  101. height: 80px;
  102. width: 100%;
  103. }
  104. </style>