Skip to content

Commit 9730f57

Browse files
authored
feat(MusicWiki): 在音乐百科页面上显示发布日期 (#1000)
1 parent 2abf150 commit 9730f57

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

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
<div class="actions">
7277
<n-button
@@ -296,6 +301,7 @@ import {
296301
import { formatSongsList, removeBrackets } from "@/utils/format";
297302
import { useSettingStore } from "@/stores";
298303
import dayjs from "dayjs";
304+
import { formatTimestamp } from "@/utils/time";
299305
300306
const route = useRoute();
301307
const player = usePlayerController();
@@ -308,6 +314,11 @@ const viewModel = ref<WikiViewModel | null>(null);
308314
const similarSongsList = ref<SongType[]>([]);
309315
const sheetLoading = ref<Record<number, boolean>>({});
310316
317+
const publishTime = computed(() => {
318+
const createTime = currentSong.value?.createTime;
319+
return typeof createTime === "number" ? formatTimestamp(createTime, "YYYY-MM-DD") : "";
320+
});
321+
311322
// 简单的转换逻辑,避免过多判断
312323
const normalizeWikiData = (
313324
wiki: SongWikiData | null,
@@ -568,7 +579,7 @@ onActivated(() => {
568579
margin-right: 4px;
569580
flex-shrink: 0;
570581
}
571-
.n-text {
582+
.clickable-text {
572583
cursor: pointer;
573584
&:hover {
574585
color: var(--primary-hex);

0 commit comments

Comments
 (0)