@@ -6,7 +6,7 @@ import styles from '@/UI/Menu/Options/options.module.scss';
66import useFullScreen from '@/hooks/useFullScreen' ;
77import useTrans from '@/hooks/useTrans' ;
88import { RootState } from '@/store/store' ;
9- import { textFont , textSize } from '@/store/userDataInterface' ;
9+ import { textSize } from '@/store/userDataInterface' ;
1010import { setOptionData } from '@/store/userDataReducer' ;
1111import { useDispatch , useSelector } from 'react-redux' ;
1212import { OptionSlider } from '../OptionSlider' ;
@@ -16,6 +16,15 @@ export function Display() {
1616 const dispatch = useDispatch ( ) ;
1717 const t = useTrans ( 'menu.options.pages.display.options.' ) ;
1818 const { isSupported : isFullscreenSupported , enter : enterFullscreen , exit : exitFullscreen } = useFullScreen ( ) ;
19+ const fontOptions = useSelector ( ( state : RootState ) => state . GUI . fontOptions ) ;
20+ const fontOptionTexts = fontOptions . map ( ( option ) => {
21+ if ( option . labelKey ) return t ( option . labelKey ) ;
22+ if ( option . label ) return option . label ;
23+ return option . family ;
24+ } ) ;
25+ const currentFontIndex = fontOptions . length
26+ ? Math . min ( userDataState . optionData . textboxFont , fontOptions . length - 1 )
27+ : 0 ;
1928
2029 return (
2130 < div className = { styles . Options_main_content_half } >
@@ -50,22 +59,12 @@ export function Display() {
5059 </ NormalOption >
5160 < NormalOption key = "textFont" title = { t ( 'textFont.title' ) } >
5261 < NormalButton
53- textList = { t ( 'textFont.options.siYuanSimSun' , 'textFont.options.SimHei' , 'textFont.options.lxgw' ) }
54- functionList = { [
55- ( ) => {
56- dispatch ( setOptionData ( { key : 'textboxFont' , value : textFont . song } ) ) ;
57- setStorage ( ) ;
58- } ,
59- ( ) => {
60- dispatch ( setOptionData ( { key : 'textboxFont' , value : textFont . hei } ) ) ;
61- setStorage ( ) ;
62- } ,
63- ( ) => {
64- dispatch ( setOptionData ( { key : 'textboxFont' , value : textFont . lxgw } ) ) ;
65- setStorage ( ) ;
66- } ,
67- ] }
68- currentChecked = { userDataState . optionData . textboxFont }
62+ textList = { fontOptionTexts }
63+ functionList = { fontOptions . map ( ( _ , index ) => ( ) => {
64+ dispatch ( setOptionData ( { key : 'textboxFont' , value : index } ) ) ;
65+ setStorage ( ) ;
66+ } ) }
67+ currentChecked = { currentFontIndex }
6968 />
7069 </ NormalOption >
7170 < NormalOption key = "textSpeed" title = { t ( 'textSpeed.title' ) } >
0 commit comments