Commit ac2beea7 authored by love_飞影's avatar love_飞影 Committed by Chunchi Che

feat: 移除音效代理

parent 3413d383
import { Button } from "antd";
import { settingStore } from "@/stores/settingStore"; import { settingStore } from "@/stores/settingStore";
import { audioContextManger } from "../core/manager"; import { audioContextManger } from "../core/manager";
...@@ -12,27 +10,3 @@ export function playEffect(effect: AudioActionType) { ...@@ -12,27 +10,3 @@ export function playEffect(effect: AudioActionType) {
settingStore.audio.soundEffectsVolume, settingStore.audio.soundEffectsVolume,
); );
} }
// 代理所有 antd button 音效
Reflect.set(
Button,
"render",
new Proxy(Reflect.get(Button, "render"), {
apply(target, thisArg, args) {
const [props] = args;
const { onClick } = props;
// onClick is read-only, so we need to use the following code
const _onClick: React.MouseEventHandler<HTMLElement> = (...args) => {
playEffect(AudioActionType.SOUND_BUTTON);
onClick(...args);
};
return target.apply(thisArg, [
{
...props,
onClick: _onClick,
},
...args.slice(1),
]);
},
}),
);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment