Skip to content

Commit c554987

Browse files
committed
🌈 style: 完善播放器组件样式
1 parent 7239f84 commit c554987

17 files changed

Lines changed: 491 additions & 508 deletions

File tree

auto-eslint.mjs

Lines changed: 314 additions & 314 deletions
Large diffs are not rendered by default.

components.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ declare module 'vue' {
2626
CommentFilter: typeof import('./src/components/Modal/CommentFilter.vue')['default']
2727
CommentList: typeof import('./src/components/List/CommentList.vue')['default']
2828
ConfigurableInputNumber: typeof import('./src/components/Setting/items/ConfigurableInputNumber.vue')['default']
29+
copy: typeof import('./src/components/Global/Provider copy.vue')['default']
2930
CopyLyrics: typeof import('./src/components/Modal/CopyLyrics.vue')['default']
3031
CoverList: typeof import('./src/components/List/CoverList.vue')['default']
3132
CoverMenu: typeof import('./src/components/Menu/CoverMenu.vue')['default']
@@ -155,6 +156,7 @@ declare module 'vue' {
155156
PlayerData: typeof import('./src/components/Player/PlayerMeta/PlayerData.vue')['default']
156157
PlayerLyric: typeof import('./src/components/Player/PlayerLyric/index.vue')['default']
157158
PlayerMenu: typeof import('./src/components/Player/PlayerMenu.vue')['default']
159+
PlayerProvider: typeof import('./src/components/Global/PlayerProvider.vue')['default']
158160
PlayerRightMenu: typeof import('./src/components/Player/PlayerRightMenu.vue')['default']
159161
PlayerSlider: typeof import('./src/components/Player/PlayerComponents/PlayerSlider.vue')['default']
160162
PlayerSpectrum: typeof import('./src/components/Player/PlayerComponents/PlayerSpectrum.vue')['default']
Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* auto-generated by NAPI-RS */
22
/* eslint-disable */
33
/** 关闭 Discord RPC */
4-
export declare function disableDiscordRpc(): void
4+
export declare function disableDiscordRpc(): void;
55

66
/**
77
* 禁用媒体控件
@@ -10,7 +10,7 @@ export declare function disableDiscordRpc(): void
1010
*
1111
* 会在调用 API 失败时抛出错误
1212
*/
13-
export declare function disableSystemMedia(): void
13+
export declare function disableSystemMedia(): void;
1414

1515
/** Discord 配置参数 */
1616
export interface DiscordConfigPayload {
@@ -19,22 +19,23 @@ export interface DiscordConfigPayload {
1919
*
2020
* 注意暂停时进度会固定为 0
2121
*/
22-
showWhenPaused: boolean
22+
showWhenPaused: boolean;
2323
/** 显示模式,参考 [`DiscordDisplayMode`] */
24-
displayMode?: DiscordDisplayMode
24+
displayMode?: DiscordDisplayMode;
2525
}
2626

2727
/**
2828
* Discord 显示模式枚举
2929
*
3030
* 不打开详细信息面板时,在用户名下方显示的小字
3131
*/
32-
export type DiscordDisplayMode = /** Listening to SPlayer */
33-
'Name'|
34-
/** Listening to Rick Astley */
35-
'State'|
36-
/** Listening to Never Gonna Give You Up */
37-
'Details';
32+
export type DiscordDisplayMode =
33+
/** Listening to SPlayer */
34+
| "Name"
35+
/** Listening to Rick Astley */
36+
| "State"
37+
/** Listening to Never Gonna Give You Up */
38+
| "Details";
3839

3940
/**
4041
* 启用 Discord RPC
@@ -43,7 +44,7 @@ export type DiscordDisplayMode = /** Listening to SPlayer */
4344
*
4445
* 启用后会立刻尝试连接,如果 Discord 未启动,或因为其他未知原因连接失败,会每 5 秒尝试连接一次
4546
*/
46-
export declare function enableDiscordRpc(): void
47+
export declare function enableDiscordRpc(): void;
4748

4849
/**
4950
* 启用媒体控件
@@ -52,7 +53,7 @@ export declare function enableDiscordRpc(): void
5253
*
5354
* 会在调用 API 失败时抛出错误
5455
*/
55-
export declare function enableSystemMedia(): void
56+
export declare function enableSystemMedia(): void;
5657

5758
/**
5859
* 初始化插件
@@ -69,20 +70,20 @@ export declare function enableSystemMedia(): void
6970
*
7071
* 如果其他 API 调用失败,则只会打印日志并静默失败
7172
*/
72-
export declare function initialize(logDir: string): void
73+
export declare function initialize(logDir: string): void;
7374

7475
export interface MetadataParam {
75-
songName: string
76-
authorName: string
77-
albumName: string
76+
songName: string;
77+
authorName: string;
78+
albumName: string;
7879
/** 封面的原始字节数据,适用于除 Discord RPC 之外的其他平台 */
79-
coverData?: Buffer
80+
coverData?: Buffer;
8081
/**
8182
* 封面的 HTTP URL,更新 Discord RPC 时必传,其他平台可不传
8283
*
8384
* Linux 平台在没有提供 `cover_data` 时会使用它
8485
*/
85-
originalCoverUrl?: string
86+
originalCoverUrl?: string;
8687
/**
8788
* 网易云音乐中对应的曲目 ID
8889
*
@@ -91,26 +92,25 @@ export interface MetadataParam {
9192
* - 生成 Discord RPC 的按钮链接
9293
* - MacOS 和 Linux 会使用此值来填充唯一的曲目 ID
9394
*/
94-
ncmId?: number
95+
ncmId?: number;
9596
/**
9697
* 当前歌曲时长,单位是毫秒
9798
*
9899
* 用于 Linux、MacOS、Discord RPC 的元数据更新。Windows 使用 [`TimelinePayload`] 的
99100
* `total_time` 字段。
100101
*/
101-
duration?: number
102+
duration?: number;
102103
}
103104

104-
export type PlaybackStatus = 'Playing'|
105-
'Paused';
105+
export type PlaybackStatus = "Playing" | "Paused";
106106

107107
export interface PlayModePayload {
108-
isShuffling: boolean
109-
repeatMode: RepeatMode
108+
isShuffling: boolean;
109+
repeatMode: RepeatMode;
110110
}
111111

112112
export interface PlayStatePayload {
113-
status: PlaybackStatus
113+
status: PlaybackStatus;
114114
}
115115

116116
/**
@@ -124,35 +124,34 @@ export interface PlayStatePayload {
124124
*
125125
* 如果 N-API 创建线程安全函数失败,会抛出错误。通常不应该发生,除非 JS 环境已经销毁了
126126
*/
127-
export declare function registerEventHandler(callback: (arg: SystemMediaEvent) => void): void
127+
export declare function registerEventHandler(callback: (arg: SystemMediaEvent) => void): void;
128128

129-
export type RepeatMode = 'None'|
130-
'Track'|
131-
'List';
129+
export type RepeatMode = "None" | "Track" | "List";
132130

133131
/** 关闭插件,清理资源 */
134-
export declare function shutdown(): void
132+
export declare function shutdown(): void;
135133

136134
export interface SystemMediaEvent {
137-
type: SystemMediaEventType
138-
positionMs?: number
135+
type: SystemMediaEventType;
136+
positionMs?: number;
139137
}
140138

141-
export type SystemMediaEventType = 'Play'|
142-
'Pause'|
143-
'Stop'|
144-
'NextSong'|
145-
'PreviousSong'|
146-
'ToggleShuffle'|
147-
'ToggleRepeat'|
148-
/** 绝对位置,毫秒 */
149-
'Seek';
139+
export type SystemMediaEventType =
140+
| "Play"
141+
| "Pause"
142+
| "Stop"
143+
| "NextSong"
144+
| "PreviousSong"
145+
| "ToggleShuffle"
146+
| "ToggleRepeat"
147+
/** 绝对位置,毫秒 */
148+
| "Seek";
150149

151150
export interface TimelinePayload {
152151
/** 单位是毫秒 */
153-
currentTime: number
152+
currentTime: number;
154153
/** 单位是毫秒 */
155-
totalTime: number
154+
totalTime: number;
156155
}
157156

158157
/**
@@ -163,7 +162,7 @@ export interface TimelinePayload {
163162
* * `payload` - 配置信息,可以配置是否在暂停后也显示 Discord Activity 和 状态显示风格。详情请查看
164163
* [`DiscordConfigPayload`]
165164
*/
166-
export declare function updateDiscordConfig(payload: DiscordConfigPayload): void
165+
export declare function updateDiscordConfig(payload: DiscordConfigPayload): void;
167166

168167
/**
169168
* 更新歌曲元数据
@@ -174,7 +173,7 @@ export declare function updateDiscordConfig(payload: DiscordConfigPayload): void
174173
*
175174
* 更新 Discord RPC 的元数据时,必须提供 `original_cover_url`
176175
*/
177-
export declare function updateMetadata(payload: MetadataParam): void
176+
export declare function updateMetadata(payload: MetadataParam): void;
178177

179178
/**
180179
* 更新播放模式
@@ -183,14 +182,14 @@ export declare function updateMetadata(payload: MetadataParam): void
183182
*
184183
* 只会更新媒体控件的信息,不会更新 Discord RPC 上的信息
185184
*/
186-
export declare function updatePlayMode(payload: PlayModePayload): void
185+
export declare function updatePlayMode(payload: PlayModePayload): void;
187186

188187
/**
189188
* 更新播放状态 (播放/暂停)
190189
*
191190
* 同时也会更新 Discord 的播放状态 (如果启用了 Discord RPC)
192191
*/
193-
export declare function updatePlayState(payload: PlayStatePayload): void
192+
export declare function updatePlayState(payload: PlayStatePayload): void;
194193

195194
/**
196195
* 更新进度信息
@@ -201,4 +200,4 @@ export declare function updatePlayState(payload: PlayStatePayload): void
201200
*
202201
* Discord RPC 实现的进度更新有节流,调用此函数无需担心 Discord RPC 的速率限制
203202
*/
204-
export declare function updateTimeline(payload: TimelinePayload): void
203+
export declare function updateTimeline(payload: TimelinePayload): void;

src/components/Card/SongCard.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@
101101
</n-tag>
102102
<!-- 脏标 -->
103103
<n-tag
104-
v-if="settingStore.showSongExplicitTag && (song.mark && (song.mark & EXPLICIT_CONTENT_MARK))"
104+
v-if="
105+
settingStore.showSongExplicitTag && song.mark && song.mark & EXPLICIT_CONTENT_MARK
106+
"
105107
:bordered="false"
106108
class="explicit"
107109
type="error"
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<!-- 全局配置 -->
2+
<template>
3+
<n-config-provider :theme-overrides="themeOverrides" abstract preflight-style-disabled>
4+
<slot />
5+
</n-config-provider>
6+
</template>
7+
8+
<script setup lang="ts">
9+
import type { GlobalThemeOverrides } from "naive-ui";
10+
import { useStatusStore } from "@/stores";
11+
12+
const statusStore = useStatusStore();
13+
14+
// 轻量的 rgba 构造器
15+
const toRGBA = (rgb: string, alpha: number) => `rgba(${rgb}, ${alpha})`;
16+
17+
const themeOverrides = computed<GlobalThemeOverrides>(() => {
18+
const { r, g, b } = statusStore.songCoverTheme.main ?? { r: 239, g: 239, b: 239 };
19+
const coverRGB = `${r},${g},${b}`;
20+
const commonBase = {
21+
primaryColor: `rgb(${coverRGB})`,
22+
primaryColorHover: toRGBA(coverRGB, 0.78),
23+
primaryColorPressed: toRGBA(coverRGB, 0.26),
24+
primaryColorSuppl: toRGBA(coverRGB, 0.12),
25+
} as GlobalThemeOverrides["common"];
26+
27+
return {
28+
common: {
29+
...commonBase,
30+
textColorBase: coverRGB,
31+
textColor1: coverRGB,
32+
textColor2: toRGBA(coverRGB, 0.82),
33+
textColor3: toRGBA(coverRGB, 0.52),
34+
cardColor: toRGBA(coverRGB, 0.2),
35+
tagColor: toRGBA(coverRGB, 0.2),
36+
modalColor: toRGBA(coverRGB, 0.2),
37+
popoverColor: toRGBA(coverRGB, 0.2),
38+
buttonColor2: toRGBA(coverRGB, 0.08),
39+
buttonColor2Hover: toRGBA(coverRGB, 0.12),
40+
buttonColor2Pressed: toRGBA(coverRGB, 0.08),
41+
iconColor: coverRGB,
42+
iconColorHover: toRGBA(coverRGB, 0.475),
43+
closeIconColor: toRGBA(coverRGB, 0.58),
44+
hoverColor: toRGBA(coverRGB, 0.09),
45+
borderColor: toRGBA(coverRGB, 0.09),
46+
textColorDisabled: toRGBA(coverRGB, 0.3),
47+
placeholderColorDisabled: toRGBA(coverRGB, 0.3),
48+
iconColorDisabled: toRGBA(coverRGB, 0.3),
49+
},
50+
Button: {
51+
textColorHover: toRGBA(coverRGB, 0.82),
52+
textColorFocus: toRGBA(coverRGB, 0.82),
53+
colorPrimary: toRGBA(coverRGB, 0.9),
54+
colorHoverPrimary: toRGBA(coverRGB, 0.8),
55+
colorPressedPrimary: toRGBA(coverRGB, 0.7),
56+
colorFocusPrimary: toRGBA(coverRGB, 0.6),
57+
},
58+
Slider: {
59+
handleColor: toRGBA(coverRGB, 0.9),
60+
fillColor: toRGBA(coverRGB, 0.9),
61+
fillColorHover: toRGBA(coverRGB, 0.9),
62+
railColor: toRGBA(coverRGB, 0.2),
63+
railColorHover: toRGBA(coverRGB, 0.3),
64+
indicatorColor: toRGBA(coverRGB, 0.2),
65+
indicatorTextColor: toRGBA(coverRGB, 0.9),
66+
},
67+
Popover: {
68+
color: toRGBA(coverRGB, 0.2),
69+
},
70+
Icon: {
71+
color: coverRGB,
72+
},
73+
Tooltip: {
74+
color: coverRGB,
75+
},
76+
};
77+
});
78+
</script>

src/components/Global/Provider.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const settingStore = useSettingStore();
5050
// 操作系统主题
5151
const osTheme = useOsTheme();
5252
53-
// 全局主题(使用 shallowRef 避免深层追踪开销)
53+
// 全局主题
5454
const themeOverrides = shallowRef<GlobalThemeOverrides>({});
5555
// 轻量的 rgba 构造器
5656
const toRGBA = (rgb: string, alpha: number) => `rgba(${rgb}, ${alpha})`;

src/components/List/CommentList.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<Transition name="fade" mode="out-in">
33
<n-flex v-if="data.length > 0" :size="20" :class="['comment-list', { transparent }]" vertical>
44
<n-flex
5-
v-for="(item, index) in data"
6-
:key="index"
7-
:size="20"
8-
class="comments"
9-
@dblclick="handleDoubleClick(item)"
10-
>
5+
v-for="(item, index) in data"
6+
:key="index"
7+
:size="20"
8+
class="comments"
9+
@dblclick="handleDoubleClick(item)"
10+
>
1111
<div v-if="!transparent" class="user">
1212
<div class="avatar">
1313
<n-image

src/components/Player/PlayerComponents/PlayerSlider.vue

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,5 @@ const formatTooltip = (value: number) => {
135135
}
136136
}
137137
}
138-
&.player {
139-
--n-rail-color: rgba(var(--main-cover-color), 0.14);
140-
--n-rail-color-hover: rgba(var(--main-cover-color), 0.3);
141-
--n-fill-color: rgb(var(--main-cover-color));
142-
--n-handle-color: rgb(var(--main-cover-color));
143-
--n-fill-color-hover: rgb(var(--main-cover-color));
144-
}
145138
}
146139
</style>

src/components/Player/PlayerControl.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@
105105
<!-- 进度条 -->
106106
<div class="slider">
107107
<span @click="toggleTimeFormat">{{ timeDisplay[0] }}</span>
108-
<PlayerSlider class="player" :show-tooltip="false" />
108+
<PlayerSlider :show-tooltip="false" />
109109
<span @click="toggleTimeFormat">{{ timeDisplay[1] }}</span>
110110
</div>
111111
</div>
112112
<n-flex class="right" align="center" justify="end">
113113
<!-- 功能区 -->
114-
<PlayerRightMenu player />
114+
<PlayerRightMenu />
115115
</n-flex>
116116
</div>
117117
</Transition>

src/components/Player/PlayerMeta/PlayerData.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ const lyricMode = computed(() => {
153153
154154
// 左侧外边距
155155
const leftMargin = computed(() => {
156-
if (props.center) return "0px";
156+
if (props.center || !props.light) return "0px";
157157
const offset = settingStore.lyricHorizontalOffset;
158158
return settingStore.useAMLyrics ? `${offset + 40}px` : `${offset + 10}px`;
159159
});

0 commit comments

Comments
 (0)