Extract theme toggle as command (#1161)

* Extract theme toggle as command

* nit
This commit is contained in:
Chenlei Hu
2024-10-07 21:54:58 -04:00
committed by GitHub
parent 5ba1d1a3f7
commit a4e08f60fe
2 changed files with 30 additions and 11 deletions

View File

@@ -436,6 +436,27 @@ export const useCommandStore = defineStore('command', () => {
node.collapse()
})
}
},
{
id: 'Comfy.ToggleTheme',
icon: 'pi pi-moon',
label: 'Toggle Theme',
versionAdded: '1.3.12',
function: (() => {
let previousDarkTheme: string = 'dark'
// Official light theme is the only light theme supported now.
const isDarkMode = (themeId: string) => themeId !== 'light'
return () => {
const currentTheme = settingStore.get('Comfy.ColorPalette')
if (isDarkMode(currentTheme)) {
previousDarkTheme = currentTheme
settingStore.set('Comfy.ColorPalette', 'light')
} else {
settingStore.set('Comfy.ColorPalette', previousDarkTheme)
}
}
})()
}
]