{"id":14976380,"url":"https://github.com/scorpionjay/r-music","last_synced_at":"2025-10-27T20:31:07.327Z","repository":{"id":50553982,"uuid":"87905102","full_name":"ScorpionJay/r-music","owner":"ScorpionJay","description":"react music demo","archived":false,"fork":false,"pushed_at":"2017-05-12T06:52:31.000Z","size":1192,"stargazers_count":57,"open_issues_count":0,"forks_count":24,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-02-01T08:02:56.764Z","etag":null,"topics":["fetch","react","redux","router","sass","webpack2"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ScorpionJay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-11T07:44:21.000Z","updated_at":"2023-05-20T09:51:19.000Z","dependencies_parsed_at":"2022-08-31T18:31:02.864Z","dependency_job_id":null,"html_url":"https://github.com/ScorpionJay/r-music","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScorpionJay%2Fr-music","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScorpionJay%2Fr-music/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScorpionJay%2Fr-music/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScorpionJay%2Fr-music/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ScorpionJay","download_url":"https://codeload.github.com/ScorpionJay/r-music/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238553003,"owners_count":19491358,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fetch","react","redux","router","sass","webpack2"],"created_at":"2024-09-24T13:53:48.304Z","updated_at":"2025-10-27T20:31:01.912Z","avatar_url":"https://github.com/ScorpionJay.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# music\n\n\n\n## 扫码体验\n\n[http://cenuon.com:8666](http://cenuon.com:8666)\n\n![http://cenuon.com:8666](doc/qcode.png)\n\n## 部分截图\n\n![](doc/1.png) ![](doc/2.png)\n![](doc/3.png) ![](doc/4.png)\n\n\n\n## 干货：项目说明\n\n### 技术栈\nreact + react-router + redux + webpack + ES6 + fetch + sass + flex\n\n### 项目结构\n```\nr-music\n│  .babelrc\n│  .eslintrc.js\n│  .gitignore\n│  package.json\n│  README.md\n│  server.js                    //node启动脚本\n│  webpack.config.js            \n│  \n├─config\n│      webpack.dev.js           //开发环境的webpack配置文件\n│      webpack.hash.js          //开发环境的webpack配置文件\n│      webpack.prod.js          //生产环境的webpack配置文件\n│           \n└─src\n    │  api.js                   //封装的fetch\n    │  app.js                   \n    │  config.js                //api接口配置文件\n    │  index.hash.js\n    │  index.js\n    │  index.temp.hash.html\n    │  index.temp.html\n    │  routers.js               //路由\n    │  storage.js               //window.localStorage的各种方法\n    │      \n    ├─components               //组件\n    │          \n    ├─containers               //页面\n    │      account.js\n    │      album.js\n    │      friend.js\n    │      home.js\n    │      music.js\n    │      play.js\n    │      \n    ├─images\n    │      favicon.ico\n    │      \n    ├─json\n    │      home.json\n    │       \n    ├─actions                 //redux -- action\n    │      album.js\n    │      dialog.js\n    │      home.js\n    │      .\n    │      .     \n    ├─reducers                //redux -- reducer\n    │      album.js\n    │      dialog.js\n    │      home.js\n    │      index.js\n    │      login.js\n    │      message.js\n    │      music.js\n    │      spin.js\n    │      user.js\n    │      \n    stores                     //redux  -- store\n    │      index.js\n    │      \n    └─sass                    //样式文件\n            common.scss\n            home.scss\n            login.scss\n            main.scss\n            pagination.scss\n            slider.scss\n            \n\n```\n\n## 项目运行\n```\ngit clone https://github.com/ScorpionJay/r-music.git\ncd r-music\nnpm install\n```\n### 本地开发环境\n```\nnpm run dev\n```\n该命令在package.json的scripts中，即`\"dev\": \"webpack-dev-server --config webpack.config.js --hot\"`，启动一个服务。\n如果一切正常，会自动打开浏览器并访问`http://localhost:9999`。\n\n```\n// config/webpack.dev.js部分代码\n        devServer: {\n            contentBase: \"./src\",//本地服务器所加载的页面所在的目录\n            historyApiFallback: true,//不跳转\n            inline: true,//实时刷新\n            host: '0.0.0.0',\n            port:9999,\n            // 设置代理\n            proxy:{\n                \"/kugou\": {\n                    target: \"http://m.kugou.com\",\n                    changeOrigin: true,\n                    pathRewrite: {\"^/kugou\" : \"\"}\n                }\n            }\n        }\n```\n因为在 `config/webpack.dev.js `设置了host:'0.0.0.0'，所以同局域网的其他手机或PC也可以通过ip+端口号访问。\n\nproxy，设置代理，是为了解决跨域的问题。\n\n### 生产环境\n```\nnpm run build\n```\n该命令会将所有文件打包，并放在dist目录下。\n#### 配置nginx，设置反向代理，解决跨域问题，（数据用的酷狗的）\n安装好nginx，找到nginx.conf，并添加如下代码（与默认80端口的server同级，这里只列出了主要的配置项）\n```\nserver {\n    #端口号\n    listen 8666;\n    #项目根目录位置\n    root E:/r-music/dist\n    #访问首页文件\n    location / {\n        index index.html\n\t      try_files $uri  /index.html    // 解决刷新页面404问题\n   }\n    #缓存静态文件，30d表示30天，可按需调整大小\n    location ~ ^/(images|javascript|js|css|flash|media|static)/ {\n        expires 30d; \n    }\n    #设置代理，解决跨域\n    location ^~/kugou/{\n      rewrite ^/kugou/(.*)$ /$1 break;\n      proxy_pass http://m.kugou.com;\n    }\n    \n    location ^~/ad/{\n      rewrite ^/ad/(.*)$ /$1 break;\n      proxy_pass http://ads.service.kugou.com;\n    }\n    \n    location ^~/musicSearch/{\n      rewrite ^/musicSearch/(.*)$ /$1 break;\n      proxy_pass http://mobilecdn.kugou.com;\n    }\n}\n```\n重启nginx即可\n```\nnginx -s reload\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscorpionjay%2Fr-music","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscorpionjay%2Fr-music","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscorpionjay%2Fr-music/lists"}