Skip to content

Commit 5cdce75

Browse files
committed
Merge branch 'dev' into pr/MoYingJi/999
2 parents 6669fba + 9730f57 commit 5cdce75

4 files changed

Lines changed: 21 additions & 7 deletions

File tree

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
- 正确: `// 监听主进程消息`
1919
- 错误: `// 1. listen to main process`, `// this function handles ipc...`
2020

21-
### 2. UI 组件使用Naive UI
21+
### 2. UI 组件使用 Naive UI
2222

2323
- **原则**: 严禁重复造轮子。所有通用交互必须优先使用 Naive UI 组件。
2424
- **处理方式**: 如果未找到合适组件,必须先询问用户,禁止擅自手写原生 CSS/HTML 组件。
@@ -27,7 +27,7 @@
2727

2828
### 3. 图标
2929

30-
- **原则**: 优先复用项目 `src/icons` 或现有图标方案。
30+
- **原则**: 优先复用项目 `src/assets/icons` 或现有图标方案。
3131
- **具体实现**: 严格遵循项目现有的图标组件用法。
3232
- 正确: `<SvgIcon :name="isLikeAlbum ? 'Favorite' : 'FavoriteBorder'" />`
3333
- 错误: 擅自引入 `xicons` (除非用户明确允许) 或手写 SVG 代码。

src/components/Modal/CopySongInfo.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ const duration = computed(() => {
197197
});
198198
199199
const publishTime = computed(() => {
200-
return songInfo.value?.createTime ? formatTimestamp(songInfo.value.createTime, "YYYY-MM-DD") : "";
200+
const createTime = songInfo.value?.createTime;
201+
return typeof createTime === "number" ? formatTimestamp(createTime, "YYYY-MM-DD", true) : "";
201202
});
202203
203204
const songLink = computed(() => {

src/utils/time.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,17 @@ export const msToS = (milliseconds: number, decimalPlaces: number = 2): number =
3333
* 格式化时间戳,同年省略年份
3434
* @param timestamp 时间戳(毫秒),为空或 0 时返回空字符串
3535
* @param format 时间格式,默认 "YYYY-MM-DD"
36+
* @param keepSameYear 是否保留同年年份,默认为 false(即同年省略年份)
3637
*/
3738
export const formatTimestamp = (
3839
timestamp: number | undefined,
3940
format: string = "YYYY-MM-DD",
41+
keepSameYear: boolean = false,
4042
): string => {
4143
if (!timestamp) return "";
4244
const date = dayjs(timestamp);
43-
const isSameYear = date.year() === dayjs().year();
44-
return date.format(isSameYear ? format.replace("YYYY-", "") : format);
45+
const shouldOmitYear = !keepSameYear && date.year() === dayjs().year();
46+
return date.format(shouldOmitYear ? format.replace("YYYY-", "") : format);
4547
};
4648

4749
/**

src/views/Song/wiki.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<template v-if="Array.isArray(currentSong.artists)">
3535
<n-text
3636
v-for="(ar, index) in currentSong.artists"
37+
class="clickable-text"
3738
:key="ar.id"
3839
@click="$router.push({ name: 'artist', query: { id: ar.id } })"
3940
>
@@ -52,7 +53,7 @@
5253
<SvgIcon name="Album" :depth="3" />
5354
<n-text
5455
v-if="typeof currentSong.album !== 'string'"
55-
class="text-hidden"
56+
class="text-hidden clickable-text"
5657
@click="$router.push({ name: 'album', query: { id: currentSong.album.id } })"
5758
>
5859
{{
@@ -67,6 +68,10 @@
6768
: currentSong.album
6869
}}</n-text>
6970
</div>
71+
<div class="item" v-if="publishTime" title="发行日期">
72+
<SvgIcon name="Time" :depth="3" />
73+
<n-text class="text-hidden">{{ publishTime }}</n-text>
74+
</div>
7075
</div>
7176
<n-flex class="actions">
7277
<n-button
@@ -308,6 +313,7 @@ import { formatSongsList, removeBrackets } from "@/utils/format";
308313
import { useSettingStore } from "@/stores";
309314
import dayjs from "dayjs";
310315
import { useSongMenu } from "@/composables/useSongMenu";
316+
import { formatTimestamp } from "@/utils/time";
311317
312318
const route = useRoute();
313319
const player = usePlayerController();
@@ -322,6 +328,11 @@ const viewModel = ref<WikiViewModel | null>(null);
322328
const similarSongsList = ref<SongType[]>([]);
323329
const sheetLoading = ref<Record<number, boolean>>({});
324330
331+
const publishTime = computed(() => {
332+
const createTime = currentSong.value?.createTime;
333+
return typeof createTime === "number" ? formatTimestamp(createTime, "YYYY-MM-DD") : "";
334+
});
335+
325336
// 简单的转换逻辑,避免过多判断
326337
const normalizeWikiData = (
327338
wiki: SongWikiData | null,
@@ -582,7 +593,7 @@ onActivated(() => {
582593
margin-right: 4px;
583594
flex-shrink: 0;
584595
}
585-
.n-text {
596+
.clickable-text {
586597
cursor: pointer;
587598
&:hover {
588599
color: var(--primary-hex);

0 commit comments

Comments
 (0)