|
|
@@ -1,5 +1,5 @@
|
|
1
|
1
|
<template>
|
|
2
|
|
- <view :class="['app-container', `theme-${themeStore.currentTheme}`]">
|
|
|
2
|
+ <view class="app-container">
|
|
3
|
3
|
<router-view />
|
|
4
|
4
|
</view>
|
|
5
|
5
|
</template>
|
|
|
@@ -7,54 +7,16 @@
|
|
7
|
7
|
<script>
|
|
8
|
8
|
import config from './config'
|
|
9
|
9
|
import { getToken } from '@/utils/auth'
|
|
10
|
|
-import { onLaunch, onShow } from '@dcloudio/uni-app'
|
|
11
|
|
-import { mapState } from 'pinia'
|
|
12
|
|
-import { useThemeStore } from '@/store/theme' // 修正路径
|
|
13
|
|
-import { useUserStore } from '@/store/user' // 修正路径
|
|
14
|
|
-import { useVipStore } from '@/store/vip' // 修正路径
|
|
15
|
|
-import { useReminder } from '@/utils/reminder'
|
|
16
|
|
-import { readingService } from '@/services/readingService'
|
|
17
|
10
|
|
|
18
|
11
|
export default {
|
|
19
|
|
- data() {
|
|
20
|
|
- return {
|
|
21
|
|
- }
|
|
22
|
|
- },
|
|
23
|
|
- computed: {
|
|
24
|
|
- ...mapState(useThemeStore, ['currentTheme']),
|
|
25
|
|
- ...mapState(useUserStore, ['user']),
|
|
26
|
|
- ...mapState(useVipStore, ['vipStatus'])
|
|
27
|
|
- },
|
|
28
|
12
|
onLaunch() {
|
|
29
|
|
- // 初始化主题
|
|
30
|
|
- const themeStore = useThemeStore()
|
|
31
|
|
- themeStore.initTheme()
|
|
32
|
13
|
// 检查登录状态
|
|
33
|
14
|
this.checkLogin()
|
|
34
|
|
- // 初始化用户
|
|
35
|
|
- this.userStore.initUser()
|
|
36
|
|
- // 初始化签到提醒
|
|
37
|
|
- useReminder.init()
|
|
38
|
15
|
|
|
39
|
|
- // 登录成功后同步进度
|
|
40
|
|
- // uni.$on('loginSuccess', async () => {
|
|
41
|
|
- // await readingService.syncAllLocalProgress()
|
|
42
|
|
- // uni.showToast({ title: '阅读进度已同步', icon: 'success' })
|
|
43
|
|
- // })
|
|
44
|
|
-
|
|
45
|
|
- // 检查登录状态
|
|
46
|
|
- //this.checkLogin()
|
|
47
|
|
- },
|
|
48
|
|
- onShow() {
|
|
49
|
|
- // 加载用户和VIP状态
|
|
50
|
|
- this.loadUserData()
|
|
|
16
|
+ // 初始化主题(临时实现)
|
|
|
17
|
+ this.initTheme()
|
|
51
|
18
|
},
|
|
52
|
19
|
methods: {
|
|
53
|
|
- // 初始化应用配置
|
|
54
|
|
- initConfig() {
|
|
55
|
|
- this.globalData.config = config
|
|
56
|
|
- },
|
|
57
|
|
-
|
|
58
|
20
|
// 检查用户登录状态
|
|
59
|
21
|
checkLogin() {
|
|
60
|
22
|
if (!getToken()) {
|
|
|
@@ -62,112 +24,57 @@ export default {
|
|
62
|
24
|
}
|
|
63
|
25
|
},
|
|
64
|
26
|
|
|
65
|
|
- // 同步阅读进度(需要实现)
|
|
66
|
|
- async syncReadingProgress() {
|
|
67
|
|
- // 实现阅读进度同步逻辑
|
|
68
|
|
- console.log('阅读进度同步逻辑待实现')
|
|
|
27
|
+ // 临时主题初始化
|
|
|
28
|
+ initTheme() {
|
|
|
29
|
+ const themeName = uni.getStorageSync('selectedTheme') || 'aydzBlue'
|
|
|
30
|
+
|
|
|
31
|
+ // 应用主题变量
|
|
|
32
|
+ const themes = {
|
|
|
33
|
+ aydzBlue: {
|
|
|
34
|
+ '--primary-color': '#2a5caa',
|
|
|
35
|
+ '--bg-color': '#e6f7ff',
|
|
|
36
|
+ '--text-color': '#1a3353',
|
|
|
37
|
+ '--card-bg': '#d0e8ff',
|
|
|
38
|
+ '--header-bg': '#2a5caa'
|
|
|
39
|
+ },
|
|
|
40
|
+ darkMode: {
|
|
|
41
|
+ '--primary-color': '#52c41a',
|
|
|
42
|
+ '--bg-color': '#1a1a1a',
|
|
|
43
|
+ '--text-color': '#e6e6e6',
|
|
|
44
|
+ '--card-bg': '#2a2a2a'
|
|
69
|
45
|
},
|
|
70
|
|
- // 加载用户数据
|
|
71
|
|
- async loadUserData() {
|
|
72
|
|
- // 检查登录状态
|
|
73
|
|
- if (uni.getStorageSync('token')) {
|
|
74
|
|
- // 加载用户信息
|
|
75
|
|
- await this.userStore.initUser()
|
|
76
|
|
-
|
|
77
|
|
- // 加载VIP状态
|
|
78
|
|
- if (this.userStore.userId) {
|
|
79
|
|
- await this.vipStore.loadVipStatus(this.userStore.userId)
|
|
|
46
|
+ default: {
|
|
|
47
|
+ '--primary-color': '#1890ff',
|
|
|
48
|
+ '--bg-color': '#f8f9fa',
|
|
|
49
|
+ '--text-color': '#333',
|
|
|
50
|
+ '--card-bg': '#ffffff'
|
|
80
|
51
|
}
|
|
81
|
52
|
}
|
|
|
53
|
+
|
|
|
54
|
+ const root = document.documentElement
|
|
|
55
|
+ const themeVars = themes[themeName] || themes.aydzBlue
|
|
|
56
|
+
|
|
|
57
|
+ Object.keys(themeVars).forEach(key => {
|
|
|
58
|
+ root.style.setProperty(key, themeVars[key])
|
|
|
59
|
+ })
|
|
|
60
|
+
|
|
|
61
|
+ // 动态设置导航栏颜色
|
|
|
62
|
+ if (themeName === 'darkMode') {
|
|
|
63
|
+ uni.setNavigationBarColor({
|
|
|
64
|
+ frontColor: '#ffffff',
|
|
|
65
|
+ backgroundColor: '#1a1a1a'
|
|
|
66
|
+ })
|
|
|
67
|
+ } else if (themeName === 'aydzBlue') {
|
|
|
68
|
+ uni.setNavigationBarColor({
|
|
|
69
|
+ frontColor: '#ffffff',
|
|
|
70
|
+ backgroundColor: '#2a5caa'
|
|
|
71
|
+ })
|
|
|
72
|
+ }
|
|
82
|
73
|
}
|
|
83
|
74
|
}
|
|
84
|
75
|
}
|
|
85
|
76
|
</script>
|
|
86
|
77
|
|
|
87
|
78
|
<style lang="scss">
|
|
88
|
|
- /* 确保所有页面有基本样式 */
|
|
89
|
|
- page {
|
|
90
|
|
- height: 100%;
|
|
91
|
|
- background-color: #ffffff;
|
|
92
|
|
- font-size: 28rpx;
|
|
93
|
|
- color: #333;
|
|
94
|
|
- }
|
|
95
|
|
- /* 解决部分设备显示问题 */
|
|
96
|
|
- body, html {
|
|
97
|
|
- height: 100%;
|
|
98
|
|
- background-color: #ffffff;
|
|
99
|
|
- }
|
|
100
|
|
- /* 容器样式 */
|
|
101
|
|
- .container {
|
|
102
|
|
- min-height: 100%;
|
|
103
|
|
- padding: 20rpx;
|
|
104
|
|
- box-sizing: border-box;
|
|
105
|
|
- }
|
|
106
|
|
-/* 修正:每个 @import 语句末尾添加分号 */
|
|
107
|
|
-@import '@/static/scss/index.scss';
|
|
108
|
|
-//@import '@/styles/themes/default.scss';
|
|
109
|
|
-//@import '@/styles/themes/aydz-blue.scss';
|
|
110
|
|
-
|
|
111
|
|
-.app-container {
|
|
112
|
|
- font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
|
|
113
|
|
- height: 100vh;
|
|
114
|
|
- background-color: var(--bg-color);
|
|
115
|
|
- color: var(--text-color);
|
|
116
|
|
-}
|
|
117
|
|
-
|
|
118
|
|
-/* 全局主题变量 */
|
|
119
|
|
-:root {
|
|
120
|
|
- --primary-color: #1890ff;
|
|
121
|
|
- --bg-color: #f8f9fa;
|
|
122
|
|
- --text-color: #333;
|
|
123
|
|
- --card-bg: #ffffff;
|
|
124
|
|
- --header-bg: #ffffff;
|
|
125
|
|
-
|
|
126
|
|
- /* 确保所有页面继承主题 */
|
|
127
|
|
- background-color: var(--bg-color);
|
|
128
|
|
- color: var(--text-color);
|
|
129
|
|
-}
|
|
130
|
|
-
|
|
131
|
|
-/* 哎呀科技蓝主题变量覆盖 */
|
|
132
|
|
-.theme-aydzBlue {
|
|
133
|
|
- --primary-color: #2a5caa;
|
|
134
|
|
- --bg-color: #e6f7ff;
|
|
135
|
|
- --text-color: #1a3353;
|
|
136
|
|
- --card-bg: #d0e8ff;
|
|
137
|
|
- --header-bg: #2a5caa;
|
|
138
|
|
-}
|
|
139
|
|
-
|
|
140
|
|
-/* 深色模式主题变量覆盖 */
|
|
141
|
|
-.theme-darkMode {
|
|
142
|
|
- --primary-color: #52c41a;
|
|
143
|
|
- --bg-color: #1a1a1a;
|
|
144
|
|
- --text-color: #e6e6e6;
|
|
145
|
|
- --card-bg: #2a2a2a;
|
|
146
|
|
- --header-bg: #1a1a1a;
|
|
147
|
|
-}
|
|
148
|
|
-
|
|
149
|
|
-/* 公共组件样式 */
|
|
150
|
|
-.card {
|
|
151
|
|
- background-color: var(--card-bg);
|
|
152
|
|
- border-radius: 12px;
|
|
153
|
|
- padding: 16px;
|
|
154
|
|
- margin-bottom: 16px;
|
|
155
|
|
- box-shadow: 0 2px 8px rgba(0,0,0,0.05);
|
|
156
|
|
-}
|
|
157
|
|
-
|
|
158
|
|
-.primary-button {
|
|
159
|
|
- background-color: var(--primary-color);
|
|
160
|
|
- color: white;
|
|
161
|
|
- border: none;
|
|
162
|
|
- border-radius: 24px;
|
|
163
|
|
- padding: 10px 20px;
|
|
164
|
|
- font-weight: bold;
|
|
165
|
|
-}
|
|
166
|
|
-
|
|
167
|
|
-/* 全局样式 */
|
|
168
|
|
-page {
|
|
169
|
|
- background-color: var(--bg-color);
|
|
170
|
|
- color: var(--text-color);
|
|
171
|
|
- font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
|
|
172
|
|
-}
|
|
|
79
|
+/* 保留原有样式 */
|
|
173
|
80
|
</style>
|