mirror of
https://ghproxy.com/https://github.com/StreakingMan/solvable-sheep-game
synced 2025-07-08 05:46:07 +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 (!bgmRef.current) return;
|
||||||
if (bgmOn) {
|
if (bgmOn) {
|
||||||
bgmRef.current.volume = 0.5;
|
bgmRef.current.volume = 0.5;
|
||||||
bgmRef.current.play();
|
bgmRef.current.play().then();
|
||||||
} else {
|
} else {
|
||||||
bgmRef.current?.pause();
|
bgmRef.current.pause();
|
||||||
}
|
}
|
||||||
}, [bgmOn]);
|
}, [bgmOn]);
|
||||||
|
|
||||||
|
@ -416,9 +416,13 @@ const App: FC = () => {
|
||||||
symbol.status = 1;
|
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].currentTime = 0;
|
||||||
soundRefMap.current[symbol.icon.clickSound].play();
|
soundRefMap.current[symbol.icon.clickSound].play().then();
|
||||||
}
|
}
|
||||||
|
|
||||||
let updateQueue = queue.slice();
|
let updateQueue = queue.slice();
|
||||||
|
@ -440,11 +444,16 @@ const App: FC = () => {
|
||||||
if (find) {
|
if (find) {
|
||||||
find.status = 2;
|
find.status = 2;
|
||||||
// 三连音效
|
// 三连音效
|
||||||
if (soundRefMap.current) {
|
if (
|
||||||
|
soundRefMap.current &&
|
||||||
|
soundRefMap.current[symbol.icon.tripleSound]
|
||||||
|
) {
|
||||||
soundRefMap.current[
|
soundRefMap.current[
|
||||||
symbol.icon.tripleSound
|
symbol.icon.tripleSound
|
||||||
].currentTime = 0;
|
].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') && (
|
{customThemeInfo?.background?.startsWith('https') && (
|
||||||
<>
|
<>
|
||||||
毛玻璃效果:
|
毛玻璃:
|
||||||
<input
|
<input
|
||||||
checked={customThemeInfo.backgroundBlur}
|
checked={customThemeInfo.backgroundBlur}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user