fix: 切换主题不成功
This commit is contained in:
@@ -27,7 +27,6 @@
|
|||||||
"pinia": "^2.2.6",
|
"pinia": "^2.2.6",
|
||||||
"pinia-plugin-persist": "^1.0.0",
|
"pinia-plugin-persist": "^1.0.0",
|
||||||
"sparticles": "^1.3.1",
|
"sparticles": "^1.3.1",
|
||||||
"theme-change": "^2.5.0",
|
|
||||||
"three": "^0.166.0",
|
"three": "^0.166.0",
|
||||||
"three-css3d": "^1.0.6",
|
"three-css3d": "^1.0.6",
|
||||||
"vue": "^3.5.13",
|
"vue": "^3.5.13",
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import PlayMusic from '@/components/PlayMusic/index.vue'
|
import PlayMusic from '@/components/PlayMusic/index.vue'
|
||||||
import useStore from '@/store'
|
import useStore from '@/store'
|
||||||
|
import { themeChange } from '@/utils'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { themeChange } from 'theme-change'
|
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
|
||||||
@@ -14,10 +14,6 @@ const { getTheme: localTheme } = storeToRefs(globalConfig)
|
|||||||
const { getPrizeConfig: prizeList } = storeToRefs(prizeConfig)
|
const { getPrizeConfig: prizeList } = storeToRefs(prizeConfig)
|
||||||
|
|
||||||
const tipDialog = ref()
|
const tipDialog = ref()
|
||||||
// const isMobileValue = ref(structuredClone(isMobile.value))
|
|
||||||
function setLocalTheme(theme: any) {
|
|
||||||
themeChange(theme.name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 设置当前奖列表
|
// 设置当前奖列表
|
||||||
function setCurrentPrize() {
|
function setCurrentPrize() {
|
||||||
@@ -53,7 +49,7 @@ function judgeChromeOrEdge() {
|
|||||||
return isChrome || isEdge
|
return isChrome || isEdge
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
setLocalTheme(localTheme.value)
|
themeChange(localTheme.value.name)
|
||||||
setCurrentPrize()
|
setCurrentPrize()
|
||||||
if (judgeMobile() || !judgeChromeOrEdge()) {
|
if (judgeMobile() || !judgeChromeOrEdge()) {
|
||||||
tipDialog.value.showModal()
|
tipDialog.value.showModal()
|
||||||
|
|||||||
@@ -39,3 +39,12 @@ export function selectCard(cardIndexArr: number[], tableLength: number, personId
|
|||||||
|
|
||||||
return cardIndex
|
return cardIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function themeChange(theme: string) {
|
||||||
|
// 获取根html
|
||||||
|
const html = document.querySelectorAll('html')
|
||||||
|
if (html) {
|
||||||
|
html[0].setAttribute('data-theme', theme)
|
||||||
|
localStorage.setItem('theme', theme)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
import i18n, { languageList } from '@/locales/i18n'
|
import i18n, { languageList } from '@/locales/i18n'
|
||||||
|
|
||||||
import useStore from '@/store'
|
import useStore from '@/store'
|
||||||
|
import { themeChange } from '@/utils'
|
||||||
import { isHex, isRgbOrRgba } from '@/utils/color'
|
import { isHex, isRgbOrRgba } from '@/utils/color'
|
||||||
import daisyuiThemes from 'daisyui/src/theming/themes'
|
import daisyuiThemes from 'daisyui/src/theming/themes'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { themeChange } from 'theme-change'
|
|
||||||
import { onMounted, ref, watch } from 'vue'
|
import { onMounted, ref, watch } from 'vue'
|
||||||
import { ColorPicker } from 'vue3-colorpicker'
|
import { ColorPicker } from 'vue3-colorpicker'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
|||||||
Reference in New Issue
Block a user