-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.vue
112 lines (92 loc) · 2.36 KB
/
App.vue
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
103
104
105
106
107
108
109
110
111
112
<script>
import {
mapMutations
} from 'vuex'
export default {
onLaunch: function() {
console.log(process.env.NODE_ENV)
let that = this
let systemInfo = uni.getSystemInfoSync()
this.setStatusBarHeight(systemInfo.statusBarHeight)
//#ifdef MP-WEIXIN
wx.getSystemInfo({
success(res) {
let {
theme
} = res
if (!theme) {
//不支持theme
return
} else {
// console.log(theme)
that.setTheme(theme)
wx.onThemeChange(({
theme
}) => {
that.setTheme(theme)
})
}
}
})
//#endif
if (window && window.matchMedia) {
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
that.setTheme('dark')
} else {
that.setTheme('light')
}
let listeners = {
dark: (mediaQueryList) => {
if (mediaQueryList.matches) {
that.setTheme('dark')
}
},
light: (mediaQueryList) => {
if (mediaQueryList.matches) {
that.setTheme('light')
}
}
}
window.matchMedia('(prefers-color-scheme: dark)').addListener(listeners.dark)
window.matchMedia('(prefers-color-scheme: light)').addListener(listeners.light)
}
},
methods: {
...mapMutations(['setTheme', 'setStatusBarHeight']),
}
}
</script>
<style lang="scss">
body,
page {
--theme-color: #ff0054;
--page-bg-color: #e5ebee;
--card-bg-color: #fff;
--text-title-color: #303030;
--text-p-color: #606060;
--text-help-color: #909090;
--text-tip-color: #c0c0c0;
--divider-color: #f0f0f0;
--color-ruby: #dc0005;
--color-ruby-lighter: #ff3136;
@media (prefers-color-scheme: dark) {
--theme-color: #ff1360;
--page-bg-color: #121212;
--card-bg-color: #1e1e1e;
--text-title-color: #e0e0e0;
--text-p-color: #c0c0c0;
--text-help-color: #a0a0a0;
--text-tip-color: #707070;
--divider-color: #2c2c2c;
}
background-color: var(--page-bg-color);
font-size: 32rpx;
color: var(--text-p-color);
@include pad-devices {
font-size: toPadPx(32);
}
}
.top-fixed-wrapper {
z-index: 114555;
}
</style>