@@ -1086,9 +1086,6 @@ function initScript() {
10861086 updatePureModeButton ( ) ;
10871087
10881088 const navigation = document . querySelector ( '.navigation' ) ;
1089- const mobileControls = document . querySelector ( '.mobile-controls' ) ;
1090- const topControls = document . querySelector ( '.top-controls' ) ;
1091- const readingControls = document . querySelector ( '.reading-controls' ) ;
10921089 const contentContainer = document . querySelector ( '.content-container' ) ;
10931090 const ebContent = document . getElementById ( 'eb-content' ) ;
10941091
@@ -1100,11 +1097,20 @@ function initScript() {
11001097 // 根据设备类型隐藏不同的控件
11011098 if ( isMobile ( ) ) {
11021099 // 移动端:隐藏 mobile-controls
1103- mobileControls . style . display = 'none' ;
1100+ const mobileControls = document . querySelector ( '.mobile-controls' ) ;
1101+ if ( mobileControls ) {
1102+ mobileControls . style . display = 'none' ;
1103+ }
11041104 } else {
11051105 // 桌面端:隐藏 top-controls 和 reading-controls
1106- topControls . style . display = 'none' ;
1107- readingControls . style . display = 'none' ;
1106+ const topControls = document . querySelector ( '.top-controls' ) ;
1107+ const readingControls = document . querySelector ( '.reading-controls' ) ;
1108+ if ( topControls ) {
1109+ topControls . style . display = 'none' ;
1110+ }
1111+ if ( readingControls ) {
1112+ readingControls . style . display = 'none' ;
1113+ }
11081114 }
11091115
11101116 // 调整内容容器高度,填充导航栏的空间
@@ -1118,11 +1124,20 @@ function initScript() {
11181124 // 根据设备类型显示不同的控件
11191125 if ( isMobile ( ) ) {
11201126 // 移动端:显示 mobile-controls
1121- mobileControls . style . display = 'flex' ;
1127+ const mobileControls = document . querySelector ( '.mobile-controls' ) ;
1128+ if ( mobileControls ) {
1129+ mobileControls . style . display = 'flex' ;
1130+ }
11221131 } else {
11231132 // 桌面端:显示 top-controls 和 reading-controls
1124- topControls . style . display = 'flex' ;
1125- readingControls . style . display = 'flex' ;
1133+ const topControls = document . querySelector ( '.top-controls' ) ;
1134+ const readingControls = document . querySelector ( '.reading-controls' ) ;
1135+ if ( topControls ) {
1136+ topControls . style . display = 'flex' ;
1137+ }
1138+ if ( readingControls ) {
1139+ readingControls . style . display = 'flex' ;
1140+ }
11261141 }
11271142
11281143 // 恢复默认高度
@@ -1148,9 +1163,6 @@ function initScript() {
11481163 updatePureModeButton ( ) ;
11491164
11501165 const navigation = document . querySelector ( '.navigation' ) ;
1151- const mobileControls = document . querySelector ( '.mobile-controls' ) ;
1152- const topControls = document . querySelector ( '.top-controls' ) ;
1153- const readingControls = document . querySelector ( '.reading-controls' ) ;
11541166 const contentContainer = document . querySelector ( '.content-container' ) ;
11551167 const ebContent = document . getElementById ( 'eb-content' ) ;
11561168
@@ -1161,11 +1173,20 @@ function initScript() {
11611173 // 根据设备类型隐藏不同的控件
11621174 if ( isMobile ( ) ) {
11631175 // 移动端:隐藏 mobile-controls
1164- mobileControls . style . display = 'none' ;
1176+ const mobileControls = document . querySelector ( '.mobile-controls' ) ;
1177+ if ( mobileControls ) {
1178+ mobileControls . style . display = 'none' ;
1179+ }
11651180 } else {
11661181 // 桌面端:隐藏 top-controls 和 reading-controls
1167- topControls . style . display = 'none' ;
1168- readingControls . style . display = 'none' ;
1182+ const topControls = document . querySelector ( '.top-controls' ) ;
1183+ const readingControls = document . querySelector ( '.reading-controls' ) ;
1184+ if ( topControls ) {
1185+ topControls . style . display = 'none' ;
1186+ }
1187+ if ( readingControls ) {
1188+ readingControls . style . display = 'none' ;
1189+ }
11691190 }
11701191
11711192 // 调整内容容器高度,填充导航栏的空间
@@ -1181,11 +1202,20 @@ function initScript() {
11811202 // 根据设备类型显示不同的控件
11821203 if ( isMobile ( ) ) {
11831204 // 移动端:显示 mobile-controls
1184- mobileControls . style . display = 'flex' ;
1205+ const mobileControls = document . querySelector ( '.mobile-controls' ) ;
1206+ if ( mobileControls ) {
1207+ mobileControls . style . display = 'flex' ;
1208+ }
11851209 } else {
11861210 // 桌面端:显示 top-controls 和 reading-controls
1187- topControls . style . display = 'flex' ;
1188- readingControls . style . display = 'flex' ;
1211+ const topControls = document . querySelector ( '.top-controls' ) ;
1212+ const readingControls = document . querySelector ( '.reading-controls' ) ;
1213+ if ( topControls ) {
1214+ topControls . style . display = 'flex' ;
1215+ }
1216+ if ( readingControls ) {
1217+ readingControls . style . display = 'flex' ;
1218+ }
11891219 }
11901220
11911221 // 恢复默认高度
0 commit comments