mirror of
https://github.com/imsyy/SPlayer.git
synced 2025-11-25 03:14:57 +08:00
🐞 fix: 修复未加载提示 #561
This commit is contained in:
@@ -59,7 +59,6 @@ export default {
|
||||
"isRef": true,
|
||||
"isShallow": true,
|
||||
"makeDestructurable": true,
|
||||
"manualResetRef": true,
|
||||
"markRaw": true,
|
||||
"nextTick": true,
|
||||
"onActivated": true,
|
||||
@@ -97,11 +96,11 @@ export default {
|
||||
"refAutoReset": true,
|
||||
"refDebounced": true,
|
||||
"refDefault": true,
|
||||
"refManualReset": true,
|
||||
"refThrottled": true,
|
||||
"refWithControl": true,
|
||||
"resolveComponent": true,
|
||||
"resolveRef": true,
|
||||
"resolveUnref": true,
|
||||
"shallowReactive": true,
|
||||
"shallowReadonly": true,
|
||||
"shallowRef": true,
|
||||
|
||||
@@ -82,7 +82,7 @@ const initLyricIpc = (): void => {
|
||||
|
||||
// 音乐名称更改
|
||||
ipcMain.on("play-song-change", (_, title) => {
|
||||
if (!title || !isWinAlive(lyricWin)) return;
|
||||
if (!isWinAlive(lyricWin)) return;
|
||||
lyricWin.webContents.send("update-desktop-lyric-data", { playName: title });
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ipcMain } from "electron";
|
||||
import { getMainTray } from "../tray";
|
||||
import lyricWindow from "../windows/lyric-window";
|
||||
import { appName } from "../utils/config";
|
||||
|
||||
/**
|
||||
* 托盘 IPC
|
||||
@@ -18,7 +19,7 @@ const initTrayIpc = (): void => {
|
||||
|
||||
// 音乐名称更改
|
||||
ipcMain.on("play-song-change", (_, title) => {
|
||||
if (!title) return;
|
||||
if (!title) title = appName;
|
||||
// 更改标题
|
||||
tray?.setTitle(title);
|
||||
tray?.setPlayName(title);
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
<!-- 音质 -->
|
||||
<n-tag
|
||||
v-if="song?.quality && settingStore.showSongQuality"
|
||||
:bordered="false"
|
||||
:type="qualityColor"
|
||||
class="quality"
|
||||
round
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { DropdownOption } from "naive-ui";
|
||||
import type { SongType, SortType } from "@/types/main";
|
||||
import { SongType, SortType } from "@/types/main";
|
||||
import { useMusicStore, useStatusStore } from "@/stores";
|
||||
import { VirtList } from "vue-virt-list";
|
||||
import { entries, isEmpty } from "lodash-es";
|
||||
|
||||
@@ -81,13 +81,7 @@
|
||||
<template #footer>
|
||||
<n-grid :cols="2" x-gap="16" class="playlist-menu">
|
||||
<n-gi>
|
||||
<n-button
|
||||
:focusable="false"
|
||||
size="large"
|
||||
strong
|
||||
secondary
|
||||
@click="player.cleanPlayList()"
|
||||
>
|
||||
<n-button :focusable="false" size="large" strong secondary @click="cleanPlayList">
|
||||
<template #icon>
|
||||
<SvgIcon name="DeleteSweep" />
|
||||
</template>
|
||||
@@ -139,6 +133,20 @@ const playListData = computed(() => {
|
||||
const scrollToItem = (index: number, behavior: "smooth" | "auto" = "smooth") => {
|
||||
playListRef.value?.scrollTo({ index, behavior });
|
||||
};
|
||||
|
||||
// 清空播放列表
|
||||
const cleanPlayList = () => {
|
||||
window.$dialog.warning({
|
||||
title: "清空播放列表",
|
||||
content: "确认清空全部播放列表吗?",
|
||||
positiveText: "确认",
|
||||
negativeText: "取消",
|
||||
onPositiveClick: () => {
|
||||
player.cleanPlayList();
|
||||
window.$message.success("播放列表已清空");
|
||||
},
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -433,7 +433,7 @@
|
||||
/>
|
||||
</n-flex>
|
||||
</n-card>
|
||||
<n-card class="set-item">
|
||||
<!-- <n-card class="set-item">
|
||||
<div class="label">
|
||||
<n-text class="name">显示逐字歌词</n-text>
|
||||
<n-text class="tip" :depth="3">是否显示桌面歌词逐字效果</n-text>
|
||||
@@ -444,7 +444,7 @@
|
||||
class="set"
|
||||
@update:value="saveDesktopLyricConfig"
|
||||
/>
|
||||
</n-card>
|
||||
</n-card> -->
|
||||
<n-card class="set-item">
|
||||
<div class="label">
|
||||
<n-text class="name">显示翻译</n-text>
|
||||
|
||||
@@ -78,10 +78,13 @@ export const useMusicStore = defineStore("music", {
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
// 恢复默认音乐数据
|
||||
/** 重置音乐数据 */
|
||||
resetMusicData() {
|
||||
this.playSong = { ...defaultMusicData };
|
||||
this.songLyric = { lrcData: [], yrcData: [] };
|
||||
this.setSongLyric({ lrcData: [], yrcData: [] }, true);
|
||||
if (isElectron) {
|
||||
window.electron.ipcRenderer.send("play-song-change", undefined);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 设置/更新歌曲歌词数据
|
||||
|
||||
@@ -55,7 +55,7 @@ const initIpc = () => {
|
||||
"update-desktop-lyric-data",
|
||||
cloneDeep({
|
||||
playStatus: statusStore.playStatus,
|
||||
playName: getPlayerInfo() ?? "未知歌曲",
|
||||
playName: getPlayerInfo(),
|
||||
currentTime: statusStore.currentTime,
|
||||
songId: musicStore.playSong?.id,
|
||||
songOffset: statusStore.getSongOffset(musicStore.playSong?.id),
|
||||
|
||||
@@ -73,7 +73,6 @@ class Player {
|
||||
250,
|
||||
{ immediate: false },
|
||||
);
|
||||
|
||||
/** 自动关闭定时器 */
|
||||
private autoCloseInterval: ReturnType<typeof setInterval> | undefined;
|
||||
/** 频谱数据 */
|
||||
@@ -125,10 +124,8 @@ class Player {
|
||||
const settingStore = useSettingStore();
|
||||
// 播放信息
|
||||
const { id, path, type } = musicStore.playSong;
|
||||
|
||||
// 统一重置底层播放器
|
||||
this.resetPlayerCore();
|
||||
|
||||
// 创建播放器
|
||||
this.player = new Howl({
|
||||
src,
|
||||
@@ -146,12 +143,8 @@ class Player {
|
||||
if (!settingStore.showSpectrums) this.toggleOutputDevice();
|
||||
// 自动播放
|
||||
if (autoPlay) await this.play();
|
||||
// // 获取歌曲附加信息 - 非电台和本地
|
||||
// if (type !== "radio" && !path) getLyricData(id);
|
||||
// else resetSongLyric();
|
||||
// 获取歌词数据
|
||||
lyricManager.handleLyric(id, path);
|
||||
|
||||
// 新增播放历史
|
||||
if (type !== "radio") dataStore.setHistory(musicStore.playSong);
|
||||
// 获取歌曲封面主色
|
||||
@@ -255,7 +248,6 @@ class Player {
|
||||
this.playerInterval.pause();
|
||||
// statusStore.playStatus = false;
|
||||
console.log("⏹️ song end:", playSongData);
|
||||
|
||||
// 检查是否需要在歌曲结束时执行自动关闭
|
||||
const statusStore = useStatusStore();
|
||||
if (
|
||||
@@ -267,7 +259,6 @@ class Player {
|
||||
this.executeAutoClose();
|
||||
return;
|
||||
}
|
||||
|
||||
this.nextOrPrev("next", true, true);
|
||||
});
|
||||
// 错误
|
||||
@@ -461,8 +452,9 @@ class Player {
|
||||
* 重置状态
|
||||
*/
|
||||
resetStatus() {
|
||||
const statusStore = useStatusStore();
|
||||
const musicStore = useMusicStore();
|
||||
const statusStore = useStatusStore();
|
||||
const settingStore = useSettingStore();
|
||||
// 重置状态
|
||||
statusStore.$patch({
|
||||
currentTime: 0,
|
||||
@@ -472,10 +464,11 @@ class Player {
|
||||
playStatus: false,
|
||||
playLoading: false,
|
||||
});
|
||||
musicStore.$patch({
|
||||
playPlaylistId: 0,
|
||||
playSong: {},
|
||||
});
|
||||
musicStore.playPlaylistId = 0;
|
||||
musicStore.resetMusicData();
|
||||
if (settingStore.showTaskbarProgress) {
|
||||
window.electron.ipcRenderer.send("set-bar", "none");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 初始化播放器
|
||||
@@ -515,7 +508,7 @@ class Player {
|
||||
}
|
||||
}
|
||||
// 在线歌曲
|
||||
else if (id && dataStore.playList.length) {
|
||||
else if (id && (dataStore.playList.length || statusStore.personalFmMode)) {
|
||||
// 播放地址
|
||||
let playerUrl: string | null = null;
|
||||
|
||||
@@ -662,15 +655,18 @@ class Player {
|
||||
const { playList } = dataStore;
|
||||
const { playSong } = musicStore;
|
||||
const { playSongMode, playHeartbeatMode } = statusStore;
|
||||
// 列表长度
|
||||
const playListLength = playList.length;
|
||||
// 播放列表是否为空
|
||||
if (playListLength === 0) throw new Error("Play list is empty");
|
||||
// 若为私人FM
|
||||
if (statusStore.personalFmMode) {
|
||||
await this.initPersonalFM(true);
|
||||
return;
|
||||
}
|
||||
// 列表长度
|
||||
const playListLength = playList.length;
|
||||
// 播放列表是否为空
|
||||
if (playListLength === 0) {
|
||||
window.$message.error("播放列表为空,请添加歌曲");
|
||||
return;
|
||||
}
|
||||
// 只有一首歌的特殊处理
|
||||
if (playListLength === 1) {
|
||||
statusStore.playLoading = false;
|
||||
@@ -1048,7 +1044,6 @@ class Player {
|
||||
*/
|
||||
async cleanPlayList() {
|
||||
const dataStore = useDataStore();
|
||||
const musicStore = useMusicStore();
|
||||
const statusStore = useStatusStore();
|
||||
// 停止播放
|
||||
Howler.unload();
|
||||
@@ -1061,9 +1056,9 @@ class Player {
|
||||
personalFmMode: false,
|
||||
playIndex: -1,
|
||||
});
|
||||
musicStore.resetMusicData();
|
||||
dataStore.setPlayList([]);
|
||||
window.$message.success("已清空播放列表");
|
||||
// 清空播放列表及缓存
|
||||
await dataStore.setPlayList([]);
|
||||
await dataStore.clearOriginalPlayList();
|
||||
}
|
||||
/**
|
||||
* 切换输出设备
|
||||
|
||||
@@ -72,9 +72,7 @@
|
||||
:ref="(el) => line.active && (currentLineRef = el as HTMLElement)"
|
||||
>
|
||||
<!-- 逐字歌词渲染 -->
|
||||
<template
|
||||
v-if="lyricConfig.showYrc && lyricData?.yrcData?.length && line.line?.words?.length > 1"
|
||||
>
|
||||
<template v-if="lyricData?.yrcData?.length && line.line?.words?.length > 1">
|
||||
<span
|
||||
class="scroll-content"
|
||||
:style="getScrollStyle(line)"
|
||||
@@ -132,7 +130,7 @@ import defaultDesktopLyricConfig from "@/assets/data/lyricConfig";
|
||||
|
||||
// 桌面歌词数据
|
||||
const lyricData = reactive<LyricData>({
|
||||
playName: "未知歌曲",
|
||||
playName: "",
|
||||
playStatus: false,
|
||||
currentTime: 0,
|
||||
lyricLoading: false,
|
||||
@@ -230,6 +228,10 @@ const renderLyricLines = computed<RenderLine[]>(() => {
|
||||
active: true,
|
||||
},
|
||||
];
|
||||
// 无歌曲名且无歌词
|
||||
if (!lyricData.playName && !lyrics?.length) {
|
||||
return placeholder("SPlayer Desktop Lyric");
|
||||
}
|
||||
// 加载中
|
||||
if (lyricData.lyricLoading) return placeholder("歌词加载中...");
|
||||
// 纯音乐
|
||||
|
||||
Reference in New Issue
Block a user