mirror of
https://github.com/imsyy/SPlayer.git
synced 2025-11-25 19:37:35 +08:00
🎈 perf: 完善部分桌面歌词
This commit is contained in:
1
components.d.ts
vendored
1
components.d.ts
vendored
@@ -106,7 +106,6 @@ declare module 'vue' {
|
|||||||
NSlider: typeof import('naive-ui')['NSlider']
|
NSlider: typeof import('naive-ui')['NSlider']
|
||||||
NSpin: typeof import('naive-ui')['NSpin']
|
NSpin: typeof import('naive-ui')['NSpin']
|
||||||
NSwitch: typeof import('naive-ui')['NSwitch']
|
NSwitch: typeof import('naive-ui')['NSwitch']
|
||||||
NTab: typeof import('naive-ui')['NTab']
|
|
||||||
NTabPane: typeof import('naive-ui')['NTabPane']
|
NTabPane: typeof import('naive-ui')['NTabPane']
|
||||||
NTabs: typeof import('naive-ui')['NTabs']
|
NTabs: typeof import('naive-ui')['NTabs']
|
||||||
NTag: typeof import('naive-ui')['NTag']
|
NTag: typeof import('naive-ui')['NTag']
|
||||||
|
|||||||
1
src/assets/icons/Collapse.svg
Normal file
1
src/assets/icons/Collapse.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><!-- Icon from Material Symbols by Google - https://github.com/google/material-design-icons/blob/master/LICENSE --><path fill="currentColor" d="M9 15H6q-.425 0-.712-.288T5 14t.288-.712T6 13h4q.425 0 .713.288T11 14v4q0 .425-.288.713T10 19t-.712-.288T9 18zm6-6h3q.425 0 .713.288T19 10t-.288.713T18 11h-4q-.425 0-.712-.288T13 10V6q0-.425.288-.712T14 5t.713.288T15 6z"/></svg>
|
||||||
|
After Width: | Height: | Size: 455 B |
1
src/assets/icons/Expand.svg
Normal file
1
src/assets/icons/Expand.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><!-- Icon from Material Symbols by Google - https://github.com/google/material-design-icons/blob/master/LICENSE --><path fill="currentColor" d="M7 17h3q.425 0 .713.288T11 18t-.288.713T10 19H6q-.425 0-.712-.288T5 18v-4q0-.425.288-.712T6 13t.713.288T7 14zM17 7h-3q-.425 0-.712-.288T13 6t.288-.712T14 5h4q.425 0 .713.288T19 6v4q0 .425-.288.713T18 11t-.712-.288T17 10z"/></svg>
|
||||||
|
After Width: | Height: | Size: 456 B |
@@ -42,7 +42,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</n-image>
|
</n-image>
|
||||||
<!-- 打开播放器 -->
|
<!-- 打开播放器 -->
|
||||||
<SvgIcon name="Zoom" :size="30" />
|
<SvgIcon name="Expand" :size="30" />
|
||||||
</div>
|
</div>
|
||||||
</Transition>
|
</Transition>
|
||||||
<!-- 信息 -->
|
<!-- 信息 -->
|
||||||
|
|||||||
2
src/views/DesktopLyrics/index.d.ts
vendored
2
src/views/DesktopLyrics/index.d.ts
vendored
@@ -11,6 +11,8 @@ export interface LyricData {
|
|||||||
/** 歌词数据 */
|
/** 歌词数据 */
|
||||||
lrcData: LyricType[];
|
lrcData: LyricType[];
|
||||||
yrcData: LyricType[];
|
yrcData: LyricType[];
|
||||||
|
/** 歌词播放索引 */
|
||||||
|
lyricIndex: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 桌面歌词配置 */
|
/** 桌面歌词配置 */
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<n-config-provider :theme="null">
|
<n-config-provider :theme="null">
|
||||||
<div ref="desktopLyricsRef" class="desktop-lyrics">
|
<div
|
||||||
{{ lyricData.playName }}
|
ref="desktopLyricsRef"
|
||||||
{{ lyricConfig }}
|
:class="[
|
||||||
|
'desktop-lyrics',
|
||||||
|
{
|
||||||
|
locked: lyricConfig.isLock,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
>
|
||||||
<div class="header" align="center" justify="space-between">
|
<div class="header" align="center" justify="space-between">
|
||||||
<n-flex :wrap="false" align="center" justify="flex-start" size="small">
|
<n-flex :wrap="false" align="center" justify="flex-start" size="small">
|
||||||
<div class="menu-btn" title="返回应用">
|
<div class="menu-btn" title="返回应用">
|
||||||
@@ -39,6 +45,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</n-flex>
|
</n-flex>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
:style="{
|
||||||
|
fontSize: lyricConfig.fontSize + 'px',
|
||||||
|
fontFamily: lyricConfig.fontFamily,
|
||||||
|
lineHeight: lyricConfig.lineHeight + 'px',
|
||||||
|
}"
|
||||||
|
class="lyrics-container"
|
||||||
|
>
|
||||||
|
<span v-for="(item, index) in displayLyricLines" :key="index" class="lyric-line">
|
||||||
|
{{ item }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</n-config-provider>
|
</n-config-provider>
|
||||||
</template>
|
</template>
|
||||||
@@ -54,6 +72,7 @@ const lyricData = reactive<LyricData>({
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
lrcData: [],
|
lrcData: [],
|
||||||
yrcData: [],
|
yrcData: [],
|
||||||
|
lyricIndex: -1,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 桌面歌词配置
|
// 桌面歌词配置
|
||||||
@@ -73,6 +92,36 @@ const lyricConfig = reactive<LyricConfig>({
|
|||||||
// 桌面歌词元素
|
// 桌面歌词元素
|
||||||
const desktopLyricsRef = useTemplateRef<HTMLElement>("desktopLyricsRef");
|
const desktopLyricsRef = useTemplateRef<HTMLElement>("desktopLyricsRef");
|
||||||
|
|
||||||
|
// 需要显示的歌词行
|
||||||
|
const displayLyricLines = computed<string[]>(() => {
|
||||||
|
// 优先使用逐字歌词,无则使用普通歌词
|
||||||
|
const lyrics = lyricData.yrcData.length ? lyricData.yrcData : lyricData.lrcData;
|
||||||
|
if (!lyrics.length) return ["纯音乐,请欣赏"];
|
||||||
|
// 当前播放歌词索引
|
||||||
|
let idx = lyricData.lyricIndex;
|
||||||
|
if (idx < 0) idx = 0; // 开头之前按首句处理
|
||||||
|
// 当前与下一句
|
||||||
|
const current = lyrics[idx];
|
||||||
|
const next = lyrics[idx + 1];
|
||||||
|
if (!current) return [];
|
||||||
|
// 若当前句有翻译,无论单/双行设置都显示两行:原文 + 翻译
|
||||||
|
if (current.tran && current.tran.trim().length > 0) {
|
||||||
|
return [current.content, current.tran];
|
||||||
|
}
|
||||||
|
// 单行:仅返回当前句原文
|
||||||
|
if (!lyricConfig.isDoubleLine) {
|
||||||
|
return [current.content];
|
||||||
|
}
|
||||||
|
// 双行:两行内容交替
|
||||||
|
const isEven = idx % 2 === 0;
|
||||||
|
if (isEven) {
|
||||||
|
// 偶数句:第一行当前句,第二行下一句
|
||||||
|
return [current.content, next?.content ?? ""];
|
||||||
|
}
|
||||||
|
// 奇数句:第一行下一句,第二行当前句
|
||||||
|
return [next?.content ?? "", current.content];
|
||||||
|
});
|
||||||
|
|
||||||
// 桌面歌词拖动
|
// 桌面歌词拖动
|
||||||
const lyricDragMove = (position: Position) => {
|
const lyricDragMove = (position: Position) => {
|
||||||
console.log(position);
|
console.log(position);
|
||||||
@@ -112,6 +161,8 @@ onMounted(() => {
|
|||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
|
line-height: 36px;
|
||||||
|
padding: 0 8px;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
|||||||
Reference in New Issue
Block a user