小说小程序前端代码仓库(小程序)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
2.7 KiB

  1. # 小说阅读相关组件
  2. 本目录包含小说阅读页面使用的各种公共组件,所有组件都支持暗色主题模式。
  3. ## 组件列表
  4. ### 1. 订阅弹窗 (subscriptionPopup.vue)
  5. 中心弹出的订阅章节提示弹窗。
  6. #### 使用方法
  7. ```html
  8. <template>
  9. <subscriptionPopup ref="subscriptionPopup" @subscribe="handleSubscribe"/>
  10. </template>
  11. <script>
  12. import subscriptionPopup from 'pages_order/components/novel/subscriptionPopup.vue'
  13. export default {
  14. components: {
  15. subscriptionPopup
  16. },
  17. methods: {
  18. showSubscriptionPopup() {
  19. this.$refs.subscriptionPopup.open()
  20. },
  21. handleSubscribe() {
  22. // 处理订阅事件
  23. }
  24. }
  25. }
  26. </script>
  27. ```
  28. ### 2. 支付弹窗 (paymentPopup.vue)
  29. 从底部弹出的支付方式选择弹窗。
  30. #### 使用方法
  31. ```html
  32. <template>
  33. <paymentPopup ref="paymentPopup" @subscribe="handleSubscribe" @close="handleClose"/>
  34. </template>
  35. <script>
  36. import paymentPopup from 'pages_order/components/novel/paymentPopup.vue'
  37. export default {
  38. components: {
  39. paymentPopup
  40. },
  41. methods: {
  42. showPaymentPopup() {
  43. this.$refs.paymentPopup.open()
  44. },
  45. handleSubscribe() {
  46. // 处理订阅事件
  47. },
  48. handleClose() {
  49. // 处理关闭事件
  50. }
  51. }
  52. }
  53. </script>
  54. ```
  55. ### 3. 章节目录弹窗 (chapterPopup.vue)
  56. 显示小说章节列表的弹窗。
  57. #### 使用方法
  58. ```html
  59. <template>
  60. <chapterPopup ref="chapterPopup"/>
  61. </template>
  62. <script>
  63. import chapterPopup from 'pages_order/components/novel/chapterPopup.vue'
  64. export default {
  65. components: {
  66. chapterPopup
  67. },
  68. methods: {
  69. showChapterList() {
  70. this.$refs.chapterPopup.open()
  71. }
  72. }
  73. }
  74. </script>
  75. ```
  76. ### 4. 评分弹窗 (novelVotePopup.vue)
  77. 用于评价小说的弹窗组件。
  78. ## 暗色主题支持
  79. 所有组件都支持暗色主题模式,当系统切换到暗色模式或用户手动切换时,组件会自动应用暗色样式。
  80. ### 主题切换
  81. 主题的状态保存在Vuex中,可以通过以下方式切换:
  82. ```js
  83. // 切换主题模式
  84. this.$store.commit('toggleThemeMode')
  85. // 设置为特定模式
  86. this.$store.commit('setThemeMode', 'dark') // 或 'light'
  87. // 获取当前主题模式
  88. const isDarkMode = this.$store.getters.isDarkMode
  89. ```
  90. ### 使用主题混入器
  91. 为了方便在组件中使用主题相关功能,可以引入主题混入器:
  92. ```js
  93. import themeMixin from '@/mixins/themeMode.js'
  94. export default {
  95. mixins: [themeMixin],
  96. // 然后可以直接使用以下属性和方法
  97. created() {
  98. console.log(this.isDarkMode) // 是否为暗色模式
  99. console.log(this.currentTheme) // 'light' 或 'dark'
  100. // 切换主题
  101. this.toggleThemeMode()
  102. }
  103. }
  104. ```
  105. 详细的文档请参考 `doc/dark-mode-guide.md`