fix: 调整优化展示判断逻辑

This commit is contained in:
ykxkykx
2023-01-03 17:40:31 +08:00
parent 936e882ac2
commit 1a0047e244
4 changed files with 19 additions and 13 deletions

View File

@@ -103,8 +103,8 @@ const CommonScript = () => {
</>)}
{/* 引入音乐播放 */}
<script async src="https://cdnjs.cloudflare.com/ajax/libs/aplayer/1.10.1/APlayer.min.js" />
<script async src="https://cdnjs.cloudflare.com/ajax/libs/meting/2.0.1/Meting.min.js" />
{JSON.parse(BLOG.MUSIC_PLAYER) && <script async src="https://cdnjs.cloudflare.com/ajax/libs/aplayer/1.10.1/APlayer.min.js" />}
{JSON.parse(BLOG.MUSIC_PLAYER) && JSON.parse(BLOG.MUSIC_PLAYER_METING) && <script async src="https://cdnjs.cloudflare.com/ajax/libs/meting/2.0.1/Meting.min.js" />}
</>)
}

View File

@@ -5,14 +5,20 @@ const Player = () => {
const [player, setPlayer] = React.useState()
const ref = React.useRef(null)
const showLrc = JSON.parse(BLOG.MUSIC_PLAYER_SHOW_LRC)
const playerVisible = JSON.parse(BLOG.MUSIC_PLAYER_VISIBLE)
const autoPlay = JSON.parse(BLOG.MUSIC_PLAYER_AUTO_PLAY)
const meting = JSON.parse(BLOG.MUSIC_PLAYER_METING)
React.useEffect(() => {
if (BLOG.MUSIC_PLAYER && !BLOG.MUSIC_PLAYER_METING) {
if (!meting) {
setPlayer(new window.APlayer({
container: ref.current,
fixed: true,
showlrc: BLOG.MUSIC_PLAYER_SHOW_LRC,
showlrc: showLrc,
autoplay: autoPlay,
order: BLOG.MUSIC_PLAYER_ORDER,
autoplay: BLOG.MUSIC_PLAYER_AUTO_PLAY,
audio: BLOG.MUSIC_PLAYER_AUDIO_LIST
}))
}
@@ -22,18 +28,18 @@ const Player = () => {
}, [])
return (
<div className={BLOG.MUSIC_PLAYER_VISIBLE ? 'visible' : 'invisible'}>
<div className={playerVisible ? 'visible' : 'invisible'}>
<link
rel="stylesheet"
type="text/css"
href="https://cdnjs.cloudflare.com/ajax/libs/aplayer/1.10.1/APlayer.min.css"
/>
{BLOG.MUSIC_PLAYER && BLOG.MUSIC_PLAYER_METING
{meting
? <meting-js
fixed
type="playlist"
autoplay={autoPlay}
order={BLOG.MUSIC_PLAYER_ORDER}
autoplay={BLOG.MUSIC_PLAYER_AUTO_PLAY}
server={BLOG.MUSIC_PLAYER_METING_SERVER}
id={BLOG.MUSIC_PLAYER_METING_ID}
/>