Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/list/SongList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ const emit = defineEmits<{
onActivated(batch.exit);

defineExpose({
sortedItems,
/** 进入批量管理模式 */
enterBatch: batch.enter,
});
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@
},
"liked": {
"title": "Liked Songs",
"copyToClipboard": "Copy to Clipboard",
"tabs": {
"local": "Local",
"online": "Online"
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@
},
"liked": {
"title": "我喜欢的音乐",
"copyToClipboard": "复制到剪贴板",
"tabs": {
"local": "本地",
"online": "在线"
Expand Down
25 changes: 24 additions & 1 deletion src/pages/Liked.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ import type { DropdownMenuItem } from "@/components/ui/SDropdownMenu.vue";
import { useLibraryStore } from "@/stores/library";
import { useUserStore } from "@/stores/user";
import { useStatusStore } from "@/stores/status";
import { useCopyText } from "@/composables/useCopyText";
import SongList from "@/components/list/SongList.vue";
import * as player from "@/core/player";
import IconLucideCopy from "~icons/lucide/copy";
import IconLucideListChecks from "~icons/lucide/list-checks";
import IconLucideRefreshCw from "~icons/lucide/refresh-cw";

const { t } = useI18n();
const library = useLibraryStore();
const user = useUserStore();
const status = useStatusStore();
const { copy } = useCopyText();

/** 当前 tab */
const tab = computed({
Expand Down Expand Up @@ -98,14 +101,34 @@ const moreMenuItems = computed<DropdownMenuItem[]>(() => {
label: t("songList.batch.manage"),
icon: markRaw(IconLucideListChecks),
});
items.push({
key: "copy",
label: t("liked.copyToClipboard"),
icon: markRaw(IconLucideCopy),
disabled: !songListRef.value?.sortedItems.length,
});
return items;
});

const handleMoreMenu = (key: string): void => {
/**
* 处理喜欢列表的刷新、批量管理与复制操作
* @param key - 所选菜单操作
*/
const handleMoreMenu = async (key: string): Promise<void> => {
if (key === "refresh") {
user.ensureLikedPlaylist(true);
} else if (key === "batch") {
songListRef.value?.enterBatch();
} else if (key === "copy") {
const tracks = songListRef.value?.sortedItems;
if (!tracks?.length) return;
await copy(
tracks
.map(
(track) => `${track.title} - ${track.artists.map((artist) => artist.name).join(" / ")}`,
)
.join("\n"),
);
}
};
</script>
Expand Down