1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
| <script>
| import activationService from './services/activationService'
| import {
| initDatabase,
| query
| } from './common/sqlite'
|
| export default {
| onLaunch() {
| try {
| // #ifdef APP-PLUS
| initDatabase();
| // #endif
|
| } catch (e) {
| console.log('数据库初始化失败', e);
| }
| // const activationStatus = activationService.checkActivationStatus()
|
| // 将激活状态保存到全局变量
| // this.globalData = {
| // activationStatus: activationStatus
| // }
| },
| onShow() {
| this.$nextTick(() => {
| setTimeout(() => {
| // 检查激活状态
| activationService.checkDataCount().then(result => {
| if (result.expStatus) {
| uni.redirectTo({
| url: '/pages/system/activation'
| })
| }
| })
| }, 1000)
| })
| },
| onHide: function() {
| console.log('App Hide')
| },
| methods: {
| toggleTheme() {
| this.$store.dispatch('toggleTheme')
| }
| },
| computed: {
| theme() {
| return this.$store.state.theme
| }
| },
| watch: {
| theme(newVal) {
| // 应用主题样式
| document.documentElement.setAttribute('data-theme', newVal)
| }
| }
| }
| </script>
|
| <style lang="scss">
| @import "uview-ui/index.scss";
|
| /* 主题变量 */
| :root {
| --bg-color: #f5f7fa;
| --text-color: #333;
| --card-bg: #fff;
| --border-color: #eee;
| --shadow-color: rgba(0, 0, 0, 0.05);
| }
|
| [data-theme="dark"] {
| --bg-color: #1a1a2e;
| --text-color: #fff;
| --card-bg: rgba(255, 255, 255, 0.1);
| --border-color: rgba(255, 255, 255, 0.1);
| --shadow-color: rgba(0, 0, 0, 0.2);
| }
|
| /* 主题切换按钮 */
| .theme-toggle {
| position: fixed;
| right: 30rpx;
| top: 30rpx;
| z-index: 999;
| width: 80rpx;
| height: 80rpx;
| border-radius: 50%;
| background-color: var(--card-bg);
| display: flex;
| justify-content: center;
| align-items: center;
| box-shadow: 0 2rpx 10rpx var(--shadow-color);
| }
|
| /* 每个页面公共css */
| page {
| background-color: var(--bg-color);
| color: var(--text-color);
| }
| </style>
|
|