diff --git a/CHANGELOG.md b/CHANGELOG.md index 7239ede2..d309bd8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,20 @@ Project versioning adheres to [Semantic Versioning](http://semver.org/). Commit convention is based on [Conventional Commits](http://conventionalcommits.org). Change log format is based on [Keep a Changelog](http://keepachangelog.com/). +## [1.3.0](https://github.com/lyswhut/lx-music-desktop/compare/v1.2.2...v1.3.0) - 2020-11-01 + +### 新增 + +- 播放详情页新增歌曲评论加载显示(某些平台暂不支持显示子评论) + +### 优化 + +- 修改播放详情页的歌曲图片的显示效果 + +### 修复 + +- 修复小芸源音乐搜索结果最多只有20条搜索结果的问题 + ## [1.2.2](https://github.com/lyswhut/lx-music-desktop/compare/v1.2.1...v1.2.2) - 2020-10-18 ### 修复 diff --git a/README.md b/README.md index 216353d2..588d8522 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ 所用技术栈: -- Electron 9 +- Electron 10 - Vue 2 已支持的平台: diff --git a/package.json b/package.json index 857bae8b..12cf2a87 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { - "name": "lx-music-desktop", - "version": "1.2.2", - "description": "一个免费的音乐下载助手", + "name": "5yin", + "version": "1.3.0", + "description": "一个基于洛雪音乐助手修改的免费音乐下载助手", "main": "./dist/electron/main.js", - "productName": "洛雪音乐助手(五音版)", + "productName": "五音助手", "scripts": { "pack": "node build-config/pack.js && npm run pack:win", "pack:win": "npm run pack:win:setup:x86_64 && npm run pack:win:7z", @@ -90,7 +90,7 @@ "icon": "./resources/icons", "category": "Utility;AudioVideo;Audio;Player;Music;", "desktop": { - "Name[zh_CN]": "洛雪音乐助手(五音版)" + "Name[zh_CN]": "五音助手" } }, "nsis": { @@ -99,7 +99,7 @@ "allowToChangeInstallationDirectory": true, "differentialPackage": true, "license": "./licenses/license.rtf", - "shortcutName": "洛雪音乐助手(五音版)" + "shortcutName": "五音助手" }, "dmg": { "window": { @@ -110,7 +110,7 @@ { "x": 106, "y": 252, - "name": "洛雪音乐助手(五音版)" + "name": "五音助手" }, { "x": 490, @@ -119,7 +119,7 @@ "path": "/Applications" } ], - "title": "洛雪音乐助手(五音版) v${version}" + "title": "五音助手 v${version}" }, "appImage": { "license": "./licenses/license_zh.txt", @@ -176,11 +176,11 @@ "cross-env": "^7.0.2", "css-loader": "^4.3.0", "del": "^6.0.0", - "electron": "^9.3.2", + "electron": "^9.3.3", "electron-builder": "^22.9.1", "electron-debug": "^3.1.0", "electron-devtools-installer": "^3.1.1", - "eslint": "^7.11.0", + "eslint": "^7.12.1", "eslint-config-standard": "^14.1.1", "eslint-formatter-friendly": "^7.0.0", "eslint-loader": "^4.0.2", @@ -188,8 +188,8 @@ "eslint-plugin-import": "^2.22.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^4.2.1", - "eslint-plugin-standard": "^4.0.1", - "file-loader": "^6.1.1", + "eslint-plugin-standard": "^4.0.2", + "file-loader": "^6.2.0", "friendly-errors-webpack-plugin": "^1.7.0", "html-webpack-plugin": "^4.5.0", "less": "^3.12.2", @@ -206,16 +206,16 @@ "rimraf": "^3.0.2", "spinnies": "^0.5.1", "stylus": "^0.54.8", - "stylus-loader": "^4.1.1", + "stylus-loader": "^4.2.0", "terser-webpack-plugin": "^4.2.3", "url-loader": "^4.1.1", - "vue-loader": "^15.9.3", + "vue-loader": "^15.9.4", "vue-template-compiler": "^2.6.12", "webpack": "^4.44.2", "webpack-cli": "^3.3.12", "webpack-dev-server": "^3.11.0", "webpack-hot-middleware": "^2.25.0", - "webpack-merge": "^5.2.0" + "webpack-merge": "^5.3.0" }, "dependencies": { "crypto-js": "^4.0.0", @@ -224,15 +224,15 @@ "electron-store": "^6.0.1", "electron-updater": "^4.3.5", "iconv-lite": "^0.6.2", - "image-size": "^0.9.1", + "image-size": "^0.9.3", "js-htmlencode": "^0.3.0", "lrc-file-parser": "^1.0.5", "needle": "^2.5.2", - "node-id3": "^0.1.19", + "node-id3": "^0.2.1", "request": "^2.88.2", "vue": "^2.6.12", - "vue-i18n": "^8.22.0", - "vue-router": "^3.4.7", + "vue-i18n": "^8.22.1", + "vue-router": "^3.4.8", "vuex": "^3.5.1", "vuex-router-sync": "^5.0.0" } diff --git a/publish/changeLog.md b/publish/changeLog.md index dffcaabf..b183e271 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -1,4 +1,11 @@ +### 新增 + +- 播放详情页新增歌曲评论加载显示(某些平台暂不支持显示子评论) + ### 优化 - 修改播放详情页的歌曲图片的显示效果 +### 修复 + +- 修复小芸源音乐搜索结果最多只有20条搜索结果的问题 diff --git a/publish/version.json b/publish/version.json index 6f2deeb7..8b4d3a97 100644 --- a/publish/version.json +++ b/publish/version.json @@ -1 +1 @@ -{"version":"1.2.2","desc":"

修复

\n\n","history":[{"version":"1.2.1","desc":"

优化

\n\n

修复

\n\n"},{"version":"1.2.0","desc":"

提前祝大家中秋&国庆快乐~

\n

新增

\n\n

优化

\n\n

修复

\n\n

其他

\n\n"},{"version":"1.1.1","desc":"

修复

\n\n"},{"version":"1.1.0","desc":"

新增

\n\n

修复

\n\n

优化

\n\n

移除

\n\n

其他

\n\n"},{"version":"1.0.1","desc":"

优化

\n\n

修复

\n\n"},{"version":"1.0.0","desc":"

新增

\n\n

优化

\n\n

修复

\n\n

更变

\n\n

其他

\n\n"},{"version":"0.18.2","desc":"

修复

\n\n"},{"version":"0.18.1","desc":"

优化

\n\n

修复

\n\n"},{"version":"0.18.0","desc":"

新增

\n\n

优化

\n\n

更变

\n\n

修复

\n\n

移除

\n\n

其他

\n

更新 Electron 到 8.2.5

\n"},{"version":"0.17.0","desc":"

新增

\n\n

优化

\n\n

修复

\n\n

其他

\n\n"},{"version":"0.16.0","desc":"

新增

\n\n

优化

\n\n

修复

\n\n

其他

\n\n"},{"version":"0.15.0","desc":"

洛雪提前祝大家新年快乐、身体健康、阖家幸福!

\n

修复

\n\n"},{"version":"0.14.1","desc":"

洛雪提前祝大家新年快乐、身体健康、阖家幸福!

\n

修复

\n\n"},{"version":"0.14.0","desc":"

洛雪提前祝大家新年快乐、身体健康、阖家幸福!

\n

新增

\n\n

优化

\n\n

修复

\n\n

其他

\n\n"},{"version":"0.13.1","desc":"

修复

\n\n

其他

\n\n"},{"version":"0.13.0","desc":"

新增

\n\n

优化

\n\n

修复

\n\n

移除

\n\n

其他

\n\n"},{"version":"0.12.1","desc":"

优化

\n\n

修复

\n\n

其他

\n\n"},{"version":"0.12.0","desc":"

由于新下载库仍然没有完成,但下载功能已经可用,so 移除之前使用的第三方下载库,暂时把新下载库的下载模块直接加入本程序,若出现下载问题欢迎反馈!

\n

新增

\n\n

优化

\n\n

修复

\n\n"},{"version":"0.11.0","desc":"

新增

\n\n

优化

\n\n"},{"version":"0.10.0","desc":"

优化

\n\n

修复

\n\n"},{"version":"0.9.1","desc":"

修复

\n\n"},{"version":"0.9.0","desc":"

新增

\n\n

修复

\n\n"},{"version":"0.8.2","desc":"

修复

\n\n"},{"version":"0.8.1","desc":"

修复

\n\n"},{"version":"0.8.0","desc":"

新增

\n\n

优化

\n\n

修复

\n\n"},{"version":"0.7.0","desc":"

新增

\n\n

优化

\n\n

修复

\n\n"},{"version":"0.6.2","desc":"

祝贺祖国成立70周年~!

\n

新增

\n\n

修复

\n\n"},{"version":"0.6.1","desc":"

新增

\n\n

优化

\n\n

修复

\n\n

移除

\n\n"},{"version":"0.6.0","desc":"

新增

\n\n

优化

\n\n

修复

\n\n"},{"version":"0.5.5","desc":"

新增

\n\n

修复

\n\n"},{"version":"0.5.4","desc":"

移除

\n\n"},{"version":"0.5.3","desc":"

优化

\n\n

修复

\n\n"},{"version":"0.5.2","desc":"

新增

\n\n

优化

\n\n

修复

\n\n

移除

\n\n"},{"version":"0.5.1","desc":"

新增

\n\n

修复

\n\n"},{"version":"0.5.0","desc":"

新增

\n\n

优化

\n\n

修复

\n\n"},{"version":"0.4.0","desc":"

新增

\n\n

移除

\n\n"},{"version":"0.3.5","desc":"

新增

\n\n

优化

\n\n

修复

\n\n"},{"version":"0.3.4","desc":"

优化

\n\n

修复

\n\n"},{"version":"0.3.3","desc":"

修复

\n\n"},{"version":"0.3.2","desc":"

新增

\n\n"},{"version":"0.3.1","desc":"

修复

\n\n"},{"version":"0.3.0","desc":"

新增

\n\n

修复

\n\n"},{"version":"0.2.3","desc":"

新增

\n\n

修复

\n\n

移除

\n\n"},{"version":"0.2.2","desc":"

修复

\n\n"},{"version":"0.2.1","desc":"

优化

\n\n

修复

\n\n"},{"version":"0.2.0","desc":"

新增

\n\n

修复

\n\n"},{"version":"0.1.6","desc":"

修复

\n\n"},{"version":"0.1.5","desc":"

新增

\n\n

优化

\n\n"},{"version":"0.1.4","desc":"

新增

\n\n

优化

\n\n"},{"version":"0.1.3","desc":"

新增

\n\n

修复

\n\n

移除

\n\n"},{"version":"0.1.2","desc":"

修复

\n\n"},{"version":"0.1.1","desc":"

新增

\n\n

优化

\n\n

修复

\n\n"},{"version":"0.1.0","desc":"0.1.0版本发布"}]} +{"version":"1.3.0","desc":"

新增

\n\n

优化

\n\n

修复

\n\n","history":[{"version":"1.2.2","desc":"

修复

\n\n"},{"version":"1.2.1","desc":"

优化

\n\n

修复

\n\n"},{"version":"1.2.0","desc":"

提前祝大家中秋&国庆快乐~

\n

新增

\n\n

优化

\n\n

修复

\n\n

其他

\n\n"},{"version":"1.1.1","desc":"

修复

\n\n"},{"version":"1.1.0","desc":"

新增

\n\n

修复

\n\n

优化

\n\n

移除

\n\n

其他

\n\n"},{"version":"1.0.1","desc":"

优化

\n\n

修复

\n\n"},{"version":"1.0.0","desc":"

新增

\n\n

优化

\n\n

修复

\n\n

更变

\n\n

其他

\n\n"},{"version":"0.18.2","desc":"

修复

\n\n"},{"version":"0.18.1","desc":"

优化

\n\n

修复

\n\n"},{"version":"0.18.0","desc":"

新增

\n\n

优化

\n\n

更变

\n\n

修复

\n\n

移除

\n\n

其他

\n

更新 Electron 到 8.2.5

\n"},{"version":"0.17.0","desc":"

新增

\n\n

优化

\n\n

修复

\n\n

其他

\n\n"},{"version":"0.16.0","desc":"

新增

\n\n

优化

\n\n

修复

\n\n

其他

\n\n"},{"version":"0.15.0","desc":"

洛雪提前祝大家新年快乐、身体健康、阖家幸福!

\n

修复

\n\n"},{"version":"0.14.1","desc":"

洛雪提前祝大家新年快乐、身体健康、阖家幸福!

\n

修复

\n\n"},{"version":"0.14.0","desc":"

洛雪提前祝大家新年快乐、身体健康、阖家幸福!

\n

新增

\n\n

优化

\n\n

修复

\n\n

其他

\n\n"},{"version":"0.13.1","desc":"

修复

\n\n

其他

\n\n"},{"version":"0.13.0","desc":"

新增

\n\n

优化

\n\n

修复

\n\n

移除

\n\n

其他

\n\n"},{"version":"0.12.1","desc":"

优化

\n\n

修复

\n\n

其他

\n\n"},{"version":"0.12.0","desc":"

由于新下载库仍然没有完成,但下载功能已经可用,so 移除之前使用的第三方下载库,暂时把新下载库的下载模块直接加入本程序,若出现下载问题欢迎反馈!

\n

新增

\n\n

优化

\n\n

修复

\n\n"},{"version":"0.11.0","desc":"

新增

\n\n

优化

\n\n"},{"version":"0.10.0","desc":"

优化

\n\n

修复

\n\n"},{"version":"0.9.1","desc":"

修复

\n\n"},{"version":"0.9.0","desc":"

新增

\n\n

修复

\n\n"},{"version":"0.8.2","desc":"

修复

\n\n"},{"version":"0.8.1","desc":"

修复

\n\n"},{"version":"0.8.0","desc":"

新增

\n\n

优化

\n\n

修复

\n\n"},{"version":"0.7.0","desc":"

新增

\n\n

优化

\n\n

修复

\n\n"},{"version":"0.6.2","desc":"

祝贺祖国成立70周年~!

\n

新增

\n\n

修复

\n\n"},{"version":"0.6.1","desc":"

新增

\n\n

优化

\n\n

修复

\n\n

移除

\n\n"},{"version":"0.6.0","desc":"

新增

\n\n

优化

\n\n

修复

\n\n"},{"version":"0.5.5","desc":"

新增

\n\n

修复

\n\n"},{"version":"0.5.4","desc":"

移除

\n\n"},{"version":"0.5.3","desc":"

优化

\n\n

修复

\n\n"},{"version":"0.5.2","desc":"

新增

\n\n

优化

\n\n

修复

\n\n

移除

\n\n"},{"version":"0.5.1","desc":"

新增

\n\n

修复

\n\n"},{"version":"0.5.0","desc":"

新增

\n\n

优化

\n\n

修复

\n\n"},{"version":"0.4.0","desc":"

新增

\n\n

移除

\n\n"},{"version":"0.3.5","desc":"

新增

\n\n

优化

\n\n

修复

\n\n"},{"version":"0.3.4","desc":"

优化

\n\n

修复

\n\n"},{"version":"0.3.3","desc":"

修复

\n\n"},{"version":"0.3.2","desc":"

新增

\n\n"},{"version":"0.3.1","desc":"

修复

\n\n"},{"version":"0.3.0","desc":"

新增

\n\n

修复

\n\n"},{"version":"0.2.3","desc":"

新增

\n\n

修复

\n\n

移除

\n\n"},{"version":"0.2.2","desc":"

修复

\n\n"},{"version":"0.2.1","desc":"

优化

\n\n

修复

\n\n"},{"version":"0.2.0","desc":"

新增

\n\n

修复

\n\n"},{"version":"0.1.6","desc":"

修复

\n\n"},{"version":"0.1.5","desc":"

新增

\n\n

优化

\n\n"},{"version":"0.1.4","desc":"

新增

\n\n

优化

\n\n"},{"version":"0.1.3","desc":"

新增

\n\n

修复

\n\n

移除

\n\n"},{"version":"0.1.2","desc":"

修复

\n\n"},{"version":"0.1.1","desc":"

新增

\n\n

优化

\n\n

修复

\n\n"},{"version":"0.1.0","desc":"0.1.0版本发布"}]} diff --git a/src/main/modules/appMenu.js b/src/main/modules/appMenu.js index da3c9d8c..4ea3e682 100644 --- a/src/main/modules/appMenu.js +++ b/src/main/modules/appMenu.js @@ -6,7 +6,7 @@ if (isMac) { { label: app.getName(), submenu: [ - { label: '关于洛雪音乐(五音版)', role: 'about' }, + { label: '关于五音助手', role: 'about' }, { type: 'separator' }, { label: '隐藏', role: 'hide' }, { type: 'separator' }, diff --git a/src/main/modules/tray.js b/src/main/modules/tray.js index 6cc05436..45da4293 100644 --- a/src/main/modules/tray.js +++ b/src/main/modules/tray.js @@ -39,7 +39,7 @@ const createTray = () => { // 托盘 global.modules.tray = new Tray(iconPath) - global.modules.tray.setToolTip('洛雪音乐助手(五音版)') + global.modules.tray.setToolTip('五音助手') createMenu(global.modules.tray) global.modules.tray.setIgnoreDoubleClickEvents(true) global.modules.tray.on('click', () => { diff --git a/src/main/utils/flacMeta.js b/src/main/utils/flacMeta.js index ab9a18ba..43362ac4 100644 --- a/src/main/utils/flacMeta.js +++ b/src/main/utils/flacMeta.js @@ -72,9 +72,9 @@ module.exports = (filePath, meta) => { if (respones.statusCode !== 200 && respones.statusCode != 206) return writeMeta(filePath, meta) respones .pipe(fs.createWriteStream(picPath)) - .on('finish', () => { + .on('finish', async() => { if (respones.complete) { - writeMeta(filePath, meta, picPath) + await writeMeta(filePath, meta, picPath) } else { writeMeta(filePath, meta) } diff --git a/src/renderer-lyric/index.pug b/src/renderer-lyric/index.pug index f4b6a710..fd972c12 100644 --- a/src/renderer-lyric/index.pug +++ b/src/renderer-lyric/index.pug @@ -3,7 +3,7 @@ html(lang="cn") meta(charset="UTF-8") meta(name="viewport" content="width=device-width, initial-scale=1.0") meta(http-equiv="X-UA-Compatible" content="ie=edge") - title 桌面歌词-洛雪音乐助手(五音版) + title 桌面歌词-五音助手 body #root diff --git a/src/renderer/App.vue b/src/renderer/App.vue index d9b4d3b5..14951541 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -1,5 +1,5 @@ diff --git a/src/renderer/components/core/Player.vue b/src/renderer/components/core/Player.vue index 09af86de..9f6d9053 100644 --- a/src/renderer/components/core/Player.vue +++ b/src/renderer/components/core/Player.vue @@ -17,9 +17,9 @@ div(:class="$style.player") div(:class="$style.volumeMask" @mousedown="handleVolumeMsDown" ref="dom_volumeMask" :tips="`${$t('core.player.volume')}${parseInt(volume * 100)}%`") div(:class="$style.titleBtn" @click='toggleDesktopLyric' @contextmenu="handleToggleLockDesktopLyric" :tips="toggleDesktopLyricBtnTitle") svg(v-if="setting.desktopLyric.enable" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 512 512' space='preserve') - use(xlink:href='#icon-desktop-lyric-off') - svg(v-else version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 512 512' space='preserve') use(xlink:href='#icon-desktop-lyric-on') + svg(v-else version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 512 512' space='preserve') + use(xlink:href='#icon-desktop-lyric-off') div(:class="$style.titleBtn" @click='toggleNextPlayMode' :tips="nextTogglePlayName") svg(v-if="setting.player.togglePlayMethod == 'listLoop'" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='80%' viewBox='0 0 24 24' space='preserve') use(xlink:href='#icon-list-loop') @@ -63,10 +63,12 @@ div(:class="$style.player") //- transition(enter-active-class="animated lightSpeedIn" transition(enter-active-class="animated lightSpeedIn" leave-active-class="animated slideOutDown") - core-player-detail(v-if="isShowPlayerDetail" :musicInfo="musicInfo" + core-player-detail(v-if="isShowPlayerDetail" :musicInfo="listId == 'download' ? targetSong.musicInfo : targetSong" :lyric="lyric" :list="list" :listId="listId" :playInfo="{ nowPlayTimeStr, maxPlayTimeStr, progress, nowPlayTime, status }" - :isPlay="isPlay" @action="handlePlayDetailAction") + :isPlay="isPlay" @action="handlePlayDetailAction" + :nextTogglePlayName="nextTogglePlayName" + @toggle-next-play-mode="toggleNextPlayMode" @add-music-to="addMusicTo") material-list-add-modal(:show="isShowAddMusicTo" :musicInfo="listId == 'download' ? targetSong.musicInfo : targetSong" @close="isShowAddMusicTo = false") svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' style="display: none;") @@ -767,6 +769,7 @@ export default { }) }, showPlayerDetail() { + if (!this.targetSong) return this.visiblePlayerDetail(true) }, handleTransitionEnd(e) { diff --git a/src/renderer/components/core/PlayerDetail.vue b/src/renderer/components/core/PlayerDetail.vue index cd6b46a7..2aad7d09 100644 --- a/src/renderer/components/core/PlayerDetail.vue +++ b/src/renderer/components/core/PlayerDetail.vue @@ -21,7 +21,7 @@ //- div(:class="$style.info") div(:class="$style.info") img(:class="$style.img" :src="musicInfo.img" v-if="musicInfo.img") - div(:class="$style.description" @click="isShowComment = true") + div(:class="$style.description") p {{$t('core.player.name')}}{{musicInfo.name}} p {{$t('core.player.singer')}}{{musicInfo.singer}} p(v-if="musicInfo.album") {{$t('core.player.album')}}{{musicInfo.album}} @@ -32,21 +32,28 @@ p(v-for="(info, index) in lyricLines" :key="index" :class="lyric.line == index ? $style.lrcActive : null") {{info.text}} div(:class="$style.lyricSpace") - div(:class="$style.comment") - div(:class="$style.commentHeader" @click="isShowComment = false") - h3 {{title}} - div.scroll(:class="$style.commentMain") - div - h2(:class="$style.commentType") - material-comment-floor(v-if="comment.hotComments.length" :class="$style.reply_floor" :comments="comment.hotComments") - div - h2(:class="$style.commentType") - material-comment-floor(v-if="comment.comments.length" :class="$style.reply_floor" :comments="comment.comments") - div(:class="$style.pagination") - material-pagination(:count="comment.total" :limit="comment.limit" :page="comment.page" @btn-click="handleToggleCommentPage") + material-music-comment(:class="$style.comment" :titleFormat="this.setting.download.fileName" :musicInfo="musicInfo" v-model="isShowComment") div(:class="$style.footer") - div(:class="$style.left") + div(:class="$style.footerLeft") + div(:class="$style.footerLeftControlBtns") + div(:class="[$style.footerLeftControlBtn, isShowComment ? $style.active : null]" @click="isShowComment = !isShowComment" :tips="$t('core.player.comment_show')") + svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' width='95%' viewBox='0 0 24 24' space='preserve') + use(xlink:href='#icon-comment') + div(:class="$style.footerLeftControlBtn" @click="$emit('toggle-next-play-mode')" :tips="nextTogglePlayName") + svg(v-if="setting.player.togglePlayMethod == 'listLoop'" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' viewBox='0 0 24 24' space='preserve') + use(xlink:href='#icon-list-loop') + svg(v-else-if="setting.player.togglePlayMethod == 'random'" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' viewBox='0 0 24 24' space='preserve') + use(xlink:href='#icon-list-random') + svg(v-else-if="setting.player.togglePlayMethod == 'list'" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' width='120%' viewBox='0 0 24 24' space='preserve') + use(xlink:href='#icon-list-order') + svg(v-else-if="setting.player.togglePlayMethod == 'singleLoop'" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' width='110%' viewBox='0 0 24 24' space='preserve') + use(xlink:href='#icon-single-loop') + svg(v-else version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' width='120%' viewBox='0 0 24 24' space='preserve') + use(xlink:href='#icon-single') + div(:class="$style.footerLeftControlBtn" @click="$emit('add-music-to', musicInfo)" :tips="$t('core.player.add_music_to')") + svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' viewBox='0 0 512 512' space='preserve') + use(xlink:href='#icon-add-2') div(:class="$style.progressContainer") div(:class="$style.progressContent") div(:class="$style.progress") @@ -136,6 +143,7 @@ export default { type: Boolean, default: false, }, + nextTogglePlayName: String, }, watch: { // 'musicInfo.img': { @@ -218,108 +226,6 @@ export default { lyricLines: [], isSetedLines: false, isShowComment: false, - comment: { - page: 1, - total: 10, - maxPage: 1, - limit: 5, - comments: [{ - text: ['123123hhh'], - userName: 'dsads', - avatar: 'http://img4.kuwo.cn/star/userhead/39/52/1602393411654_512039239s.jpg', - time: '2020-10-22 22:14:17', - likedCount: 100, - reply: [ - { - text: ['123123hhh'], - userName: 'dsads', - avatar: 'http://img4.kuwo.cn/star/userhead/39/52/1602393411654_512039239s.jpg', - time: '2020-10-22 22:14:17', - likedCount: 100, - }, - ], - }, { - text: ['123123hhh'], - userName: 'dsads', - avatar: 'http://img4.kuwo.cn/star/userhead/39/52/1602393411654_512039239s.jpg', - time: '2020-10-22 22:14:17', - likedCount: 100, - reply: [ - { - text: ['123123hhh'], - userName: 'dsads', - avatar: 'http://img4.kuwo.cn/star/userhead/39/52/1602393411654_512039239s.jpg', - time: '2020-10-22 22:14:17', - likedCount: 100, - }, - { - text: ['123123hhh'], - userName: 'dsads', - avatar: 'http://img4.kuwo.cn/star/userhead/39/52/1602393411654_512039239s.jpg', - time: '2020-10-22 22:14:17', - likedCount: 100, - }, - ], - }, { - text: ['123123hhh'], - userName: 'dsads', - avatar: 'http://img4.kuwo.cn/star/userhead/39/52/1602393411654_512039239s.jpg', - time: '2020-10-22 22:14:17', - likedCount: 100, - reply: [], - }, { - text: ['123123hhh'], - userName: 'dsads', - avatar: 'http://img4.kuwo.cn/star/userhead/39/52/1602393411654_512039239s.jpg', - time: '2020-10-22 22:14:17', - likedCount: 100, - reply: [], - }, { - text: ['123123hhh'], - userName: 'dsads', - avatar: 'http://img4.kuwo.cn/star/userhead/39/52/1602393411654_512039239s.jpg', - time: '2020-10-22 22:14:17', - likedCount: 100, - reply: [], - }, { - text: ['123123hhh'], - userName: 'dsads', - avatar: 'http://img4.kuwo.cn/star/userhead/39/52/1602393411654_512039239s.jpg', - time: '2020-10-22 22:14:17', - likedCount: 100, - reply: [], - }, { - text: ['123123hhh'], - userName: 'dsads', - avatar: 'http://img4.kuwo.cn/star/userhead/39/52/1602393411654_512039239s.jpg', - time: '2020-10-22 22:14:17', - likedCount: 100, - reply: [], - }, { - text: ['123123hhh'], - userName: 'dsads', - avatar: 'http://img4.kuwo.cn/star/userhead/39/52/1602393411654_512039239s.jpg', - time: '2020-10-22 22:14:17', - likedCount: 100, - reply: [], - }], - hotComments: [{ - text: ['123123hhh'], - userName: 'dsads', - avatar: 'http://img4.kuwo.cn/star/userhead/39/52/1602393411654_512039239s.jpg', - time: '2020-10-22 22:14:17', - likedCount: 100, - reply: [ - { - text: ['123123hhh'], - userName: 'dsads', - avatar: 'http://img4.kuwo.cn/star/userhead/39/52/1602393411654_512039239s.jpg', - time: '2020-10-22 22:14:17', - likedCount: 100, - }, - ], - }], - }, } }, mounted() { @@ -339,11 +245,6 @@ export default { computed: { ...mapGetters(['setting']), ...mapGetters('player', ['isShowPlayerDetail']), - title() { - return this.musicInfo.name - ? this.setting.download.fileName.replace('', this.musicInfo.name).replace('', this.musicInfo.singer) - : '^-^' - }, }, methods: { ...mapMutations('player', [ @@ -445,9 +346,6 @@ export default { close() { window.eventHub.$emit(eventBaseName.close) }, - handleToggleCommentPage(page) { - - }, }, } @@ -596,7 +494,7 @@ export default { } } .left { - flex: auto; + flex: 40%; display: flex; flex-flow: column nowrap; align-items: center; @@ -688,36 +586,8 @@ export default { .comment { flex: 0 0 0; - display: flex; - flex-flow: column nowrap; - transition: @transition-theme; - transition-property: flex-basis opacity; - overflow: hidden; opacity: 0; - -} -.commentHeader { - flex: none; - padding-bottom: 10px; - // border-bottom: 1px solid #eee; - h3 { - font-size: 14px; - } -} -.commentMain { - flex: auto; - padding-left: 15px; - padding-right: 10px; - background-color: @color-reply-floor; - border-radius: 4px; -} -.commentType { - padding: 10px 0; - font-size: 13px; - color: @color-theme_2-font; -} -.pagination { - padding: 10px 0; + margin-left: 10px; } .footer { @@ -726,7 +596,39 @@ export default { display: flex; align-items: center; } +.footerLeft { + flex: auto; + display: flex; + flex-flow: column nowrap; + padding: 13px; + overflow: hidden; +} +.footerLeftControlBtns { + color: @color-theme_2-font; + display: flex; + flex-flow: row nowrap; + justify-content: flex-end; +} +.footerLeftControlBtn { + width: 18px; + height: 18px; + opacity: .5; + cursor: pointer; + transition: opacity @transition-theme; + &:hover { + opacity: .9; + } + + +.footerLeftControlBtn { + margin-left: 6px; + } + + &.active { + color: @color-theme; + opacity: .8; + } +} .progress-container { width: 100%; position: relative; @@ -785,6 +687,7 @@ export default { } .time-label { width: 100%; + height: 18px; display: flex; justify-content: space-between; span { @@ -869,6 +772,14 @@ each(@themes, { .lrc-active { color: ~'@{color-@{value}-theme}'; } + .footerLeftControlBtns { + color: ~'@{color-@{value}-theme_2-font}'; + } + .footerLeftControlBtn { + &.active { + color: ~'@{color-@{value}-theme}'; + } + } .progress { background-color: ~'@{color-@{value}-player-progress}'; } diff --git a/src/renderer/components/material/CommentFloor.vue b/src/renderer/components/material/CommentFloor.vue index 5cda949c..0a776505 100644 --- a/src/renderer/components/material/CommentFloor.vue +++ b/src/renderer/components/material/CommentFloor.vue @@ -7,10 +7,13 @@ img( :class="$style.avatar" :src="item.avatar || commentDefImg" @error="handleUserImg") div(:class="$style.right") div(:class="$style.info") - div(:class="$style.name") {{item.userName}} - time(:class="$style.time") {{timeFormat(item.time)}} - div(:class="$style.likes") {{item.likedCount}} - div(:class="$style.comment_text") + div.select(:class="$style.name") {{item.userName}} + time(:class="$style.time" v-if="item.timeStr") {{timeFormat(item.timeStr)}} + div(:class="$style.likes" v-if="item.likedCount != null") + svg(:class="$style.likesIcon" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' viewBox='0 0 512 512' space='preserve') + use(xlink:href='#icon-thumbs-up') + | {{item.likedCount}} + div.select(:class="$style.comment_text") p(v-for="text in item.text") {{text}} material-comment-floor(v-if="item.reply && item.reply.length" :class="$style.reply_floor" :comments="item.reply") @@ -82,31 +85,39 @@ export default { flex-flow: row nowrap; align-items: flex-end; min-width: 0; + line-height: 1.3; + color: @color-theme_2-font-label; } .name { - flex: auto; + flex: 0 1 auto; min-width: 0; .mixin-ellipsis-1; } .time { flex: none; - color: @color-theme_2-font-label; font-size: 11px; - margin-left: 10px; + margin-left: 5px; } .likes { - flex: none; + flex: 1 0 auto; margin-left: 10px; - color: @color-theme_2-font-label; font-size: 11px; align-self: flex-end; + text-align: right; +} +.likesIcon { + width: 12px; + height: 12px; + margin-right: 3px; + color: @color-theme-active; } .comment_text { text-align: justify; font-size: 14px; + padding-top: 5px; p { line-height: 1.5; - margin-top: 8px; + word-break: break-all; } } @@ -127,4 +138,25 @@ export default { background-color: @color-reply-floor; } + +each(@themes, { + :global(#container.@{value}) { + .listItem { + border-bottom-color: ~'@{color-@{value}-theme_2-active}'; + } + .content { + color: ~'@{color-@{value}-theme_2-font}'; + } + .info { + color: ~'@{color-@{value}-theme_2-font-label}'; + } + .likesIcon { + color: ~'@{color-@{value}-theme-active}'; + } + .reply_floor { + background-color: ~'@{color-@{value}-reply-floor}'; + } + } +}) + diff --git a/src/renderer/components/material/MusicComment.vue b/src/renderer/components/material/MusicComment.vue new file mode 100644 index 00000000..7b5c198e --- /dev/null +++ b/src/renderer/components/material/MusicComment.vue @@ -0,0 +1,270 @@ + + + + + diff --git a/src/renderer/components/material/PactModal.vue b/src/renderer/components/material/PactModal.vue index 5227a382..e91d4d10 100644 --- a/src/renderer/components/material/PactModal.vue +++ b/src/renderer/components/material/PactModal.vue @@ -8,7 +8,7 @@ material-modal(:show="!setting.isAgreePact || globalObj.isShowPact" @close="hand strong.hover.underline(@click="openUrl('http://www.apache.org/licenses/LICENSE-2.0')") Apache License 2.0 |  许可证发行,在使用本软件前,你(使用者)需签署本协议才可继续使用,以下协议是对于 Apache License 2.0 的补充,如有冲突,以以下协议为准。 br - p 词语约定:本协议中的“本软件”指洛雪音乐桌面版(五音版)项目;“使用者”指签署本协议的使用者;“官方音乐平台”指对本软件内置的包括酷我、酷狗、咪咕等音乐源的官方平台统称;“版权数据”指包括但不限于图像、音频、名字等在内的他人拥有所属版权的数据。 + p 词语约定:本协议中的“本软件”指五音助手桌面版项目;“使用者”指签署本协议的使用者;“官方音乐平台”指对本软件内置的包括酷我、酷狗、咪咕等音乐源的官方平台统称;“版权数据”指包括但不限于图像、音频、名字等在内的他人拥有所属版权的数据。 br p strong 1、 diff --git a/src/renderer/components/material/SearchInput.vue b/src/renderer/components/material/SearchInput.vue index 907ee083..142d5a00 100644 --- a/src/renderer/components/material/SearchInput.vue +++ b/src/renderer/components/material/SearchInput.vue @@ -94,6 +94,7 @@ export default { this.$refs.dom_input.focus() }, handleTemplistClick(index) { + console.log(index) this.sendEvent('listClick', index) }, handleFocus() { diff --git a/src/renderer/index.pug b/src/renderer/index.pug index 9401de1c..b8bad748 100644 --- a/src/renderer/index.pug +++ b/src/renderer/index.pug @@ -3,7 +3,7 @@ html(lang="cn") meta(charset="UTF-8") meta(name="viewport" content="width=device-width, initial-scale=1.0") meta(http-equiv="X-UA-Compatible" content="ie=edge") - title 洛雪音乐助手(五音版) + title 五音助手 body #root diff --git a/src/renderer/lang/en-us/base.json b/src/renderer/lang/en-us/base.json new file mode 100644 index 00000000..09199968 --- /dev/null +++ b/src/renderer/lang/en-us/base.json @@ -0,0 +1,5 @@ +{ + "date_format_second": "{num} seconds ago", + "date_format_minute": "{num} minutes ago", + "date_format_hour": "{num} hours ago" +} diff --git a/src/renderer/lang/en-us/core/player.json b/src/renderer/lang/en-us/core/player.json index 64cc68c1..2de3604c 100644 --- a/src/renderer/lang/en-us/core/player.json +++ b/src/renderer/lang/en-us/core/player.json @@ -27,5 +27,16 @@ "play_toggle_mode_random": "List Random", "play_toggle_mode_list": "Play in order", "play_toggle_mode_single_loop": "Single Loop", - "play_toggle_mode_off": "Disable" + "play_toggle_mode_off": "Disable", + + "comment_show": "Show song comments", + "comment_hot_loading": "Hot comments are loading", + "comment_new_loading": "Latest comments are loading", + "comment_hot_load_error": "Hot comments failed to load, click to try to reload", + "comment_new_load_error": "The latest comment failed to load, click to try to reload", + "comment_refresh": "Refresh comments", + "comment_no_content": "No comments yet", + "comment_hot_title": "Hot Comment", + "comment_new_title": "Latest comment", + "comment_title": "{name} comment" } diff --git a/src/renderer/lang/zh-cn/base.json b/src/renderer/lang/zh-cn/base.json new file mode 100644 index 00000000..6a12f4bf --- /dev/null +++ b/src/renderer/lang/zh-cn/base.json @@ -0,0 +1,5 @@ +{ + "date_format_second": "{num}秒前", + "date_format_minute": "{num}分钟前", + "date_format_hour": "{num}小时前" +} diff --git a/src/renderer/lang/zh-cn/core/player.json b/src/renderer/lang/zh-cn/core/player.json index 31be9f68..bcdf2b7e 100644 --- a/src/renderer/lang/zh-cn/core/player.json +++ b/src/renderer/lang/zh-cn/core/player.json @@ -27,5 +27,16 @@ "play_toggle_mode_random": "列表随机", "play_toggle_mode_list": "顺序播放", "play_toggle_mode_single_loop": "单曲循环", - "play_toggle_mode_off": "禁用" + "play_toggle_mode_off": "禁用", + + "comment_show": "显示歌曲评论", + "comment_hot_loading": "热门评论加载中", + "comment_new_loading": "最新评论加载中", + "comment_hot_load_error": "热门评论加载失败,点击尝试重新加载", + "comment_new_load_error": "最新评论加载失败,点击尝试重新加载", + "comment_refresh": "刷新评论", + "comment_no_content": "暂无评论", + "comment_hot_title": "热门评论", + "comment_new_title": "最新评论", + "comment_title": "{name} 的评论" } diff --git a/src/renderer/lang/zh-cn/view/setting.json b/src/renderer/lang/zh-cn/view/setting.json index fdee1024..8dd3d636 100644 --- a/src/renderer/lang/zh-cn/view/setting.json +++ b/src/renderer/lang/zh-cn/view/setting.json @@ -153,7 +153,7 @@ "update_checking": "检查更新中...", "update_init": "更新初始化中...", - "about": "关于洛雪音乐(五音版)", + "about": "关于五音助手", "is_enable": "是否启用", diff --git a/src/renderer/lang/zh-tw/base.json b/src/renderer/lang/zh-tw/base.json new file mode 100644 index 00000000..8c323e89 --- /dev/null +++ b/src/renderer/lang/zh-tw/base.json @@ -0,0 +1,5 @@ +{ + "date_format_second": "{num}秒前", + "date_format_minute": "{num}分鐘前", + "date_format_hour": "{num}小時前" +} diff --git a/src/renderer/lang/zh-tw/core/player.json b/src/renderer/lang/zh-tw/core/player.json index c727ccb0..05eaa62c 100644 --- a/src/renderer/lang/zh-tw/core/player.json +++ b/src/renderer/lang/zh-tw/core/player.json @@ -27,5 +27,16 @@ "play_toggle_mode_random": "列表隨機", "play_toggle_mode_list": "順序播放", "play_toggle_mode_single_loop": "單曲循環", - "play_toggle_mode_off": "禁用" + "play_toggle_mode_off": "禁用", + + "comment_show": "顯示歌曲評論", + "comment_hot_loading": "熱門評論加載中", + "comment_new_loading": "最新評論加載中", + "comment_hot_load_error": "熱門評論加載失敗,點擊嘗試重新加載", + "comment_new_load_error": "最新評論加載失敗,點擊嘗試重新加載", + "comment_refresh": "刷新評論", + "comment_no_content": "暫無評論", + "comment_hot_title": "熱門評論", + "comment_new_title": "最新評論", + "comment_title": "{name} 的評論" } diff --git a/src/renderer/lang/zh-tw/view/setting.json b/src/renderer/lang/zh-tw/view/setting.json index a4841a9f..ae92330c 100644 --- a/src/renderer/lang/zh-tw/view/setting.json +++ b/src/renderer/lang/zh-tw/view/setting.json @@ -141,7 +141,7 @@ "update_open_version_modal_btn": "打開更新窗口 🚀", "update_checking": "檢查更新中...", "update_init": "更新初始化中...", - "about": "關於洛雪音樂(五音版)", + "about": "關於五音助手", "is_enable": "是否啟用", "is_show": "是否顯示", "click_open": "點擊打開", diff --git a/src/renderer/utils/index.js b/src/renderer/utils/index.js index 8c5f91a9..4112bb85 100644 --- a/src/renderer/utils/index.js +++ b/src/renderer/utils/index.js @@ -20,6 +20,39 @@ export const sizeFormate = size => { return `${(size / Math.pow(1024, Math.floor(number))).toFixed(2)} ${units[number]}` } +/** + * 日期格式化 + * @param {*} date 时间 + * @param {String} format 时间格式,默认YYYY-MM-DD hh:mm:ss + */ +export const dateFormat = (date = new Date(), format = 'YYYY-MM-DD hh:mm:ss') => { + if (typeof date != 'object') date = new Date(date) + const munFix = (n) => n < 10 ? ('0' + n) : n + return format + .replace('YYYY', date.getFullYear()) + .replace('MM', munFix(date.getMonth() + 1)) + .replace('DD', munFix(date.getDate())) + .replace('hh', munFix(date.getHours())) + .replace('mm', munFix(date.getMinutes())) + .replace('ss', munFix(date.getSeconds())) +} + +/** + * 时间格式化 + */ +export const dateFormat2 = time => { + let differ = parseInt((Date.now() - time) / 1000) + if (differ < 60) { + return window.i18n.t('base.date_format_second', { num: differ }) + } else if (differ < 3600) { + return window.i18n.t('base.date_format_minute', { num: parseInt(differ / 60) }) + } else if (differ < 86400) { + return window.i18n.t('base.date_format_hour', { num: parseInt(differ / 3600) }) + } else { + return dateFormat(time) + } +} + export const formatPlayTime = time => { let m = parseInt(time / 60) let s = parseInt(time % 60) @@ -205,7 +238,7 @@ export const openUrl = url => { * 设置标题 */ let dom_title = document.getElementsByTagName('title')[0] -export const setTitle = (title = '洛雪音乐助手(五音版)') => { +export const setTitle = (title = '五音助手') => { dom_title.innerText = title } diff --git a/src/renderer/utils/music/kg/comment.js b/src/renderer/utils/music/kg/comment.js new file mode 100644 index 00000000..71515fc1 --- /dev/null +++ b/src/renderer/utils/music/kg/comment.js @@ -0,0 +1,75 @@ +import { httpFetch } from '../../request' +import { dateFormat2 } from '../../' + +export default { + _requestObj: null, + _requestObj2: null, + async getComment({ hash }, page = 1, limit = 20) { + if (this._requestObj) this._requestObj.cancelHttp() + + const _requestObj = httpFetch(`http://comment.service.kugou.com/index.php?r=commentsv2/getCommentWithLike&code=fc4be23b4e972707f36b8a828a93ba8a&extdata=${hash}&p=${page}&pagesize=${limit}&ver=1.01&clientver=8373&appid=1001&kugouid=687373022`, { + headers: { + 'User-Agent': 'Android712-AndroidPhone-8983-18-0-COMMENT-wifi', + }, + }) + const { body, statusCode } = await _requestObj.promise + // console.log(body) + if (statusCode != 200 || body.err_code !== 0) throw new Error('获取评论失败') + return { source: 'kg', comments: this.filterComment(body.list || []), total: body.count, page, limit, maxPage: Math.ceil(body.count / limit) || 1 } + }, + async getHotComment({ hash, songmid }, page = 1, limit = 100) { + // console.log(songmid) + if (this._requestObj2) this._requestObj2.cancelHttp() + + const _requestObj2 = httpFetch(`http://comment.service.kugou.com/index.php?r=commentsv2/getCommentWithLike&code=fc4be23b4e972707f36b8a828a93ba8a&extdata=${hash}&p=${page}&pagesize=${limit}&ver=1.01&clientver=8373&appid=1001&kugouid=687373022`, { + headers: { + 'User-Agent': 'Android712-AndroidPhone-8983-18-0-COMMENT-wifi', + }, + }) + const { body, statusCode } = await _requestObj2.promise + // console.log(body) + if (statusCode != 200 || body.err_code !== 0) throw new Error('获取热门评论失败') + return { source: 'kg', comments: this.filterComment(body.weightList || []) } + }, + async getReplyComment({ songmid }, replyId, page = 1, limit = 100) { + if (this._requestObj2) this._requestObj2.cancelHttp() + + const _requestObj2 = httpFetch(`http://comment.service.kugou.com/index.php?r=commentsv2/getReplyWithLike&code=fc4be23b4e972707f36b8a828a93ba8a&p=${page}&pagesize=${limit}&ver=1.01&clientver=8373&kugouid=687373022&appid=1001&childrenid=${songmid}&tid=${replyId}`, { + headers: { + 'User-Agent': 'Android712-AndroidPhone-8983-18-0-COMMENT-wifi', + }, + }) + const { body, statusCode } = await _requestObj2.promise + // console.log(body) + if (statusCode != 200 || body.err_code !== 0) throw new Error('获取回复评论失败') + return { source: 'kg', comments: this.filterComment(body.list || []) } + }, + filterComment(rawList) { + return rawList.map(item => { + let data = { + id: item.id, + text: item.content.split('\n'), + time: item.addtime, + timeStr: dateFormat2(new Date(item.addtime).getTime()), + userName: item.user_name, + avatar: item.user_pic, + userId: item.user_id, + likedCount: item.like.likenum, + replyNum: item.reply_num, + reply: [], + } + + return item.pcontent ? { + id: item.id, + text: item.pcontent.split('\n'), + time: null, + userName: item.puser, + avatar: null, + userId: item.puser_id, + likedCount: null, + replyNum: null, + reply: [data], + } : data + }) + }, +} diff --git a/src/renderer/utils/music/kg/index.js b/src/renderer/utils/music/kg/index.js index 524c5fbd..c0ccfbb2 100644 --- a/src/renderer/utils/music/kg/index.js +++ b/src/renderer/utils/music/kg/index.js @@ -5,12 +5,14 @@ import musicSearch from './musicSearch' import pic from './pic' import lyric from './lyric' import hotSearch from './hotSearch' +import comment from './comment' const kg = { leaderboard, songList, musicSearch, hotSearch, + comment, getMusicUrl(songInfo, type) { return apis('kg').getMusicUrl(songInfo, type) }, diff --git a/src/renderer/utils/music/kw/comment.js b/src/renderer/utils/music/kw/comment.js new file mode 100644 index 00000000..99f160b4 --- /dev/null +++ b/src/renderer/utils/music/kw/comment.js @@ -0,0 +1,61 @@ +import { httpFetch } from '../../request' +import { dateFormat2 } from '../../' + +export default { + _requestObj: null, + _requestObj2: null, + async getComment({ songmid }, page = 1, limit = 20) { + if (this._requestObj) this._requestObj.cancelHttp() + + const _requestObj = httpFetch(`http://comment.kuwo.cn/com.s?type=get_comment&uid=0&digest=15&sid=${songmid}&page=${page}&rows=${limit}&f=web&prod=MUSIC_8.7.7.0_BCS37&devid=28556413`, { + headers: { + 'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 9;)', + }, + }) + const { body, statusCode } = await _requestObj.promise + if (statusCode != 200 || body.result !== 'ok') throw new Error('获取评论失败') + // console.log(body) + return { source: 'kw', comments: this.filterComment(body.rows), total: body.total, page, limit, maxPage: Math.ceil(body.total / limit) || 1 } + }, + async getHotComment({ songmid }, page = 1, limit = 100) { + if (this._requestObj2) this._requestObj2.cancelHttp() + + const _requestObj2 = httpFetch(`http://comment.kuwo.cn/com.s?type=get_rec_comment&uid=0&digest=15&sid=${songmid}&page=${page}&rows=${limit}&f=web&prod=MUSIC_8.7.7.0_BCS37&devid=28556413`, { + headers: { + 'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 9;)', + }, + }) + const { body, statusCode } = await _requestObj2.promise + if (statusCode != 200 || body.result !== 'ok') throw new Error('获取热门评论失败') + // console.log(body) + return { source: 'kw', comments: this.filterComment(body.rows) } + }, + filterComment(rawList) { + if (!rawList) return [] + return rawList.map(item => { + let data = { + id: item.id, + text: item.msg.split('\n'), + time: item.time, + timeStr: dateFormat2(new Date(item.time).getTime()), + userName: decodeURIComponent(item.u_name), + avatar: item.u_pic, + userId: item.u_id, + likedCount: item.like_num, + reply: [], + } + return item.reply ? { + id: item.id, + rootId: item.reply.id, + text: item.reply.msg.split('\n'), + time: item.reply.time, + timeStr: dateFormat2(new Date(item.reply.time).getTime()), + userName: decodeURIComponent(item.reply.u_name), + avatar: item.reply.u_pic, + userId: item.reply.u_id, + likedCount: item.reply.like_num, + reply: [data], + } : data + }) + }, +} diff --git a/src/renderer/utils/music/kw/index.js b/src/renderer/utils/music/kw/index.js index 19c0c143..1039305e 100644 --- a/src/renderer/utils/music/kw/index.js +++ b/src/renderer/utils/music/kw/index.js @@ -8,6 +8,7 @@ import pic from './pic' import { apis } from '../api-source' import songList from './songList' import hotSearch from './hotSearch' +import comment from './comment' const kw = { _musicInfoRequestObj: null, @@ -36,6 +37,7 @@ const kw = { leaderboard, songList, hotSearch, + comment, getLyric(songInfo, isGetLyricx) { // let singer = songInfo.singer.indexOf('、') > -1 ? songInfo.singer.split('、')[0] : songInfo.singer return lyric.getLyric(songInfo.songmid, isGetLyricx) diff --git a/src/renderer/utils/music/mg/album.js b/src/renderer/utils/music/mg/album.js new file mode 100644 index 00000000..625fc3ac --- /dev/null +++ b/src/renderer/utils/music/mg/album.js @@ -0,0 +1,30 @@ +import { httpFetch } from '../../request' + +export default { + getAlbum(songInfo, tryNum = 0) { + let requestObj = httpFetch(`http://app.c.nf.migu.cn/MIGUM2.0/v1.0/content/queryAlbumSong?albumId=${songInfo.albumId}&pageNo=1`, { + headers: { + sign: '46DB65104950B98FE451AD41047CC6C4', + timestamp: 1603451430776, + appId: 'yyapp2', + mode: 'android', + ua: 'Android_migu', + version: '6.9.4', + osVersion: 'android 7.0', + 'User-Agent': 'okhttp/3.9.1', + channel: '0146832', + }, + }) + requestObj.promise = requestObj.promise.then(({ body }) => { + if (body.code !== '000000') { + if (tryNum > 5) return Promise.reject('获取专辑失败') + let tryRequestObj = this.getAlbum(songInfo, ++tryNum) + requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj) + return tryRequestObj.promise + } + console.log(body) + return body.songList + }) + return requestObj + }, +} diff --git a/src/renderer/utils/music/mg/comment.js b/src/renderer/utils/music/mg/comment.js new file mode 100644 index 00000000..2e9f1621 --- /dev/null +++ b/src/renderer/utils/music/mg/comment.js @@ -0,0 +1,95 @@ +import { httpFetch } from '../../request' +import album from './album' +import { dateFormat2 } from '../../' + +export default { + _requestObj: null, + _requestObj2: null, + _requestObj3: null, + async getSongId(musicInfo) { + if (this._requestObj3) this._requestObj3.cancelHttp() + this.requestObj3 = album.getAlbum(musicInfo) + const list = await this.requestObj3.promise + const copyrightId = musicInfo.copyrightId + let info = list.find(s => s.copyrightId == copyrightId) + const songmid = musicInfo.songmid + if (!info) info = list.find(s => s.songId == songmid) + return info ? info.songId : null + }, + async getComment(musicInfo, page = 1, limit = 20) { + if (this._requestObj) this._requestObj.cancelHttp() + if (!musicInfo.songId) { + let id = await this.getSongId(musicInfo) + if (!id) throw new Error('获取评论失败') + musicInfo.songId = id + } + + const _requestObj = httpFetch(`https://music.migu.cn/v3/api/comment/listComments?targetId=${musicInfo.songId}&pageSize=${limit}&pageNo=${page}`, { + headers: { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4195.1 Safari/537.36', + Referer: 'https://music.migu.cn', + }, + }) + const { body, statusCode } = await _requestObj.promise + console.log(body) + if (statusCode != 200 || body.returnCode !== '000000') throw new Error('获取评论失败') + return { source: 'mg', comments: this.filterComment(body.data.items), total: body.data.itemTotal, page, limit, maxPage: Math.ceil(body.data.itemTotal / limit) || 1 } + }, + async getHotComment(musicInfo, page = 1, limit = 100) { + if (this._requestObj2) this._requestObj2.cancelHttp() + + if (!musicInfo.songId) { + let id = await this.getSongId(musicInfo) + if (!id) throw new Error('获取评论失败') + musicInfo.songId = id + } + + const _requestObj2 = httpFetch(`https://music.migu.cn/v3/api/comment/listTopComments?targetId=${musicInfo.songId}&pageSize=${limit}&pageNo=${page}`, { + headers: { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4195.1 Safari/537.36', + Referer: 'https://music.migu.cn', + }, + }) + const { body, statusCode } = await _requestObj2.promise + // console.log(body) + if (statusCode != 200 || body.returnCode !== '000000') throw new Error('获取热门评论失败') + return { source: 'mg', comments: this.filterComment(body.data.items) } + }, + async getReplyComment(musicInfo, replyId, page = 1, limit = 100) { + if (this._requestObj2) this._requestObj2.cancelHttp() + + const _requestObj2 = httpFetch(`https://music.migu.cn/v3/api/comment/listCommentsById?commentId=${replyId}&pageSize=${limit}&pageNo=${page}`, { + headers: { + 'User-Agent': 'Android712-AndroidPhone-8983-18-0-COMMENT-wifi', + }, + }) + const { body, statusCode } = await _requestObj2.promise + // console.log(body) + if (statusCode != 200 || body.returnCode !== '000000') throw new Error('获取回复评论失败') + return { source: 'mg', comments: this.filterComment(body.data.items) } + }, + filterComment(rawList) { + return rawList.map(item => ({ + id: item.commentId, + text: item.body.split('\n'), + time: item.createTime, + timeStr: dateFormat2(new Date(item.createTime).getTime()), + userName: item.author.name, + avatar: item.author.avatar, + userId: item.author.id, + likedCount: item.praiseCount, + replyNum: item.replyTotal, + reply: item.replyCommentList.map(c => ({ + id: c.commentId, + text: c.body.split('\n'), + time: c.createTime, + timeStr: dateFormat2(new Date(c.createTime).getTime()), + userName: c.author.name, + avatar: c.author.avatar, + userId: c.author.id, + likedCount: c.praiseCount, + replyNum: c.replyTotal, + })), + })) + }, +} diff --git a/src/renderer/utils/music/mg/index.js b/src/renderer/utils/music/mg/index.js index 3ee240a8..72ccde6a 100644 --- a/src/renderer/utils/music/mg/index.js +++ b/src/renderer/utils/music/mg/index.js @@ -5,12 +5,14 @@ import musicSearch from './musicSearch' import pic from './pic' import lyric from './lyric' import hotSearch from './hotSearch' +import comment from './comment' const mg = { songList, musicSearch, leaderboard, hotSearch, + comment, getMusicUrl(songInfo, type) { return apis('mg').getMusicUrl(songInfo, type) }, diff --git a/src/renderer/utils/music/mg/leaderboard.js b/src/renderer/utils/music/mg/leaderboard.js index 32602ffb..37dba46c 100644 --- a/src/renderer/utils/music/mg/leaderboard.js +++ b/src/renderer/utils/music/mg/leaderboard.js @@ -137,6 +137,7 @@ export default { albumName: item.album, albumId: item.albumId, songmid: item.copyrightId, + songId: item.songId, copyrightId: item.copyrightId, source: 'mg', interval: null, @@ -195,7 +196,7 @@ export default { getList(bangid, page, retryNum = 0) { if (++retryNum > 3) return Promise.reject(new Error('try max num')) return this.getData(this.getUrl(bangid, page)).then(({ statusCode, body }) => { - // console.log(body) + console.log(body) if (statusCode !== 200 || body.code !== this.successCode) return this.getList(bangid, page, retryNum) const list = this.filterData(body.data.columnInfo.dataList) return { diff --git a/src/renderer/utils/music/mg/musicSearch.js b/src/renderer/utils/music/mg/musicSearch.js index 9433596d..9e370395 100644 --- a/src/renderer/utils/music/mg/musicSearch.js +++ b/src/renderer/utils/music/mg/musicSearch.js @@ -36,7 +36,7 @@ export default { return arr.join('、') }, handleResult(rawData) { - // console.log(rawData) + console.log(rawData) let ids = new Set() const list = [] rawData.forEach(item => { @@ -82,6 +82,7 @@ export default { albumName: albumNInfo.name, albumId: albumNInfo.id, songmid: item.id, + songId: item.songId, copyrightId: item.copyrightId, source: 'mg', interval: null, diff --git a/src/renderer/utils/music/mg/songList.js b/src/renderer/utils/music/mg/songList.js index 0fa8ec33..2def8cce 100644 --- a/src/renderer/utils/music/mg/songList.js +++ b/src/renderer/utils/music/mg/songList.js @@ -24,25 +24,25 @@ export default { list: /
  • .+?<\/li>/g, listInfo: /.+data-original="(.+?)".*data-id="(\d+)".*
    (.+?)<\/a>.+<\/i>(.+?)<\/div>/, - // http://music.migu.cn/v3/music/playlist/161044573?page=1 + // https://music.migu.cn/v3/music/playlist/161044573?page=1 listDetailLink: /^.+\/playlist\/(\d+)(?:\?.*|&.*$|#.*$|$)/, }, tagsUrl: 'https://app.c.nf.migu.cn/MIGUM2.0/v1.0/content/indexTagPage.do?needAll=0', getSongListUrl(sortId, tagId, page) { // if (tagId == null) { // return sortId == 'recommend' - // ? `http://music.migu.cn/v3/music/playlist?page=${page}&from=migu` - // : `http://music.migu.cn/v3/music/playlist?sort=${sortId}&page=${page}&from=migu` + // ? `https://music.migu.cn/v3/music/playlist?page=${page}&from=migu` + // : `https://music.migu.cn/v3/music/playlist?sort=${sortId}&page=${page}&from=migu` // } - // return `http://music.migu.cn/v3/music/playlist?tagId=${tagId}&page=${page}&from=migu` + // return `https://music.migu.cn/v3/music/playlist?tagId=${tagId}&page=${page}&from=migu` if (tagId == null) { - // return `http://app.c.nf.migu.cn/MIGUM2.0/v2.0/content/getMusicData.do?count=${this.limit_list}&start=${page}&templateVersion=5&type=1` + // return `https://app.c.nf.migu.cn/MIGUM2.0/v2.0/content/getMusicData.do?count=${this.limit_list}&start=${page}&templateVersion=5&type=1` // return `https://c.musicapp.migu.cn/MIGUM2.0/v2.0/content/getMusicData.do?count=${this.limit_list}&start=${page}&templateVersion=5&type=${sortId}` - // http://app.c.nf.migu.cn/MIGUM2.0/v2.0/content/getMusicData.do?count=50&start=2&templateVersion=5&type=1 - return `http://m.music.migu.cn/migu/remoting/playlist_bycolumnid_tag?playListType=2&type=1&columnId=${sortId}&startIndex=${(page - 1) * 10}` + // https://app.c.nf.migu.cn/MIGUM2.0/v2.0/content/getMusicData.do?count=50&start=2&templateVersion=5&type=1 + return `https://m.music.migu.cn/migu/remoting/playlist_bycolumnid_tag?playListType=2&type=1&columnId=${sortId}&startIndex=${(page - 1) * 10}` } // return `https://app.c.nf.migu.cn/MIGUM2.0/v2.0/content/getMusicData.do?area=2&count=${this.limit_list}&start=${page}&tags=${tagId}&templateVersion=5&type=3` - return `http://m.music.migu.cn/migu/remoting/playlist_bycolumnid_tag?playListType=2&type=1&tagId=${tagId}&startIndex=${(page - 1) * 10}` + return `https://m.music.migu.cn/migu/remoting/playlist_bycolumnid_tag?playListType=2&type=1&tagId=${tagId}&startIndex=${(page - 1) * 10}` }, getSongListDetailUrl(id, page) { return `https://app.c.nf.migu.cn/MIGUM2.0/v1.0/user/queryMusicListSongs.do?musicListId=${id}&pageNo=${page}&pageSize=${this.limit_song}` @@ -74,7 +74,7 @@ export default { return this._requestObj_listDetail.promise.then(({ body }) => { if (body.code !== this.successCode) return this.getListDetail(id, page, ++tryNum) // console.log(JSON.stringify(body)) - console.log(body) + // console.log(body) return { list: this.filterListDetail(body.list), page, @@ -135,6 +135,7 @@ export default { albumId: item.albumId, songmid: item.copyrightId, copyrightId: item.copyrightId, + songId: item.songId, source: 'mg', interval: null, img: item.albumImgs && item.albumImgs.length ? item.albumImgs[0].img : null, @@ -185,7 +186,6 @@ export default { // }) return this._requestObj_list.promise.then(({ body }) => { if (body.retCode !== '100000' || body.retMsg.code !== this.successCode) return this.getList(sortId, tagId, page, ++tryNum) - // console.log(body) return { list: this.filterList(body.retMsg.playlist), total: parseInt(body.retMsg.countSize), diff --git a/src/renderer/utils/music/tx/comment.js b/src/renderer/utils/music/tx/comment.js new file mode 100644 index 00000000..1367df36 --- /dev/null +++ b/src/renderer/utils/music/tx/comment.js @@ -0,0 +1,187 @@ +import { httpFetch } from '../../request' +import { dateFormat2 } from '../../' + +const emojis = { + e400846: '😘', + e400874: '😴', + e400825: '😃', + e400847: '😙', + e400835: '😍', + e400873: '😳', + e400836: '😎', + e400867: '😭', + e400832: '😊', + e400837: '😏', + e400875: '😫', + e400831: '😉', + e400855: '😡', + e400823: '😄', + e400862: '😨', + e400844: '😖', + e400841: '😓', + e400830: '😈', + e400828: '😆', + e400833: '😋', + e400822: '😀', + e400843: '😕', + e400829: '😇', + e400824: '😂', + e400834: '😌', + e400877: '😷', + e400132: '🍉', + e400181: '🍺', + e401067: '☕️', + e400186: '🥧', + e400343: '🐷', + e400116: '🌹', + e400126: '🍃', + e400613: '💋', + e401236: '❤️', + e400622: '💔', + e400637: '💣', + e400643: '💩', + e400773: '🔪', + e400102: '🌛', + e401328: '🌞', + e400420: '👏', + e400914: '🙌', + e400408: '👍', + e400414: '👎', + e401121: '✋', + e400396: '👋', + e400384: '👉', + e401115: '✊', + e400402: '👌', + e400905: '🙈', + e400906: '🙉', + e400907: '🙊', + e400562: '👻', + e400932: '🙏', + e400644: '💪', + e400611: '💉', + e400185: '🎁', + e400655: '💰', + e400325: '🐥', + e400612: '💊', + e400198: '🎉', + e401685: '⚡️', + e400631: '💝', + e400768: '🔥', + e400432: '👑', +} + +export default { + _requestObj: null, + _requestObj2: null, + async getComment({ songId }, page = 1, limit = 20) { + if (this._requestObj) this._requestObj.cancelHttp() + + const _requestObj = httpFetch('http://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg', { + headers: { + 'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)', + }, + form: { + uin: '0', + format: 'json', + cid: '205360772', + reqtype: '2', + biztype: '1', + topid: songId, + cmd: '8', + needmusiccrit: '1', + pagenum: page - 1, + pagesize: limit, + }, + }) + const { body, statusCode } = await _requestObj.promise + if (statusCode != 200 || body.code !== 0) throw new Error('获取评论失败') + // console.log(body, statusCode) + const comment = body.comment + return { + source: 'tx', + comments: this.filterComment(comment.commentlist), + total: comment.commenttotal, + page, + limit, + maxPage: Math.ceil(comment.commenttotal / limit) || 1, + } + }, + async getHotComment({ songId }, page = 1, limit = 100) { + if (this._requestObj2) this._requestObj2.cancelHttp() + + const _requestObj2 = httpFetch('http://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg', { + headers: { + 'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)', + }, + form: { + uin: '0', + format: 'json', + cid: '205360772', + reqtype: '2', + biztype: '1', + topid: songId, + cmd: '9', + needmusiccrit: '1', + pagenum: page - 1, + pagesize: limit, + }, + }) + const { body, statusCode } = await _requestObj2.promise + if (statusCode != 200 || body.code !== 0) throw new Error('获取热门评论失败') + // console.log(body, statusCode) + const comment = body.comment + return { + source: 'tx', + comments: this.filterComment(comment.commentlist), + total: comment.commenttotal, + } + }, + replaceEmoji(msg) { + let rxp = /^\[em\](e\d+)\[\/em\]$/ + let result = msg.match(/\[em\]e\d+\[\/em\]/g) + if (!result) return msg + result = Array.from(new Set(result)) + for (let item of result) { + let code = item.replace(rxp, '$1') + msg = msg.replace(new RegExp(item.replace('[em]', '\\[em\\]').replace('[/em]', '\\[\\/em\\]'), 'g'), emojis[code] || '') + } + return msg + }, + filterComment(rawList) { + return rawList.map(item => { + let time = item.rootcommentid ? parseInt(item.rootcommentid.substring(item.rootcommentid.lastIndexOf('_') + 1) + '000') : null + if (item.middlecommentcontent) { + let firstItem = item.middlecommentcontent[0] + firstItem.avatarurl = item.avatarurl + firstItem.praisenum = item.praisenum + item.avatarurl = null + item.praisenum = null + item.middlecommentcontent.reverse() + } + return { + id: item.subcommentid, + rootId: item.rootcommentid, + text: item.rootcommentcontent ? this.replaceEmoji(item.rootcommentcontent).replace(/\\n/g, '\n').split('\n') : [], + time, + timeStr: time ? dateFormat2(time) : null, + userName: item.rootcommentnick ? item.rootcommentnick.substring(1) : '', + avatar: item.avatarurl, + userId: item.encrypt_rootcommentuin, + likedCount: item.praisenum, + reply: item.middlecommentcontent ? item.middlecommentcontent.map(c => { + let index = c.subcommentid.lastIndexOf('_') + return { + id: c.subcommentid, + text: this.replaceEmoji(c.subcommentcontent).replace(/\\n/g, '\n').split('\n'), + time: parseInt(c.subcommentid.substring(index + 1) + '000'), + timeStr: dateFormat2(parseInt(c.subcommentid.substring(index + 1) + '000')), + userName: c.replynick.substring(1), + avatar: c.avatarurl, + userId: c.encrypt_replyuin, + likedCount: c.praisenum, + } + }) : [], + } + }) + }, +} diff --git a/src/renderer/utils/music/tx/index.js b/src/renderer/utils/music/tx/index.js index ffa94b54..6c1bd568 100644 --- a/src/renderer/utils/music/tx/index.js +++ b/src/renderer/utils/music/tx/index.js @@ -4,12 +4,14 @@ import songList from './songList' import musicSearch from './musicSearch' import { apis } from '../api-source' import hotSearch from './hotSearch' +import comment from './comment' const tx = { leaderboard, songList, musicSearch, hotSearch, + comment, getMusicUrl(songInfo, type) { return apis('tx').getMusicUrl(songInfo, type) diff --git a/src/renderer/utils/music/wy/comment.js b/src/renderer/utils/music/wy/comment.js new file mode 100644 index 00000000..0847a44c --- /dev/null +++ b/src/renderer/utils/music/wy/comment.js @@ -0,0 +1,138 @@ +import { httpFetch } from '../../request' +import { weapi } from './utils/crypto' +import { dateFormat2 } from '../../' + +let cursorTools = { + cache: {}, + getCursor(id, page, limit) { + let cacheData = this.cache[id] + if (!cacheData) cacheData = this.cache[id] = {} + let orderType + let cursor + let offset + if (page == 1) { + cacheData.page = 1 + cursor = cacheData.cursor = cacheData.prevCursor = Date.now() + orderType = 1 + offset = 0 + } else if (cacheData.page) { + cursor = cacheData.cursor + if (page > cacheData.page) { + orderType = 1 + offset = (page - cacheData.page - 1) * limit + } else if (page < cacheData.page) { + orderType = 0 + offset = (cacheData.page - page - 1) * limit + } else { + cursor = cacheData.cursor = cacheData.prevCursor + offset = cacheData.offset + orderType = cacheData.orderType + } + } + return { + orderType, + cursor, + offset, + } + }, + setCursor(id, cursor, orderType, offset, page) { + let cacheData = this.cache[id] + if (!cacheData) cacheData = this.cache[id] = {} + cacheData.prevCursor = cacheData.cursor + cacheData.cursor = cursor + cacheData.orderType = orderType + cacheData.offset = offset + cacheData.page = page + }, +} + +export default { + _requestObj: null, + _requestObj2: null, + async getComment({ songmid }, page = 1, limit = 20) { + if (this._requestObj) this._requestObj.cancelHttp() + + const id = 'R_SO_4_' + songmid + + const cursorInfo = cursorTools.getCursor(songmid, page, limit) + + const _requestObj = httpFetch('https://music.163.com/weapi/comment/resource/comments/get', { + method: 'post', + headers: { + 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36', + origin: 'https://music.163.com', + Refere: 'http://music.163.com/', + }, + form: weapi({ + cursor: cursorInfo.cursor, + offset: cursorInfo.offset, + orderType: cursorInfo.orderType, + pageNo: page, + pageSize: limit, + rid: id, + threadId: id, + }), + }) + const { body, statusCode } = await _requestObj.promise + // console.log(body) + if (statusCode != 200 || body.code !== 200) throw new Error('获取评论失败') + cursorTools.setCursor(songmid, body.data.cursor, cursorInfo.orderType, cursorInfo.offset, page) + return { source: 'wy', comments: this.filterComment(body.data.comments), total: body.data.totalCount, page, limit, maxPage: Math.ceil(body.data.totalCount / limit) || 1 } + }, + async getHotComment({ songmid }, page = 1, limit = 100) { + if (this._requestObj2) this._requestObj2.cancelHttp() + + const id = 'R_SO_4_' + songmid + + const _requestObj2 = httpFetch('https://music.163.com/weapi/comment/resource/comments/get', { + method: 'post', + headers: { + 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36', + origin: 'https://music.163.com', + Refere: 'http://music.163.com/', + }, + form: weapi({ + cursor: Date.now().toString(), + offset: 0, + orderType: 1, + pageNo: page, + pageSize: limit, + rid: id, + threadId: id, + }), + }) + const { body, statusCode } = await _requestObj2.promise + if (statusCode != 200 || body.code !== 200) throw new Error('获取热门评论失败') + // console.log(body) + return { source: 'wy', comments: this.filterComment(body.data.hotComments) } + }, + filterComment(rawList) { + return rawList.map(item => { + let data = { + id: item.commentId, + text: item.content ? item.content.split('\n') : '', + time: item.time ? item.time : '', + timeStr: item.time ? dateFormat2(item.time) : '', + userName: item.user.nickname, + avatar: item.user.avatarUrl, + userId: item.user.userId, + likedCount: item.likedCount, + reply: [], + } + + let replyData = item.beReplied && item.beReplied[0] + return replyData ? { + id: item.commentId, + rootId: replyData.beRepliedCommentId, + text: replyData.content ? replyData.content.split('\n') : '', + time: item.time, + timeStr: null, + userName: replyData.user.nickname, + avatar: replyData.user.avatarUrl, + userId: replyData.user.userId, + likedCount: null, + reply: [data], + } : data + }) + }, +} diff --git a/src/renderer/utils/music/wy/index.js b/src/renderer/utils/music/wy/index.js index a06284a4..69830372 100644 --- a/src/renderer/utils/music/wy/index.js +++ b/src/renderer/utils/music/wy/index.js @@ -5,12 +5,14 @@ import getMusicInfo from './musicInfo' import musicSearch from './musicSearch' import songList from './songList' import hotSearch from './hotSearch' +import comment from './comment' const wy = { leaderboard, musicSearch, songList, hotSearch, + comment, getMusicUrl(songInfo, type) { return apis('wy').getMusicUrl(songInfo, type) }, diff --git a/src/renderer/utils/music/wy/musicSearch.js b/src/renderer/utils/music/wy/musicSearch.js index 6f99b12e..d7a40fd9 100644 --- a/src/renderer/utils/music/wy/musicSearch.js +++ b/src/renderer/utils/music/wy/musicSearch.js @@ -1,6 +1,7 @@ import { httpFetch } from '../../request' import { weapi } from './utils/crypto' -import { sizeFormate, formatPlayTime } from '../../index' +// import { sizeFormate, formatPlayTime } from '../../index' +import musicDetailApi from './musicDetail' let searchRequest export default { @@ -10,8 +11,12 @@ export default { allPage: 1, musicSearch(str, page) { if (searchRequest && searchRequest.cancelHttp) searchRequest.cancelHttp() - searchRequest = httpFetch('http://music.163.com/weapi/cloudsearch/get/web?csrf_token=', { + searchRequest = httpFetch('https://music.163.com/weapi/search/get', { method: 'post', + headers: { + 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36', + origin: 'https://music.163.com', + }, form: weapi({ s: str, type: 1, // 1: 单曲, 10: 专辑, 100: 歌手, 1000: 歌单, 1002: 用户, 1004: MV, 1006: 歌词, 1009: 电台, 1014: 视频 @@ -19,7 +24,24 @@ export default { offset: this.limit * (page - 1), }), }) - return searchRequest.promise.then(({ body }) => body) + return searchRequest.promise.then(({ body }) => + body && body.code === 200 + ? musicDetailApi.getList(body.result.songs.map(s => s.id)).then(({ list }) => { + this.total = body.result.songCount || 0 + this.page = page + this.allPage = Math.ceil(this.total / this.limit) + return { + code: 200, + data: { + list, + allPage: this.allPage, + limit: this.limit, + total: this.total, + source: 'wy', + }, + } + }) + : body) }, getSinger(singers) { let arr = [] @@ -28,7 +50,7 @@ export default { }) return arr.join('、') }, - handleResult(rawList) { + /* handleResult(rawList) { // console.log(rawList) if (!rawList) return [] return rawList.map(item => { @@ -78,27 +100,29 @@ export default { typeUrl: {}, } }) - }, + }, */ search(str, page = 1, { limit } = {}, retryNum = 0) { if (++retryNum > 3) return Promise.reject(new Error('try max num')) if (limit != null) this.limit = limit return this.musicSearch(str, page).then(result => { + // console.log(result) if (!result || result.code !== 200) return this.search(str, page, { limit }, retryNum) - let list = this.handleResult(result.result.songs || []) + // let list = this.handleResult(result.result.songs || []) - if (list == null) return this.search(str, page, { limit }, retryNum) + // if (list == null) return this.search(str, page, { limit }, retryNum) - this.total = result.result.songCount || 0 - this.page = page - this.allPage = Math.ceil(this.total / this.limit) + // this.total = result.result.songCount || 0 + // this.page = page + // this.allPage = Math.ceil(this.total / this.limit) - return Promise.resolve({ - list, - allPage: this.allPage, - limit: this.limit, - total: this.total, - source: 'wy', - }) + // return Promise.resolve({ + // list, + // allPage: this.allPage, + // limit: this.limit, + // total: this.total, + // source: 'wy', + // }) + return result.data }) }, } diff --git a/src/renderer/utils/music/xm/comment.js b/src/renderer/utils/music/xm/comment.js new file mode 100644 index 00000000..d8432cbe --- /dev/null +++ b/src/renderer/utils/music/xm/comment.js @@ -0,0 +1,47 @@ +import { xmRequest } from './util' +import { dateFormat2 } from '../../' + +export default { + _requestObj: null, + _requestObj2: null, + async getComment({ songmid }, page = 1, limit = 20) { + if (this._requestObj) this._requestObj.cancelHttp() + + const _requestObj = xmRequest('/api/comment/getCommentList', { objectId: songmid, objectType: 'song', pagingVO: { page, pageSize: limit } }) + const { body, statusCode } = await _requestObj.promise + // console.log(body) + if (statusCode != 200 || body.code !== 'SUCCESS') throw new Error('获取评论失败') + return { source: 'xm', comments: this.filterComment(body.result.data.commentList), total: body.result.data.pagingVO.count, page, limit, maxPage: Math.ceil(body.result.data.pagingVO.count / limit) || 1 } + }, + async getHotComment({ songmid }, page = 1, limit = 100) { + if (this._requestObj2) this._requestObj2.cancelHttp() + if (!songmid) throw new Error('获取失败') + const _requestObj2 = xmRequest('/api/comment/getHotCommentList', { objectId: songmid, objectType: 'song', pagingVO: { page, pageSize: limit } }) + const { body, statusCode } = await _requestObj2.promise + // console.log(body) + if (statusCode != 200 || body.code !== 'SUCCESS') throw new Error('获取热门评论失败') + return { source: 'xm', comments: this.filterComment(body.result.data.hotList) } + }, + filterComment(rawList) { + return rawList.map(item => ({ + id: item.commentId, + text: item.message.split('\n').filter(t => !!t), + time: item.gmtCreate, + timeStr: dateFormat2(item.gmtCreate), + userName: item.nickName, + avatar: item.avatar, + userId: item.userId, + likedCount: item.likes, + reply: item.replyData ? item.replyData.map(c => ({ + id: c.commentId, + text: c.message.split('\n').filter(t => !!t), + time: c.gmtCreate, + timeStr: dateFormat2(c.gmtCreate), + userName: c.nickName, + avatar: c.avatar, + userId: c.userId, + likedCount: c.likes, + })) : [], + })) + }, +} diff --git a/src/renderer/utils/music/xm/index.js b/src/renderer/utils/music/xm/index.js index 06c07b2c..e586bf25 100644 --- a/src/renderer/utils/music/xm/index.js +++ b/src/renderer/utils/music/xm/index.js @@ -5,6 +5,8 @@ import musicSearch from './musicSearch' // import pic from './pic' import lyric from './lyric' import hotSearch from './hotSearch' +import comment from './comment' +import musicInfo from './musicInfo' import { closeVerifyModal } from './util' const xm = { @@ -13,6 +15,7 @@ const xm = { leaderboard, hotSearch, closeVerifyModal, + comment, getMusicUrl(songInfo, type) { return apis('xm').getMusicUrl(songInfo, type) }, @@ -24,7 +27,12 @@ const xm = { // return pic.getPic(songInfo) }, getMusicDetailPageUrl(songInfo) { - return songInfo.songStringId ? `https://www.xiami.com/song/${songInfo.songStringId}` : null + if (songInfo.songStringId) return `https://www.xiami.com/song/${songInfo.songStringId}` + + musicInfo.getMusicInfo(songInfo).then(({ data }) => { + songInfo.songStringId = data.songStringId + }) + return `https://www.xiami.com/song/${songInfo.songmid}` }, // init() { // getToken() diff --git a/src/renderer/utils/music/xm/musicInfo.js b/src/renderer/utils/music/xm/musicInfo.js new file mode 100644 index 00000000..7ca9b1be --- /dev/null +++ b/src/renderer/utils/music/xm/musicInfo.js @@ -0,0 +1,14 @@ +import { xmRequest } from './util' + +export default { + _requestObj: null, + async getMusicInfo({ songmid }, page = 1, limit = 20) { + if (this._requestObj) this._requestObj.cancelHttp() + + const _requestObj = xmRequest('/api/song/initialize', { songId: songmid }) + const { body, statusCode } = await _requestObj.promise + // console.log(body) + if (statusCode != 200 || body.code !== 'SUCCESS') throw new Error('获取歌曲信息失败') + return { source: 'xm', data: body.result.data.songDetail } + }, +} diff --git a/src/renderer/views/Setting.vue b/src/renderer/views/Setting.vue index 2bf3b452..ef0a0c21 100644 --- a/src/renderer/views/Setting.vue +++ b/src/renderer/views/Setting.vue @@ -1,9 +1,19 @@