-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.vue
122 lines (117 loc) · 3.1 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
113
114
115
116
117
118
119
120
121
122
<template>
<n-config-provider inline-theme-disabled :theme="theme" :theme-overrides="theme === null ? lightThemeOverrides : darkThemeOverrides">
<n-message-provider>
<NuxtLayout>
<NuxtPage/>
</NuxtLayout>
</n-message-provider>
</n-config-provider>
</template>
<script setup lang="ts">
import {
NConfigProvider,
type GlobalThemeOverrides
} from 'naive-ui'
import { useColorMode } from '@vueuse/core'
import { darkTheme } from 'naive-ui'
// import { isMobile } from '~/composables/utils.ts'
const theme = ref<null | typeof darkTheme>(null)
const lightThemeOverrides: GlobalThemeOverrides = {
Scrollbar: {
width: '0px',
borderRadius: '0px'
},
common: {
baseColor: '#FFF',
primaryColor: '#2764AD',
primaryColorHover: '#457FBD',
primaryColorPressed: '#194D95',
primaryColorSuppl: '#457FBD',
infoColor: '#61649F',
infoColorHover: '#777CB2',
infoColorPressed: '#3F418A',
infoColorSuppl: '#777CB2',
successColor: '#55BB8A',
successColorHover: '#6DC99A',
successColorPressed: '#369F70',
successColorSuppl: '#6DC99A',
warningColor: '#FC6315',
warningColorHover: '#FD843F',
warningColorPressed: '#D0480D',
warningColorSuppl: '#FD843F',
errorColor: '#EE3F4D',
errorColorHover: '#F15F66',
errorColorPressed: '#C6273A',
errorColorSuppl: '#F15F66'
}
}
const darkThemeOverrides: GlobalThemeOverrides = {
Scrollbar: {
width: '0px',
borderRadius: '0px'
},
common: {
primaryColor: '#4780BD',
primaryColorHover: '#336BAD',
primaryColorPressed: '#6A9ECE',
primaryColorSuppl: '#336BAD',
infoColor: '#878BB2',
infoColorHover: '#5F629F',
infoColorPressed: '#9EA2C5',
infoColorSuppl: '#5F629F',
successColor: '#84C9A6',
successColorHover: '#60BB8F',
successColorPressed: '#9BD6B6',
successColorSuppl: '#60BB8F',
warningColor: '#FD813B',
warningColorHover: '#FC742E',
warningColorPressed: '#FDA266',
warningColorSuppl: '#FC742E',
errorColor: '#F1646B',
errorColorHover: '#EE4D5A',
errorColorPressed: '#F58587',
errorColorSuppl: '#EE4D5A'
}
}
const { ColorMode, CurrentColor } = storeToRefs(
useConfigStore()
)
const colorMode = useColorMode()
function InitTheme() {
if (ColorMode.value === 0) {
switch (colorMode.value) {
case 'light':
theme.value = null
CurrentColor.value = 'light'
document.documentElement.classList.remove('dark')
document.documentElement.classList.add('light')
break
case 'dark':
theme.value = darkTheme
CurrentColor.value = 'dark'
document.documentElement.classList.add('dark')
document.documentElement.classList.remove('light')
break
}
} else if (ColorMode.value === 1) {
theme.value = null
CurrentColor.value = 'light'
document.documentElement.classList.add('light')
document.documentElement.classList.remove('dark')
} else {
theme.value = darkTheme
CurrentColor.value = 'dark'
document.documentElement.classList.add('dark')
document.documentElement.classList.remove('light')
}
}
watch([ColorMode, colorMode], () => {
InitTheme()
})
onMounted(() => {
InitTheme()
console.log(
// isMobile() ? '当前环境是移动端' : '当前环境不是移动端'
)
})
</script>