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