├── php-api/ # 改造后的PHP接口层 ├── java-ad-service/ # 若依框架微服务(广告+VIP+分账) ├── uniapp-reader/ # UniApp前端项目 │ ├── pages/ # 各端页面 │ └──
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="app-container">
  3. <router-view />
  4. </view>
  5. </template>
  6. <script>
  7. import config from './config'
  8. import { getToken } from '@/utils/auth'
  9. export default {
  10. onLaunch() {
  11. // 检查阅读进度
  12. this.checkReadingProgress()
  13. // 初始化主题(临时实现)
  14. this.initTheme()
  15. // 检查登录状态
  16. //this.checkLogin()
  17. },
  18. onShow() {
  19. // 检查云端阅读进度
  20. if (this.$store.getters.token) {
  21. this.syncReadingProgress()
  22. }
  23. },
  24. methods: {
  25. // 检查阅读进度
  26. checkReadingProgress() {
  27. const chapter = uni.getStorageSync('readingProgress') || 1
  28. // 如果用户阅读超过5章但未登录,提示登录
  29. if (chapter > 5 && !uni.getStorageSync('token')) {
  30. uni.showModal({
  31. title: '登录提示',
  32. content: `您已阅读到第${chapter}章,登录后继续阅读`,
  33. confirmText: '立即登录',
  34. success: (res) => {
  35. if (res.confirm) {
  36. uni.navigateTo({
  37. url: '/pages/login'
  38. })
  39. }
  40. }
  41. })
  42. }
  43. },
  44. async syncReadingProgress() {
  45. try {
  46. const res = await this.$api.getReadingProgress()
  47. const cloudChapter = res.data.chapter
  48. const localChapter = uni.getStorageSync('readingProgress') || 1
  49. // 使用最新的阅读进度
  50. if (cloudChapter > localChapter) {
  51. uni.setStorageSync('readingProgress', cloudChapter)
  52. } else if (localChapter > cloudChapter) {
  53. await this.$api.saveReadingProgress(localChapter)
  54. }
  55. } catch (err) {
  56. console.error('同步阅读进度失败', err)
  57. }
  58. },
  59. // 添加 checkLogin 方法
  60. // checkLogin() {
  61. // // 这里写登录检查逻辑
  62. // // 示例:检查本地存储的登录状态
  63. // const isLoggedIn = uni.getStorageSync('isLogin');
  64. // if (!isLoggedIn) {
  65. // uni.navigateTo({ url: '/pages/login' });
  66. // }
  67. // },
  68. // 临时主题初始化
  69. initTheme() {
  70. const themeName = uni.getStorageSync('selectedTheme') || 'aydzBlue'
  71. // 应用主题变量
  72. const themes = {
  73. aydzBlue: {
  74. '--primary-color': '#2a5caa',
  75. '--bg-color': '#e6f7ff',
  76. '--text-color': '#1a3353',
  77. '--card-bg': '#d0e8ff',
  78. '--header-bg': '#2a5caa'
  79. },
  80. darkMode: {
  81. '--primary-color': '#52c41a',
  82. '--bg-color': '#1a1a1a',
  83. '--text-color': '#e6e6e6',
  84. '--card-bg': '#2a2a2a'
  85. },
  86. default: {
  87. '--primary-color': '#1890ff',
  88. '--bg-color': '#f8f9fa',
  89. '--text-color': '#333',
  90. '--card-bg': '#ffffff'
  91. }
  92. }
  93. const root = document.documentElement
  94. const themeVars = themes[themeName] || themes.aydzBlue
  95. Object.keys(themeVars).forEach(key => {
  96. root.style.setProperty(key, themeVars[key])
  97. })
  98. // 动态设置导航栏颜色
  99. if (themeName === 'darkMode') {
  100. uni.setNavigationBarColor({
  101. frontColor: '#ffffff',
  102. backgroundColor: '#1a1a1a'
  103. })
  104. } else if (themeName === 'aydzBlue') {
  105. uni.setNavigationBarColor({
  106. frontColor: '#ffffff',
  107. backgroundColor: '#2a5caa'
  108. })
  109. }
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss">
  115. /* 保留原有样式 */
  116. uni-tabbar {
  117. z-index: 999;
  118. }
  119. </style>