settingMenu.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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="db_color" @change="change">
  4. <view v-if="showSettingFontSizeMode==false" class="selects-box">
  5. <view @click="emit('clickPreChapter')" :style="{'color':font_color}">上一章</view>
  6. <view @click="emit('clickKeep')" style="align-items: center; display: flex;">
  7. <image src="../../static/logo.png" style="width: 40rpx;height: 40rpx; margin-right: 10px;"></image>
  8. <view :style="{'color':font_color}">{{BookshelfStatusTitle}}</view>
  9. </view>
  10. <view @click="emit('clickNextChapter')" :style="{'color':font_color}">下一章</view>
  11. </view>
  12. <view v-if="showSettingFontSizeMode==false" class="popup-content">
  13. <view class="items-box">
  14. <view class="item-box" @click="emit('clickCatalog')" :style="{'color':font_color}">
  15. 目录
  16. </view>
  17. <view class="item-box" v-if="mode === config.read_config.readMode.Bright" @click="emit('clickMode',config.read_config.readMode.Dark)" :style="{'color':font_color}">
  18. 夜间
  19. </view>
  20. <view class="item-box" v-if="mode === config.read_config.readMode.Dark" @click="emit('clickMode',config.read_config.readMode.Bright)" :style="{'color':font_color}">
  21. 日间
  22. </view>
  23. <view class="item-box" @click="emit('clickOpenSetting')" :style="{'color':font_color}">
  24. 设置
  25. </view>
  26. </view>
  27. </view>
  28. <view v-if="showSettingFontSizeMode==true" class="fontSelect" >
  29. <view :style="{'color':font_color}">字号</view>
  30. <view @touchstart="emit('changeFontSize',-1)" :style="{'color':font_color}">小</view>
  31. <view :style="{'color':font_color}">{{showFontSize}}</view>
  32. <view @touchstart="emit('changeFontSize',+1)" :style="{'color':font_color}">大</view>
  33. </view>
  34. <view v-if="showSettingFontSizeMode==true" style="height: 10rpx;"></view>
  35. <view v-if="showSettingFontSizeMode==true" style="display: flex;justify-content: space-between;" >
  36. <view style="margin-left: 50rpx;" :style="{'color':font_color}">颜色</view>
  37. <image @touchstart="emit('changeBgColor',0)" src="../../static/logo.png" style="width: 50rpx;height: 50rpx;"></image>
  38. <image @touchstart="emit('changeBgColor',1)" src="../../static/logo.png" style="width: 50rpx;height: 50rpx;"></image>
  39. <image @touchstart="emit('changeBgColor',2)" src="../../static/logo.png" style="width: 50rpx;height: 50rpx;"></image>
  40. <image @touchstart="emit('changeBgColor',3)" src="../../static/logo.png" style="width: 50rpx;height: 50rpx;"></image>
  41. <image @touchstart="emit('changeBgColor',4)" src="../../static/logo.png" style="width: 50rpx;height: 50rpx; margin-right: 50rpx;"></image>
  42. </view>
  43. <view v-if="showSettingFontSizeMode==true" style="height: 30rpx;" ></view>
  44. <view v-if="showSettingFontSizeMode==true" style="display: flex;justify-content: center; align-items: center; ">
  45. <checkbox-group @change="emit('selectAutoBuy',!isAutoBuy)">
  46. <checkbox :checked="isAutoBuy" value="cb" :style="{'color':font_color}"> 自动购买下一章 </checkbox>
  47. </checkbox-group>
  48. </view>
  49. <view v-if="showSettingFontSizeMode==true" style="height: 50rpx;"></view>
  50. </uni-popup>
  51. </view>
  52. </template>
  53. <script setup lang="ts">
  54. import {ref, onMounted,defineProps,defineEmits, watch} from 'vue'
  55. import { config } from '../../config/config';
  56. import { ReadSetting } from '../../stores/readSetting';
  57. import { tools } from '../../framework/tools';
  58. const emit = defineEmits(['clickCatalog','clickPreChapter','clickNextChapter','clickMode','clickOpenSetting','Close','changeFontSize','changeBgColor','selectAutoBuy','clickKeep'])
  59. // const { windowWidth, windowHeight, statusBarHeight, platform, pixelRatio } = uni.getSystemInfoSync();
  60. const {book_id} = defineProps(['book_id'])
  61. let menu = ref(null)
  62. function change(e){
  63. if(e.show==false){
  64. emit('Close')
  65. }
  66. // console.log('当前模式:' + e.type + ',状态:' + e.show);
  67. }
  68. let type = 'bottom'
  69. onMounted(()=>{
  70. // open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
  71. menu.value.open(type)
  72. })
  73. let mode = ref(ReadSetting().data.readMode)
  74. let startPosY = ref(-1)
  75. function maskTouch(e){
  76. if(Math.abs(e.changedTouches[0].pageY-startPosY.value)>10){
  77. startPosY.value = -1
  78. emit('Close')
  79. }
  80. }
  81. function maskStart(e){
  82. startPosY.value = e.changedTouches[0].pageY
  83. }
  84. let showSettingFontSizeMode = ref(false)
  85. function showSettingFont(){
  86. showSettingFontSizeMode.value = true
  87. }
  88. let showFontSize = ref(config.read_config.fontSizeList[ReadSetting().getReadSetting().fontSizeIndex])
  89. let bgColorIndex = ref(ReadSetting().data.colorBgIndex)
  90. let isAutoBuy = ref(ReadSetting().data.autoBuyNextChpater)
  91. watch(
  92. () => ReadSetting().data.fontSizeIndex, // 监听的数据源
  93. (newVal, oldVal) => {
  94. // console.log(`Count changed from ${oldVal} to ${newVal}`);
  95. showFontSize.value = config.read_config.fontSizeList[ReadSetting().data.fontSizeIndex]
  96. // 可以在这里执行一些操作,比如更新其他状态或触发其他函数
  97. }
  98. );
  99. watch(() => ReadSetting().data.autoBuyNextChpater, // 监听的数据源
  100. (newVal, oldVal) => {
  101. isAutoBuy.value = newVal
  102. }
  103. );
  104. watch(() => ReadSetting().data.readMode, // 监听的数据源
  105. (newVal, oldVal) => {
  106. mode.value = ReadSetting().data.readMode
  107. font_color.value = tools.getFontColorByMode(ReadSetting().data.readMode)
  108. db_color.value = tools.getDbColorByMode(ReadSetting().data.readMode)
  109. }
  110. );
  111. let font_color = ref(tools.getFontColorByMode(ReadSetting().data.readMode))
  112. let db_color = ref(tools.getDbColorByMode(ReadSetting().data.readMode))
  113. let BookshelfStatusTitle = ref('加入书架')
  114. tools.checkBookOnBookshelf(book_id,(is_on)=>{
  115. BookshelfStatusTitle.value = '已添加书架'
  116. })
  117. defineExpose({showSettingFont})
  118. </script>
  119. <style lang="scss" scoped>
  120. .selects-box{
  121. display: flex;
  122. justify-content: space-around;
  123. align-items: center;
  124. height: 80px;
  125. width: 100%;
  126. .item-box {
  127. display: flex;
  128. flex-flow: column;
  129. justify-content: center;
  130. align-items: center;
  131. height: 100%;
  132. }
  133. }
  134. .items-box {
  135. display: flex;
  136. justify-content: space-around;
  137. align-items: center;
  138. height: 80px;
  139. width: 100%;
  140. margin-bottom: 5%;
  141. .item-box {
  142. display: flex;
  143. flex-flow: column;
  144. justify-content: center;
  145. align-items: center;
  146. height: 100%;
  147. }
  148. }
  149. .fontSelect {
  150. display: flex;
  151. justify-content: space-around;
  152. align-items: center;
  153. height: 80px;
  154. width: 100%;
  155. }
  156. </style>