Update ColorPicker.vue

This commit is contained in:
land 2025-11-03 14:45:59 +05:30
parent ba9fe8fa3f
commit b607799836

View file

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { colors } from '@fmhy/colors' import { colors } from '@fmhy/colors'
import { useStorage, useStyleTag } from '@vueuse/core' import { useStorage, useStyleTag } from '@vueuse/core'
import { watch, onMounted } from 'vue' import { watch, onMounted, nextTick } from 'vue'
import amoledswitch from './amoledswitch.vue' import amoledswitch from './amoledswitch.vue'
const colorScales = [ const colorScales = [
@ -91,13 +91,19 @@ const updateThemeColor = (colorName: ColorNames, amoledEnabled: boolean) => {
` `
} }
onMounted(() => { onMounted(async () => {
if (isAmoledMode.value) { // Wait for next tick to ensure DOM is ready
document.documentElement.classList.add('theme-amoled') await nextTick()
}
// Re-apply the theme to ensure everything is initialized // Small delay to ensure VitePress dark mode is initialized
updateThemeColor(selectedColor.value, isAmoledMode.value) setTimeout(() => {
if (isAmoledMode.value) {
document.documentElement.classList.add('theme-amoled')
}
// Force re-apply the theme
updateThemeColor(selectedColor.value, isAmoledMode.value)
}, 100)
}) })
watch([selectedColor, isAmoledMode], ([color, amoled]) => { watch([selectedColor, isAmoledMode], ([color, amoled]) => {