Skip to content

Commit

Permalink
feat: 支持云盘歌曲纠正
Browse files Browse the repository at this point in the history
  • Loading branch information
imsyy committed Dec 7, 2023
1 parent b65369a commit 6d5fa15
Show file tree
Hide file tree
Showing 7 changed files with 289 additions and 74 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ module.exports = {
$notification: true,
$changeThemeColor: true,
$canNotConnect: true,
$refreshCloudList: true,
},
};
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: 转到讨论区
url: https://github.com/imsyy/SPlayer/discussions
about: Issues 用于反馈 Bug, 新的功能建议和提问答疑请到讨论区发起
- name: 提问的艺术
url: https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md
about: 默认所有 Issues 发起者均已了解此处的内容
2 changes: 2 additions & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
AddPlaylist: typeof import('./src/components/Modal/AddPlaylist.vue')['default']
CloudMatch: typeof import('./src/components/Modal/CloudMatch.vue')['default']
CloudSongMatch: typeof import('./src/components/Modal/CloudSongMatch.vue')['default']
CommentList: typeof import('./src/components/List/CommentList.vue')['default']
CountDown: typeof import('./src/components/Player/CountDown.vue')['default']
CoverDropdown: typeof import('./src/components/Cover/CoverDropdown.vue')['default']
Expand Down
74 changes: 0 additions & 74 deletions src/api/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,80 +151,6 @@ export const setLikeSong = (id, like = true) => {
});
};

/**
* 获取用户云盘数据
* @param {number} [limit=30] - 返回数量,默认30
* @param {number} [offset=0] - 偏移数量,默认0
*/
export const getCloud = (limit = 30, offset = 0) => {
return axios({
method: "GET",
url: "/user/cloud",
params: {
limit,
offset,
timestamp: new Date().getTime(),
},
});
};

/**
* 用户云盘歌曲删除
* @param {string} id - 歌曲的id
*/
export const setCloudDel = (id) => {
return axios({
method: "GET",
url: "/user/cloud/del",
params: {
id,
timestamp: new Date().getTime(),
},
});
};

/**
* 云盘歌曲信息匹配纠正
* @param {string} uid - 用户id
* @param {string} sid - 原歌曲id
* @param {string} asid - 要匹配的歌曲id
*/
export const setCloudMatch = (uid, sid, asid) => {
return axios({
method: "GET",
url: "/cloud/match",
params: {
uid,
sid,
asid,
timestamp: new Date().getTime(),
},
});
};

/**
* 用户云盘上传
* @param {File} file - 要上传的文件
*/
export const upCloudSong = (file, onUploadProgress) => {
const formData = new FormData();
formData.append("songFile", file);
return axios({
url: "/cloud",
method: "POST",
hiddenBar: true,
params: {
timestamp: new Date().getTime(),
},
data: formData,
headers: {
"Content-Type": "multipart/form-data",
},
timeout: 200000,
onUploadProgress,
});
};

/**
* 退出登录
*/
Expand Down
26 changes: 26 additions & 0 deletions src/components/List/SongListDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<AddPlaylist ref="addPlaylistRef" />
<!-- 下载歌曲 -->
<DownloadSong ref="downloadSongRef" />
<!-- 云盘歌曲纠正 -->
<CloudSongMatch ref="cloudSongMatchRef" />
</template>

<script setup>
Expand All @@ -27,6 +29,7 @@ import { useRouter } from "vue-router";
import { addSongToNext } from "@/utils/Player";
import { setCloudDel } from "@/api/cloud";
import { addSongToPlayList } from "@/api/playlist";
import { copyData } from "@/utils/helper";
import SvgIcon from "@/components/Global/SvgIcon";

const emit = defineEmits(["playSong"]);
Expand All @@ -45,6 +48,7 @@ const dropdownOptions = ref(null);
// 子组件
const addPlaylistRef = ref(null);
const downloadSongRef = ref(null);
const cloudSongMatchRef = ref(null);

// 图标渲染
const renderIcon = (icon, size, translate = 0) => {
Expand Down Expand Up @@ -183,6 +187,17 @@ const openDropdown = (e, data, song, index, sourceId) => {
},
icon: renderIcon("video"),
},
{
key: "copy",
label: "复制歌曲 ID",
props: {
onClick: () => {
const songId = song?.id?.toString();
copyData(songId);
},
},
icon: renderIcon("content-copy"),
},
{
key: "line-cloud",
type: "divider",
Expand All @@ -199,6 +214,17 @@ const openDropdown = (e, data, song, index, sourceId) => {
},
icon: renderIcon("delete"),
},
{
key: "edit",
label: "云盘歌曲纠正",
show: isCloud,
props: {
onClick: () => {
cloudSongMatchRef.value?.openCloudSongMatch(song, index);
},
},
icon: renderIcon("edit"),
},
{
key: "delete",
label: "从云盘中删除",
Expand Down
Loading

0 comments on commit 6d5fa15

Please sign in to comment.