Skip to content
Merged
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
7 changes: 5 additions & 2 deletions src/components/Menu/CoverMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<script setup lang="ts">
import type { DropdownOption } from "naive-ui";
import type { CoverType } from "@/types/main";
import { renderIcon, copyData } from "@/utils/helper";
import { renderIcon, copyData, getShareUrl } from "@/utils/helper";
import { useMusicStore, useStatusStore } from "@/stores";

const emit = defineEmits<{
Expand Down Expand Up @@ -101,7 +101,10 @@ const openDropdown = async (
show: item.id !== 0 && item.id?.toString().length < 16,
props: {
onClick: () =>
copyData(`https://music.163.com/#/${type}?id=${item.id}`, "已复制分享链接到剪贴板"),
copyData(
getShareUrl(type, item.id),
"已复制分享链接到剪贴板",
),
},
icon: renderIcon("Share", { size: 18 }),
},
Expand Down
6 changes: 3 additions & 3 deletions src/components/Modal/CopySongInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
import type { SongType, MetaData } from "@/types/main";
import { songDetail } from "@/api/song";
import { formatSongsList } from "@/utils/format";
import { copyData } from "@/utils/helper";
import { copyData, getShareUrl } from "@/utils/helper";
import { msToTime, formatTimestamp } from "@/utils/time";

const props = defineProps<{ songId: number; onClose: () => void }>();
Expand Down Expand Up @@ -201,7 +201,7 @@ const publishTime = computed(() => {
});

const songLink = computed(() => {
return songInfo.value?.id ? `https://music.163.com/#/song?id=${songInfo.value.id}` : "";
return songInfo.value?.id ? getShareUrl("song", songInfo.value.id) : "";
});

// 获取歌曲详情
Expand Down Expand Up @@ -243,7 +243,7 @@ const handleCopyAll = () => {
`链接:${songLink.value}`,
].filter((line) => line);

copyData(lines.join("\n"), "已复制全部信息");
copyData(lines, "已复制全部信息");
};

