mirror of
https://github.com/imsyy/SPlayer.git
synced 2025-11-25 11:29:26 +08:00
fix: 使消息同时只存在一个
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<Transition mode="out-in" appear>
|
||||
<Transition mode="out-in" appear v-if="music.getPlaySongLyric">
|
||||
<div
|
||||
class="countdown"
|
||||
:style="{ animationPlayState: music.getPlayState ? 'running' : 'paused' }"
|
||||
@@ -24,33 +24,35 @@ const music = musicStore();
|
||||
// 剩余点数
|
||||
const remainingPoint = ref(0);
|
||||
// 总时长
|
||||
const totalDuration = ref(
|
||||
music.getPlaySongLyric.hasYrc
|
||||
? music.getPlaySongLyric?.yrc[0].time
|
||||
: music.getPlaySongLyric?.lrc[0].time
|
||||
);
|
||||
const totalDuration = ref(0);
|
||||
|
||||
// 监听歌曲时长变化
|
||||
watch(
|
||||
() => music.getPlaySongTime.currentTime,
|
||||
(val) => {
|
||||
if (music.getPlaySongLyric.lrc[0]) {
|
||||
const remainingTime = totalDuration.value - val - 0.5;
|
||||
const progress = 1 - remainingTime / totalDuration.value;
|
||||
remainingPoint.value = Number(Math.floor(3 * progress));
|
||||
if (music.getPlaySongLyric) {
|
||||
const lyric =
|
||||
music.getPlaySongLyric.lrc[0] || music.getPlaySongLyric.yrc[0];
|
||||
if (lyric) {
|
||||
totalDuration.value = lyric.time;
|
||||
const remainingTime = totalDuration.value - val - 0.5;
|
||||
const progress = 1 - remainingTime / totalDuration.value;
|
||||
remainingPoint.value = Number(Math.floor(3 * progress));
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// 监听歌曲改变
|
||||
watch(
|
||||
() => music.getPlaySongLyric?.lrc,
|
||||
() => music.getPlaySongLyric,
|
||||
(val) => {
|
||||
if (music.getPlaySongLyric.lrc[0]) {
|
||||
totalDuration.value = music.getPlaySongLyric.hasYrc
|
||||
? music.getPlaySongLyric?.yrc[0].time
|
||||
: val[0].time;
|
||||
remainingPoint.value = 0;
|
||||
if (val) {
|
||||
const lyric = val.lrc[0] || val.yrc[0];
|
||||
if (lyric) {
|
||||
totalDuration.value = lyric.time;
|
||||
remainingPoint.value = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -67,6 +69,7 @@ watch(
|
||||
opacity: 0;
|
||||
transform: scale(0);
|
||||
}
|
||||
|
||||
.countdown {
|
||||
animation: breathe 5s ease-in-out infinite;
|
||||
.point {
|
||||
@@ -77,13 +80,16 @@ watch(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes breathe {
|
||||
0% {
|
||||
transform: scale(0.95);
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: scale(0.95);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<n-loading-bar-provider>
|
||||
<n-dialog-provider>
|
||||
<n-notification-provider>
|
||||
<n-message-provider>
|
||||
<n-message-provider :max="1">
|
||||
<slot></slot>
|
||||
<NaiveProviderContent />
|
||||
</n-message-provider>
|
||||
|
||||
@@ -49,8 +49,6 @@ const useMusicDataStore = defineStore("musicData", {
|
||||
},
|
||||
// 是否正在加载数据
|
||||
isLoadingSong: false,
|
||||
// 临时弹窗数据
|
||||
message: null,
|
||||
// 持久化数据
|
||||
persistData: {
|
||||
// 搜索历史
|
||||
@@ -369,8 +367,7 @@ const useMusicDataStore = defineStore("musicData", {
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.message?.destroy();
|
||||
this.message = $message.info(getLanguageData(value), {
|
||||
$message.info(getLanguageData(value), {
|
||||
icon: () =>
|
||||
h(NIcon, null, {
|
||||
default: () => h(modeObj[this.persistData.playSongMode]),
|
||||
|
||||
@@ -81,12 +81,15 @@ export const createSound = (src, autoPlay = true) => {
|
||||
music.setPlayState(true);
|
||||
const songName = music.getPlaySongData.name;
|
||||
const songArtist = music.getPlaySongData.artist[0].name;
|
||||
$message.info(songName + " - " + songArtist, {
|
||||
icon: () =>
|
||||
h(NIcon, null, {
|
||||
default: () => h(MusicNoteFilled),
|
||||
}),
|
||||
});
|
||||
// 播放通知
|
||||
if (typeof $message !== "undefined") {
|
||||
$message.info(songName + " - " + songArtist, {
|
||||
icon: () =>
|
||||
h(NIcon, null, {
|
||||
default: () => h(MusicNoteFilled),
|
||||
}),
|
||||
});
|
||||
}
|
||||
console.log("开始播放:" + songName + " - " + songArtist);
|
||||
// 获取播放器信息
|
||||
timeupdateInterval = setInterval(() => checkAudioTime(sound, music), 250);
|
||||
|
||||
Reference in New Issue
Block a user