Skip to content

Commit a547346

Browse files
committed
chore: 接口整理
1 parent 7b38069 commit a547346

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+376
-1450
lines changed

music-client/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"lint": "vue-cli-service lint"
99
},
1010
"dependencies": {
11+
"axios": "^0.26.0",
1112
"core-js": "^3.8.3",
13+
"element-plus": "^2.0.4",
1214
"vue": "^3.2.13",
1315
"vue-router": "^4.0.3",
1416
"vuex": "^4.0.0"
@@ -24,8 +26,6 @@
2426
"@vue/cli-plugin-vuex": "~5.0.0",
2527
"@vue/cli-service": "~5.0.0",
2628
"@vue/eslint-config-typescript": "^9.1.0",
27-
"axios": "^0.26.0",
28-
"element-plus": "^2.0.4",
2929
"eslint": "^7.32.0",
3030
"eslint-plugin-vue": "^8.0.3",
3131
"sass": "^1.32.7",

music-client/src/components/Comment.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ export default defineComponent({
6969
// 获取所有评论
7070
async function getComment() {
7171
try {
72-
const result = (await HttpManager.getAllComment(type.value, playId.value)) as any[];
73-
commentList.value = result;
74-
for (const item of result) {
72+
const result = (await HttpManager.getAllComment(type.value, playId.value)) as ResponseBody;
73+
commentList.value = result.data;
74+
for (const item of commentList.value) {
7575
// 获取评论用户的昵称和头像
76-
const resultUser = await HttpManager.getUserOfId(item.userId);
77-
userPicList.value.push(resultUser[0].avator);
78-
userNameList.value.push(resultUser[0].username);
76+
const resultUser = await HttpManager.getUserOfId(item.userId) as ResponseBody;
77+
userPicList.value.push(resultUser.data[0].avator);
78+
userNameList.value.push(resultUser.data[0].username);
7979
}
8080
} catch (error) {
8181
console.error(error);
@@ -97,7 +97,7 @@ export default defineComponent({
9797
params.append("type", `${type.value}`);
9898
params.append("content", textarea.value);
9999
100-
const result = (await HttpManager.setComment(params)) as { success: boolean; type: string };
100+
const result = (await HttpManager.setComment(params)) as ResponseBody;
101101
(proxy as any).$message({
102102
message: result.success,
103103
type: result.type,
@@ -117,7 +117,7 @@ export default defineComponent({
117117
params.append("id", id);
118118
params.append("up", up + 1);
119119
120-
const result = (await HttpManager.setSupport(params)) as { success: boolean };
120+
const result = (await HttpManager.setSupport(params)) as ResponseBody;
121121
if (result.success) {
122122
proxy.$refs.up[index].children[0].style.color = "#2796dd";
123123
await getComment();

music-client/src/components/layouts/YinPlayBar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export default defineComponent({
134134
return
135135
}
136136
137-
const result = (await HttpManager.downloadMusic(this.songUrl)) as { data: any };
137+
const result = (await HttpManager.downloadMusic(this.songUrl)) as ResponseBody;
138138
const eleLink = document.createElement("a");
139139
eleLink.download = `${this.singerName}-${this.songTitle}.mp3`;
140140
eleLink.style.display = "none";

music-client/src/views/Home.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ const singerList = ref([]); // 歌手列表
2323
const { changeIndex } = mixin();
2424
try {
2525
HttpManager.getSongList().then((res) => {
26-
songList.value = (res as any[]).sort().slice(0, 10);
26+
songList.value = (res as ResponseBody).data.sort().slice(0, 10);
2727
});
2828
2929
HttpManager.getAllSinger().then((res) => {
30-
singerList.value = (res as any[]).sort().slice(0, 10);
30+
singerList.value = (res as ResponseBody).data.sort().slice(0, 10);
3131
});
3232
3333
onMounted(() => {

music-client/src/views/personal/Personal.vue

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="personal">
33
<div class="personal-info">
44
<div class="personal-img">
5-
<img :src="attachImageUrl(userPic)" alt="" @click="dialogTableVisible = true"/>
5+
<img :src="attachImageUrl(userPic)" alt="" @click="dialogTableVisible = true" />
66
</div>
77
<div class="personal-msg">
88
<div class="username">{{ personalInfo.username }}</div>
@@ -22,15 +22,7 @@
2222
</template>
2323

2424
<script lang="ts">
25-
import {
26-
defineComponent,
27-
nextTick,
28-
ref,
29-
markRaw,
30-
computed,
31-
watch,
32-
reactive,
33-
} from "vue";
25+
import { defineComponent, nextTick, ref, computed, watch, reactive } from "vue";
3426
import { useStore } from "vuex";
3527
import { Edit } from "@element-plus/icons-vue";
3628
import SongList from "@/components/SongList.vue";
@@ -67,38 +59,24 @@ export default defineComponent({
6759
function goPage() {
6860
routerManager(RouterName.PersonalData, { path: RouterName.PersonalData });
6961
}
70-
function getUserInfo(id) {
71-
HttpManager.getUserOfId(id)
72-
.then((res) => {
73-
personalInfo.username = res[0].username;
74-
personalInfo.userSex = res[0].sex;
75-
personalInfo.birth = res[0].birth;
76-
personalInfo.introduction = res[0].introduction;
77-
personalInfo.location = res[0].location;
78-
})
79-
.catch((err) => {
80-
console.error(err);
81-
});
62+
async function getUserInfo(id) {
63+
const result = (await HttpManager.getUserOfId(id)) as ResponseBody;
64+
personalInfo.username = result.data[0].username;
65+
personalInfo.userSex = result.data[0].sex;
66+
personalInfo.birth = result.data[0].birth;
67+
personalInfo.introduction = result.data[0].introduction;
68+
personalInfo.location = result.data[0].location;
8269
}
83-
// 收藏的歌曲ID
70+
// 获取收藏的歌曲
8471
async function getCollection(userId) {
85-
const result = (await HttpManager.getCollectionOfUser(userId)) as any[];
86-
const collectIDList = result || []; // 存放收藏的歌曲ID
72+
const result = (await HttpManager.getCollectionOfUser(userId)) as ResponseBody;
73+
const collectIDList = result.data || []; // 存放收藏的歌曲ID
8774
// 通过歌曲ID获取歌曲信息
8875
for (const item of collectIDList) {
89-
getCollectSongList(item.songId);
76+
const result = await HttpManager.getSongOfId(item.songId) as ResponseBody;
77+
collectSongList.value.push(result.data[0]);
9078
}
9179
}
92-
// 获取收藏的歌曲
93-
function getCollectSongList(id) {
94-
HttpManager.getSongOfId(id)
95-
.then((res) => {
96-
collectSongList.value.push(res[0]);
97-
})
98-
.catch((err) => {
99-
console.error(err);
100-
});
101-
}
10280
10381
nextTick(() => {
10482
getUserInfo(userId.value);

music-client/src/views/personal/PersonalData.vue

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ export default defineComponent({
7373
const userId = computed(() => store.getters.userId);
7474
7575
async function getUserInfo(id) {
76-
const result = await HttpManager.getUserOfId(id);
77-
registerForm.username = result[0].username;
78-
registerForm.password = result[0].password;
79-
registerForm.sex = result[0].sex;
80-
registerForm.phoneNum = result[0].phoneNum;
81-
registerForm.email = result[0].email;
82-
registerForm.birth = result[0].birth;
83-
registerForm.introduction = result[0].introduction;
84-
registerForm.location = result[0].location;
85-
registerForm.userPic = result[0].avator;
76+
const result = await HttpManager.getUserOfId(id) as ResponseBody;
77+
registerForm.username = result.data[0].username;
78+
registerForm.password = result.data[0].password;
79+
registerForm.sex = result.data[0].sex;
80+
registerForm.phoneNum = result.data[0].phoneNum;
81+
registerForm.email = result.data[0].email;
82+
registerForm.birth = result.data[0].birth;
83+
registerForm.introduction = result.data[0].introduction;
84+
registerForm.location = result.data[0].location;
85+
registerForm.userPic = result.data[0].avator;
8686
}
8787
8888
async function saveMsg() {
@@ -103,7 +103,7 @@ export default defineComponent({
103103
params.append("introduction", registerForm.introduction);
104104
params.append("location", registerForm.location);
105105
106-
const result = (await HttpManager.updateUserMsg(params)) as { success: boolean; message: string; type: string };
106+
const result = (await HttpManager.updateUserMsg(params)) as ResponseBody;
107107
(proxy as any).$message({
108108
message: result.message,
109109
type: result.type,

music-client/src/views/search/SearchSong.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ export default defineComponent({
3737
currentSongList.value = [];
3838
return;
3939
}
40-
const result = (await HttpManager.getSongOfSingerName(value)) as any[];
41-
if (!result.length) {
40+
const result = (await HttpManager.getSongOfSingerName(value)) as ResponseBody;
41+
if (!result.data.length) {
4242
currentSongList.value = [];
4343
(proxy as any).$message({
4444
message: "暂时没有相关歌曲",
4545
type: "warning",
4646
});
4747
} else {
48-
currentSongList.value = result;
48+
currentSongList.value = result.data;
4949
}
5050
}
5151

music-client/src/views/search/SearchSongList.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ export default defineComponent({
3434
3535
async function getSearchList(value) {
3636
if (!value) return;
37-
const result = await HttpManager.getSongListOfLikeTitle(value) as any[];
38-
if (!result.length) {
37+
const result = await HttpManager.getSongListOfLikeTitle(value) as ResponseBody;
38+
if (!result.data.length) {
3939
(proxy as any).$message({
4040
message: "暂无该歌曲内容",
4141
type: "warning",
4242
});
4343
} else {
44-
playList.value = result;
44+
playList.value = result.data;
4545
}
4646
}
4747

music-client/src/views/singer/Singer.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ const data = computed(() => {
4646
4747
// 获取所有歌手
4848
async function getAllSinger() {
49-
const result = await HttpManager.getAllSinger() as any[];
49+
const result = await HttpManager.getAllSinger() as ResponseBody;
5050
currentPage.value = 1;
51-
allPlayList.value = result;
51+
allPlayList.value = result.data;
5252
}
5353
5454
getAllSinger();
@@ -70,9 +70,9 @@ function handleChangeView(item) {
7070
7171
// 通过性别对歌手分类
7272
async function getSingerSex(sex) {
73-
const result = await HttpManager.getSingerOfSex(sex) as any[];
73+
const result = await HttpManager.getSingerOfSex(sex) as ResponseBody;
7474
currentPage.value = 1;
75-
allPlayList.value = result;
75+
allPlayList.value = result.data;
7676
}
7777
</script>
7878

music-client/src/views/singer/SingerDetail.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ export default defineComponent({
4545
4646
onMounted(async () => {
4747
try {
48-
const result = (await HttpManager.getSongOfSingerId(songDetails.value.id)) as any[];
49-
currentSongList.value = result;
48+
const result = (await HttpManager.getSongOfSingerId(songDetails.value.id)) as ResponseBody;
49+
currentSongList.value = result.data;
5050
} catch (error) {
5151
console.error(error);
5252
}

music-client/src/views/song-sheet/SongSheet.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ export default defineComponent({
4040
4141
// 获取全部歌单
4242
async function getSongList() {
43-
allPlayList.value = (await HttpManager.getSongList()) as any[];
43+
allPlayList.value = ((await HttpManager.getSongList()) as ResponseBody).data;
4444
currentPage.value = 1;
4545
}
4646
// 通过类别获取歌单
4747
async function getSongListOfStyle(style) {
48-
allPlayList.value = (await HttpManager.getSongListOfStyle(style)) as any[];
48+
allPlayList.value = ((await HttpManager.getSongListOfStyle(style)) as ResponseBody).data;
4949
currentPage.value = 1;
5050
}
5151

music-client/src/views/song-sheet/SongSheetDetail.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,22 @@ export default defineComponent({
6666
6767
// 收集歌单里面的歌曲
6868
async function getSongId(id) {
69-
const result = (await HttpManager.getListSongOfSongId(id)) as any[];
69+
const result = (await HttpManager.getListSongOfSongId(id)) as ResponseBody;
7070
// 获取歌单里的歌曲信息
71-
for (const item of result) {
71+
for (const item of result.data) {
7272
// 获取单里的歌曲
73-
const resultSong = await HttpManager.getSongOfId(item.songId);
74-
currentSongList.value.push(resultSong[0]);
73+
const resultSong = await HttpManager.getSongOfId(item.songId) as ResponseBody;
74+
currentSongList.value.push(resultSong.data[0]);
7575
}
7676
}
7777
// 获取评分
7878
async function getRank(id) {
79-
const result = (await HttpManager.getRankOfSongListId(id)) as number;
80-
rank.value = result / 2;
79+
const result = (await HttpManager.getRankOfSongListId(id)) as ResponseBody;
80+
rank.value = result.data / 2;
8181
}
8282
async function getUserRank(userId, songListId) {
83-
const result = (await HttpManager.getUserRank(userId, songListId)) as string;
84-
score.value = parseInt(result);
83+
const result = (await HttpManager.getUserRank(userId, songListId)) as ResponseBody;
84+
score.value = parseInt(result.data);
8585
disabledRank.value = true;
8686
assistText.value = "已评价";
8787
}

0 commit comments

Comments
 (0)