mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 14:29:15 +08:00
feat(preferences): update user theme settings and add new preferences
- Updated preferences configuration with new user theme options including font family and code font family. - Added new preferences for chat and export menus. - Adjusted default preferences to include new settings for user theme. - Enhanced useUserTheme hook to manage new font family preferences.
This commit is contained in:
parent
57fd73e51a
commit
78a8ebc777
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* Auto-generated preferences configuration
|
* Auto-generated preferences configuration
|
||||||
* Generated at: 2025-09-03T13:39:01.110Z
|
* Generated at: 2025-09-14T09:02:01.333Z
|
||||||
*
|
*
|
||||||
* This file is automatically generated from classification.json
|
* This file is automatically generated from classification.json
|
||||||
* To update this file, modify classification.json and run:
|
* To update this file, modify classification.json and run:
|
||||||
@ -91,6 +91,8 @@ export interface PreferencesType {
|
|||||||
'chat.code.execution.enabled': boolean
|
'chat.code.execution.enabled': boolean
|
||||||
// redux/settings/codeExecution.timeoutMinutes
|
// redux/settings/codeExecution.timeoutMinutes
|
||||||
'chat.code.execution.timeout_minutes': number
|
'chat.code.execution.timeout_minutes': number
|
||||||
|
// redux/settings/codeFancyBlock
|
||||||
|
'chat.code.fancy_block': boolean
|
||||||
// redux/settings/codeImageTools
|
// redux/settings/codeImageTools
|
||||||
'chat.code.image_tools': boolean
|
'chat.code.image_tools': boolean
|
||||||
// redux/settings/codePreview.themeDark
|
// redux/settings/codePreview.themeDark
|
||||||
@ -241,6 +243,8 @@ export interface PreferencesType {
|
|||||||
'data.export.menus.markdown': boolean
|
'data.export.menus.markdown': boolean
|
||||||
// redux/settings/exportMenuOptions.markdown_reason
|
// redux/settings/exportMenuOptions.markdown_reason
|
||||||
'data.export.menus.markdown_reason': boolean
|
'data.export.menus.markdown_reason': boolean
|
||||||
|
// redux/settings/exportMenuOptions.notes
|
||||||
|
'data.export.menus.notes': boolean
|
||||||
// redux/settings/exportMenuOptions.notion
|
// redux/settings/exportMenuOptions.notion
|
||||||
'data.export.menus.notion': boolean
|
'data.export.menus.notion': boolean
|
||||||
// redux/settings/exportMenuOptions.obsidian
|
// redux/settings/exportMenuOptions.obsidian
|
||||||
@ -297,14 +301,18 @@ export interface PreferencesType {
|
|||||||
'feature.minapp.show_opened_in_sidebar': boolean
|
'feature.minapp.show_opened_in_sidebar': boolean
|
||||||
// redux/note/settings.defaultEditMode
|
// redux/note/settings.defaultEditMode
|
||||||
'feature.notes.default_edit_mode': string
|
'feature.notes.default_edit_mode': string
|
||||||
// redux/note/settings.fontFamily
|
|
||||||
'feature.notes.default_font_family': string
|
|
||||||
// redux/note/settings.defaultViewMode
|
// redux/note/settings.defaultViewMode
|
||||||
'feature.notes.default_view_mode': string
|
'feature.notes.default_view_mode': string
|
||||||
|
// redux/note/settings.fontFamily
|
||||||
|
'feature.notes.font_family': string
|
||||||
|
// redux/note/settings.fontSize
|
||||||
|
'feature.notes.font_size': number
|
||||||
// redux/note/settings.isFullWidth
|
// redux/note/settings.isFullWidth
|
||||||
'feature.notes.full_width': boolean
|
'feature.notes.full_width': boolean
|
||||||
// redux/note/settings.showTabStatus
|
// redux/note/settings.showTabStatus
|
||||||
'feature.notes.show_tab_status': boolean
|
'feature.notes.show_tab_status': boolean
|
||||||
|
// redux/note/settings.showTableOfContents
|
||||||
|
'feature.notes.show_table_of_contents': boolean
|
||||||
// redux/note/settings.showWorkspace
|
// redux/note/settings.showWorkspace
|
||||||
'feature.notes.show_workspace': boolean
|
'feature.notes.show_workspace': boolean
|
||||||
// redux/settings/clickTrayToShowQuickAssistant
|
// redux/settings/clickTrayToShowQuickAssistant
|
||||||
@ -393,8 +401,12 @@ export interface PreferencesType {
|
|||||||
'ui.sidebar.icons.visible': PreferenceTypes.SidebarIcon[]
|
'ui.sidebar.icons.visible': PreferenceTypes.SidebarIcon[]
|
||||||
// redux/settings/theme
|
// redux/settings/theme
|
||||||
'ui.theme_mode': PreferenceTypes.ThemeMode
|
'ui.theme_mode': PreferenceTypes.ThemeMode
|
||||||
|
// redux/settings/userTheme.userCodeFontFamily
|
||||||
|
'ui.theme_user.code_font_family': string
|
||||||
// redux/settings/userTheme.colorPrimary
|
// redux/settings/userTheme.colorPrimary
|
||||||
'ui.theme_user.color_primary': string
|
'ui.theme_user.color_primary': string
|
||||||
|
// redux/settings/userTheme.userFontFamily
|
||||||
|
'ui.theme_user.font_family': string
|
||||||
// redux/settings/windowStyle
|
// redux/settings/windowStyle
|
||||||
'ui.window_style': PreferenceTypes.WindowStyle
|
'ui.window_style': PreferenceTypes.WindowStyle
|
||||||
}
|
}
|
||||||
@ -439,6 +451,7 @@ export const DefaultPreferences: PreferencesType = {
|
|||||||
'chat.code.editor.theme_light': 'auto',
|
'chat.code.editor.theme_light': 'auto',
|
||||||
'chat.code.execution.enabled': false,
|
'chat.code.execution.enabled': false,
|
||||||
'chat.code.execution.timeout_minutes': 1,
|
'chat.code.execution.timeout_minutes': 1,
|
||||||
|
'chat.code.fancy_block': true,
|
||||||
'chat.code.image_tools': false,
|
'chat.code.image_tools': false,
|
||||||
'chat.code.preview.theme_dark': 'auto',
|
'chat.code.preview.theme_dark': 'auto',
|
||||||
'chat.code.preview.theme_light': 'auto',
|
'chat.code.preview.theme_light': 'auto',
|
||||||
@ -514,6 +527,7 @@ export const DefaultPreferences: PreferencesType = {
|
|||||||
'data.export.menus.joplin': true,
|
'data.export.menus.joplin': true,
|
||||||
'data.export.menus.markdown': true,
|
'data.export.menus.markdown': true,
|
||||||
'data.export.menus.markdown_reason': true,
|
'data.export.menus.markdown_reason': true,
|
||||||
|
'data.export.menus.notes': true,
|
||||||
'data.export.menus.notion': true,
|
'data.export.menus.notion': true,
|
||||||
'data.export.menus.obsidian': true,
|
'data.export.menus.obsidian': true,
|
||||||
'data.export.menus.plain_text': true,
|
'data.export.menus.plain_text': true,
|
||||||
@ -542,10 +556,12 @@ export const DefaultPreferences: PreferencesType = {
|
|||||||
'feature.minapp.open_link_external': false,
|
'feature.minapp.open_link_external': false,
|
||||||
'feature.minapp.show_opened_in_sidebar': true,
|
'feature.minapp.show_opened_in_sidebar': true,
|
||||||
'feature.notes.default_edit_mode': 'preview',
|
'feature.notes.default_edit_mode': 'preview',
|
||||||
'feature.notes.default_font_family': 'default',
|
|
||||||
'feature.notes.default_view_mode': 'edit',
|
'feature.notes.default_view_mode': 'edit',
|
||||||
|
'feature.notes.font_family': 'default',
|
||||||
|
'feature.notes.font_size': 16,
|
||||||
'feature.notes.full_width': true,
|
'feature.notes.full_width': true,
|
||||||
'feature.notes.show_tab_status': true,
|
'feature.notes.show_tab_status': true,
|
||||||
|
'feature.notes.show_table_of_contents': true,
|
||||||
'feature.notes.show_workspace': true,
|
'feature.notes.show_workspace': true,
|
||||||
'feature.quick_assistant.click_tray_to_show': false,
|
'feature.quick_assistant.click_tray_to_show': false,
|
||||||
'feature.quick_assistant.enabled': false,
|
'feature.quick_assistant.enabled': false,
|
||||||
@ -647,7 +663,9 @@ export const DefaultPreferences: PreferencesType = {
|
|||||||
'notes'
|
'notes'
|
||||||
],
|
],
|
||||||
'ui.theme_mode': PreferenceTypes.ThemeMode.system,
|
'ui.theme_mode': PreferenceTypes.ThemeMode.system,
|
||||||
|
'ui.theme_user.code_font_family': '',
|
||||||
'ui.theme_user.color_primary': '#00b96b',
|
'ui.theme_user.color_primary': '#00b96b',
|
||||||
|
'ui.theme_user.font_family': '',
|
||||||
'ui.window_style': 'opaque'
|
'ui.window_style': 'opaque'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -656,8 +674,8 @@ export const DefaultPreferences: PreferencesType = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成统计:
|
* 生成统计:
|
||||||
* - 总配置项: 189
|
* - 总配置项: 195
|
||||||
* - electronStore项: 1
|
* - electronStore项: 1
|
||||||
* - redux项: 188
|
* - redux项: 194
|
||||||
* - localStorage项: 0
|
* - localStorage项: 0
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -6,6 +6,8 @@ import Color from 'color'
|
|||||||
|
|
||||||
export default function useUserTheme() {
|
export default function useUserTheme() {
|
||||||
const [colorPrimary, setColorPrimary] = usePreference('ui.theme_user.color_primary')
|
const [colorPrimary, setColorPrimary] = usePreference('ui.theme_user.color_primary')
|
||||||
|
const [userFontFamily, setUserFontFamily] = usePreference('ui.theme_user.font_family')
|
||||||
|
const [userCodeFontFamily, setUserCodeFontFamily] = usePreference('ui.theme_user.code_font_family')
|
||||||
|
|
||||||
const initUserTheme = (theme: { colorPrimary: string } = { colorPrimary }) => {
|
const initUserTheme = (theme: { colorPrimary: string } = { colorPrimary }) => {
|
||||||
const colorPrimary = Color(theme.colorPrimary)
|
const colorPrimary = Color(theme.colorPrimary)
|
||||||
@ -17,8 +19,8 @@ export default function useUserTheme() {
|
|||||||
document.body.style.setProperty('--color-primary-mute', colorPrimary.alpha(0.3).toString())
|
document.body.style.setProperty('--color-primary-mute', colorPrimary.alpha(0.3).toString())
|
||||||
|
|
||||||
// Set font family CSS variables
|
// Set font family CSS variables
|
||||||
document.documentElement.style.setProperty('--user-font-family', `'${theme.userFontFamily}'`)
|
document.documentElement.style.setProperty('--user-font-family', `'${userFontFamily}'`)
|
||||||
document.documentElement.style.setProperty('--user-code-font-family', `'${theme.userCodeFontFamily}'`)
|
document.documentElement.style.setProperty('--user-code-font-family', `'${userCodeFontFamily}'`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -26,10 +28,12 @@ export default function useUserTheme() {
|
|||||||
|
|
||||||
initUserTheme,
|
initUserTheme,
|
||||||
|
|
||||||
userTheme: { colorPrimary },
|
userTheme: { colorPrimary, userFontFamily, userCodeFontFamily },
|
||||||
|
|
||||||
setUserTheme(userTheme: { colorPrimary: string }) {
|
setUserTheme(userTheme: { colorPrimary: string; userFontFamily: string; userCodeFontFamily: string }) {
|
||||||
setColorPrimary(userTheme.colorPrimary)
|
setColorPrimary(userTheme.colorPrimary)
|
||||||
|
setUserFontFamily(userTheme.userFontFamily)
|
||||||
|
setUserCodeFontFamily(userTheme.userCodeFontFamily)
|
||||||
initUserTheme(userTheme)
|
initUserTheme(userTheme)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,9 +62,7 @@ export interface SettingsState {
|
|||||||
trayOnClose: boolean
|
trayOnClose: boolean
|
||||||
tray: boolean
|
tray: boolean
|
||||||
theme: ThemeMode
|
theme: ThemeMode
|
||||||
userTheme: {
|
userTheme: UserTheme
|
||||||
colorPrimary: string
|
|
||||||
}
|
|
||||||
windowStyle: 'transparent' | 'opaque'
|
windowStyle: 'transparent' | 'opaque'
|
||||||
fontSize: number
|
fontSize: number
|
||||||
topicPosition: 'left' | 'right'
|
topicPosition: 'left' | 'right'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user