feat: 更新场景和组件,优化用户体验
- 更新多个场景中的引导对话,提升学习互动性。 - 修改组件以清理不必要的学习引导弹窗,简化用户流程。 - 调整文本内容,确保信息准确性和一致性。 - 添加背景音乐控制,增强沉浸式体验。
This commit is contained in:
1 parent
d226283e15
commit
71f607f6a3
46 files changed
+423
-372
No files matched your search
@@ -109,11 +109,22 @@ const LuxunInternalization = () => {
|
||||
const [showLetter, setShowLetter] = useState(false);
|
||||
const [showStudyGuide, setShowStudyGuide] = useState(false);
|
||||
const videoRef = useRef<VideoRef>(null);
|
||||
const audioRef = useRef<HTMLAudioElement | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
setVisible(true);
|
||||
}, []);
|
||||
|
||||
// 组件卸载时清理背景音乐
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (audioRef.current) {
|
||||
audioRef.current.pause();
|
||||
audioRef.current.currentTime = 0;
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handleVideoCanPlay = () => {
|
||||
if (showVideo && videoRef.current) {
|
||||
videoRef.current.play().catch((error) => {
|
||||
@@ -247,6 +258,13 @@ const LuxunInternalization = () => {
|
||||
onClick={() => navigate(`/${moduleName}/${starName}/home`)}
|
||||
/>
|
||||
|
||||
{/* 内化结束后的背景音乐 */}
|
||||
<audio
|
||||
ref={audioRef}
|
||||
src={getPublicPath("audio/letter/3我和我的祖国.m4a")}
|
||||
loop
|
||||
/>
|
||||
|
||||
{showVideo && (
|
||||
<Video
|
||||
ref={videoRef}
|
||||
@@ -259,6 +277,14 @@ const LuxunInternalization = () => {
|
||||
onEnded={() => {
|
||||
setShowVideo(false);
|
||||
setPostGuideVisible(true);
|
||||
if (audioRef.current) {
|
||||
audioRef.current.currentTime = 0;
|
||||
audioRef.current
|
||||
.play()
|
||||
.catch((error) => {
|
||||
console.warn("背景音乐播放失败:", error);
|
||||
});
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
@@ -325,6 +351,10 @@ const LuxunInternalization = () => {
|
||||
<StudyGuideModal
|
||||
visible={showStudyGuide}
|
||||
onContinue={() => {
|
||||
if (audioRef.current) {
|
||||
audioRef.current.pause();
|
||||
audioRef.current.currentTime = 0;
|
||||
}
|
||||
setShowStudyGuide(false);
|
||||
navigate(`/${moduleName}/${starName}/home`);
|
||||
}}
|
||||
|
||||
Reference in new issue
Block a user