mirror of
https://ghproxy.com/https://github.com/StreakingMan/solvable-sheep-game
synced 2025-07-07 20:58:17 +08:00
fix: 防止音频配置错误时阻塞主流程
This commit is contained in:
parent
b158f2346c
commit
ad01eb2dbb
21
src/App.tsx
21
src/App.tsx
|
@ -215,9 +215,9 @@ const App: FC = () => {
|
|||
if (!bgmRef.current) return;
|
||||
if (bgmOn) {
|
||||
bgmRef.current.volume = 0.5;
|
||||
bgmRef.current.play();
|
||||
bgmRef.current.play().then();
|
||||
} else {
|
||||
bgmRef.current?.pause();
|
||||
bgmRef.current.pause();
|
||||
}
|
||||
}, [bgmOn]);
|
||||
|
||||
|
@ -416,9 +416,13 @@ const App: FC = () => {
|
|||
symbol.status = 1;
|
||||
|
||||
// 点击音效
|
||||
if (soundRefMap.current) {
|
||||
// 不知道为啥敲可选链会提示错误。。。
|
||||
if (
|
||||
soundRefMap.current &&
|
||||
soundRefMap.current[symbol.icon.clickSound]
|
||||
) {
|
||||
soundRefMap.current[symbol.icon.clickSound].currentTime = 0;
|
||||
soundRefMap.current[symbol.icon.clickSound].play();
|
||||
soundRefMap.current[symbol.icon.clickSound].play().then();
|
||||
}
|
||||
|
||||
let updateQueue = queue.slice();
|
||||
|
@ -440,11 +444,16 @@ const App: FC = () => {
|
|||
if (find) {
|
||||
find.status = 2;
|
||||
// 三连音效
|
||||
if (soundRefMap.current) {
|
||||
if (
|
||||
soundRefMap.current &&
|
||||
soundRefMap.current[symbol.icon.tripleSound]
|
||||
) {
|
||||
soundRefMap.current[
|
||||
symbol.icon.tripleSound
|
||||
].currentTime = 0;
|
||||
soundRefMap.current[symbol.icon.tripleSound].play();
|
||||
soundRefMap.current[symbol.icon.tripleSound]
|
||||
.play()
|
||||
.then();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -399,7 +399,7 @@ export const ConfigDialog: FC<{
|
|||
/>
|
||||
{customThemeInfo?.background?.startsWith('https') && (
|
||||
<>
|
||||
毛玻璃效果:
|
||||
毛玻璃:
|
||||
<input
|
||||
checked={customThemeInfo.backgroundBlur}
|
||||
onChange={(e) =>
|
||||
|
|
Loading…
Reference in New Issue
Block a user