Skip to content

Commit ce67e74

Browse files
authored
Merge pull request #605 from SUBearH/P503
✨ feat: 为每个页面添加链接分享按钮
2 parents 59858ab + 3529c8e commit ce67e74

6 files changed

Lines changed: 89 additions & 9 deletions

File tree

src/components/Menu/CoverMenu.vue

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,32 @@ const openDropdown = async (
8080
type: "divider",
8181
},
8282
{
83-
key: "copy",
84-
label: "复制链接",
83+
key: "code-name",
84+
label: `复制${type === "playlist" ? "歌单" : type === "album" ? "专辑" : type === "video" ? "视频" : "电台"}名称`,
8585
props: {
86-
onClick: () => copyData(`https://music.163.com/#/${type}?id=${item.id}`),
86+
onClick: () => copyData(item.name),
8787
},
88-
icon: renderIcon("Link"),
88+
icon: renderIcon("Copy", { size: 18 }),
89+
},
90+
{
91+
key: "code-id",
92+
label: `复制${type === "playlist" ? "歌单" : type === "album" ? "专辑" : type === "video" ? "视频" : "电台"} ID`,
93+
props: {
94+
onClick: () => copyData(item.id),
95+
},
96+
icon: renderIcon("Copy", { size: 18 }),
97+
},
98+
{
99+
key: "share",
100+
label: `分享${type === "playlist" ? "歌单" : type === "album" ? "专辑" : type === "video" ? "视频" : "电台"}链接`,
101+
props: {
102+
onClick: () =>
103+
copyData(
104+
`https://music.163.com/#/${type}?id=${item.id}`,
105+
"已复制分享链接到剪贴板",
106+
),
107+
},
108+
icon: renderIcon("Share", { size: 18 }),
89109
},
90110
];
91111
// 显示菜单