onMounted(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Player/MainPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ import { useDataStore, useMusicStore, useSettingStore, useStatusStore } from "@/
import { toLikeSong } from "@/utils/auth";
import { useTimeFormat } from "@/composables/useTimeFormat";
import { useSwipe } from "@vueuse/core";
import { copyData, coverLoaded, renderIcon } from "@/utils/helper";
import { copyData, coverLoaded, renderIcon, getShareUrl } from "@/utils/helper";
import {
openAutoClose,
openChangeRate,
Expand Down Expand Up @@ -327,7 +327,7 @@ const songMoreOptions = computed<DropdownOption[]>(() => {
props: {
onClick: () =>
copyData(
`https://music.163.com/#/${song.type}?id=${song.id}`,
getShareUrl(song.type, song.id),
"已复制分享链接到剪切板",
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent terminology: "剪切板" should be "剪贴板" to match the terminology used elsewhere in the codebase. The correct Chinese term for clipboard is "剪贴板" (not "剪切板" which means "cut board").

Suggested change
"已复制分享链接到剪切板",
"已复制分享链接到剪贴板",

Copilot uses AI. Check for mistakes.
),
},
Expand Down
19 changes: 19 additions & 0 deletions src/components/Setting/config/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,25 @@ export const useGeneralSettings = (): SettingConfig => {
},
],
},
{
title: "其他设置",
items: [
{
key: "shareUrlFormat",
label: "分享链接格式",
type: "select",
description: "自定义分享链接的生成格式",
options: [
{ label: "网页版", value: "web" },
{ label: "移动版", value: "mobile" },
],
value: computed({
get: () => settingStore.shareUrlFormat,
set: (v) => (settingStore.shareUrlFormat = v),
}),
},
],
},
{
title: "备份与恢复",
tags: [{ text: "Beta", type: "warning" }],
Expand Down
4 changes: 2 additions & 2 deletions src/composables/useSongMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "@/stores";
import { useDownloadManager } from "@/core/resource/DownloadManager";
import { usePlayerController } from "@/core/player/PlayerController";
import { renderIcon, copyData } from "@/utils/helper";
import { renderIcon, copyData, getShareUrl } from "@/utils/helper";
import { deleteCloudSong, importCloudSong } from "@/api/cloud";
import {
openCloudMatch,
Expand Down Expand Up @@ -264,7 +264,7 @@ export const useSongMenu = () => {
show: !isLocal && type !== "streaming",
props: {
onClick: () =>
copyData(`https://music.163.com/#/${type}?id=${song.id}`, "已复制分享链接到剪切板"),
copyData(getShareUrl(type, song.id), "已复制分享链接到剪贴板"),
},
icon: renderIcon("Share", { size: 18 }),
},
Expand Down
3 changes: 3 additions & 0 deletions src/stores/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export interface SettingState {
taskbarLyricFontWeight: number;
/** 是否使用在线服务 */
useOnlineService: boolean;
/** 分享链接格式 */
shareUrlFormat: "web" | "mobile";
/** 启动时检查更新 */
checkUpdateOnStart: boolean;
/** 隐藏 VIP 标签 */
Expand Down Expand Up @@ -513,6 +515,7 @@ export const useSettingStore = defineStore("setting", {
routeAnimation: "slide",
playerExpandAnimation: "up",
useOnlineService: true,
shareUrlFormat: "web",
showCloseAppTip: true,
closeAppMethod: "hide",
showTaskbarProgress: false,
Expand Down
24 changes: 23 additions & 1 deletion src/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,12 @@ export const formatFileSize = (bytes: number): string => {
*/
export const copyData = async (text: any, message?: string) => {
if (!text) return;
const content = typeof text === "string" ? text.trim() : JSON.stringify(text, null, 2);
const content =
typeof text === "string"
? text.trim()
: Array.isArray(text)
? text.join("\n")
: JSON.stringify(text, null, 2);
if (navigator.clipboard && window.isSecureContext) {
try {
await navigator.clipboard.writeText(content);
Expand Down Expand Up @@ -470,3 +475,20 @@ export const handleSongQuality = (
}
return undefined;
};

/**
* 获取分享链接
* @param type 资源类型 (song, playlist, album, artist, mv, etc.)
* @param id 资源 ID
* @returns 分享链接
*/
export const getShareUrl = (type: string, id: number | string): string => {
const settingStore = useSettingStore();
const { shareUrlFormat } = settingStore;

if (shareUrlFormat === "mobile") {
return `https://y.music.163.com/m/${type}?id=${id}`;
}

return `https://music.163.com/#/${type}?id=${id}`;
};
7 changes: 5 additions & 2 deletions src/views/Artist/layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
<script setup lang="ts">
import type { DropdownOption } from "naive-ui";
import type { ArtistType } from "@/types/main";
import { coverLoaded, renderIcon, copyData } from "@/utils/helper";
import { coverLoaded, renderIcon, copyData, getShareUrl } from "@/utils/helper";
import { renderToolbar } from "@/utils/meta";
import { openDescModal, openBatchList } from "@/utils/modal";
import { artistDetail } from "@/api/artist";
Expand Down Expand Up @@ -209,7 +209,10 @@ const moreOptions = computed<DropdownOption[]>(() => [
key: "copy",
props: {
onClick: () =>
copyData(`https://music.163.com/#/artist?id=${artistId.value}`, "已复制分享链接到剪贴板"),
copyData(
getShareUrl("artist", artistId.value),
"已复制分享链接到剪贴板",
),
},
icon: renderIcon("Share"),
},
Expand Down
7 changes: 5 additions & 2 deletions src/views/List/album.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import type { DropdownOption } from "naive-ui";
import { songDetail } from "@/api/song";
import { albumDetail } from "@/api/album";
import { formatCoverList, formatSongsList } from "@/utils/format";
import { renderIcon, copyData } from "@/utils/helper";
import { renderIcon, copyData, getShareUrl } from "@/utils/helper";
import { openBatchList } from "@/utils/modal";
import { useDataStore } from "@/stores";
import { toLikeAlbum } from "@/utils/auth";
Expand Down Expand Up @@ -163,7 +163,10 @@ const moreOptions = computed<DropdownOption[]>(() => [
key: "copy",
props: {
onClick: () =>
copyData(`https://music.163.com/#/album?id=${albumId.value}`, "已复制分享链接到剪贴板"),
copyData(
getShareUrl("album", albumId.value),
"已复制分享链接到剪贴板",
),
},
icon: renderIcon("Share"),
},
Expand Down
4 changes: 2 additions & 2 deletions src/views/List/liked.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import { SongType } from "@/types/main";
import { songDetail } from "@/api/song";
import { playlistDetail, playlistAllSongs } from "@/api/playlist";
import { formatCoverList, formatSongsList } from "@/utils/format";
import { renderIcon, copyData } from "@/utils/helper";
import { renderIcon, copyData, getShareUrl } from "@/utils/helper";
import { isObject } from "lodash-es";
import { useDataStore } from "@/stores";
import { openBatchList, openUpdatePlaylist } from "@/utils/modal";
Expand Down Expand Up @@ -146,7 +146,7 @@ const moreOptions = computed<DropdownOption[]>(() => [
props: {
onClick: () =>
copyData(
`https://music.163.com/#/playlist?id=${playlistId.value}`,
getShareUrl("playlist", playlistId.value),
"已复制分享链接到剪贴板",
),
},
Expand Down
4 changes: 2 additions & 2 deletions src/views/List/playlist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ import {
updatePlaylistPrivacy,
} from "@/api/playlist";
import { formatCoverList, formatSongsList } from "@/utils/format";
import { renderIcon, copyData } from "@/utils/helper";
import { renderIcon, copyData, getShareUrl } from "@/utils/helper";
import { isLogin, toLikePlaylist, updateUserLikePlaylist } from "@/utils/auth";
import { useDataStore, useLocalStore } from "@/stores";
import { openBatchList, openUpdatePlaylist } from "@/utils/modal";
Expand Down Expand Up @@ -229,7 +229,7 @@ const moreOptions = computed<DropdownOption[]>(() => [
props: {
onClick: () =>
copyData(
`https://music.163.com/#/playlist?id=${playlistId.value}`,
getShareUrl("playlist", playlistId.value),
"已复制分享链接到剪贴板",
),
},
Expand Down
7 changes: 5 additions & 2 deletions src/views/List/radio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<script setup lang="ts">
import type { DropdownOption, MessageReactive } from "naive-ui";
import { formatCoverList, formatSongsList } from "@/utils/format";
import { renderIcon, copyData } from "@/utils/helper";
import { renderIcon, copyData, getShareUrl } from "@/utils/helper";
import { useDataStore } from "@/stores";
import { radioAllProgram, radioDetail } from "@/api/radio";
import { useListDetail } from "@/composables/List/useListDetail";
Expand Down Expand Up @@ -170,7 +170,10 @@ const moreOptions = computed<DropdownOption[]>(() => [
key: "copy",
props: {
onClick: () =>
copyData(`https://music.163.com/#/djradio?id=${radioId.value}`, "已复制分享链接到剪贴板"),
copyData(
getShareUrl("djradio", radioId.value),
"已复制分享链接到剪贴板",
),
},
icon: renderIcon("Share"),
},
Expand Down