mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-23 12:11:55 +08:00
- Introduced a new color selection feature in DisplaySettings, allowing users to choose from predefined theme color presets. - Added a dedicated section for zoom settings in the DisplaySettings component, enhancing user customization options. - Updated localization files to include new zoom settings titles in multiple languages.
30 lines
905 B
TypeScript
30 lines
905 B
TypeScript
import { useAppDispatch, useAppSelector } from '@renderer/store'
|
|
import { setUserTheme, UserTheme } from '@renderer/store/settings'
|
|
import Color from 'color'
|
|
|
|
export default function useUserTheme() {
|
|
const userTheme = useAppSelector((state) => state.settings.userTheme)
|
|
|
|
const dispatch = useAppDispatch()
|
|
|
|
const initUserTheme = (theme: UserTheme = userTheme) => {
|
|
const colorPrimary = Color(theme.colorPrimary)
|
|
|
|
document.body.style.setProperty('--color-primary', colorPrimary.toString())
|
|
document.body.style.setProperty('--color-primary-soft', colorPrimary.alpha(0.6).toString())
|
|
document.body.style.setProperty('--color-primary-mute', colorPrimary.alpha(0.3).toString())
|
|
}
|
|
|
|
return {
|
|
colorPrimary: Color(userTheme.colorPrimary),
|
|
|
|
initUserTheme,
|
|
|
|
setUserTheme(userTheme: UserTheme) {
|
|
dispatch(setUserTheme(userTheme))
|
|
|
|
initUserTheme(userTheme)
|
|
}
|
|
}
|
|
}
|