src/views/Artist/layout.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
<script setup lang="ts">
155155
import type { DropdownOption } from "naive-ui";
156156
import type { ArtistType } from "@/types/main";
157-
import { coverLoaded, renderIcon } from "@/utils/helper";
157+
import { coverLoaded, renderIcon, copyData } from "@/utils/helper";
158158
import { renderToolbar } from "@/utils/meta";
159159
import { artistDetail } from "@/api/artist";
160160
import { formatArtistsList } from "@/utils/format";
@@ -183,6 +183,18 @@ const listScrolling = ref<boolean>(false);
183183
184184
// 更多操作
185185
const moreOptions = computed<DropdownOption[]>(() => [
186+
{
187+
label: "复制分享链接",
188+
key: "copy",
189+
props: {
190+
onClick: () =>
191+
copyData(
192+
`https://music.163.com/#/artist?id=${artistId.value}`,
193+
"已复制分享链接到剪贴板",
194+
),
195+
},
196+
icon: renderIcon("Share"),
197+
},
186198
{
187199
label: "打开源页面",
188200
key: "open",

src/views/List/album.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ import type { DropdownOption } from "naive-ui";
175175
import { songDetail } from "@/api/song";
176176
import { albumDetail } from "@/api/album";
177177
import { formatCoverList, formatSongsList } from "@/utils/format";
178-
import { coverLoaded, fuzzySearch, renderIcon } from "@/utils/helper";
178+
import { coverLoaded, fuzzySearch, renderIcon, copyData } from "@/utils/helper";
179179
import { renderToolbar } from "@/utils/meta";
180180
import { useDataStore, useStatusStore } from "@/stores";
181181
import { debounce } from "lodash-es";
@@ -222,6 +222,18 @@ const songListHeight = computed(() => {
222222
223223
// 更多操作
224224
const moreOptions = computed<DropdownOption[]>(() => [
225+
{
226+
label: "复制分享链接",
227+
key: "copy",
228+
props: {
229+
onClick: () =>
230+
copyData(
231+
`https://music.163.com/#/album?id=${albumId.value}`,
232+
"已复制分享链接到剪贴板",
233+
),
234+
},
235+
icon: renderIcon("Share"),
236+
},
225237
{
226238
label: "打开源页面",
227239
key: "open",

src/views/List/liked.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ import type { DropdownOption, MessageReactive } from "naive-ui";
169169
import { songDetail } from "@/api/song";
170170
import { playlistDetail, playlistAllSongs } from "@/api/playlist";
171171
import { formatCoverList, formatSongsList } from "@/utils/format";
172-
import { coverLoaded, formatNumber, fuzzySearch, renderIcon } from "@/utils/helper";
172+
import { coverLoaded, formatNumber, fuzzySearch, renderIcon, copyData } from "@/utils/helper";
173173
import { renderToolbar } from "@/utils/meta";
174174
import { debounce, isObject, uniqBy } from "lodash-es";
175175
import { useDataStore, useStatusStore } from "@/stores";
@@ -240,6 +240,18 @@ const moreOptions = computed<DropdownOption[]>(() => [
240240
},
241241
icon: renderIcon("Batch"),
242242
},
243+
{
244+
label: "复制分享链接",
245+
key: "copy",
246+
props: {
247+
onClick: () =>
248+
copyData(
249+
`https://music.163.com/#/playlist?id=${playlistId.value}`,
250+
"已复制分享链接到剪贴板",
251+
),
252+
},
253+
icon: renderIcon("Share"),
254+
},
243255
{
244256
label: "打开源页面",
245257
key: "open",

src/views/List/playlist.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ import {
219219
updatePlaylistPrivacy,
220220
} from "@/api/playlist";
221221
import { formatCoverList, formatSongsList } from "@/utils/format";
222-
import { coverLoaded, formatNumber, fuzzySearch, renderIcon } from "@/utils/helper";
222+
import { coverLoaded, formatNumber, fuzzySearch, renderIcon, copyData } from "@/utils/helper";
223223
import { renderToolbar } from "@/utils/meta";
224224
import { isLogin, toLikePlaylist, updateUserLikePlaylist } from "@/utils/auth";
225225
import { debounce } from "lodash-es";
@@ -311,6 +311,18 @@ const moreOptions = computed<DropdownOption[]>(() => [
311311
},
312312
icon: renderIcon("Batch"),
313313
},
314+
{
315+
label: "复制分享链接",
316+
key: "copy",
317+
props: {
318+
onClick: () =>
319+
copyData(
320+
`https://music.163.com/#/playlist?id=${playlistId.value}`,
321+
"已复制分享链接到剪贴板",
322+
),
323+
},
324+
icon: renderIcon("Share"),
325+
},
314326
{
315327
label: "打开源页面",
316328
key: "open",

src/views/List/radio.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
import type { CoverType, SongType } from "@/types/main";
175175
import type { DropdownOption, MessageReactive } from "naive-ui";
176176
import { formatCoverList, formatSongsList } from "@/utils/format";
177-
import { coverLoaded, fuzzySearch, renderIcon } from "@/utils/helper";
177+
import { coverLoaded, fuzzySearch, renderIcon, copyData } from "@/utils/helper";
178178
import { renderToolbar } from "@/utils/meta";
179179
import { debounce } from "lodash-es";
180180
import { useDataStore, useStatusStore } from "@/stores";
@@ -239,6 +239,18 @@ const moreOptions = computed<DropdownOption[]>(() => [
239239
},
240240
icon: renderIcon("Refresh"),
241241
},
242+
{
243+
label: "复制分享链接",
244+
key: "copy",
245+
props: {
246+
onClick: () =>
247+
copyData(
248+
`https://music.163.com/#/djradio?id=${radioId.value}`,
249+
"已复制分享链接到剪贴板",
250+
),
251+
},
252+
icon: renderIcon("Share"),
253+
},
242254
{
243255
label: "打开源页面",
244256
key: "open",

0 commit comments

Comments
 (0)