@@ -305,6 +305,39 @@ async function scopeEBStyles(scopeSelector = '[data-eb-styles]') {
305305
306306
307307function initScript ( ) {
308+ // 创建加载动画元素
309+ function createLoadingOverlay ( ) {
310+ const overlay = document . createElement ( 'div' ) ;
311+ overlay . className = 'loading-overlay' ;
312+ overlay . id = 'loadingOverlay' ;
313+
314+ const spinner = document . createElement ( 'div' ) ;
315+ spinner . className = 'loading-spinner' ;
316+
317+ overlay . appendChild ( spinner ) ;
318+ document . body . appendChild ( overlay ) ;
319+ }
320+
321+ // 显示加载动画
322+ function showLoading ( ) {
323+ const overlay = document . getElementById ( 'loadingOverlay' ) ;
324+ if ( overlay ) {
325+ overlay . style . display = 'flex' ;
326+ }
327+ }
328+
329+ // 隐藏加载动画
330+ function hideLoading ( ) {
331+ const overlay = document . getElementById ( 'loadingOverlay' ) ;
332+ if ( overlay ) {
333+ overlay . style . display = 'none' ;
334+ }
335+ }
336+
337+ // 初始化加载动画
338+ createLoadingOverlay ( ) ;
339+ showLoading ( ) ;
340+
308341 // 样式重写,增加区域限定
309342 scopeEBStyles ( ) ;
310343
@@ -583,6 +616,8 @@ function initScript() {
583616
584617 // 创建页面 - 使用 CSS Column 实现
585618 function createPages ( ) {
619+ showLoading ( ) ;
620+
586621 // 保存原始内容
587622 const originalContent = preprocessContent ( content ) ;
588623
@@ -633,6 +668,10 @@ function initScript() {
633668 setTimeout ( ( ) => {
634669 calculateTotalPages ( ) ;
635670 pageJumpInput . setAttribute ( 'max' , totalPages ) ;
671+ // 延迟隐藏加载动画,确保页面完全渲染
672+ setTimeout ( function ( ) {
673+ hideLoading ( ) ;
674+ } , 500 ) ;
636675 } , 200 ) ;
637676 } , 200 ) ;
638677 }
@@ -1097,8 +1136,8 @@ function initScript() {
10971136 const contentContainer = document . querySelector ( '.content-container' ) ;
10981137 const ebContent = document . getElementById ( 'eb-content' ) ;
10991138
1100- // 应用保存的状态
1101- if ( isPureModeEnabled ) {
1139+ // 应用保存的状态 - 只在翻页模式下生效
1140+ if ( isPureModeEnabled && isPaginationMode ) {
11021141 // 隐藏工具栏
11031142 navigation . style . display = 'none' ;
11041143
@@ -1166,6 +1205,12 @@ function initScript() {
11661205
11671206 // 切换纯净阅读模式
11681207 function togglePureMode ( ) {
1208+ // 只在翻页模式下才能切换纯净阅读模式
1209+ if ( ! isPaginationMode ) {
1210+ showNotification ( 'Pure reading mode is only available in page-turning mode' , 'info' ) ;
1211+ return ;
1212+ }
1213+
11691214 isPureModeEnabled = ! isPureModeEnabled ;
11701215 savePureModeState ( ) ;
11711216 updatePureModeButton ( ) ;
@@ -1202,7 +1247,7 @@ function initScript() {
12021247 contentContainer . style . marginBottom = '0' ;
12031248 ebContent . style . minHeight = 'calc(100vh - 80px)' ; // 减去页面顶部和底部的 padding
12041249
1205- showNotification ( 'Pure reading mode enabled' , 'info' ) ;
1250+ showNotification ( 'Pure reading mode enabled. You can click the "Click" button to enable edge-click page turning, or use Spacebar and arrow keys for page navigation. ' , 'info' ) ;
12061251 } else {
12071252 // 显示工具栏
12081253 navigation . style . display = 'flex' ;
@@ -1276,8 +1321,19 @@ function initScript() {
12761321 const centerAreaHeight = rect . height * 0.3 ;
12771322
12781323 if ( Math . abs ( e . clientX - centerX ) < centerAreaWidth && Math . abs ( e . clientY - centerY ) < centerAreaHeight ) {
1279- // 点击中间部分,无论设备类型,都切换纯净模式
1280- togglePureMode ( ) ;
1324+ // 点击中间部分,只有在翻页模式下才切换纯净模式
1325+ if ( isPaginationMode ) {
1326+ // 区分桌面端和移动端的行为
1327+ if ( isMobile ( ) ) {
1328+ // 移动端:点击中间部分切换纯净模式
1329+ togglePureMode ( ) ;
1330+ } else {
1331+ // 桌面端:只有在纯净阅读模式已开启时,点击中间部分才关闭纯净模式
1332+ if ( isPureModeEnabled ) {
1333+ togglePureMode ( ) ;
1334+ }
1335+ }
1336+ }
12811337 }
12821338 } ) ;
12831339
@@ -1303,6 +1359,14 @@ function initScript() {
13031359 showNotification ( 'Click edge to turn page disabled' , 'info' ) ;
13041360 }
13051361 } ) ;
1362+
1363+ // 页面加载完成后隐藏加载动画
1364+ window . addEventListener ( 'load' , function ( ) {
1365+ // 延迟隐藏加载动画,确保页面完全渲染
1366+ setTimeout ( function ( ) {
1367+ hideLoading ( ) ;
1368+ } , 500 ) ;
1369+ } ) ;
13061370
13071371 // 自定义 css
13081372 customCssFunc ( ) ;
0 commit comments