├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .postcssrc.js ├── README.md ├── build ├── build.js ├── check-versions.js ├── dev-client.js ├── dev-server.js ├── utils.js ├── vue-loader.conf.js ├── webpack.base.conf.js ├── webpack.dev.conf.js └── webpack.prod.conf.js ├── config ├── dev.env.js ├── index.js └── prod.env.js ├── index.html ├── package.json ├── prod.server.js ├── src ├── App.vue ├── api │ ├── config.js │ ├── rank.js │ ├── recommend.js │ ├── search.js │ ├── singer.js │ └── song.js ├── base │ ├── confirm │ │ └── confirm.vue │ ├── listview │ │ └── listview.vue │ ├── loading │ │ ├── loading.gif │ │ └── loading.vue │ ├── no-result │ │ ├── no-result.vue │ │ ├── no-result@2x.png │ │ └── no-result@3x.png │ ├── progress-bar │ │ └── progress-bar.vue │ ├── progress-circle │ │ └── progress-circle.vue │ ├── scroll │ │ └── scroll.vue │ ├── search-box │ │ └── search-box.vue │ ├── search-list │ │ └── search-list.vue │ ├── slider │ │ └── slider.vue │ ├── song-list │ │ ├── first@2x.png │ │ ├── first@3x.png │ │ ├── second@2x.png │ │ ├── second@3x.png │ │ ├── song-list.vue │ │ ├── third@2x.png │ │ └── third@3x.png │ ├── switches │ │ └── switches.vue │ └── top-tip │ │ └── top-tip.vue ├── common │ ├── fonts │ │ ├── music-icon.eot │ │ ├── music-icon.svg │ │ ├── music-icon.ttf │ │ └── music-icon.woff │ ├── image │ │ └── default.png │ ├── js │ │ ├── cache.js │ │ ├── config.js │ │ ├── dom.js │ │ ├── jsonp.js │ │ ├── mixin.js │ │ ├── singer.js │ │ ├── song.js │ │ └── util.js │ └── stylus │ │ ├── base.styl │ │ ├── icon.styl │ │ ├── index.styl │ │ ├── mixin.styl │ │ ├── reset.styl │ │ └── variable.styl ├── components │ ├── add-song │ │ └── add-song.vue │ ├── disc │ │ └── disc.vue │ ├── m-header │ │ ├── logo@2x.png │ │ ├── logo@3x.png │ │ └── m-header.vue │ ├── music-list │ │ └── music-list.vue │ ├── player │ │ └── player.vue │ ├── playlist │ │ └── playlist.vue │ ├── rank │ │ └── rank.vue │ ├── recommend │ │ └── recommend.vue │ ├── search │ │ └── search.vue │ ├── singer-detail │ │ └── singer-detail.vue │ ├── singer │ │ └── singer.vue │ ├── suggest │ │ └── suggest.vue │ ├── tab │ │ └── tab.vue │ ├── top-list │ │ └── top-list.vue │ └── user-center │ │ └── user-center.vue ├── main.js ├── router │ └── index.js └── store │ ├── actions.js │ ├── getters.js │ ├── index.js │ ├── mutation-types.js │ ├── mutations.js │ └── state.js └── static ├── .gitkeep ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png └── 6.png /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { "modules": false }], 4 | "stage-2" 5 | ], 6 | "plugins": ["transform-runtime"], 7 | "comments": false, 8 | "env": { 9 | "test": { 10 | "presets": ["env", "stage-2"], 11 | "plugins": [ "istanbul" ] 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | build/*.js 2 | config/*.js 3 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | // http://eslint.org/docs/user-guide/configuring 2 | 3 | module.exports = { 4 | root: true, 5 | parser: 'babel-eslint', 6 | parserOptions: { 7 | sourceType: 'module' 8 | }, 9 | env: { 10 | browser: true, 11 | }, 12 | // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style 13 | extends: 'standard', 14 | // required to lint *.vue files 15 | plugins: [ 16 | 'html' 17 | ], 18 | // add your custom rules here 19 | 'rules': { 20 | // allow paren-less arrow functions 21 | 'arrow-parens': 0, 22 | // allow async-await 23 | 'generator-star-spacing': 0, 24 | // allow debugger during development 25 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, 26 | 'eol-last': 0, 27 | 'space-before-function-paren': 0 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | dist/ 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | .idea/ 8 | -------------------------------------------------------------------------------- /.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | // to edit target browsers: use "browserlist" field in package.json 6 | "autoprefixer": {} 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-music 2 | 3 | > Vue2.0构建移动端音乐 App 4 | 5 | ## 预览地址:http://www.upyang.com/Vue-music/index.html#/recommend 6 | 7 | ## 效果截图 8 | 9 | 10 | ## 技术栈 11 | 12 | 【前端】 13 | 14 | - `Vue`:用于构建用户界面的 MVVM 框架。它的核心是**响应的数据绑定**和**组系统件** 15 | - `vue-router`:为单页面应用提供的路由系统,项目上线前使用了 `Lazy Loading Routes` 技术来实现异步加载优化性能 16 | - `vuex`:Vue 集中状态管理,在多个组件共享某些状态时非常便捷 17 | - `vue-lazyload`:第三方图片懒加载库,优化页面加载速度 18 | - `better-scroll`:iscroll 的优化版,使移动端滑动体验更加流畅 19 | - `Sass(Scss)`:css 预编译处理器 20 | - `ES6`:ECMAScript 新一代语法,模块化、解构赋值、Promise、Class 等方法非常好用 21 | 22 | 【后端】 23 | 24 | - `Node.js`:利用 Express 起一个本地测试服务器 25 | - `jsonp`:服务端通讯。抓取 QQ音乐(移动端)数据 26 | - `axios`:服务端通讯。结合 Node.js 代理后端请求,抓取 QQ音乐(PC端)数据 27 | 28 | 【自动化构建及其他工具】 29 | 30 | - `webpack`:项目的编译打包 31 | - `vue-cli`:Vue 脚手架工具,快速搭建项目 32 | - `eslint`:代码风格检查工具,规范代码格式 33 | - `vConsole`:移动端调试工具,在移动端输出日志 34 | 35 | 36 | ## 收获 37 | 38 | 1. 总结出一套适用于 Vue项目的通用组件 39 | 2. 总结了一套常用的 SCSS mixin 库 40 | 3. 总结了一套常用的 JS 工具函数库 41 | 4. 学会了如何在Vue中优雅的操作Dom来完成优秀的用户交互体验 42 | 43 | ## 实现页面 44 | 45 | 主要页面:播放器内核页、推荐页、歌单详情页、歌手页、歌手详情页、排行页、搜索页、添加歌曲页、个人中心页等。 46 | 47 | 核心页面:播放器内核页 48 | 49 | **推荐页** 50 | 51 | 上部分是一个轮播图组件,使用第三方库 `better-scroll` 辅助实现,使用 `jsonp` 抓取 QQ音乐(移动端)数据 52 | 53 | 下部分是一个歌单推荐列表,使用 `axios + Node.js` 代理后端请求,绕过主机限制 (伪造 headers),抓取 QQ音乐(PC端)数据 54 | 55 | 歌单推荐列表图片,使用图片懒加载技术 `vue-lazyload`,优化页面加载速度 56 | 57 | 为了更好的用户体验,当数据未请求到时,显示 `loading` 组件 58 | 59 | **推荐页 -> 歌单详情页** 60 | 61 | 由于歌手的状态多且杂,这里使用 `vuex` 集中管理歌手状态 62 | 63 | 这个组件更加注重 UX,做了很多类原生 APP 动画,如下拉图片放大、跟随推动、ios 渐进增强的高斯模糊效果 `backdrop-filter` 等 64 | 65 | **歌手页** 66 | 67 | 左右联动是这个组件的难点 68 | 69 | 左侧是一个歌手列表,使用 `jsonp` 抓取 QQ音乐(PC端)歌手数据并重组 JSON 数据结构 70 | 71 | 列表图片使用懒加载技术 `vue-lazyload`,优化页面加载速度 72 | 73 | 右侧是一个字母列表,与左侧歌手列表联动,滚动固定标题实现 74 | 75 | **歌手页 -> 歌手详情页** 76 | 77 | 复用歌单详情页,只改变传入的参数,数据同样爬取自 QQ音乐 78 | 79 | **播放器内核页** 80 | 81 | 核心组件。用 `vuex` 管理各种播放时状态,播放、暂停等功能调用 [audio API](http://www.w3school.com.cn/tags/html_ref_audio_video_dom.asp) 82 | 83 | 播放器可以最大化和最小化 84 | 85 | 中部唱片动画使用第三方 JS 动画库 `create-keyframe-animation` 实现 86 | 87 | 底部操作区图标使用 `iconfonts`。 88 | 89 | 抽象了一个横向进度条组件和一个圆形进度条组件,横向进度条可以拖动小球和点击进度条来改变播放进度,圆形进度条组件使用 SVG `` 元素 90 | 91 | 播放模式有:顺序播放、单曲循环、随机播放,原理是调整歌单列表数组 92 | 93 | 歌词的爬取利用 `axios` 代理后端请求,伪造 `headers` 来实现,先将歌词 jsonp 格式转换为 json 格式,再使用第三方库 [`js-base64`](https://github.com/dankogai/js-base64) 进行 Base64 解码操作,最后再使用第三方库 [`lyric-parser`](https://github.com/ustbhuangyi/lyric-parser)对歌词进行格式化 94 | 95 | 实现了侧滑显示歌词、歌词跟随进度条高亮等交互效果 96 | 97 | 增加了当前播放列表组件,可在其中加入/删除歌曲 98 | 99 | **排行页** 100 | 101 | 普通组件,没什么好说的 102 | 103 | **排行页 -> 歌单详情页** 104 | 105 | 复用歌单详情页,没什么好说的 106 | 107 | **搜索页** 108 | 109 | 抓数据,写组件,另外,根据抓取的数据特征,做了上拉刷新的功能 110 | 111 | 考虑到数据量大且频繁的问题,对请求做了节流处理 112 | 113 | 考虑到移动端键盘占屏的问题,对滚动前的 `input` 做了 `blur()` 操作 114 | 115 | 对搜索历史进行了 `localstorage` 缓存,清空搜索历史时使用了改装过的 `confirm` 组件 116 | 117 | 支持将搜索的歌曲添加到播放列表 118 | 119 | **个人中心** 120 | 121 | 将 `localstorage` 中 “我的收藏” 和 “最近播放” 反映到界面上 122 | 123 | **其他** 124 | 125 | 此应用的全部数据来自 QQ音乐,推荐页的歌单列表及歌词是利用 `axios` 结合 `node.js` 代理后端请求抓取的。 126 | 127 | 全局通用的应用级状态使用 `vuex` 集中管理 128 | 129 | 全局引入 `fastclick` 库,消除 click 移动浏览器300ms延迟 130 | 131 | 页面是响应式的,适配常见的移动端屏幕,采用 `flex` 布局 132 | 133 | ## 注意 134 | 135 | 此音乐播放器数据全部来自 QQ 音乐,接口改变了就需要修改 `jsonp` 和 `axios` 代码 136 | 137 | ## 安装与运行 138 | 139 | ``` 140 | git clone https://github.com/Aaron0525/Vue-music.git 141 | 142 | cd Vue-music 143 | 144 | npm install //安装依赖 145 | 146 | npm run dev //服务端运行 访问 http://localhost:8080 147 | 148 | npm run build //项目打包 149 | ``` 150 | 151 | ### 觉得有用的,可以来个star哦! 152 | 153 | -------------------------------------------------------------------------------- /build/build.js: -------------------------------------------------------------------------------- 1 | require('./check-versions')() 2 | 3 | process.env.NODE_ENV = 'production' 4 | 5 | var ora = require('ora') 6 | var rm = require('rimraf') 7 | var path = require('path') 8 | var chalk = require('chalk') 9 | var webpack = require('webpack') 10 | var config = require('../config') 11 | var webpackConfig = require('./webpack.prod.conf') 12 | 13 | var spinner = ora('building for production...') 14 | spinner.start() 15 | 16 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { 17 | if (err) throw err 18 | webpack(webpackConfig, function (err, stats) { 19 | spinner.stop() 20 | if (err) throw err 21 | process.stdout.write(stats.toString({ 22 | colors: true, 23 | modules: false, 24 | children: false, 25 | chunks: false, 26 | chunkModules: false 27 | }) + '\n\n') 28 | 29 | console.log(chalk.cyan(' Build complete.\n')) 30 | console.log(chalk.yellow( 31 | ' Tip: built files are meant to be served over an HTTP server.\n' + 32 | ' Opening index.html over file:// won\'t work.\n' 33 | )) 34 | }) 35 | }) 36 | -------------------------------------------------------------------------------- /build/check-versions.js: -------------------------------------------------------------------------------- 1 | var chalk = require('chalk') 2 | var semver = require('semver') 3 | var packageConfig = require('../package.json') 4 | var shell = require('shelljs') 5 | function exec (cmd) { 6 | return require('child_process').execSync(cmd).toString().trim() 7 | } 8 | 9 | var versionRequirements = [ 10 | { 11 | name: 'node', 12 | currentVersion: semver.clean(process.version), 13 | versionRequirement: packageConfig.engines.node 14 | }, 15 | ] 16 | 17 | if (shell.which('npm')) { 18 | versionRequirements.push({ 19 | name: 'npm', 20 | currentVersion: exec('npm --version'), 21 | versionRequirement: packageConfig.engines.npm 22 | }) 23 | } 24 | 25 | module.exports = function () { 26 | var warnings = [] 27 | for (var i = 0; i < versionRequirements.length; i++) { 28 | var mod = versionRequirements[i] 29 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { 30 | warnings.push(mod.name + ': ' + 31 | chalk.red(mod.currentVersion) + ' should be ' + 32 | chalk.green(mod.versionRequirement) 33 | ) 34 | } 35 | } 36 | 37 | if (warnings.length) { 38 | console.log('') 39 | console.log(chalk.yellow('To use this template, you must update following to modules:')) 40 | console.log() 41 | for (var i = 0; i < warnings.length; i++) { 42 | var warning = warnings[i] 43 | console.log(' ' + warning) 44 | } 45 | console.log() 46 | process.exit(1) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /build/dev-client.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | require('eventsource-polyfill') 3 | var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true') 4 | 5 | hotClient.subscribe(function (event) { 6 | if (event.action === 'reload') { 7 | window.location.reload() 8 | } 9 | }) 10 | -------------------------------------------------------------------------------- /build/dev-server.js: -------------------------------------------------------------------------------- 1 | require('./check-versions')() 2 | 3 | var config = require('../config') 4 | if (!process.env.NODE_ENV) { 5 | process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV) 6 | } 7 | 8 | var opn = require('opn') 9 | var path = require('path') 10 | var express = require('express') 11 | var webpack = require('webpack') 12 | var proxyMiddleware = require('http-proxy-middleware') 13 | var webpackConfig = require('./webpack.dev.conf') 14 | var axios = require('axios') 15 | 16 | // default port where dev server listens for incoming traffic 17 | var port = process.env.PORT || config.dev.port 18 | // automatically open browser, if not set will be false 19 | var autoOpenBrowser = !!config.dev.autoOpenBrowser 20 | // Define HTTP proxies to your custom API backend 21 | // https://github.com/chimurai/http-proxy-middleware 22 | var proxyTable = config.dev.proxyTable 23 | 24 | var app = express() 25 | 26 | var apiRoutes = express.Router() 27 | 28 | apiRoutes.get('/getDiscList', function (req, res) { 29 | var url = 'https://c.y.qq.com/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg' 30 | axios.get(url, { 31 | headers: { 32 | referer: 'https://c.y.qq.com/', 33 | host: 'c.y.qq.com' 34 | }, 35 | params: req.query 36 | }).then((response) => { 37 | res.json(response.data) 38 | }).catch((e) => { 39 | console.log(e) 40 | }) 41 | }) 42 | 43 | apiRoutes.get('/lyric', function (req, res) { 44 | var url = 'https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg' 45 | 46 | axios.get(url, { 47 | headers: { 48 | referer: 'https://c.y.qq.com/', 49 | host: 'c.y.qq.com' 50 | }, 51 | params: req.query 52 | }).then((response) => { 53 | var ret = response.data 54 | if (typeof ret === 'string') { 55 | var reg = /^\w+\(({[^()]+})\)$/ 56 | var matches = ret.match(reg) 57 | if (matches) { 58 | ret = JSON.parse(matches[1]) 59 | } 60 | } 61 | res.json(ret) 62 | }).catch((e) => { 63 | console.log(e) 64 | }) 65 | }) 66 | 67 | app.use('/api', apiRoutes) 68 | 69 | var compiler = webpack(webpackConfig) 70 | 71 | var devMiddleware = require('webpack-dev-middleware')(compiler, { 72 | publicPath: webpackConfig.output.publicPath, 73 | quiet: true 74 | }) 75 | 76 | var hotMiddleware = require('webpack-hot-middleware')(compiler, { 77 | log: () => {} 78 | }) 79 | // force page reload when html-webpack-plugin template changes 80 | compiler.plugin('compilation', function (compilation) { 81 | compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) { 82 | hotMiddleware.publish({ action: 'reload' }) 83 | cb() 84 | }) 85 | }) 86 | 87 | // proxy api requests 88 | Object.keys(proxyTable).forEach(function (context) { 89 | var options = proxyTable[context] 90 | if (typeof options === 'string') { 91 | options = { target: options } 92 | } 93 | app.use(proxyMiddleware(options.filter || context, options)) 94 | }) 95 | 96 | // handle fallback for HTML5 history API 97 | app.use(require('connect-history-api-fallback')()) 98 | 99 | // serve webpack bundle output 100 | app.use(devMiddleware) 101 | 102 | // enable hot-reload and state-preserving 103 | // compilation error display 104 | app.use(hotMiddleware) 105 | 106 | // serve pure static assets 107 | var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory) 108 | app.use(staticPath, express.static('./static')) 109 | 110 | var uri = 'http://localhost:' + port 111 | 112 | var _resolve 113 | var readyPromise = new Promise(resolve => { 114 | _resolve = resolve 115 | }) 116 | 117 | console.log('> Starting dev server...') 118 | devMiddleware.waitUntilValid(() => { 119 | console.log('> Listening at ' + uri + '\n') 120 | // when env is testing, don't need open it 121 | if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') { 122 | opn(uri) 123 | } 124 | _resolve() 125 | }) 126 | 127 | var server = app.listen(port) 128 | 129 | module.exports = { 130 | ready: readyPromise, 131 | close: () => { 132 | server.close() 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /build/utils.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var config = require('../config') 3 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 4 | 5 | exports.assetsPath = function (_path) { 6 | var assetsSubDirectory = process.env.NODE_ENV === 'production' 7 | ? config.build.assetsSubDirectory 8 | : config.dev.assetsSubDirectory 9 | return path.posix.join(assetsSubDirectory, _path) 10 | } 11 | 12 | exports.cssLoaders = function (options) { 13 | options = options || {} 14 | 15 | var cssLoader = { 16 | loader: 'css-loader', 17 | options: { 18 | minimize: process.env.NODE_ENV === 'production', 19 | sourceMap: options.sourceMap 20 | } 21 | } 22 | 23 | // generate loader string to be used with extract text plugin 24 | function generateLoaders (loader, loaderOptions) { 25 | var loaders = [cssLoader] 26 | if (loader) { 27 | loaders.push({ 28 | loader: loader + '-loader', 29 | options: Object.assign({}, loaderOptions, { 30 | sourceMap: options.sourceMap 31 | }) 32 | }) 33 | } 34 | 35 | // Extract CSS when that option is specified 36 | // (which is the case during production build) 37 | if (options.extract) { 38 | return ExtractTextPlugin.extract({ 39 | use: loaders, 40 | fallback: 'vue-style-loader' 41 | }) 42 | } else { 43 | return ['vue-style-loader'].concat(loaders) 44 | } 45 | } 46 | 47 | // https://vue-loader.vuejs.org/en/configurations/extract-css.html 48 | return { 49 | css: generateLoaders(), 50 | postcss: generateLoaders(), 51 | less: generateLoaders('less'), 52 | sass: generateLoaders('sass', { indentedSyntax: true }), 53 | scss: generateLoaders('sass'), 54 | stylus: generateLoaders('stylus'), 55 | styl: generateLoaders('stylus') 56 | } 57 | } 58 | 59 | // Generate loaders for standalone style files (outside of .vue) 60 | exports.styleLoaders = function (options) { 61 | var output = [] 62 | var loaders = exports.cssLoaders(options) 63 | for (var extension in loaders) { 64 | var loader = loaders[extension] 65 | output.push({ 66 | test: new RegExp('\\.' + extension + '$'), 67 | use: loader 68 | }) 69 | } 70 | return output 71 | } 72 | -------------------------------------------------------------------------------- /build/vue-loader.conf.js: -------------------------------------------------------------------------------- 1 | var utils = require('./utils') 2 | var config = require('../config') 3 | var isProduction = process.env.NODE_ENV === 'production' 4 | 5 | module.exports = { 6 | loaders: utils.cssLoaders({ 7 | sourceMap: isProduction 8 | ? config.build.productionSourceMap 9 | : config.dev.cssSourceMap, 10 | extract: isProduction 11 | }) 12 | } 13 | -------------------------------------------------------------------------------- /build/webpack.base.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var utils = require('./utils') 3 | var config = require('../config') 4 | var vueLoaderConfig = require('./vue-loader.conf') 5 | 6 | function resolve(dir) { 7 | return path.join(__dirname, '..', dir) 8 | } 9 | 10 | module.exports = { 11 | entry: { 12 | app: './src/main.js' 13 | }, 14 | output: { 15 | path: config.build.assetsRoot, 16 | filename: '[name].js', 17 | publicPath: process.env.NODE_ENV === 'production' 18 | ? config.build.assetsPublicPath 19 | : config.dev.assetsPublicPath 20 | }, 21 | resolve: { 22 | extensions: ['.js', '.vue', '.json'], 23 | alias: { 24 | '@': resolve('src'), 25 | 'common': resolve('src/common'), 26 | 'components': resolve('src/components'), 27 | 'base': resolve('src/base'), 28 | 'api': resolve('src/api') 29 | } 30 | }, 31 | module: { 32 | rules: [ 33 | { 34 | test: /\.(js|vue)$/, 35 | loader: 'eslint-loader', 36 | enforce: 'pre', 37 | include: [resolve('src'), resolve('test')], 38 | options: { 39 | formatter: require('eslint-friendly-formatter') 40 | } 41 | }, 42 | { 43 | test: /\.vue$/, 44 | loader: 'vue-loader', 45 | options: vueLoaderConfig 46 | }, 47 | { 48 | test: /\.js$/, 49 | loader: 'babel-loader', 50 | include: [resolve('src'), resolve('test')] 51 | }, 52 | { 53 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 54 | loader: 'url-loader', 55 | options: { 56 | limit: 10000, 57 | name: utils.assetsPath('img/[name].[hash:7].[ext]') 58 | } 59 | }, 60 | { 61 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 62 | loader: 'url-loader', 63 | options: { 64 | limit: 10000, 65 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]') 66 | } 67 | } 68 | ] 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 1 | var utils = require('./utils') 2 | var webpack = require('webpack') 3 | var config = require('../config') 4 | var merge = require('webpack-merge') 5 | var baseWebpackConfig = require('./webpack.base.conf') 6 | var HtmlWebpackPlugin = require('html-webpack-plugin') 7 | var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') 8 | 9 | // add hot-reload related code to entry chunks 10 | Object.keys(baseWebpackConfig.entry).forEach(function (name) { 11 | baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name]) 12 | }) 13 | 14 | module.exports = merge(baseWebpackConfig, { 15 | module: { 16 | rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap }) 17 | }, 18 | // cheap-module-eval-source-map is faster for development 19 | devtool: '#cheap-module-eval-source-map', 20 | plugins: [ 21 | new webpack.DefinePlugin({ 22 | 'process.env': config.dev.env 23 | }), 24 | // https://github.com/glenjamin/webpack-hot-middleware#installation--usage 25 | new webpack.HotModuleReplacementPlugin(), 26 | new webpack.NoEmitOnErrorsPlugin(), 27 | // https://github.com/ampedandwired/html-webpack-plugin 28 | new HtmlWebpackPlugin({ 29 | filename: 'index.html', 30 | template: 'index.html', 31 | inject: true 32 | }), 33 | new FriendlyErrorsPlugin() 34 | ] 35 | }) 36 | -------------------------------------------------------------------------------- /build/webpack.prod.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var utils = require('./utils') 3 | var webpack = require('webpack') 4 | var config = require('../config') 5 | var merge = require('webpack-merge') 6 | var baseWebpackConfig = require('./webpack.base.conf') 7 | var CopyWebpackPlugin = require('copy-webpack-plugin') 8 | var HtmlWebpackPlugin = require('html-webpack-plugin') 9 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 10 | var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') 11 | 12 | var env = config.build.env 13 | 14 | var webpackConfig = merge(baseWebpackConfig, { 15 | module: { 16 | rules: utils.styleLoaders({ 17 | sourceMap: config.build.productionSourceMap, 18 | extract: true 19 | }) 20 | }, 21 | devtool: config.build.productionSourceMap ? '#source-map' : false, 22 | output: { 23 | path: config.build.assetsRoot, 24 | filename: utils.assetsPath('js/[name].[chunkhash].js'), 25 | chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') 26 | }, 27 | plugins: [ 28 | // http://vuejs.github.io/vue-loader/en/workflow/production.html 29 | new webpack.DefinePlugin({ 30 | 'process.env': env 31 | }), 32 | new webpack.optimize.UglifyJsPlugin({ 33 | compress: { 34 | warnings: false 35 | }, 36 | sourceMap: true 37 | }), 38 | // extract css into its own file 39 | new ExtractTextPlugin({ 40 | filename: utils.assetsPath('css/[name].[contenthash].css') 41 | }), 42 | // Compress extracted CSS. We are using this plugin so that possible 43 | // duplicated CSS from different components can be deduped. 44 | new OptimizeCSSPlugin({ 45 | cssProcessorOptions: { 46 | safe: true 47 | } 48 | }), 49 | // generate dist index.html with correct asset hash for caching. 50 | // you can customize output by editing /index.html 51 | // see https://github.com/ampedandwired/html-webpack-plugin 52 | new HtmlWebpackPlugin({ 53 | filename: config.build.index, 54 | template: 'index.html', 55 | inject: true, 56 | minify: { 57 | removeComments: true, 58 | collapseWhitespace: true, 59 | removeAttributeQuotes: true 60 | // more options: 61 | // https://github.com/kangax/html-minifier#options-quick-reference 62 | }, 63 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin 64 | chunksSortMode: 'dependency' 65 | }), 66 | // split vendor js into its own file 67 | new webpack.optimize.CommonsChunkPlugin({ 68 | name: 'vendor', 69 | minChunks: function (module, count) { 70 | // any required modules inside node_modules are extracted to vendor 71 | return ( 72 | module.resource && 73 | /\.js$/.test(module.resource) && 74 | module.resource.indexOf( 75 | path.join(__dirname, '../node_modules') 76 | ) === 0 77 | ) 78 | } 79 | }), 80 | // extract webpack runtime and module manifest to its own file in order to 81 | // prevent vendor hash from being updated whenever app bundle is updated 82 | new webpack.optimize.CommonsChunkPlugin({ 83 | name: 'manifest', 84 | chunks: ['vendor'] 85 | }), 86 | // copy custom static assets 87 | new CopyWebpackPlugin([ 88 | { 89 | from: path.resolve(__dirname, '../static'), 90 | to: config.build.assetsSubDirectory, 91 | ignore: ['.*'] 92 | } 93 | ]) 94 | ] 95 | }) 96 | 97 | if (config.build.productionGzip) { 98 | var CompressionWebpackPlugin = require('compression-webpack-plugin') 99 | 100 | webpackConfig.plugins.push( 101 | new CompressionWebpackPlugin({ 102 | asset: '[path].gz[query]', 103 | algorithm: 'gzip', 104 | test: new RegExp( 105 | '\\.(' + 106 | config.build.productionGzipExtensions.join('|') + 107 | ')$' 108 | ), 109 | threshold: 10240, 110 | minRatio: 0.8 111 | }) 112 | ) 113 | } 114 | 115 | if (config.build.bundleAnalyzerReport) { 116 | var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin 117 | webpackConfig.plugins.push(new BundleAnalyzerPlugin()) 118 | } 119 | 120 | module.exports = webpackConfig 121 | -------------------------------------------------------------------------------- /config/dev.env.js: -------------------------------------------------------------------------------- 1 | var merge = require('webpack-merge') 2 | var prodEnv = require('./prod.env') 3 | 4 | module.exports = merge(prodEnv, { 5 | NODE_ENV: '"development"' 6 | }) 7 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | // see http://vuejs-templates.github.io/webpack for documentation. 2 | var path = require('path') 3 | module.exports = { 4 | build: { 5 | env: require('./prod.env'), 6 | port: 9000, 7 | index: path.resolve(__dirname, '../dist/index.html'), 8 | assetsRoot: path.resolve(__dirname, '../dist'), 9 | assetsSubDirectory: 'static', 10 | assetsPublicPath: '', 11 | productionSourceMap: true, 12 | // Gzip off by default as many popular static hosts such as 13 | // Surge or Netlify already gzip all static assets for you. 14 | // Before setting to `true`, make sure to: 15 | // npm install --save-dev compression-webpack-plugin 16 | productionGzip: false, 17 | productionGzipExtensions: ['js', 'css'], 18 | // Run the build command with an extra argument to 19 | // View the bundle analyzer report after build finishes: 20 | // `npm run build --report` 21 | // Set to `true` or `false` to always turn it on or off 22 | bundleAnalyzerReport: process.env.npm_config_report 23 | }, 24 | dev: { 25 | env: require('./dev.env'), 26 | port: 8080, 27 | autoOpenBrowser: true, 28 | assetsSubDirectory: 'static', 29 | assetsPublicPath: '/', 30 | proxyTable: {}, 31 | // CSS Sourcemaps off by default because relative paths are "buggy" 32 | // with this option, according to the CSS-Loader README 33 | // (https://github.com/webpack/css-loader#sourcemaps) 34 | // In our experience, they generally work as expected, 35 | // just be aware of this issue when enabling this option. 36 | cssSourceMap: false 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /config/prod.env.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | NODE_ENV: '"production"' 3 | } 4 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | vue-music 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-music", 3 | "version": "1.0.0", 4 | "description": "音乐播放器", 5 | "author": "songhao", 6 | "private": true, 7 | "scripts": { 8 | "dev": "node build/dev-server.js", 9 | "start": "node build/dev-server.js", 10 | "build": "node build/build.js", 11 | "lint": "eslint --ext .js,.vue src" 12 | }, 13 | "dependencies": { 14 | "babel-runtime": "^6.0.0", 15 | "vue": "^2.3.3", 16 | "vue-router": "^2.5.3", 17 | "vuex": "^2.3.1", 18 | "fastclick": "^1.0.6", 19 | "vue-lazyload": "1.0.3", 20 | "axios": "^0.16.1", 21 | "jsonp": "0.2.1", 22 | "better-scroll": "^0.1.15", 23 | "create-keyframe-animation": "^0.1.0", 24 | "js-base64": "^2.1.9", 25 | "lyric-parser": "^1.0.1", 26 | "good-storage": "^1.0.1" 27 | }, 28 | "devDependencies": { 29 | "autoprefixer": "^6.7.2", 30 | "babel-core": "^6.22.1", 31 | "babel-eslint": "^7.1.1", 32 | "babel-loader": "^6.2.10", 33 | "babel-plugin-transform-runtime": "^6.22.0", 34 | "babel-preset-env": "^1.3.2", 35 | "babel-preset-stage-2": "^6.22.0", 36 | "babel-register": "^6.22.0", 37 | "babel-polyfill": "^6.2.0", 38 | "chalk": "^1.1.3", 39 | "connect-history-api-fallback": "^1.3.0", 40 | "copy-webpack-plugin": "^4.0.1", 41 | "css-loader": "^0.28.0", 42 | "eslint": "^3.19.0", 43 | "eslint-friendly-formatter": "^2.0.7", 44 | "eslint-loader": "^1.7.1", 45 | "eslint-plugin-html": "^2.0.0", 46 | "eslint-config-standard": "^6.2.1", 47 | "eslint-plugin-promise": "^3.4.0", 48 | "eslint-plugin-standard": "^2.0.1", 49 | "eventsource-polyfill": "^0.9.6", 50 | "express": "^4.14.1", 51 | "extract-text-webpack-plugin": "^2.0.0", 52 | "file-loader": "^0.11.1", 53 | "friendly-errors-webpack-plugin": "^1.1.3", 54 | "html-webpack-plugin": "^2.28.0", 55 | "http-proxy-middleware": "^0.17.3", 56 | "webpack-bundle-analyzer": "^2.2.1", 57 | "semver": "^5.3.0", 58 | "shelljs": "^0.7.6", 59 | "opn": "^4.0.2", 60 | "optimize-css-assets-webpack-plugin": "^1.3.0", 61 | "ora": "^1.2.0", 62 | "rimraf": "^2.6.0", 63 | "url-loader": "^0.5.8", 64 | "vue-loader": "^11.3.4", 65 | "vue-style-loader": "^2.0.5", 66 | "vue-template-compiler": "^2.3.3", 67 | "webpack": "^2.3.3", 68 | "webpack-dev-middleware": "^1.10.0", 69 | "webpack-hot-middleware": "^2.18.0", 70 | "webpack-merge": "^4.1.0", 71 | "stylus": "^0.54.5", 72 | "stylus-loader": "^2.1.1", 73 | "vconsole": "^2.5.2" 74 | }, 75 | "engines": { 76 | "node": ">= 4.0.0", 77 | "npm": ">= 3.0.0" 78 | }, 79 | "browserslist": [ 80 | "> 1%", 81 | "last 2 versions", 82 | "not ie <= 8" 83 | ] 84 | } 85 | -------------------------------------------------------------------------------- /prod.server.js: -------------------------------------------------------------------------------- 1 | var express = require('express') 2 | var config = require('./config/index') 3 | var axios = require('axios') 4 | 5 | var port = process.env.PORT || config.build.port 6 | 7 | var app = express() 8 | 9 | var apiRoutes = express.Router() 10 | 11 | apiRoutes.get('/getDiscList', function (req, res) { 12 | var url = 'https://c.y.qq.com/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg' 13 | axios.get(url, { 14 | headers: { 15 | referer: 'https://c.y.qq.com/', 16 | host: 'c.y.qq.com' 17 | }, 18 | params: req.query 19 | }).then((response) => { 20 | res.json(response.data) 21 | }).catch((e) => { 22 | console.log(e) 23 | }) 24 | }) 25 | 26 | apiRoutes.get('/lyric', function (req, res) { 27 | var url = 'https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg' 28 | 29 | axios.get(url, { 30 | headers: { 31 | referer: 'https://c.y.qq.com/', 32 | host: 'c.y.qq.com' 33 | }, 34 | params: req.query 35 | }).then((response) => { 36 | var ret = response.data 37 | if (typeof ret === 'string') { 38 | var reg = /^\w+\(({[^\(\)]+})\)$/ 39 | var matches = response.data.match(reg) 40 | if (matches) { 41 | ret = JSON.parse(matches[1]) 42 | } 43 | } 44 | res.json(ret) 45 | }).catch((e) => { 46 | console.log(e) 47 | }) 48 | }) 49 | 50 | app.use('/api', apiRoutes) 51 | 52 | app.use(express.static('./dist')) 53 | 54 | module.exports = app.listen(port, function (err) { 55 | if (err) { 56 | console.log(err) 57 | return 58 | } 59 | console.log('Listening at http://localhost:' + port + '\n') 60 | }) -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 25 | 26 | -------------------------------------------------------------------------------- /src/api/config.js: -------------------------------------------------------------------------------- 1 | export const commonParams = { 2 | g_tk: 1928093487, 3 | inCharset: 'utf-8', 4 | outCharset: 'utf-8', 5 | notice: 0, 6 | format: 'jsonp' 7 | } 8 | 9 | export const options = { 10 | param: 'jsonpCallback' 11 | } 12 | 13 | export const ERR_OK = 0 -------------------------------------------------------------------------------- /src/api/rank.js: -------------------------------------------------------------------------------- 1 | import jsonp from 'common/js/jsonp' 2 | import {commonParams, options} from './config' 3 | 4 | export function getTopList() { 5 | const url = 'https://c.y.qq.com/v8/fcg-bin/fcg_myqq_toplist.fcg' 6 | 7 | const data = Object.assign({}, commonParams, { 8 | uin: 0, 9 | needNewCode: 1, 10 | platform: 'h5' 11 | }) 12 | 13 | return jsonp(url, data, options) 14 | } 15 | 16 | export function getMusicList(topid) { 17 | const url = 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_toplist_cp.fcg' 18 | 19 | const data = Object.assign({}, commonParams, { 20 | topid, 21 | needNewCode: 1, 22 | uin: 0, 23 | tpl: 3, 24 | page: 'detail', 25 | type: 'top', 26 | platform: 'h5' 27 | }) 28 | 29 | return jsonp(url, data, options) 30 | } 31 | -------------------------------------------------------------------------------- /src/api/recommend.js: -------------------------------------------------------------------------------- 1 | import jsonp from 'common/js/jsonp' 2 | import {commonParams, options} from './config' 3 | import axios from 'axios' 4 | 5 | export function getRecommend() { 6 | const url = 'https://c.y.qq.com/musichall/fcgi-bin/fcg_yqqhomepagerecommend.fcg' 7 | 8 | const data = Object.assign({}, commonParams, { 9 | platform: 'h5', 10 | uin: 0, 11 | needNewCode: 1 12 | }) 13 | 14 | return jsonp(url, data, options) 15 | } 16 | 17 | export function getDiscList() { 18 | const url = '/api/getDiscList' 19 | 20 | const data = Object.assign({}, commonParams, { 21 | platform: 'yqq', 22 | hostUin: 0, 23 | sin: 0, 24 | ein: 29, 25 | sortId: 5, 26 | needNewCode: 0, 27 | categoryId: 10000000, 28 | rnd: Math.random(), 29 | format: 'json' 30 | }) 31 | 32 | return axios.get(url, { 33 | params: data 34 | }).then((res) => { 35 | return Promise.resolve(res.data) 36 | }) 37 | } 38 | 39 | export function getSongList(disstid) { 40 | const url = 'https://c.y.qq.com/qzone/fcg-bin/fcg_ucc_getcdinfo_byids_cp.fcg' 41 | 42 | const data = Object.assign({}, commonParams, { 43 | disstid, 44 | type: 1, 45 | json: 1, 46 | utf8: 1, 47 | onlysong: 0, 48 | platform: 'yqq', 49 | hostUin: 0, 50 | needNewCode: 0 51 | }) 52 | 53 | return jsonp(url, data, options) 54 | } -------------------------------------------------------------------------------- /src/api/search.js: -------------------------------------------------------------------------------- 1 | import jsonp from 'common/js/jsonp' 2 | import {commonParams, options} from './config' 3 | 4 | export function getHotKey() { 5 | const url = 'https://c.y.qq.com/splcloud/fcgi-bin/gethotkey.fcg' 6 | 7 | const data = Object.assign({}, commonParams, { 8 | uin: 0, 9 | needNewCode: 1, 10 | platform: 'h5' 11 | }) 12 | 13 | return jsonp(url, data, options) 14 | } 15 | 16 | export function search(query, page, zhida, perpage) { 17 | const url = 'https://c.y.qq.com/soso/fcgi-bin/search_for_qq_cp' 18 | 19 | const data = Object.assign({}, commonParams, { 20 | w: query, 21 | p: page, 22 | perpage, 23 | n: perpage, 24 | catZhida: zhida ? 1 : 0, 25 | zhidaqu: 1, 26 | t: 0, 27 | flag: 1, 28 | ie: 'utf-8', 29 | sem: 1, 30 | aggr: 0, 31 | remoteplace: 'txt.mqq.all', 32 | uin: 0, 33 | needNewCode: 1, 34 | platform: 'h5' 35 | }) 36 | 37 | return jsonp(url, data, options) 38 | } 39 | -------------------------------------------------------------------------------- /src/api/singer.js: -------------------------------------------------------------------------------- 1 | import jsonp from 'common/js/jsonp' 2 | import {commonParams, options} from './config' 3 | 4 | export function getSingerList() { 5 | const url = 'https://c.y.qq.com/v8/fcg-bin/v8.fcg' 6 | 7 | const data = Object.assign({}, commonParams, { 8 | channel: 'singer', 9 | page: 'list', 10 | key: 'all_all_all', 11 | pagesize: 100, 12 | pagenum: 1, 13 | hostUin: 0, 14 | needNewCode: 0, 15 | platform: 'yqq' 16 | }) 17 | 18 | return jsonp(url, data, options) 19 | } 20 | 21 | export function getSingerDetail(singerId) { 22 | const url = 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_singer_track_cp.fcg' 23 | 24 | const data = Object.assign({}, commonParams, { 25 | hostUin: 0, 26 | needNewCode: 0, 27 | platform: 'yqq', 28 | order: 'listen', 29 | begin: 0, 30 | num: 80, 31 | songstatus: 1, 32 | singermid: singerId 33 | }) 34 | 35 | return jsonp(url, data, options) 36 | } 37 | 38 | -------------------------------------------------------------------------------- /src/api/song.js: -------------------------------------------------------------------------------- 1 | import {commonParams} from './config' 2 | import axios from 'axios' 3 | 4 | export function getLyric(mid) { 5 | const url = '/api/lyric' 6 | 7 | const data = Object.assign({}, commonParams, { 8 | songmid: mid, 9 | platform: 'yqq', 10 | hostUin: 0, 11 | needNewCode: 0, 12 | categoryId: 10000000, 13 | pcachetime: +new Date(), 14 | format: 'json' 15 | }) 16 | 17 | return axios.get(url, { 18 | params: data 19 | }).then((res) => { 20 | return Promise.resolve(res.data) 21 | }) 22 | } -------------------------------------------------------------------------------- /src/base/confirm/confirm.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{text}} 7 | 8 | {{cancelBtnText}} 9 | {{confirmBtnText}} 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 56 | 57 | -------------------------------------------------------------------------------- /src/base/listview/listview.vue: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | {{group.title}} 11 | 12 | 13 | 14 | {{item.name}} 15 | 16 | 17 | 18 | 19 | 21 | 22 | {{item}} 24 | 25 | 26 | 27 | 28 | {{fixedTitle}} 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 169 | 170 | 237 | -------------------------------------------------------------------------------- /src/base/loading/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/src/base/loading/loading.gif -------------------------------------------------------------------------------- /src/base/loading/loading.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{title}} 5 | 6 | 7 | 17 | 28 | -------------------------------------------------------------------------------- /src/base/no-result/no-result.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{title}} 5 | 6 | 7 | 8 | 18 | 19 | -------------------------------------------------------------------------------- /src/base/no-result/no-result@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/src/base/no-result/no-result@2x.png -------------------------------------------------------------------------------- /src/base/no-result/no-result@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/src/base/no-result/no-result@3x.png -------------------------------------------------------------------------------- /src/base/progress-bar/progress-bar.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 79 | 80 | -------------------------------------------------------------------------------- /src/base/progress-circle/progress-circle.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 36 | 37 | -------------------------------------------------------------------------------- /src/base/scroll/scroll.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 102 | 103 | 106 | -------------------------------------------------------------------------------- /src/base/search-box/search-box.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 42 | 43 | -------------------------------------------------------------------------------- /src/base/search-list/search-list.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{item}} 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 32 | 33 | -------------------------------------------------------------------------------- /src/base/slider/slider.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 131 | 132 | -------------------------------------------------------------------------------- /src/base/song-list/first@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/src/base/song-list/first@2x.png -------------------------------------------------------------------------------- /src/base/song-list/first@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/src/base/song-list/first@3x.png -------------------------------------------------------------------------------- /src/base/song-list/second@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/src/base/song-list/second@2x.png -------------------------------------------------------------------------------- /src/base/song-list/second@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/src/base/song-list/second@3x.png -------------------------------------------------------------------------------- /src/base/song-list/song-list.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | {{song.name}} 10 | {{getDesc(song)}} 11 | 12 | 13 | 14 | 15 | 16 | 17 | 51 | 52 | -------------------------------------------------------------------------------- /src/base/song-list/third@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/src/base/song-list/third@2x.png -------------------------------------------------------------------------------- /src/base/song-list/third@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/src/base/song-list/third@3x.png -------------------------------------------------------------------------------- /src/base/switches/switches.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | {{item.name}} 6 | 7 | 8 | 9 | 10 | 29 | 30 | -------------------------------------------------------------------------------- /src/base/top-tip/top-tip.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 36 | 37 | -------------------------------------------------------------------------------- /src/common/fonts/music-icon.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/src/common/fonts/music-icon.eot -------------------------------------------------------------------------------- /src/common/fonts/music-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Generated by IcoMoon 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/common/fonts/music-icon.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/src/common/fonts/music-icon.ttf -------------------------------------------------------------------------------- /src/common/fonts/music-icon.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/src/common/fonts/music-icon.woff -------------------------------------------------------------------------------- /src/common/image/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/src/common/image/default.png -------------------------------------------------------------------------------- /src/common/js/cache.js: -------------------------------------------------------------------------------- 1 | import storage from 'good-storage' 2 | 3 | const SEARCH_KEY = '__search__' 4 | const SEARCH_MAX_LEN = 15 5 | 6 | const PLAY_KEY = '__play__' 7 | const PLAY_MAX_LEN = 200 8 | 9 | const FAVORITE_KEY = '__favorite__' 10 | const FAVORITE_MAX_LEN = 200 11 | 12 | function insertArray(arr, val, compare, maxLen) { 13 | const index = arr.findIndex(compare) 14 | if (index === 0) { 15 | return 16 | } 17 | if (index > 0) { 18 | arr.splice(index, 1) 19 | } 20 | arr.unshift(val) 21 | if (maxLen && arr.length > maxLen) { 22 | arr.pop() 23 | } 24 | } 25 | 26 | function deleteFromArray(arr, compare) { 27 | const index = arr.findIndex(compare) 28 | if (index > -1) { 29 | arr.splice(index, 1) 30 | } 31 | } 32 | 33 | export function saveSearch(query) { 34 | let searches = storage.get(SEARCH_KEY, []) 35 | insertArray(searches, query, (item) => { 36 | return item === query 37 | }, SEARCH_MAX_LEN) 38 | storage.set(SEARCH_KEY, searches) 39 | return searches 40 | } 41 | 42 | export function deleteSearch(query) { 43 | let searches = storage.get(SEARCH_KEY, []) 44 | deleteFromArray(searches, (item) => { 45 | return item === query 46 | }) 47 | storage.set(SEARCH_KEY, searches) 48 | return searches 49 | } 50 | 51 | export function clearSearch() { 52 | storage.remove(SEARCH_KEY) 53 | return [] 54 | } 55 | 56 | export function loadSearch() { 57 | return storage.get(SEARCH_KEY, []) 58 | } 59 | 60 | export function savePlay(song) { 61 | let songs = storage.get(PLAY_KEY, []) 62 | insertArray(songs, song, (item) => { 63 | return song.id === item.id 64 | }, PLAY_MAX_LEN) 65 | storage.set(PLAY_KEY, songs) 66 | return songs 67 | } 68 | 69 | export function loadPlay() { 70 | return storage.get(PLAY_KEY, []) 71 | } 72 | 73 | export function saveFavorite(song) { 74 | let songs = storage.get(FAVORITE_KEY, []) 75 | insertArray(songs, song, (item) => { 76 | return song.id === item.id 77 | }, FAVORITE_MAX_LEN) 78 | storage.set(FAVORITE_KEY, songs) 79 | return songs 80 | } 81 | 82 | export function deleteFavorite(song) { 83 | let songs = storage.get(FAVORITE_KEY, []) 84 | deleteFromArray(songs, (item) => { 85 | return item.id === song.id 86 | }) 87 | storage.set(FAVORITE_KEY, songs) 88 | return songs 89 | } 90 | 91 | export function loadFavorite() { 92 | return storage.get(FAVORITE_KEY, []) 93 | } 94 | 95 | -------------------------------------------------------------------------------- /src/common/js/config.js: -------------------------------------------------------------------------------- 1 | export const playMode = { 2 | sequence: 0, 3 | loop: 1, 4 | random: 2 5 | } 6 | -------------------------------------------------------------------------------- /src/common/js/dom.js: -------------------------------------------------------------------------------- 1 | export function hasClass(el, className) { 2 | let reg = new RegExp('(^|\\s)' + className + '(\\s|$)') 3 | return reg.test(el.className) 4 | } 5 | 6 | export function addClass(el, className) { 7 | if (hasClass(el, className)) { 8 | return 9 | } 10 | 11 | let newClass = el.className.split(' ') 12 | newClass.push(className) 13 | el.className = newClass.join(' ') 14 | } 15 | 16 | export function getData(el, name, val) { 17 | const prefix = 'data-' 18 | if (val) { 19 | return el.setAttribute(prefix + name, val) 20 | } 21 | return el.getAttribute(prefix + name) 22 | } 23 | 24 | let elementStyle = document.createElement('div').style 25 | 26 | let vendor = (() => { 27 | let transformNames = { 28 | webkit: 'webkitTransform', 29 | Moz: 'MozTransform', 30 | O: 'OTransform', 31 | ms: 'msTransform', 32 | standard: 'transform' 33 | } 34 | 35 | for (let key in transformNames) { 36 | if (elementStyle[transformNames[key]] !== undefined) { 37 | return key 38 | } 39 | } 40 | 41 | return false 42 | })() 43 | 44 | export function prefixStyle(style) { 45 | if (vendor === false) { 46 | return false 47 | } 48 | 49 | if (vendor === 'standard') { 50 | return style 51 | } 52 | 53 | return vendor + style.charAt(0).toUpperCase() + style.substr(1) 54 | } 55 | -------------------------------------------------------------------------------- /src/common/js/jsonp.js: -------------------------------------------------------------------------------- 1 | import originJsonp from 'jsonp' 2 | 3 | export default function jsonp(url, data, option) { 4 | url += (url.indexOf('?') < 0 ? '?' : '&') + param(data) 5 | 6 | return new Promise((resolve, reject) => { 7 | originJsonp(url, option, (err, data) => { 8 | if (!err) { 9 | resolve(data) 10 | } else { 11 | reject(err) 12 | } 13 | }) 14 | }) 15 | } 16 | 17 | export function param(data) { 18 | let url = '' 19 | for (var k in data) { 20 | let value = data[k] !== undefined ? data[k] : '' 21 | url += '&' + k + '=' + encodeURIComponent(value) 22 | } 23 | return url ? url.substring(1) : '' 24 | } 25 | -------------------------------------------------------------------------------- /src/common/js/mixin.js: -------------------------------------------------------------------------------- 1 | import {mapGetters, mapMutations, mapActions} from 'vuex' 2 | import {playMode} from 'common/js/config' 3 | import {shuffle} from 'common/js/util' 4 | 5 | export const playlistMixin = { 6 | computed: { 7 | ...mapGetters([ 8 | 'playlist' 9 | ]) 10 | }, 11 | mounted() { 12 | this.handlePlaylist(this.playlist) 13 | }, 14 | activated() { 15 | this.handlePlaylist(this.playlist) 16 | }, 17 | watch: { 18 | playlist(newVal) { 19 | this.handlePlaylist(newVal) 20 | } 21 | }, 22 | methods: { 23 | handlePlaylist() { 24 | throw new Error('component must implement handlePlaylist method') 25 | } 26 | } 27 | } 28 | 29 | export const playerMixin = { 30 | computed: { 31 | iconMode() { 32 | return this.mode === playMode.sequence ? 'icon-sequence' : this.mode === playMode.loop ? 'icon-loop' : 'icon-random' 33 | }, 34 | ...mapGetters([ 35 | 'sequenceList', 36 | 'playlist', 37 | 'currentSong', 38 | 'mode', 39 | 'favoriteList' 40 | ]) 41 | }, 42 | methods: { 43 | changeMode() { 44 | const mode = (this.mode + 1) % 3 45 | this.setPlayMode(mode) 46 | let list = null 47 | if (mode === playMode.random) { 48 | list = shuffle(this.sequenceList) 49 | } else { 50 | list = this.sequenceList 51 | } 52 | this.resetCurrentIndex(list) 53 | this.setPlaylist(list) 54 | }, 55 | resetCurrentIndex(list) { 56 | let index = list.findIndex((item) => { 57 | return item.id === this.currentSong.id 58 | }) 59 | this.setCurrentIndex(index) 60 | }, 61 | toggleFavorite(song) { 62 | if (this.isFavorite(song)) { 63 | this.deleteFavoriteList(song) 64 | } else { 65 | this.saveFavoriteList(song) 66 | } 67 | }, 68 | getFavoriteIcon(song) { 69 | if (this.isFavorite(song)) { 70 | return 'icon-favorite' 71 | } 72 | return 'icon-not-favorite' 73 | }, 74 | isFavorite(song) { 75 | const index = this.favoriteList.findIndex((item) => { 76 | return item.id === song.id 77 | }) 78 | return index > -1 79 | }, 80 | ...mapMutations({ 81 | setPlayMode: 'SET_PLAY_MODE', 82 | setPlaylist: 'SET_PLAYLIST', 83 | setCurrentIndex: 'SET_CURRENT_INDEX', 84 | setPlayingState: 'SET_PLAYING_STATE' 85 | }), 86 | ...mapActions([ 87 | 'saveFavoriteList', 88 | 'deleteFavoriteList' 89 | ]) 90 | } 91 | } 92 | 93 | export const searchMixin = { 94 | data() { 95 | return { 96 | query: '', 97 | refreshDelay: 120 98 | } 99 | }, 100 | computed: { 101 | ...mapGetters([ 102 | 'searchHistory' 103 | ]) 104 | }, 105 | methods: { 106 | onQueryChange(query) { 107 | this.query = query 108 | }, 109 | blurInput() { 110 | this.$refs.searchBox.blur() 111 | }, 112 | addQuery(query) { 113 | this.$refs.searchBox.setQuery(query) 114 | }, 115 | saveSearch() { 116 | this.saveSearchHistory(this.query) 117 | }, 118 | ...mapActions([ 119 | 'saveSearchHistory', 120 | 'deleteSearchHistory' 121 | ]) 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/common/js/singer.js: -------------------------------------------------------------------------------- 1 | export default class Singer { 2 | constructor({id, name}) { 3 | this.id = id 4 | this.name = name 5 | this.avatar = `https://y.gtimg.cn/music/photo_new/T001R300x300M000${id}.jpg?max_age=2592000` 6 | } 7 | } -------------------------------------------------------------------------------- /src/common/js/song.js: -------------------------------------------------------------------------------- 1 | import {getLyric} from 'api/song' 2 | import {ERR_OK} from 'api/config' 3 | import {Base64} from 'js-base64' 4 | 5 | export default class Song { 6 | constructor({id, mid, singer, name, album, duration, image, url}) { 7 | this.id = id 8 | this.mid = mid 9 | this.singer = singer 10 | this.name = name 11 | this.album = album 12 | this.duration = duration 13 | this.image = image 14 | this.url = url 15 | } 16 | 17 | getLyric() { 18 | if (this.lyric) { 19 | return Promise.resolve(this.lyric) 20 | } 21 | 22 | return new Promise((resolve, reject) => { 23 | getLyric(this.mid).then((res) => { 24 | if (res.retcode === ERR_OK) { 25 | this.lyric = Base64.decode(res.lyric) 26 | resolve(this.lyric) 27 | } else { 28 | reject('no lyric') 29 | } 30 | }) 31 | }) 32 | } 33 | } 34 | 35 | export function createSong(musicData) { 36 | return new Song({ 37 | id: musicData.songid, 38 | mid: musicData.songmid, 39 | singer: filterSinger(musicData.singer), 40 | name: musicData.songname, 41 | album: musicData.albumname, 42 | duration: musicData.interval, 43 | image: `https://y.gtimg.cn/music/photo_new/T002R300x300M000${musicData.albummid}.jpg?max_age=2592000`, 44 | url: `http://ws.stream.qqmusic.qq.com/${musicData.songid}.m4a?fromtag=46` 45 | }) 46 | } 47 | 48 | function filterSinger(singer) { 49 | let ret = [] 50 | if (!singer) { 51 | return '' 52 | } 53 | singer.forEach((s) => { 54 | ret.push(s.name) 55 | }) 56 | return ret.join('/') 57 | } 58 | 59 | -------------------------------------------------------------------------------- /src/common/js/util.js: -------------------------------------------------------------------------------- 1 | function getRandomInt(min, max) { 2 | return Math.floor(Math.random() * (max - min + 1) + min) 3 | } 4 | 5 | export function shuffle(arr) { 6 | let _arr = arr.slice() 7 | for (let i = 0; i < _arr.length; i++) { 8 | let j = getRandomInt(0, i) 9 | let t = _arr[i] 10 | _arr[i] = _arr[j] 11 | _arr[j] = t 12 | } 13 | return _arr 14 | } 15 | 16 | export function debounce(func, delay) { 17 | let timer 18 | 19 | return function (...args) { 20 | if (timer) { 21 | clearTimeout(timer) 22 | } 23 | timer = setTimeout(() => { 24 | func.apply(this, args) 25 | }, delay) 26 | } 27 | } -------------------------------------------------------------------------------- /src/common/stylus/base.styl: -------------------------------------------------------------------------------- 1 | @import "variable.styl" 2 | 3 | body, html 4 | line-height: 1 5 | font-family: 'PingFang SC', 'STHeitiSC-Light', 'Helvetica-Light', arial, sans-serif, 'Droid Sans Fallback' 6 | user-select: none 7 | -webkit-tap-highlight-color: transparent 8 | background: $color-background 9 | color: $color-text -------------------------------------------------------------------------------- /src/common/stylus/icon.styl: -------------------------------------------------------------------------------- 1 | @font-face 2 | font-family: 'music-icon' 3 | src: url('../fonts/music-icon.eot?2qevqt') 4 | src: url('../fonts/music-icon.eot?2qevqt#iefix') format('embedded-opentype'), 5 | url('../fonts/music-icon.ttf?2qevqt') format('truetype'), 6 | url('../fonts/music-icon.woff?2qevqt') format('woff'), 7 | url('../fonts/music-icon.svg?2qevqt#music-icon') format('svg') 8 | font-weight: normal 9 | font-style: normal 10 | 11 | [class^="icon-"], [class*=" icon-"] 12 | /* use !important to prevent issues with browser extensions that change fonts */ 13 | font-family: 'music-icon' !important 14 | speak: none 15 | font-style: normal 16 | font-weight: normal 17 | font-variant: normal 18 | text-transform: none 19 | line-height: 1 20 | 21 | /* Better Font Rendering =========== */ 22 | -webkit-font-smoothing: antialiased 23 | -moz-osx-font-smoothing: grayscale 24 | 25 | .icon-ok:before 26 | content: "\e900" 27 | 28 | .icon-close:before 29 | content: "\e901" 30 | 31 | .icon-add:before 32 | content: "\e902" 33 | 34 | .icon-play-mini:before 35 | content: "\e903" 36 | 37 | .icon-playlist:before 38 | content: "\e904" 39 | 40 | .icon-music:before 41 | content: "\e905" 42 | 43 | .icon-search:before 44 | content: "\e906" 45 | 46 | .icon-clear:before 47 | content: "\e907" 48 | 49 | .icon-delete:before 50 | content: "\e908" 51 | 52 | .icon-favorite:before 53 | content: "\e909" 54 | 55 | .icon-not-favorite:before 56 | content: "\e90a" 57 | 58 | .icon-pause:before 59 | content: "\e90b" 60 | 61 | .icon-play:before 62 | content: "\e90c" 63 | 64 | .icon-prev:before 65 | content: "\e90d" 66 | 67 | .icon-loop:before 68 | content: "\e90e" 69 | 70 | .icon-sequence:before 71 | content: "\e90f" 72 | 73 | .icon-random:before 74 | content: "\e910" 75 | 76 | .icon-back:before 77 | content: "\e911" 78 | 79 | .icon-mine:before 80 | content: "\e912" 81 | 82 | .icon-next:before 83 | content: "\e913" 84 | 85 | .icon-dismiss:before 86 | content: "\e914" 87 | 88 | .icon-pause-mini:before 89 | content: "\e915" 90 | -------------------------------------------------------------------------------- /src/common/stylus/index.styl: -------------------------------------------------------------------------------- 1 | @import "./reset.styl" 2 | @import "./base.styl" 3 | @import "./icon.styl" -------------------------------------------------------------------------------- /src/common/stylus/mixin.styl: -------------------------------------------------------------------------------- 1 | // 背景图片 2 | bg-image($url) 3 | background-image: url($url + "@2x.png") 4 | @media (-webkit-min-device-pixel-ratio: 3),(min-device-pixel-ratio: 3) 5 | background-image: url($url + "@3x.png") 6 | 7 | // 不换行 8 | no-wrap() 9 | text-overflow: ellipsis 10 | overflow: hidden 11 | white-space: nowrap 12 | 13 | // 扩展点击区域 14 | extend-click() 15 | position: relative 16 | &:before 17 | content: '' 18 | position: absolute 19 | top: -10px 20 | left: -10px 21 | right: -10px 22 | bottom: -10px -------------------------------------------------------------------------------- /src/common/stylus/reset.styl: -------------------------------------------------------------------------------- 1 | /** 2 | * Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/) 3 | * http://cssreset.com 4 | */ 5 | html, body, div, span, applet, object, iframe, 6 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 7 | a, abbr, acronym, address, big, cite, code, 8 | del, dfn, em, img, ins, kbd, q, s, samp, 9 | small, strike, strong, sub, sup, tt, var, 10 | b, u, i, center, 11 | dl, dt, dd, ol, ul, li, 12 | fieldset, form, label, legend, 13 | table, caption, tbody, tfoot, thead, tr, th, td, 14 | article, aside, canvas, details, embed, 15 | figure, figcaption, footer, header, 16 | menu, nav, output, ruby, section, summary, 17 | time, mark, audio, video, input 18 | margin: 0 19 | padding: 0 20 | border: 0 21 | font-size: 100% 22 | font-weight: normal 23 | vertical-align: baseline 24 | 25 | /* HTML5 display-role reset for older browsers */ 26 | article, aside, details, figcaption, figure, 27 | footer, header, menu, nav, section 28 | display: block 29 | 30 | body 31 | line-height: 1 32 | 33 | blockquote, q 34 | quotes: none 35 | 36 | blockquote:before, blockquote:after, 37 | q:before, q:after 38 | content: none 39 | 40 | table 41 | border-collapse: collapse 42 | border-spacing: 0 43 | 44 | /* custom */ 45 | 46 | a 47 | color: #7e8c8d 48 | -webkit-backface-visibility: hidden 49 | text-decoration: none 50 | 51 | li 52 | list-style: none 53 | 54 | body 55 | -webkit-text-size-adjust: none 56 | -webkit-tap-highlight-color: rgba(0, 0, 0, 0) 57 | -------------------------------------------------------------------------------- /src/common/stylus/variable.styl: -------------------------------------------------------------------------------- 1 | // 颜色定义规范 2 | $color-background = #222 3 | $color-background-d = rgba(0, 0, 0, 0.3) 4 | $color-highlight-background = #333 5 | $color-dialog-background = #666 6 | $color-theme = #ffcd32 7 | $color-theme-d = rgba(255, 205, 49, 0.5) 8 | $color-sub-theme = #d93f30 9 | $color-text = #fff 10 | $color-text-d = rgba(255, 255, 255, 0.3) 11 | $color-text-l = rgba(255, 255, 255, 0.5) 12 | $color-text-ll = rgba(255, 255, 255, 0.8) 13 | 14 | //字体定义规范 15 | $font-size-small-s = 10px 16 | $font-size-small = 12px 17 | $font-size-medium = 14px 18 | $font-size-medium-x = 16px 19 | $font-size-large = 18px 20 | $font-size-large-x = 22px -------------------------------------------------------------------------------- /src/components/add-song/add-song.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 添加歌曲到列表 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 1首歌曲已经添加到播放列表 37 | 38 | 39 | 40 | 41 | 42 | 43 | 120 | 121 | -------------------------------------------------------------------------------- /src/components/disc/disc.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 61 | 62 | -------------------------------------------------------------------------------- /src/components/m-header/logo@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/src/components/m-header/logo@2x.png -------------------------------------------------------------------------------- /src/components/m-header/logo@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/src/components/m-header/logo@3x.png -------------------------------------------------------------------------------- /src/components/m-header/m-header.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Chicken Music 5 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | -------------------------------------------------------------------------------- /src/components/music-list/music-list.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 随机播放全部 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 145 | 146 | -------------------------------------------------------------------------------- /src/components/player/player.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | {{playingLyric}} 33 | 34 | 35 | 36 | 37 | 38 | {{line.txt}} 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | {{format(currentTime)}} 53 | 54 | 55 | 56 | {{format(currentSong.duration)}} 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 100 | 101 | 102 | 103 | 452 | 453 | -------------------------------------------------------------------------------- /src/components/playlist/playlist.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{modeText}} 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | {{item.name}} 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 添加歌曲到队列 31 | 32 | 33 | 34 | 关闭 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 134 | 135 | -------------------------------------------------------------------------------- /src/components/rank/rank.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | {{index + 1}} 12 | {{song.songname}}-{{song.singername}} 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 80 | 81 | -------------------------------------------------------------------------------- /src/components/recommend/recommend.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 热门歌单推荐 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 103 | 104 | -------------------------------------------------------------------------------- /src/components/search/search.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 热门搜索 11 | 12 | 13 | {{item.k}} 14 | 15 | 16 | 17 | 18 | 19 | 搜索历史 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 105 | 106 | -------------------------------------------------------------------------------- /src/components/singer-detail/singer-detail.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 62 | 63 | -------------------------------------------------------------------------------- /src/components/singer/singer.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 100 | 101 | 108 | -------------------------------------------------------------------------------- /src/components/suggest/suggest.vue: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 163 | 164 | -------------------------------------------------------------------------------- /src/components/tab/tab.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 推荐 5 | 6 | 7 | 歌手 8 | 9 | 10 | 排行 11 | 12 | 13 | 14 | 搜索 15 | 16 | 17 | 18 | 19 | 22 | 23 | -------------------------------------------------------------------------------- /src/components/top-list/top-list.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 66 | 67 | -------------------------------------------------------------------------------- /src/components/user-center/user-center.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 随机播放全部 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 118 | 119 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill' 2 | import Vue from 'vue' 3 | import App from './App' 4 | import router from './router' 5 | import fastclick from 'fastclick' 6 | import VueLazyload from 'vue-lazyload' 7 | import store from './store' 8 | 9 | import 'common/stylus/index.styl' 10 | 11 | /* eslint-disable no-unused-vars */ 12 | // import vConsole from 'vconsole' 13 | 14 | fastclick.attach(document.body) 15 | 16 | Vue.use(VueLazyload, { 17 | loading: require('common/image/default.png') 18 | }) 19 | 20 | /* eslint-disable no-new */ 21 | new Vue({ 22 | el: '#app', 23 | router, 24 | store, 25 | render: h => h(App) 26 | }) 27 | -------------------------------------------------------------------------------- /src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | 4 | Vue.use(Router) 5 | 6 | const Recommend = (resolve) => { 7 | import('components/recommend/recommend').then((module) => { 8 | resolve(module) 9 | }) 10 | } 11 | 12 | const Singer = (resolve) => { 13 | import('components/singer/singer').then((module) => { 14 | resolve(module) 15 | }) 16 | } 17 | 18 | const Rank = (resolve) => { 19 | import('components/rank/rank').then((module) => { 20 | resolve(module) 21 | }) 22 | } 23 | 24 | const Search = (resolve) => { 25 | import('components/search/search').then((module) => { 26 | resolve(module) 27 | }) 28 | } 29 | 30 | const SingerDetail = (resolve) => { 31 | import('components/singer-detail/singer-detail').then((module) => { 32 | resolve(module) 33 | }) 34 | } 35 | 36 | const Disc = (resolve) => { 37 | import('components/disc/disc').then((module) => { 38 | resolve(module) 39 | }) 40 | } 41 | 42 | const TopList = (resolve) => { 43 | import('components/top-list/top-list').then((module) => { 44 | resolve(module) 45 | }) 46 | } 47 | 48 | const UserCenter = (resolve) => { 49 | import('components/user-center/user-center').then((module) => { 50 | resolve(module) 51 | }) 52 | } 53 | 54 | export default new Router({ 55 | routes: [ 56 | { 57 | path: '/', 58 | redirect: '/recommend' 59 | }, 60 | { 61 | path: '/recommend', 62 | component: Recommend, 63 | children: [ 64 | { 65 | path: ':id', 66 | component: Disc 67 | } 68 | ] 69 | }, 70 | { 71 | path: '/singer', 72 | component: Singer, 73 | children: [ 74 | { 75 | path: ':id', 76 | component: SingerDetail 77 | } 78 | ] 79 | }, 80 | { 81 | path: '/rank', 82 | component: Rank, 83 | children: [ 84 | { 85 | path: ':id', 86 | component: TopList 87 | } 88 | ] 89 | }, 90 | { 91 | path: '/search', 92 | component: Search, 93 | children: [ 94 | { 95 | path: ':id', 96 | component: SingerDetail 97 | } 98 | ] 99 | }, 100 | { 101 | path: '/user', 102 | component: UserCenter 103 | } 104 | ] 105 | }) 106 | -------------------------------------------------------------------------------- /src/store/actions.js: -------------------------------------------------------------------------------- 1 | import * as types from './mutation-types' 2 | import {playMode} from 'common/js/config' 3 | import {shuffle} from 'common/js/util' 4 | import {saveSearch, clearSearch, deleteSearch, savePlay, saveFavorite, deleteFavorite} from 'common/js/cache' 5 | 6 | function findIndex(list, song) { 7 | return list.findIndex((item) => { 8 | return item.id === song.id 9 | }) 10 | } 11 | 12 | export const selectPlay = function ({commit, state}, {list, index}) { 13 | commit(types.SET_SEQUENCE_LIST, list) 14 | if (state.mode === playMode.random) { 15 | let randomList = shuffle(list) 16 | commit(types.SET_PLAYLIST, randomList) 17 | index = findIndex(randomList, list[index]) 18 | } else { 19 | commit(types.SET_PLAYLIST, list) 20 | } 21 | commit(types.SET_CURRENT_INDEX, index) 22 | commit(types.SET_FULL_SCREEN, true) 23 | commit(types.SET_PLAYING_STATE, true) 24 | } 25 | 26 | export const randomPlay = function ({commit}, {list}) { 27 | commit(types.SET_PLAY_MODE, playMode.random) 28 | commit(types.SET_SEQUENCE_LIST, list) 29 | let randomList = shuffle(list) 30 | commit(types.SET_PLAYLIST, randomList) 31 | commit(types.SET_CURRENT_INDEX, 0) 32 | commit(types.SET_FULL_SCREEN, true) 33 | commit(types.SET_PLAYING_STATE, true) 34 | } 35 | 36 | export const insertSong = function ({commit, state}, song) { 37 | let playlist = state.playlist.slice() 38 | let sequenceList = state.sequenceList.slice() 39 | let currentIndex = state.currentIndex 40 | // 记录当前歌曲 41 | let currentSong = playlist[currentIndex] 42 | // 查找当前列表中是否有待插入的歌曲并返回其索引 43 | let fpIndex = findIndex(playlist, song) 44 | // 因为是插入歌曲,所以索引+1 45 | currentIndex++ 46 | // 插入这首歌到当前索引位置 47 | playlist.splice(currentIndex, 0, song) 48 | // 如果已经包含了这首歌 49 | if (fpIndex > -1) { 50 | // 如果当前插入的序号大于列表中的序号 51 | if (currentIndex > fpIndex) { 52 | playlist.splice(fpIndex, 1) 53 | currentIndex-- 54 | } else { 55 | playlist.splice(fpIndex + 1, 1) 56 | } 57 | } 58 | 59 | let currentSIndex = findIndex(sequenceList, currentSong) + 1 60 | 61 | let fsIndex = findIndex(sequenceList, song) 62 | 63 | sequenceList.splice(currentSIndex, 0, song) 64 | 65 | if (fsIndex > -1) { 66 | if (currentSIndex > fsIndex) { 67 | sequenceList.splice(fsIndex, 1) 68 | } else { 69 | sequenceList.splice(fsIndex + 1, 1) 70 | } 71 | } 72 | 73 | commit(types.SET_PLAYLIST, playlist) 74 | commit(types.SET_SEQUENCE_LIST, sequenceList) 75 | commit(types.SET_CURRENT_INDEX, currentIndex) 76 | commit(types.SET_FULL_SCREEN, true) 77 | commit(types.SET_PLAYING_STATE, true) 78 | } 79 | 80 | export const saveSearchHistory = function ({commit}, query) { 81 | commit(types.SET_SEARCH_HISTORY, saveSearch(query)) 82 | } 83 | 84 | export const deleteSearchHistory = function ({commit}, query) { 85 | commit(types.SET_SEARCH_HISTORY, deleteSearch(query)) 86 | } 87 | 88 | export const clearSearchHistory = function ({commit}) { 89 | commit(types.SET_SEARCH_HISTORY, clearSearch()) 90 | } 91 | 92 | export const deleteSong = function ({commit, state}, song) { 93 | let playlist = state.playlist.slice() 94 | let sequenceList = state.sequenceList.slice() 95 | let currentIndex = state.currentIndex 96 | let pIndex = findIndex(playlist, song) 97 | playlist.splice(pIndex, 1) 98 | let sIndex = findIndex(sequenceList, song) 99 | sequenceList.splice(sIndex, 1) 100 | if (currentIndex > pIndex || currentIndex === playlist.length) { 101 | currentIndex-- 102 | } 103 | 104 | commit(types.SET_PLAYLIST, playlist) 105 | commit(types.SET_SEQUENCE_LIST, sequenceList) 106 | commit(types.SET_CURRENT_INDEX, currentIndex) 107 | 108 | if (!playlist.length) { 109 | commit(types.SET_PLAYING_STATE, false) 110 | } else { 111 | commit(types.SET_PLAYING_STATE, true) 112 | } 113 | } 114 | 115 | export const deleteSongList = function ({commit}) { 116 | commit(types.SET_CURRENT_INDEX, -1) 117 | commit(types.SET_PLAYLIST, []) 118 | commit(types.SET_SEQUENCE_LIST, []) 119 | commit(types.SET_PLAYING_STATE, false) 120 | } 121 | 122 | export const savePlayHistory = function ({commit}, song) { 123 | commit(types.SET_PLAY_HISTORY, savePlay(song)) 124 | } 125 | 126 | export const saveFavoriteList = function ({commit}, song) { 127 | commit(types.SET_FAVORITE_LIST, saveFavorite(song)) 128 | } 129 | 130 | export const deleteFavoriteList = function ({commit}, song) { 131 | commit(types.SET_FAVORITE_LIST, deleteFavorite(song)) 132 | } 133 | -------------------------------------------------------------------------------- /src/store/getters.js: -------------------------------------------------------------------------------- 1 | export const singer = state => state.singer 2 | 3 | export const playing = state => state.playing 4 | 5 | export const fullScreen = state => state.fullScreen 6 | 7 | export const playlist = state => state.playlist 8 | 9 | export const sequenceList = state => state.sequenceList 10 | 11 | export const mode = state => state.mode 12 | 13 | export const currentIndex = state => state.currentIndex 14 | 15 | export const currentSong = (state) => { 16 | return state.playlist[state.currentIndex] || {} 17 | } 18 | 19 | export const disc = state => state.disc 20 | 21 | export const topList = state => state.topList 22 | 23 | export const searchHistory = state => state.searchHistory 24 | 25 | export const playHistory = state => state.playHistory 26 | 27 | export const favoriteList = state => state.favoriteList 28 | -------------------------------------------------------------------------------- /src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | import * as actions from './actions' 4 | import * as getters from './getters' 5 | import state from './state' 6 | import mutations from './mutations' 7 | import createLogger from 'vuex/dist/logger' 8 | 9 | Vue.use(Vuex) 10 | 11 | const debug = process.env.NODE_ENV !== 'production' 12 | 13 | export default new Vuex.Store({ 14 | actions, 15 | getters, 16 | state, 17 | mutations, 18 | strict: debug, 19 | plugins: debug ? [createLogger()] : [] 20 | }) -------------------------------------------------------------------------------- /src/store/mutation-types.js: -------------------------------------------------------------------------------- 1 | export const SET_SINGER = 'SET_SINGER' 2 | 3 | export const SET_PLAYING_STATE = 'SET_PLAYING_STATE' 4 | 5 | export const SET_FULL_SCREEN = 'SET_FULL_SCREEN' 6 | 7 | export const SET_PLAYLIST = 'SET_PLAYLIST' 8 | 9 | export const SET_SEQUENCE_LIST = 'SET_SEQUENCE_LIST' 10 | 11 | export const SET_PLAY_MODE = 'SET_PLAY_MODE' 12 | 13 | export const SET_CURRENT_INDEX = 'SET_CURRENT_INDEX' 14 | 15 | export const SET_DISC = 'SET_DISC' 16 | 17 | export const SET_TOP_LIST = 'SET_TOP_LIST' 18 | 19 | export const SET_SEARCH_HISTORY = 'SET_SEARCH_HISTORY' 20 | 21 | export const SET_PLAY_HISTORY = 'SET_PLAY_HISTORY' 22 | 23 | export const SET_FAVORITE_LIST = 'SET_FAVORITE_LIST' -------------------------------------------------------------------------------- /src/store/mutations.js: -------------------------------------------------------------------------------- 1 | import * as types from './mutation-types' 2 | 3 | const mutations = { 4 | [types.SET_SINGER](state, singer) { 5 | state.singer = singer 6 | }, 7 | [types.SET_PLAYING_STATE](state, flag) { 8 | state.playing = flag 9 | }, 10 | [types.SET_FULL_SCREEN](state, flag) { 11 | state.fullScreen = flag 12 | }, 13 | [types.SET_PLAYLIST](state, list) { 14 | state.playlist = list 15 | }, 16 | [types.SET_SEQUENCE_LIST](state, list) { 17 | state.sequenceList = list 18 | }, 19 | [types.SET_PLAY_MODE](state, mode) { 20 | state.mode = mode 21 | }, 22 | [types.SET_CURRENT_INDEX](state, index) { 23 | state.currentIndex = index 24 | }, 25 | [types.SET_DISC](state, disc) { 26 | state.disc = disc 27 | }, 28 | [types.SET_TOP_LIST](state, topList) { 29 | state.topList = topList 30 | }, 31 | [types.SET_SEARCH_HISTORY](state, history) { 32 | state.searchHistory = history 33 | }, 34 | [types.SET_PLAY_HISTORY](state, history) { 35 | state.playHistory = history 36 | }, 37 | [types.SET_FAVORITE_LIST](state, list) { 38 | state.favoriteList = list 39 | } 40 | } 41 | 42 | export default mutations -------------------------------------------------------------------------------- /src/store/state.js: -------------------------------------------------------------------------------- 1 | import {playMode} from 'common/js/config' 2 | import {loadSearch, loadPlay, loadFavorite} from 'common/js/cache' 3 | 4 | const state = { 5 | singer: {}, 6 | playing: false, 7 | fullScreen: false, 8 | playlist: [], 9 | sequenceList: [], 10 | mode: playMode.sequence, 11 | currentIndex: -1, 12 | disc: {}, 13 | topList: {}, 14 | searchHistory: loadSearch(), 15 | playHistory: loadPlay(), 16 | favoriteList: loadFavorite() 17 | } 18 | 19 | export default state -------------------------------------------------------------------------------- /static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/static/.gitkeep -------------------------------------------------------------------------------- /static/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/static/1.png -------------------------------------------------------------------------------- /static/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/static/2.png -------------------------------------------------------------------------------- /static/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/static/3.png -------------------------------------------------------------------------------- /static/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/static/4.png -------------------------------------------------------------------------------- /static/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/static/5.png -------------------------------------------------------------------------------- /static/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aaron0525/Vue-music/97fa7746e50dc05c3304fbb0a4777752a00f7411/static/6.png --------------------------------------------------------------------------------
{{text}}
{{title}}
{{getDesc(song)}}
{{line.txt}}