@@ -9,6 +9,10 @@ import type { Locale } from '../i18n'
99import { useUIStore } from './uiStore'
1010
1111const LOCALE_STORAGE_KEY = 'cc-haha-locale'
12+ const UI_ZOOM_STORAGE_KEY = 'cc-haha-ui-zoom'
13+ export const UI_ZOOM_MIN = 0.5
14+ export const UI_ZOOM_MAX = 2.0
15+ export const UI_ZOOM_STEP = 0.05
1216let desktopNotificationsSaveQueue : Promise < void > = Promise . resolve ( )
1317
1418function getStoredLocale ( ) : Locale {
@@ -19,6 +23,17 @@ function getStoredLocale(): Locale {
1923 return 'zh'
2024}
2125
26+ function getStoredUiZoom ( ) : number {
27+ try {
28+ const stored = localStorage . getItem ( UI_ZOOM_STORAGE_KEY )
29+ if ( stored === null ) return 1.0
30+ const parsed = parseFloat ( stored )
31+ if ( isNaN ( parsed ) ) return 1.0
32+ return Math . min ( UI_ZOOM_MAX , Math . max ( UI_ZOOM_MIN , parsed ) )
33+ } catch { /* localStorage unavailable */ }
34+ return 1.0
35+ }
36+
2237type SettingsStore = {
2338 permissionMode : PermissionMode
2439 currentModel : ModelInfo | null
@@ -34,6 +49,7 @@ type SettingsStore = {
3449 h5Access : H5AccessSettings
3550 h5AccessError : string | null
3651 responseLanguage : string
52+ uiZoom : number
3753 isLoading : boolean
3854 error : string | null
3955
@@ -61,6 +77,7 @@ type SettingsStore = {
6177 setResponseLanguage : ( language : string ) => Promise < void >
6278 fetchAppMode : ( ) => Promise < void >
6379 setAppMode : ( mode : AppMode , portableDir ?: string | null ) => Promise < void >
80+ setUiZoom : ( zoom : number ) => void
6481}
6582
6683const DEFAULT_H5_ACCESS_SETTINGS : H5AccessSettings = {
@@ -85,11 +102,17 @@ export const useSettingsStore = create<SettingsStore>((set, get) => ({
85102 h5Access : DEFAULT_H5_ACCESS_SETTINGS ,
86103 h5AccessError : null ,
87104 responseLanguage : '' ,
105+ uiZoom : getStoredUiZoom ( ) ,
88106 isLoading : false ,
89107 error : null ,
90108
91109 appMode : { mode : 'default' , portableDir : null , defaultPortableDir : null } ,
92110 appModeRequiresRestart : false ,
111+ setUiZoom : ( zoom : number ) => {
112+ const clamped = Math . min ( UI_ZOOM_MAX , Math . max ( UI_ZOOM_MIN , zoom ) )
113+ set ( { uiZoom : clamped } )
114+ try { localStorage . setItem ( UI_ZOOM_STORAGE_KEY , String ( clamped ) ) } catch { /* noop */ }
115+ } ,
93116
94117 fetchAll : async ( ) => {
95118 set ( { isLoading : true , error : null } )
0 commit comments