├── static └── .gitkeep ├── config ├── prod.env.js ├── dev.env.js └── index.js ├── .gitignore ├── src ├── assets │ ├── logo.png │ ├── search.svg │ └── close.svg ├── components │ ├── About │ │ ├── help.png │ │ ├── close.svg │ │ └── About.vue │ ├── Play │ │ ├── next.png │ │ ├── pause.png │ │ ├── play.png │ │ ├── prev.png │ │ ├── back.svg │ │ ├── list.svg │ │ ├── skinBlack.svg │ │ ├── skinBlue.svg │ │ ├── skinGreen.svg │ │ ├── skinRed.svg │ │ └── Play.vue │ ├── AsideMenu │ │ ├── back.svg │ │ ├── about.svg │ │ ├── msg.svg │ │ ├── music.svg │ │ ├── near.svg │ │ ├── friend.svg │ │ ├── shop.svg │ │ ├── skin.svg │ │ ├── vip.svg │ │ └── AsideMenu.vue │ ├── Find │ │ ├── love.svg │ │ ├── cancel.svg │ │ ├── del.svg │ │ ├── find.svg │ │ ├── history.svg │ │ ├── listening.svg │ │ ├── loading.svg │ │ ├── search.svg │ │ ├── music.svg │ │ └── Find.vue │ ├── Footer │ │ ├── pause.svg │ │ ├── play.svg │ │ ├── next.svg │ │ ├── prev.svg │ │ └── Footer.vue │ ├── MusicList │ │ ├── del.svg │ │ └── MusicList.vue │ ├── Header │ │ ├── func.svg │ │ ├── search.svg │ │ └── Header.vue │ └── Social │ │ ├── loading.svg │ │ └── Social.vue ├── router │ └── index.js ├── common │ └── style │ │ └── base.scss ├── main.js └── App.vue ├── .editorconfig ├── .postcssrc.js ├── .babelrc ├── index.html ├── music-data.json ├── package.json └── README.md /static/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /config/prod.env.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | NODE_ENV: '"production"' 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | dist/ 4 | npm-debug.log 5 | yarn-error.log 6 | -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microzz/vue-music-player/HEAD/src/assets/logo.png -------------------------------------------------------------------------------- /src/components/About/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microzz/vue-music-player/HEAD/src/components/About/help.png -------------------------------------------------------------------------------- /src/components/Play/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microzz/vue-music-player/HEAD/src/components/Play/next.png -------------------------------------------------------------------------------- /src/components/Play/pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microzz/vue-music-player/HEAD/src/components/Play/pause.png -------------------------------------------------------------------------------- /src/components/Play/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microzz/vue-music-player/HEAD/src/components/Play/play.png -------------------------------------------------------------------------------- /src/components/Play/prev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microzz/vue-music-player/HEAD/src/components/Play/prev.png -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vue音乐播放器 - Powered by microzz.com 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/components/AsideMenu/back.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import MusicList from '../components/MusicList/MusicList.vue'; 4 | import Find from '../components/Find/Find.vue'; 5 | import Social from '../components/Social/Social.vue'; 6 | 7 | Vue.use(Router) 8 | 9 | export default new Router({ 10 | linkActiveClass: 'active', 11 | routes: [ 12 | { 13 | path: '/', 14 | name: '/', 15 | component: MusicList 16 | }, 17 | { 18 | path: '/music-list', 19 | name: 'MusicList', 20 | component: MusicList 21 | }, 22 | 23 | { 24 | path: '/find', 25 | name: 'Find', 26 | component: Find 27 | }, 28 | { 29 | path: '/social', 30 | name: 'Social', 31 | component: Social 32 | } 33 | ] 34 | }) 35 | -------------------------------------------------------------------------------- /src/components/Find/love.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Play/back.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Find/cancel.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/search.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Footer/pause.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Find/del.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Footer/play.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Footer/next.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Footer/prev.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Find/find.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/close.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Find/history.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/AsideMenu/about.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/common/style/base.scss: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | html, body { 8 | width: 100%; 9 | height: 100%; 10 | overflow: hidden; 11 | } 12 | 13 | @media screen and(min-width: 769px) { 14 | html, body { 15 | width: 460px; 16 | margin: 0 auto; 17 | } 18 | 19 | body{ 20 | // padding: 10px 0; 21 | box-shadow: 0 0 30px gray; 22 | } 23 | } 24 | 25 | a { 26 | position: relative; 27 | text-decoration: none; 28 | color: white; 29 | cursor: pointer; 30 | } 31 | 32 | a::after { 33 | content: ""; 34 | position: absolute; 35 | left: 0; 36 | bottom: 0; 37 | width: 100%; 38 | height: 2px; 39 | background-color: #3F51B5; 40 | transform: scaleX(0); 41 | transition: .3s ease-in-out; 42 | } 43 | a:hover::after { 44 | transform: scaleX(1); 45 | transition: .3s ease-in-out; 46 | } 47 | .hover { 48 | transform: scaleX(1); 49 | transition: .3s ease-in-out; 50 | } 51 | 52 | .rotate { 53 | animation: imgRotate 9s linear infinite; 54 | } 55 | 56 | @keyframes imgRotate { 57 | from { 58 | transform: rotate(0); 59 | } 60 | to { 61 | transform: rotate(360deg); 62 | } 63 | } 64 | 65 | .fade-enter-active { 66 | transition: all .3s ease; 67 | } 68 | .fade-leave-active { 69 | transition: all .3s cubic-bezier(1.0, 0.5, 0.8, 1.0); 70 | } 71 | .fade-enter, .fade-leave-active { 72 | transform: translateX(10px); 73 | opacity: 0; 74 | } 75 | -------------------------------------------------------------------------------- /src/components/AsideMenu/msg.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | // see http://vuejs-templates.github.io/webpack for documentation. 2 | var path = require('path') 3 | 4 | module.exports = { 5 | build: { 6 | env: require('./prod.env'), 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 | -------------------------------------------------------------------------------- /src/components/About/close.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /music-data.json: -------------------------------------------------------------------------------- 1 | { 2 | "musicData": [ 3 | { 4 | "name": "李玉刚 - 刚好遇见你", 5 | "src": "http://m2.music.126.net/qv3RI4K7ABKJ0TyAdb3taw==/3250156397064860.mp3", 6 | "musicImgSrc": "http://p4.music.126.net/lDyytkTaPYVTb1Vpide6AA==/18591642115187138.jpg" 7 | }, 8 | { 9 | "name": "以冬 - 我的一个道姑朋友", 10 | "src": "http://m2.music.126.net/7WiRhPdirEJ2axW9Xm6uJQ==/1415071481819545.mp3", 11 | "musicImgSrc": "http://omratag7g.bkt.clouddn.com/%E6%B0%91%E8%B0%A3.jpg" 12 | }, 13 | { 14 | "name": "任素汐 - 我要你", 15 | "src": "http://m2.music.126.net/WhBIiLKYNa84TF3p5xx2FQ==/3265549607332004.mp3", 16 | "musicImgSrc": "http://omratag7g.bkt.clouddn.com/%E6%88%91%E8%A6%81%E4%BD%A0.jpg" 17 | }, 18 | { 19 | "name": "赵雷 - 成都", 20 | "src":"http://m2.music.126.net/7o5D4dA6271VktgawcbZFA==/18665309393829604.mp3", 21 | "musicImgSrc": "http://p4.music.126.net/34YW1QtKxJ_3YnX9ZzKhzw==/2946691234868155.jpg" 22 | }, 23 | { 24 | "name": "韩安旭 - 多幸运", 25 | "src":"http://m2.music.126.net/N_2fJbqpi8QDnV1YJPCsuw==/3424978721721344.mp3", 26 | "musicImgSrc": "http://p3.music.126.net/U9RoJy0AUsoYuaKjmJbAzQ==/3386495814257685.jpg" 27 | }, 28 | { 29 | "name": "李健 - 假如爱有天意", 30 | "src": "http://m2.music.126.net/sOdeUJ8DrQJpbJjjVogKuw==/7957165651997665.mp3", 31 | "musicImgSrc": "http://omratag7g.bkt.clouddn.com/%E6%9D%8E%E5%81%A5.jpg" 32 | }, 33 | { 34 | "name": "七月上", 35 | "src": "http://m2.music.126.net/K1SFXCvWf8BO9VEpSvx2ew==/7967061257205150.mp", 36 | "musicImgSrc": "http://p3.music.126.net/9kZl6NRj3HxmQQ8DqTjZ4Q==/17729624997966923.jpg" 37 | }, 38 | { 39 | "name": "咱们屯里人(粤语版)", 40 | "src": "http://m2.music.126.net/XbGWv4O15b0c1-w4pCtwgA==/3300733908037356.mp3", 41 | "musicImgSrc": "http://omratag7g.bkt.clouddn.com/%E5%A4%8F%E6%B4%9B%E7%89%B9%E7%83%A6%E6%81%BC.jpg" 42 | } 43 | ] 44 | } 45 | -------------------------------------------------------------------------------- /src/components/MusicList/del.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/AsideMenu/music.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Find/listening.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-music-player", 3 | "version": "2.0.0", 4 | "description": "A Vue.js music player", 5 | "author": "Zhaohui ", 6 | "private": true, 7 | "scripts": { 8 | "dev": "node build/dev-server.js", 9 | "build": "node build/build.js" 10 | }, 11 | "dependencies": { 12 | "axios": "^0.15.3", 13 | "vue": "^2.2.2", 14 | "vue-axios": "^2.0.1", 15 | "vue-router": "^2.2.0", 16 | "vuex": "^2.2.1" 17 | }, 18 | "devDependencies": { 19 | "autoprefixer": "^6.7.2", 20 | "babel-core": "^6.22.1", 21 | "babel-loader": "^6.2.10", 22 | "babel-plugin-transform-runtime": "^6.22.0", 23 | "babel-preset-env": "^1.2.1", 24 | "babel-preset-stage-2": "^6.22.0", 25 | "babel-register": "^6.22.0", 26 | "chalk": "^1.1.3", 27 | "connect-history-api-fallback": "^1.3.0", 28 | "copy-webpack-plugin": "^4.0.1", 29 | "css-loader": "^0.26.1", 30 | "eventsource-polyfill": "^0.9.6", 31 | "express": "^4.14.1", 32 | "extract-text-webpack-plugin": "^2.0.0", 33 | "file-loader": "^0.10.0", 34 | "friendly-errors-webpack-plugin": "^1.1.3", 35 | "function-bind": "^1.1.0", 36 | "html-webpack-plugin": "^2.28.0", 37 | "http-proxy-middleware": "^0.17.3", 38 | "node-sass": "^4.5.0", 39 | "opn": "^4.0.2", 40 | "optimize-css-assets-webpack-plugin": "^1.3.0", 41 | "ora": "^1.1.0", 42 | "rimraf": "^2.6.0", 43 | "sass": "^0.5.0", 44 | "sass-loader": "^6.0.3", 45 | "semver": "^5.3.0", 46 | "url-loader": "^0.5.7", 47 | "vue-loader": "^11.1.4", 48 | "vue-style-loader": "^2.0.0", 49 | "vue-template-compiler": "^2.2.4", 50 | "webpack": "^2.2.1", 51 | "webpack-bundle-analyzer": "^2.2.1", 52 | "webpack-dev-middleware": "^1.10.0", 53 | "webpack-hot-middleware": "^2.16.1", 54 | "webpack-merge": "^2.6.1" 55 | }, 56 | "engines": { 57 | "node": ">= 4.0.0", 58 | "npm": ">= 3.0.0" 59 | }, 60 | "browserslist": [ 61 | "> 1%", 62 | "last 2 versions", 63 | "not ie <= 8" 64 | ] 65 | } 66 | -------------------------------------------------------------------------------- /src/components/Play/list.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vue.js音乐播放器2.0升级版 2 | 之前初学Vue做了一个音乐播放器,受到不少人的喜欢。现在升级版来了!功能更强,技术栈更多。 3 | 4 | ## 源代码 5 | 源代码地址:👉 [GitHub](https://github.com/microzz/vue-music-player) 6 | 欢迎大家star和follow😄 7 | 8 | ## 预览 9 | ### 在线预览 10 | 在线预览地址:👉 [Vue音乐播放器](https://microzz.com/vue-music/) 11 | 12 | ### 预览图 13 | ![Vue音乐播放器升级版 - microzz.com](https://github.com/microzz/preview/blob/master/vue_music_player/preview.gif?raw=true) 14 | 15 | 更多预览图请看👉 [更多](https://github.com/microzz/preview/tree/master/vue_music_player) 16 | 17 | ## 技术栈 18 | **Vue2**:采用最新Vue2的语法😁 19 | 20 | **Vuex**:实现不同组件之间的状态共享✌️ 21 | 22 | **vue-router**:单页应用路由管理必备😎 23 | 24 | **axios**:发起http请求😉 25 | 26 | **SASS(SCSS)**:css预处理语言💪 27 | 28 | **Express**(上线版本是**Koa2**):因为vue-cli是用的Express做服务器,所以开源的开发版本是Express,自己生产环境用的是Koa2。 😜 29 | 30 | **Webpack**:自动化构建工具,大部分配置vue-cli脚手架已经弄好了,很方便。😏 31 | 32 | **ES6**:采用ES6语法,这是趋势。👏 33 | 34 | **localStorage(HTML5)**:本地存储,保存用户个性化设置。😊 35 | 36 | **CSS3**:CSS3动画及样式。👍 37 | 38 | ## 使用 Build Setup 39 | 40 | ``` bash 41 | # install dependencies 42 | npm install 43 | 44 | # serve with hot reload at localhost:8080 45 | npm run dev 46 | 47 | # build for production with minification 48 | npm run build 49 | 50 | # build for production and view the bundle analyzer report 51 | npm run build --report 52 | ``` 53 | 54 | ## 遇到的问题 55 | 1. vuex什么时候使用,如何使用,就要看项目需要。引用 Redux 的作者 Dan Abramov 的话说就是: 56 | 57 | > Flux 架构就像眼镜:您自会知道什么时候需要它。 58 | 59 | 各组件之间状态共享也是难点。 60 | 61 | 2. 异步编程:JS是单线程,异步编程尤为重要。当我们向后端请求数据,是异步的,如果没有处理好相关的异步操作,是会有各种问题的。JS可以利用`setTimeout`、`回调`、`Generator`、`Promise`、`Async`。 62 | 定时这种方式太麻烦,还是不推荐;回调层次多了,有回调地狱,代码维护性很差;Generator需要手动去执行,当然可以使用类似`co`的模块。相比之下`Promise`和`Async`是比较理想的。(详看👉[Promise对象](https://microzz.com/2017/01/14/promise/)、[异步操作和Async函数](https://microzz.com/2017/01/15/async/)) 63 | 3. 本项目中使用了QQ音乐和One(一个)的接口,后端API编写也是难点,包含了各种异步请求。对返回数据的解析也是难点,有的时候你还需要对数据进行解码。 64 | 4. 各组件结构的设计:一开始大纲没设计好,后面想修改涉及面会很广。 65 | 5. 过渡动画让交互更有趣,但是有的还是耗性能的,有设备差异,没用好会造成卡顿。 66 | 67 | 【声明】:本项目仅供学习交流,请不要用做任何商业用途😊有任何疑问请联系作者📩[zhaohui@microzz.com](mailto:zhaohui@microzz.com) 68 | 69 | ## About 70 | 源代码地址:👉 [GitHub](https://github.com/microzz/vue-music-player) 71 | 72 | 个人网站:🔗[microzz-IT技术分享](https://microzz.com/) 73 | 74 | GitHub:🔗[microzz](https://github.com/microzz) 75 | 76 | -------------------------------------------------------------------------------- /src/components/AsideMenu/near.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Header/func.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Find/loading.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Social/loading.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Play/skinBlack.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Play/skinBlue.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Play/skinGreen.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Play/skinRed.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/AsideMenu/friend.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Find/search.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Header/search.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/AsideMenu/shop.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Header/Header.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 51 | 52 | 135 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | // The Vue build version to load with the `import` command 2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias. 3 | import Vue from 'vue' 4 | import App from './App' 5 | import router from './router' 6 | import axios from 'axios'; 7 | import VueAxios from 'vue-axios'; 8 | import Vuex from 'vuex' 9 | 10 | 11 | Vue.config.productionTip = false 12 | 13 | // 用 axios 进行 Ajax 请求 14 | Vue.use(VueAxios, axios); 15 | 16 | // Vuex 进行状态管理 17 | Vue.use(Vuex); 18 | 19 | const store = new Vuex.Store({ 20 | state: { 21 | musicData: [], 22 | skinColor: localStorage.skinColor || '#B72712', 23 | isShowIndex: true, 24 | isPlaying: false, 25 | isAnimation: false, 26 | isShowAsideMenu: false, 27 | isShowMiniMusic: false, 28 | isShowAbout: false, 29 | linkBorderIndex: '', 30 | DOM: {}, 31 | audio: { 32 | name: '', 33 | src: '', 34 | musicImgSrc: '', 35 | index: 0 36 | } 37 | }, 38 | mutations: { 39 | del(state, index) { 40 | if (state.musicData.length === 0) { 41 | return; 42 | } 43 | state.musicData.splice(index, 1); 44 | }, 45 | play(state, flag) { 46 | state.isPlaying = flag; 47 | }, 48 | addMusic(state, payload) { 49 | for (let music of state.musicData) { 50 | if (JSON.stringify(music) === JSON.stringify(payload)) { 51 | return; 52 | } 53 | } 54 | state.musicData.unshift(payload); 55 | }, 56 | toggleMusic(state, index) { 57 | state.audio.name = state.musicData[index].name; 58 | state.audio.src = state.musicData[index].src; 59 | state.audio.musicImgSrc = state.musicData[index].musicImgSrc; 60 | state.audio.index = index; 61 | }, 62 | playMusic(state, payload) { 63 | state.audio.name = payload.name; 64 | state.audio.src = payload.src; 65 | state.audio.musicImgSrc = payload.imgSrc; 66 | state.isPlaying = true; 67 | }, 68 | findDOM(state, payload) { 69 | state.DOM[payload.name] = payload.dom; 70 | }, 71 | showIndex(state, flag) { 72 | state.isShowIndex = flag; 73 | }, 74 | showAsideMenu(state, flag) { 75 | state.isShowAsideMenu = flag; 76 | }, 77 | showMiniMusic(state, flag) { 78 | state.isShowMiniMusic = flag; 79 | }, 80 | showAbout(state, flag) { 81 | state.isShowAbout = flag; 82 | }, 83 | changeLinkBorderIndex(state, index) { 84 | state.linkBorderIndex = index; 85 | }, 86 | changeSkinColor(state, color) { 87 | state.skinColor = color; 88 | } 89 | }, 90 | actions: { 91 | getData({ commit,state }) { 92 | if (localStorage.musics !== '[]' && localStorage.musics) { 93 | state.musicData = JSON.parse(localStorage.musics); 94 | return; 95 | } 96 | return new Promise((resolve, reject) => { 97 | Vue.axios.get('/api/music-data') 98 | .then (res => { 99 | if (res.data.errno === 0) { 100 | state.musicData = res.data.musicData; 101 | localStorage.musics = JSON.stringify(state.musicData); 102 | } 103 | }) 104 | .then(() => { 105 | commit('toggleMusic',0) 106 | }); 107 | resolve(); 108 | }); 109 | } 110 | } 111 | }); 112 | 113 | /* eslint-disable no-new */ 114 | new Vue({ 115 | el: '#app', 116 | router, 117 | store, 118 | template: '', 119 | components: { App } 120 | }) 121 | -------------------------------------------------------------------------------- /src/components/AsideMenu/skin.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/MusicList/MusicList.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 72 | 73 | 143 | -------------------------------------------------------------------------------- /src/components/About/About.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 44 | 45 | 146 | -------------------------------------------------------------------------------- /src/components/AsideMenu/vip.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Find/music.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 35 | 36 | 100 | 101 | 194 | -------------------------------------------------------------------------------- /src/components/AsideMenu/AsideMenu.vue: -------------------------------------------------------------------------------- 1 | 49 | 50 | 73 | 74 | 266 | -------------------------------------------------------------------------------- /src/components/Social/Social.vue: -------------------------------------------------------------------------------- 1 | 46 | 47 | 106 | 107 | 291 | -------------------------------------------------------------------------------- /src/components/Footer/Footer.vue: -------------------------------------------------------------------------------- 1 | 28 | 29 | 125 | 126 | 259 | -------------------------------------------------------------------------------- /src/components/Find/Find.vue: -------------------------------------------------------------------------------- 1 | 51 | 52 | 144 | 145 | 391 | -------------------------------------------------------------------------------- /src/components/Play/Play.vue: -------------------------------------------------------------------------------- 1 | 68 | 69 | 182 | 183 | 516 | --------------------------------------------------------------------------------