Commit 2df095d8 authored by haiyoucuv's avatar haiyoucuv

music

parent 2ce6ec9d
...@@ -4,4 +4,4 @@ xxxxxxx ...@@ -4,4 +4,4 @@ xxxxxxx
## 20230202 [大雁链接](https://www.bilibili.com) ## 20230202 [大雁链接](https://www.bilibili.com)
+ haha + haha
+ haha1 + haha1
+ haha2 + haha2
\ No newline at end of file
import React from "react";
import { observer } from "mobx-react";
import "./MusicBtn.less";
import classNames from "classnames";
import { RES_PATH } from "../../../sparkrc";
import musicStore from "@src/store/musicStore";
import { Button } from "@src/components/Button";
@observer
class MusicBtn extends React.Component {
componentDidMount() {
}
componentWillUnmount() {
}
/**
* 音效加载/播放
*/
toggleHandle = (e) => {
const { onClick } = this.props;
musicStore.mute = !musicStore.mute;
onClick?.(e);
};
render() {
const {
children,
className,
style = {},
enable = RES_PATH + "common/musicOpen.png",
disable = RES_PATH + "common/musicClose.png"
} = this.props;
const { mute } = musicStore;
const cls = classNames(`com-music-btn`, className);
return <Button
className={cls}
style={{
...style
}}
onClick={this.toggleHandle}>
{
mute
? <img src={disable} />
: <img src={enable} />
}
{children}
</Button>;
}
}
export default MusicBtn;
@import "../../res.less";
.com-music-btn {
width: 64px;
height: 64px;
& > img {
display: block;
width: 100%;
height: 100%;
}
}
...@@ -13,6 +13,7 @@ import { SvgaPlayer } from "@spark/svgaplayer"; ...@@ -13,6 +13,7 @@ import { SvgaPlayer } from "@spark/svgaplayer";
import { RES_PATH } from "../../../sparkrc"; import { RES_PATH } from "../../../sparkrc";
import shareStore from "@src/store/share"; import shareStore from "@src/store/share";
import musicStore from "@src/store/musicStore"; import musicStore from "@src/store/musicStore";
import MusicBtn from "@src/components/MusicBtn/MusicBtn";
@observer @observer
...@@ -27,7 +28,7 @@ class Userhomepage extends React.Component { ...@@ -27,7 +28,7 @@ class Userhomepage extends React.Component {
async componentDidMount() { async componentDidMount() {
musicStore.playSound(RES_PATH + "/audio/1.mp3", true); musicStore.playSound(RES_PATH + "/audio/bgm.mp3", true);
await store.getHomeInfo(); await store.getHomeInfo();
this.flushCD(); this.flushCD();
...@@ -167,6 +168,8 @@ class Userhomepage extends React.Component { ...@@ -167,6 +168,8 @@ class Userhomepage extends React.Component {
<div className="inviteBtnImg" /> <div className="inviteBtnImg" />
</Button> </Button>
<MusicBtn className="musicBtn"/>
<div className="rankBg" style={{ borderWidth: "2px" }}> <div className="rankBg" style={{ borderWidth: "2px" }}>
<div className="rankTop" style={{ left: 0, top: -2 }} /> <div className="rankTop" style={{ left: 0, top: -2 }} />
<div className="rankBgInner"> <div className="rankBgInner">
......
...@@ -150,7 +150,6 @@ ...@@ -150,7 +150,6 @@
top: 1127px; top: 1127px;
width: 377px; width: 377px;
height: 123px; height: 123px;
//.sparkBg("userHomePage/按钮.png");
.inviteBtnImg { .inviteBtnImg {
width: 100%; width: 100%;
...@@ -160,6 +159,14 @@ ...@@ -160,6 +159,14 @@
} }
} }
.musicBtn {
position: absolute;
left: 685px;
top: 165px;
width: 47px;
height: 47px;
}
.drawBtn { .drawBtn {
position: absolute; position: absolute;
left: 585px; left: 585px;
......
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