mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-09 01:20:09 +00:00
29 lines
851 B
Vue
29 lines
851 B
Vue
<template>
|
|
<SidebarIcon
|
|
:icon="icon"
|
|
@click="toggleTheme"
|
|
:tooltip="$t('sideToolbar.themeToggle')"
|
|
class="comfy-vue-theme-toggle"
|
|
/>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed, ref } from 'vue'
|
|
import SidebarIcon from './SidebarIcon.vue'
|
|
import { useSettingStore } from '@/stores/settingStore'
|
|
|
|
const previousDarkTheme = ref('dark')
|
|
const currentTheme = computed(() => useSettingStore().get('Comfy.ColorPalette'))
|
|
const isDarkMode = computed(() => currentTheme.value !== 'light')
|
|
const icon = computed(() => (isDarkMode.value ? 'pi pi-moon' : 'pi pi-sun'))
|
|
|
|
const toggleTheme = () => {
|
|
if (isDarkMode.value) {
|
|
previousDarkTheme.value = currentTheme.value
|
|
useSettingStore().set('Comfy.ColorPalette', 'light')
|
|
} else {
|
|
useSettingStore().set('Comfy.ColorPalette', previousDarkTheme.value)
|
|
}
|
|
}
|
|
</script>
|