feat: 移除不再使用的配置文件和更新组件,提升代码整洁性
- 删除 .claude/settings.local.json 配置文件,清理不必要的代码。 - 更新多个组件以引入音频资源,增强用户互动体验。 - 调整引导对话文本,确保信息准确性和一致性。 - 更新图像资源,提升视觉内容的准确性和一致性。
This commit is contained in:
1 parent
cf64e7ec50
commit
8ba36a4a1a
132 files changed
+546
-454
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { Image } from "@/components";
|
||||
import { getStaticImage, getBackgroundImage } from "@/lib/utils";
|
||||
import type { MouseEvent } from "react";
|
||||
import { useEffect } from "react";
|
||||
import { useAudioManager } from "@/hooks/useAudioManager";
|
||||
|
||||
export interface SuccessAlertProps {
|
||||
/** 标题 */
|
||||
@@ -9,6 +10,12 @@ export interface SuccessAlertProps {
|
||||
content?: string;
|
||||
/** 是否可见 */
|
||||
visible?: boolean;
|
||||
/** 成功提示音频地址(可选) */
|
||||
audioSrc?: string;
|
||||
/** 弹窗出现时是否自动播放音频(默认 true) */
|
||||
autoPlayAudio?: boolean;
|
||||
/** 音频分组 id,相同 channel 内互斥,不同 channel 可同时播放;不传则全局互斥 */
|
||||
audioChannelId?: string;
|
||||
/** 点击遮罩层回调 */
|
||||
onMaskClick?: () => void;
|
||||
/** 继续按钮回调 */
|
||||
@@ -25,15 +32,44 @@ const SuccessAlert = ({
|
||||
title = "恭喜你, 选择正确!",
|
||||
content,
|
||||
visible = true,
|
||||
audioSrc,
|
||||
autoPlayAudio = true,
|
||||
audioChannelId,
|
||||
onMaskClick,
|
||||
onContinue,
|
||||
onClose,
|
||||
}: SuccessAlertProps) => {
|
||||
const { currentSrc, play, stop } = useAudioManager(
|
||||
audioChannelId
|
||||
? { mode: "channel", channelId: audioChannelId }
|
||||
: { mode: "global" }
|
||||
);
|
||||
|
||||
// 弹窗显示时自动播放音频
|
||||
useEffect(() => {
|
||||
if (!visible) return;
|
||||
if (!autoPlayAudio) return;
|
||||
if (!audioSrc) return;
|
||||
play(audioSrc);
|
||||
}, [visible, autoPlayAudio, audioSrc, play]);
|
||||
|
||||
// 弹窗关闭时停止音频(仅当当前播放的是该弹窗的 audioSrc)
|
||||
useEffect(() => {
|
||||
if (visible) return;
|
||||
if (audioSrc && currentSrc === audioSrc) {
|
||||
stop();
|
||||
}
|
||||
}, [visible, audioSrc, currentSrc, stop]);
|
||||
|
||||
if (!visible) return null;
|
||||
|
||||
const handleContinue = (e: MouseEvent) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
// 点击继续时停止音频
|
||||
if (audioSrc && currentSrc === audioSrc) {
|
||||
stop();
|
||||
}
|
||||
// 只调用 onContinue,它会处理关闭逻辑
|
||||
if (onContinue) {
|
||||
onContinue();
|
||||
|
||||
Reference in new issue
Block a user