feat: 在用户歌单中添加“我创建的”标签,优化获取用户歌单的逻辑

This commit is contained in:
alger
2025-05-23 20:08:40 +08:00
parent a449b74ef2
commit d56a25eb3c
4 changed files with 23 additions and 5 deletions

View File

@@ -6,6 +6,7 @@ export default {
},
playlist: {
created: 'Created Playlists',
mine: 'Mine',
trackCount: '{count} tracks',
playCount: 'Played {count} times'
},

View File

@@ -6,6 +6,7 @@ export default {
},
playlist: {
created: '创建的歌单',
mine: '我创建的',
trackCount: '{count}首',
playCount: '播放{count}次'
},

View File

@@ -159,9 +159,9 @@ const fetchUserPlaylists = async () => {
return;
}
const res = await getUserPlaylist(user.userId);
const res = await getUserPlaylist(user.userId, 999);
if (res.data?.playlist) {
playlists.value = res.data.playlist;
playlists.value = res.data.playlist.filter((item: any) => item.userId === user.userId);
}
} catch (error) {
console.error('获取歌单失败:', error);

View File

@@ -43,7 +43,12 @@
preview-disabled
/>
<div class="play-list-item-info">
<div class="play-list-item-name">{{ item.name }}</div>
<div class="play-list-item-name">
{{ item.name }}
<div v-if="item.creator.userId === user.userId" class="playlist-creator-tag">
{{ t('user.playlist.mine') }}
</div>
</div>
<div class="play-list-item-count">
{{ t('user.playlist.trackCount', { count: item.trackCount }) }}{{
t('user.playlist.playCount', { count: item.playCount })
@@ -353,11 +358,22 @@ const showFollowList = () => {
}
&-info {
@apply ml-2;
@apply ml-2 flex-1;
}
&-name {
@apply text-gray-900 dark:text-white text-base;
@apply text-gray-900 dark:text-white text-base flex items-center gap-2;
.playlist-creator-tag {
@apply inline-flex items-center justify-center px-2 rounded-full text-xs;
@apply bg-light-300 text-primary dark:bg-dark-300 dark:text-white;
@apply border border-primary/20 dark:border-primary/30;
height: 18px;
font-size: 10px;
font-weight: 500;
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
}
}
&-count {