From 421145e94850aa8c3e1de92e5ab82cedb54074a8 Mon Sep 17 00:00:00 2001 From: zjb Date: Sun, 28 Jan 2024 23:57:45 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(=E6=9C=9F=E5=88=8A=E3=80=81?= =?UTF-8?q?=E6=9B=B2=E5=BA=93):=20=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.develop | 1 + src/api/article.js | 19 +- src/api/login.js | 12 +- src/api/musicV2.js | 37 +- src/components/Breadcrumb/index.vue | 8 +- src/router/index.js | 167 ++++++++- src/store/modules/user.js | 10 +- src/styles/variables.scss | 6 +- src/utils/request.js | 1 + src/views/article/articleModify.vue | 256 +++++++------- src/views/article/index.vue | 237 ++++++------- src/views/common/unfinished.vue | 30 ++ .../layout/components/Sidebar/SidebarItem.vue | 2 +- src/views/layout/components/Sidebar/index.vue | 13 +- src/views/song/index.vue | 319 ++++++++++++------ src/views/song/musicModify.vue | 46 ++- src/views/tag/index.vue | 3 +- 17 files changed, 751 insertions(+), 416 deletions(-) create mode 100644 .env.develop create mode 100644 src/views/common/unfinished.vue diff --git a/.env.develop b/.env.develop new file mode 100644 index 0000000..3b32e8b --- /dev/null +++ b/.env.develop @@ -0,0 +1 @@ +ENV = "ddddd" \ No newline at end of file diff --git a/src/api/article.js b/src/api/article.js index 0498284..694e777 100644 --- a/src/api/article.js +++ b/src/api/article.js @@ -13,6 +13,12 @@ export default { data: data }); }, + getDetail(id) { + return request({ + url: `/luoo-music/cms/journal/${id}`, + method: "get" + }); + }, /** * 删除 * @param {*} id @@ -31,8 +37,12 @@ export default { */ publish(id, type, time) { return request({ - url: `/luoo-music/cms/journal/publish/${id}?isScheduled=${type}&state=${time}`, - method: "put" + url: `/luoo-music/cms/journal/publish/${id}`, + method: "put", + data: { + "isScheduled": type, + "pubTime": time + } }); }, /** @@ -43,8 +53,9 @@ export default { */ updateStatus(id, state) { return request({ - url: `/luoo-music/cms/journal/publish/${id}?state=${state}`, - method: "put" + url: `/luoo-music/cms/journal/update/state/${id}`, + method: "put", + data: state }); }, /** diff --git a/src/api/login.js b/src/api/login.js index f6fcc4c..2e651cc 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -1,8 +1,14 @@ +/* + * @Description: + * @version: v1 + * @Author: zhangjiabao + * @Date: 2024-01-02 21:12:35 + */ import request from '@/utils/request' export function login(username, password) { return request({ - url: '/user/admin/login', + url: '/user/cms/admin/login', method: 'post', data: { username, @@ -13,7 +19,7 @@ export function login(username, password) { export function getInfo(token) { return request({ - url: '/user/admin/info', + url: '/user/cms/admin/info', method: 'get', params: { token } }) @@ -21,7 +27,7 @@ export function getInfo(token) { export function logout() { return request({ - url: '/user/admin/logout', + url: '/user/cms/admin/logout', method: 'post' }) } diff --git a/src/api/musicV2.js b/src/api/musicV2.js index caf9062..acc8a74 100644 --- a/src/api/musicV2.js +++ b/src/api/musicV2.js @@ -15,24 +15,45 @@ export default { }, getByKeyword(keyword) { return request({ - url: `/luoo-music/cms/song/search/1/999`, + url: `/luoo-music/cms/song/search/1/99`, method: "post", data: { keyword: keyword } }); }, - updateLyric(id, lyric) { + getById(id) { return request({ - url: `/luoo-music/cms/song/update/lyric/${id}`, + url: `/luoo-music/cms/song/${id}`, + method: "get" + }) + }, + updateInfo(id, data) { + return request({ + url: `/luoo-music/cms/song/${id}`, method: "put", - params: { - lyric - } + data, + }) + }, + getLyric(id) { + return request({ + url: `/luoo-music/cms/song/lyric/${id}`, + method: "get" + }) + }, + updateLyric(id, lyric) { + const url = `/luoo-music/cms/song/update/lyric/${id}`; + + return request.put(url, lyric, { + headers: { + 'Content-Type': 'application/json', + // 可以添加其他需要的请求头 + }, }); }, updateState(id, state) { return request({ - url: `/luoo-music/cms/song/update/state/${id}?state=${state}`, - method: "put" + url: `/luoo-music/cms/song/update/state/${id}`, + method: "put", + data:state }); }, delete(id) { diff --git a/src/components/Breadcrumb/index.vue b/src/components/Breadcrumb/index.vue index b5d9471..3e59d41 100644 --- a/src/components/Breadcrumb/index.vue +++ b/src/components/Breadcrumb/index.vue @@ -1,3 +1,9 @@ + @@ -263,10 +315,19 @@ export default { timeRange: [] } }, + songUploadFileList: [], musicModifyDialog: { visible: false, data: {} }, + lyricDialog: { + visible: false, + songId: null, + data: "" + }, + uploadDialog: { + visible: false + }, // 表格 table: { show: true, @@ -308,54 +369,21 @@ export default { }; if (param.timeRange) { if (param.timeRange[0]) { - queryParam.start = param.timeRange[0] + " 00:00:00"; + queryParam.start = param.timeRange[0]; } if (param.timeRange[1]) { - queryParam.end = param.timeRange[1] + " 23:59:59"; + queryParam.end = param.timeRange[1]; } } this.table.loading = true; - - setTimeout(() => { - let musicList = [ - { - album: "范特西", - artist: "周杰伦", - duration: "1h30min", - id: "1", - journal: [1, 2, 3], - lyric: "lllll llll lll", - name: "双节棍", - picture: "https://luoow.wxwenku.com/999/cover_min.jpg", - size: "1.3m", - state: "1", - tags: [3, 5, 11], - updateTime: "2023-01-01", - url: "https://luoow.wxwenku.com/999/03._Du_und_ich_Klee.mp3", - userId: "1627863701048659968" - }, - { - album: "范特西1", - artist: "周杰伦1", - duration: "1h30min", - id: "2", - journal: [1, 2, 3], - lyric: "lllll llll lll", - name: "双节棍1", - picture: "https://luoow.wxwenku.com/999/cover_min.jpg", - size: "1.3m", - state: "1", - tags: [3, 5, 11], - updateTime: "2023-01-01", - url: "https://luoow.wxwenku.com/999/03._Du_und_ich_Klee.mp3", - userId: "1627863701048659968" - } - ]; - this.table.data = musicList; - this.table.page.total = 10; - this.table.loading = false; - }, 1000); + musicApi + .getList(queryParam, this.table.page.current, this.table.page.size) + .then(res => { + this.table.data = res.data.rows; + this.table.page.total = res.data.total; + this.table.loading = false; + }); }, /** * 创建人下拉框 @@ -373,42 +401,22 @@ export default { * 高级筛选tag */ fetchTags() { - // tagApi.queryHierarchical().then(res => { - // console.log(res) - // }) - let res = [ - { - id: 1, - nameCh: "语言类型", - children: [ - { id: 3, nameCh: "中文" }, - { id: 4, nameCh: "日文" }, - { id: 5, nameCh: "英文" } - ] - }, - { - id: 10, - nameCh: "期刊标签", - children: [ - { id: 11, nameCh: "民谣" }, - { id: 12, nameCh: "摇滚" } - ] - } - ]; - let newList = []; - for (let index in res) { - let item = res[index]; - let newItem = { value: item.id, label: item.nameCh, children: [] }; - for (let childrenIndex in item.children) { - let childrenItem = item.children[childrenIndex]; - newItem.children.push({ - value: childrenItem.id, - label: childrenItem.nameCh - }); + tagApi.queryHierarchical().then(res => { + let newList = []; + for (let index in res.data) { + let item = res.data[index]; + let newItem = { value: item.id, label: item.nameCh, children: [] }; + for (let childrenIndex in item.children) { + let childrenItem = item.children[childrenIndex]; + newItem.children.push({ + value: childrenItem.id, + label: childrenItem.nameCh + }); + } + newList.push(newItem); } - newList.push(newItem); - } - this.queryForm.remoteData.tags = newList; + this.queryForm.remoteData.tags = newList; + }); }, // ************************* 数据处理 ************************* getAuthorNameById(userId) { @@ -470,7 +478,8 @@ export default { * 编辑标签点击事件 */ handleModifyClick(row) { - this.musicModifyDialog.data = row; + let newRow = JSON.parse(JSON.stringify(row)); + this.musicModifyDialog.data = newRow; this.musicModifyDialog.visible = true; }, /** @@ -491,8 +500,7 @@ export default { * 表格内状态滑块切换事件 */ handleTableRowStatusChange($event, row) { - this.$message("状态切换" + $event); - musicApi.updateStatus(row.id, $event).then(res => { + musicApi.updateState(row.id, $event).then(res => { if (res.code === 200) { this.$message.success(res.message); } else { @@ -543,6 +551,53 @@ export default { this.$refs.songTable.toggleRowSelection(rows[rowIndex]); } }, + /** + * 打开弹窗按扭点击事件 + */ + handleLyricClick(row) { + this.lyricDialog.songId = row.id; + this.lyricDialog.visible = true; + this.lyricDialog.loading = true; + musicApi.getLyric(row.id).then(res => { + this.lyricDialog.data = res.data.lyric; + this.lyricDialog.loading = false; + }); + }, + handleLyricDialogBeforeClose(done) { + this.lyricDialog.data = ""; + this.lyricDialog.songId = null; + this.lyricDialog.visible = false; + done(); + }, + handleUploadDialogBeforeClose(done) { + this.uploadDialog.visible = false; + this.songUploadFileList = []; + done(); + }, + /** + * 弹窗提交按扭点击事件 + */ + handleLyricDialogSubmit() { + musicApi + .updateLyric(this.lyricDialog.songId, this.lyricDialog.data) + .then(res => { + if (res.code === 200) { + this.lyricDialog.data = ""; + this.lyricDialog.songId = null; + this.lyricDialog.visible = false; + } else { + this.$message.error(res.message); + } + }); + }, + /** + * 弹窗取消按扭点击事件 + */ + handleLyricDialogCancel() { + this.lyricDialog.data = ""; + this.lyricDialog.songId = null; + this.lyricDialog.visible = false; + }, /** * 分页组件页数变化事件 */ @@ -563,6 +618,54 @@ export default { handleMusicModifyDialogBeforeClose(done) { this.musicModifyDialog.visible = false; done(); + }, + handleMusicModifySave() { + let oldInfo = this.musicModifyDialog.data; + let newInfo = { + album: oldInfo["album"], + artist: oldInfo["artist"], + image: oldInfo["image"], + name: oldInfo["name"], + tags: oldInfo["tags"], + url: oldInfo["url"] + }; + musicApi.updateInfo(oldInfo["id"], newInfo).then(res => { + if (res.code === 200) { + this.musicModifyDialog.data = {}; + this.$message.success("保存成功"); + + this.musicModifyDialog.visible = false; + this.fetchData(this.queryForm.lastQuery); + } else { + this.$message.error(res.message); + } + }); + }, + handleMusicModifyClose() { + this.musicModifyDialog.data = {}; + this.musicModifyDialog.visible = false; + }, + // ************************* 上传事件 ************************* + handleRemove(file, fileList) { + console.log(file, fileList); + }, + handlePreview(file) { + console.log(file); + }, + handleExceed(files, fileList) { + this.$message.warning( + `当前限制选择 10 个文件,本次选择了 ${ + files.length + } 个文件,共选择了 ${files.length + fileList.length} 个文件` + ); + }, + beforeRemove(file, fileList) { + return this.$confirm(`确定移除 ${file.name}?`); + }, + handleUploadSongSuccess(response, file, fileList) { + if (response.status === "success") { + this.$message.success("上传成功"); + } } } }; diff --git a/src/views/song/musicModify.vue b/src/views/song/musicModify.vue index 4e74fb7..24bd87b 100644 --- a/src/views/song/musicModify.vue +++ b/src/views/song/musicModify.vue @@ -38,20 +38,21 @@ filterable > - + diff --git a/src/views/tag/index.vue b/src/views/tag/index.vue index 901f5ff..cbf046c 100644 --- a/src/views/tag/index.vue +++ b/src/views/tag/index.vue @@ -45,7 +45,7 @@ @@ -355,6 +355,7 @@ export default { let queryParam = { ...param }; + queryParam.level = this.tagType if (param.timeRange) { if (param.timeRange[0]) { queryParam.createTimeStart = param.timeRange[0] + " 00:00:00";