This repository was archived by the owner on Jan 2, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import {
2525 getPlainFromStorage ,
2626 LANGUAGE_KEY ,
2727 savePlainToStorage ,
28+ USER_FONT_SIZE_KEY ,
2829} from '../../../client/src/services/storage' ;
2930import { LocaleType } from '../../../client/src/types/general' ;
3031import { polling } from '../../../client/src/utils/requestUtils' ;
@@ -165,12 +166,25 @@ function App() {
165166 . getPropertyValue ( 'font-size' ) ;
166167 const fontSize = parseFloat ( style ) ;
167168
168- ( root as HTMLElement ) . style . fontSize =
169- ( e . key === '0' ? 16 : fontSize + ( e . key === '=' ? 1 : - 1 ) ) + 'px' ;
169+ const newFontSize =
170+ e . key === '0' ? 16 : fontSize + ( e . key === '=' ? 1 : - 1 ) ;
171+ ( root as HTMLElement ) . style . fontSize = newFontSize + 'px' ;
172+ savePlainToStorage ( USER_FONT_SIZE_KEY , newFontSize ) ;
170173 }
171174 } , [ ] ) ;
172175 useKeyboardNavigation ( handleKeyEvent ) ;
173176
177+ useEffect ( ( ) => {
178+ const root = document . querySelector ( ':root' ) ;
179+ if ( ! root ) {
180+ return ;
181+ }
182+ const newFontSize = getPlainFromStorage ( USER_FONT_SIZE_KEY ) ;
183+ if ( newFontSize ) {
184+ ( root as HTMLElement ) . style . fontSize = newFontSize + 'px' ;
185+ }
186+ } , [ ] ) ;
187+
174188 useEffect ( ( ) => {
175189 let intervalId : number ;
176190 if ( ! Object . keys ( envConfig ) . length ) {
Original file line number Diff line number Diff line change @@ -37,3 +37,4 @@ export const ANSWER_SPEED_KEY = 'answer_speed_key';
3737export const HIDE_TUTORIALS_KEY = 'hide_tutorials' ;
3838export const ACCESS_TOKEN_KEY = 'access_token' ;
3939export const REFRESH_TOKEN_KEY = 'refresh_token' ;
40+ export const USER_FONT_SIZE_KEY = 'user_font_size' ;
You can’t perform that action at this time.
0 commit comments