Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
AI_BOOK_TOOL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
AI_BOOK_TOOL
Commits
49492fb2
Commit
49492fb2
authored
Jul 02, 2025
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat
parent
6488e794
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
246 additions
and
62 deletions
+246
-62
index.css
play/index.css
+75
-0
index.html
play/index.html
+64
-47
index.js
play/index.js
+107
-15
No files found.
play/index.css
View file @
49492fb2
...
...
@@ -273,4 +273,79 @@ body::-webkit-scrollbar, html::-webkit-scrollbar {
.debug-info
div
{
margin-bottom
:
5px
;
font-family
:
monospace
;
}
/* 预加载界面样式 */
.loading-screen
{
position
:
fixed
;
top
:
0
;
left
:
0
;
width
:
100vw
;
height
:
100vh
;
background
:
linear-gradient
(
135deg
,
#667eea
0%
,
#764ba2
100%
);
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
z-index
:
9999
;
}
.loading-content
{
text-align
:
center
;
color
:
white
;
max-width
:
400px
;
padding
:
40px
;
}
.loading-spinner
{
width
:
60px
;
height
:
60px
;
border
:
4px
solid
rgba
(
255
,
255
,
255
,
0.3
);
border-top
:
4px
solid
white
;
border-radius
:
50%
;
animation
:
spin
1s
linear
infinite
;
margin
:
0
auto
20px
;
}
@keyframes
spin
{
0
%
{
transform
:
rotate
(
0deg
);
}
100
%
{
transform
:
rotate
(
360deg
);
}
}
.loading-text
{
font-size
:
24px
;
font-weight
:
bold
;
margin-bottom
:
30px
;
}
.loading-progress
{
margin-top
:
20px
;
}
.progress-bar
{
width
:
100%
;
height
:
8px
;
background
:
rgba
(
255
,
255
,
255
,
0.3
);
border-radius
:
4px
;
overflow
:
hidden
;
margin-bottom
:
10px
;
}
.progress-fill
{
height
:
100%
;
background
:
white
;
border-radius
:
4px
;
transition
:
width
0.3s
ease
;
}
.progress-text
{
font-size
:
16px
;
opacity
:
0.8
;
}
/* 主要内容样式 */
.main-content
{
width
:
100vw
;
height
:
100vh
;
position
:
relative
;
overflow
:
hidden
;
}
\ No newline at end of file
play/index.html
View file @
49492fb2
...
...
@@ -16,58 +16,75 @@
</head>
<body>
<div
id=
"app"
>
<div
class=
"page-container"
>
<transition
:name=
"pageTransition"
>
<div
class=
"full-image-wrapper"
:key=
"currentPage"
>
<img
ref=
"mainImg"
:src=
"pages[currentPage].image_url"
:alt=
"'Page ' + pages[currentPage].page"
v-if=
"pages.length"
class=
"full-image"
/>
<template
v-if=
"currentRects && isRectVisible"
>
<div
v-for=
"(rect, idx) in currentRects"
:key=
"idx"
class=
"rect-layer rect-visible"
:style=
"getRectStyle(rect)"
></div>
</template>
<!-- 单词级别矩形高亮 -->
<template
v-if=
"highlightedWordRects && isRectVisible"
>
<div
v-for=
"(wordRect, idx) in highlightedWordRects"
:key=
"'word-' + idx"
class=
"word-rect-layer"
:style=
"getWordRectStyle(wordRect)"
:title=
"wordRect.text"
></div>
</template>
<!-- 预加载界面 -->
<div
class=
"loading-screen"
v-if=
"isLoading"
>
<div
class=
"loading-content"
>
<div
class=
"loading-spinner"
></div>
<div
class=
"loading-text"
>
正在加载资源...
</div>
<div
class=
"loading-progress"
>
<div
class=
"progress-bar"
>
<div
class=
"progress-fill"
:style=
"{ width: loadingProgress + '%' }"
></div>
</div>
<div
class=
"progress-text"
>
{{ loadedAssets }}/{{ totalAssets }} ({{ loadingProgress }}%)
</div>
</div>
</transition>
</div>
<div
class=
"subtitle-bar"
v-if=
"currentAudioText"
>
<div
class=
"subtitle-text"
>
<span
v-for=
"(word, index) in currentWords"
:key=
"index"
:class=
"{ 'highlighted-word': highlightedWordIndexes.includes(index) }"
>
{{ word.word }}
</span>
</div>
</div>
<!-- 调试面板 -->
<div
class=
"debug-panel"
v-if=
"isPlaying"
>
<div
class=
"debug-info"
>
<div>
时间: {{ debugInfo.currentTime.toFixed(2) }}s
</div>
<div>
单词数: {{ debugInfo.totalWords }}
</div>
<div>
高亮索引: {{ debugInfo.highlightedIndexes.join(', ') }}
</div>
<div>
当前单词: {{ debugInfo.currentWord }}
</div>
<div>
单词矩形数: {{ debugInfo.wordRectsCount }}
</div>
<div>
组单词数: {{ debugInfo.groupWordsCount }}
</div>
<!-- 主要内容 -->
<div
class=
"main-content"
v-else
>
<div
class=
"page-container"
>
<transition
:name=
"pageTransition"
>
<div
class=
"full-image-wrapper"
:key=
"currentPage"
>
<img
ref=
"mainImg"
:src=
"pages[currentPage].image_url"
:alt=
"'Page ' + pages[currentPage].page"
v-if=
"pages.length"
class=
"full-image"
/>
<template
v-if=
"currentRects && isRectVisible"
>
<div
v-for=
"(rect, idx) in currentRects"
:key=
"idx"
class=
"rect-layer rect-visible"
:style=
"getRectStyle(rect)"
></div>
</template>
<!-- 单词级别矩形高亮 -->
<template
v-if=
"highlightedWordRects && isRectVisible"
>
<div
v-for=
"(wordRect, idx) in highlightedWordRects"
:key=
"'word-' + idx"
class=
"word-rect-layer"
:style=
"getWordRectStyle(wordRect)"
:title=
"wordRect.text"
></div>
</template>
</div>
</transition>
</div>
<div
class=
"subtitle-bar"
v-if=
"currentAudioText"
>
<div
class=
"subtitle-text"
>
<span
v-for=
"(word, index) in currentWords"
:key=
"index"
:class=
"{ 'highlighted-word': highlightedWordIndexes.includes(index) }"
>
{{ word.word }}
</span>
</div>
</div>
<!-- 调试面板 -->
<div
class=
"debug-panel"
v-if=
"isPlaying"
>
<div
class=
"debug-info"
>
<div>
时间: {{ debugInfo.currentTime.toFixed(2) }}s
</div>
<div>
单词数: {{ debugInfo.totalWords }}
</div>
<div>
高亮索引: {{ debugInfo.highlightedIndexes.join(', ') }}
</div>
<div>
当前单词: {{ debugInfo.currentWord }}
</div>
<div>
单词矩形数: {{ debugInfo.wordRectsCount }}
</div>
<div>
组单词数: {{ debugInfo.groupWordsCount }}
</div>
</div>
</div>
<div
class=
"fixed-btn-group"
>
<el-button
type=
"primary"
:icon=
"isPlaying ? 'el-icon-video-pause' : 'el-icon-video-play'"
@
click=
"togglePlay"
>
{{ isPlaying ? '暂停' : '播放' }}
</el-button>
<el-button
icon=
"el-icon-arrow-left"
@
click=
"prevPage"
>
上一页
</el-button>
<el-button
icon=
"el-icon-arrow-right"
@
click=
"nextPage"
>
下一页
</el-button>
</div>
</div>
<div
class=
"fixed-btn-group"
>
<el-button
type=
"primary"
:icon=
"isPlaying ? 'el-icon-video-pause' : 'el-icon-video-play'"
@
click=
"togglePlay"
>
{{ isPlaying ? '暂停' : '播放' }}
</el-button>
<el-button
icon=
"el-icon-arrow-left"
@
click=
"prevPage"
>
上一页
</el-button>
<el-button
icon=
"el-icon-arrow-right"
@
click=
"nextPage"
>
下一页
</el-button>
</div>
</div>
</body>
...
...
play/index.js
View file @
49492fb2
...
...
@@ -44,6 +44,11 @@ function initializeApp(data) {
// 单词级别矩形高亮相关
currentGroupWords
:
[],
// 当前活跃组的单词矩形信息
highlightedWordRects
:
[],
// 当前高亮的单词矩形
// 预加载相关
isLoading
:
true
,
loadingProgress
:
0
,
totalAssets
:
0
,
loadedAssets
:
0
,
},
computed
:
{
currentGroups
()
{
...
...
@@ -137,6 +142,8 @@ function initializeApp(data) {
};
}
});
// 开始预加载
this
.
startPreloading
();
},
beforeDestroy
()
{
if
(
this
.
audio
)
{
...
...
@@ -400,25 +407,110 @@ function initializeApp(data) {
pointerEvents
:
'
none
'
,
zIndex
:
3
};
},
startPreloading
()
{
const
assetsToLoad
=
[];
// 添加所有图片
if
(
Array
.
isArray
(
this
.
pages
))
{
this
.
pages
.
forEach
(
page
=>
{
if
(
page
.
image_url
)
{
assetsToLoad
.
push
({
type
:
'
image
'
,
url
:
page
.
image_url
,
name
:
`Page
${
page
.
page
||
'
unknown
'
}
`
});
}
});
}
// 添加音频
if
(
this
.
audioUrl
)
{
assetsToLoad
.
push
({
type
:
'
audio
'
,
url
:
this
.
audioUrl
,
name
:
'
Audio
'
});
}
this
.
totalAssets
=
assetsToLoad
.
length
;
this
.
loadedAssets
=
0
;
if
(
this
.
totalAssets
===
0
)
{
// 没有需要预加载的资源,直接完成
this
.
finishPreloading
();
return
;
}
// 开始加载每个资源
assetsToLoad
.
forEach
(
asset
=>
{
if
(
asset
.
type
===
'
image
'
)
{
this
.
loadImage
(
asset
);
}
else
if
(
asset
.
type
===
'
audio
'
)
{
this
.
loadAudio
(
asset
);
}
});
},
loadImage
(
asset
)
{
const
img
=
new
Image
();
img
.
onload
=
()
=>
{
this
.
assetLoaded
(
asset
);
};
img
.
onerror
=
()
=>
{
console
.
warn
(
`Failed to load image:
${
asset
.
url
}
`
);
this
.
assetLoaded
(
asset
);
};
img
.
src
=
asset
.
url
;
},
loadAudio
(
asset
)
{
const
audio
=
new
Audio
();
audio
.
oncanplaythrough
=
()
=>
{
this
.
assetLoaded
(
asset
);
};
audio
.
onerror
=
()
=>
{
console
.
warn
(
`Failed to load audio:
${
asset
.
url
}
`
);
this
.
assetLoaded
(
asset
);
};
audio
.
src
=
asset
.
url
;
},
assetLoaded
(
asset
)
{
this
.
loadedAssets
++
;
this
.
loadingProgress
=
Math
.
round
((
this
.
loadedAssets
/
this
.
totalAssets
)
*
100
);
console
.
log
(
`Loaded
${
asset
.
type
}
:
${
asset
.
name
}
(
${
this
.
loadedAssets
}
/
${
this
.
totalAssets
}
)`
);
if
(
this
.
loadedAssets
>=
this
.
totalAssets
)
{
this
.
finishPreloading
();
}
},
finishPreloading
()
{
console
.
log
(
'
All assets preloaded successfully!
'
);
this
.
isLoading
=
false
;
// 初始化音频播放器
this
.
audio
=
new
Audio
(
this
.
audioUrl
);
this
.
audio
.
addEventListener
(
'
timeupdate
'
,
this
.
handleTimeUpdate
);
this
.
audio
.
addEventListener
(
'
ended
'
,
this
.
handleAudioEnded
);
this
.
updateImageSize
();
window
.
addEventListener
(
'
resize
'
,
this
.
updateImageSize
);
// 监听图片加载完成,确保能拿到尺寸
this
.
$nextTick
(()
=>
{
const
img
=
this
.
$refs
.
mainImg
;
if
(
img
)
{
img
.
onload
=
()
=>
{
this
.
updateImageSize
();
};
}
});
}
}
});
// 预加载所有图片和音频
if
(
Array
.
isArray
(
data
.
pages
))
{
data
.
pages
.
forEach
(
page
=>
{
if
(
page
.
image_url
)
{
const
img
=
new
window
.
Image
();
img
.
src
=
page
.
image_url
;
}
});
}
if
(
data
.
audio_points
&&
data
.
audio_points
.
audio_url
)
{
const
audio
=
new
window
.
Audio
();
audio
.
src
=
data
.
audio_points
.
audio_url
;
// 可选:audio.preload = 'auto';
}
// Hide loading screen
window
.
air
.
hideAirClassLoading
(
t_name
,
data
);
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment