import { useGlobal } from '@/lib/global' import { saveDarkModeToCookies } from '@/lib/theme' import CONFIG_HEXO from '../config_hexo' export default function FloatDarkModeButton () { const { isDarkMode, updateDarkMode } = useGlobal() if (!CONFIG_HEXO.WIDGET_DARK_MODE) { return <> } // 用户手动设置主题 const handleChangeDarkMode = () => { const newStatus = !isDarkMode saveDarkModeToCookies(newStatus) updateDarkMode(newStatus) const htmlElement = document.getElementsByTagName('html')[0] htmlElement.classList?.remove(newStatus ? 'light' : 'dark') htmlElement.classList?.add(newStatus ? 'dark' : 'light') } return (
) }