All Projects → ScorpionJay → r-music

ScorpionJay / r-music

Licence: other
react music demo

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to r-music

vue2-element
基于vue2 + vue-router2 + element-ui + vuex2 + fetch + webpack2 企业级后台管理系统最佳实践
Stars: ✭ 115 (+101.75%)
Mutual labels:  fetch, webpack2
react-express-mongodb
基于react全家桶+antd design+webpack2+node+express+mongodb开发的前后台博客系统
Stars: ✭ 26 (-54.39%)
Mutual labels:  fetch, webpack2
Vue2 Element
基于vue2 + vue-router2 + element-ui + vuex2 + fetch + webpack2 企业级后台管理系统最佳实践
Stars: ✭ 112 (+96.49%)
Mutual labels:  fetch, webpack2
react-flight-indicators
Lightweight and simple Flight instruments/indicators written in React.
Stars: ✭ 16 (-71.93%)
Mutual labels:  webpack2
tech1-temple-javascript
JavaScript Proofs of Concepts repository. No Longer Supported
Stars: ✭ 61 (+7.02%)
Mutual labels:  webpack2
fetch-reject
Simple wrapper for fetch which rejects on HTTP error
Stars: ✭ 70 (+22.81%)
Mutual labels:  fetch
super-minimal-aurelia
A barebones Aurelia + webpack2 build
Stars: ✭ 19 (-66.67%)
Mutual labels:  webpack2
use-async-resource
A custom React hook for simple data fetching with React Suspense
Stars: ✭ 92 (+61.4%)
Mutual labels:  fetch
webpack-starter
'Just Add Water' Webpack 2, babel and glslify gourmet mix.
Stars: ✭ 13 (-77.19%)
Mutual labels:  webpack2
react-native-fetch
🌍Fetch API wrapped as a component with support for retries & timeouts
Stars: ✭ 20 (-64.91%)
Mutual labels:  fetch
vscode-exts
Visual Studio Code Extensions
Stars: ✭ 33 (-42.11%)
Mutual labels:  webpack2
Fetch
Asynchronous HTTP client with promises.
Stars: ✭ 29 (-49.12%)
Mutual labels:  fetch
micro-cacheable
A micro utility for data caching
Stars: ✭ 35 (-38.6%)
Mutual labels:  fetch
rxrest
Reactive rest library
Stars: ✭ 33 (-42.11%)
Mutual labels:  fetch
yafetch
Yet another fetch ...
Stars: ✭ 27 (-52.63%)
Mutual labels:  fetch
modular
Scaffold a react monorepo and its component parts.
Stars: ✭ 13 (-77.19%)
Mutual labels:  webpack2
fennch
Modern fetch-based axios-like HTTP client for the browser and node.js
Stars: ✭ 12 (-78.95%)
Mutual labels:  fetch
bower-resolve-webpack-plugin
Offers an enhanced bower support for enhanced-resolve plugin.
Stars: ✭ 12 (-78.95%)
Mutual labels:  webpack2
firebase-ignite
Firebase PWA Boilerplate
Stars: ✭ 12 (-78.95%)
Mutual labels:  webpack2
awesome-fetch
Command-line fetch tools for system/other information
Stars: ✭ 177 (+210.53%)
Mutual labels:  fetch

music

扫码体验

http://cenuon.com:8666

http://cenuon.com:8666

部分截图

干货:项目说明

技术栈

react + react-router + redux + webpack + ES6 + fetch + sass + flex

项目结构

r-music
│  .babelrc
│  .eslintrc.js
│  .gitignore
│  package.json
│  README.md
│  server.js                    //node启动脚本
│  webpack.config.js            
│  
├─config
│      webpack.dev.js           //开发环境的webpack配置文件
│      webpack.hash.js          //开发环境的webpack配置文件
│      webpack.prod.js          //生产环境的webpack配置文件
│           
└─src
    │  api.js                   //封装的fetch
    │  app.js                   
    │  config.js                //api接口配置文件
    │  index.hash.js
    │  index.js
    │  index.temp.hash.html
    │  index.temp.html
    │  routers.js               //路由
    │  storage.js               //window.localStorage的各种方法
    │      
    ├─components               //组件
    │          
    ├─containers               //页面
    │      account.js
    │      album.js
    │      friend.js
    │      home.js
    │      music.js
    │      play.js
    │      
    ├─images
    │      favicon.ico
    │      
    ├─json
    │      home.json
    │       
    ├─actions                 //redux -- action
    │      album.js
    │      dialog.js
    │      home.js
    │      .
    │      .     
    ├─reducers                //redux -- reducer
    │      album.js
    │      dialog.js
    │      home.js
    │      index.js
    │      login.js
    │      message.js
    │      music.js
    │      spin.js
    │      user.js
    │      
    stores                     //redux  -- store
    │      index.js
    │      
    └─sass                    //样式文件
            common.scss
            home.scss
            login.scss
            main.scss
            pagination.scss
            slider.scss
            

项目运行

git clone https://github.com/ScorpionJay/r-music.git
cd r-music
npm install

本地开发环境

npm run dev

该命令在package.json的scripts中,即"dev": "webpack-dev-server --config webpack.config.js --hot",启动一个服务。 如果一切正常,会自动打开浏览器并访问http://localhost:9999

// config/webpack.dev.js部分代码
        devServer: {
            contentBase: "./src",//本地服务器所加载的页面所在的目录
            historyApiFallback: true,//不跳转
            inline: true,//实时刷新
            host: '0.0.0.0',
            port:9999,
            // 设置代理
            proxy:{
                "/kugou": {
                    target: "http://m.kugou.com",
                    changeOrigin: true,
                    pathRewrite: {"^/kugou" : ""}
                }
            }
        }

因为在 config/webpack.dev.js 设置了host:'0.0.0.0',所以同局域网的其他手机或PC也可以通过ip+端口号访问。

proxy,设置代理,是为了解决跨域的问题。

生产环境

npm run build

该命令会将所有文件打包,并放在dist目录下。

配置nginx,设置反向代理,解决跨域问题,(数据用的酷狗的)

安装好nginx,找到nginx.conf,并添加如下代码(与默认80端口的server同级,这里只列出了主要的配置项)

server {
    #端口号
    listen 8666;
    #项目根目录位置
    root E:/r-music/dist
    #访问首页文件
    location / {
        index index.html
	      try_files $uri  /index.html    // 解决刷新页面404问题
   }
    #缓存静态文件,30d表示30天,可按需调整大小
    location ~ ^/(images|javascript|js|css|flash|media|static)/ {
        expires 30d; 
    }
    #设置代理,解决跨域
    location ^~/kugou/{
      rewrite ^/kugou/(.*)$ /$1 break;
      proxy_pass http://m.kugou.com;
    }
    
    location ^~/ad/{
      rewrite ^/ad/(.*)$ /$1 break;
      proxy_pass http://ads.service.kugou.com;
    }
    
    location ^~/musicSearch/{
      rewrite ^/musicSearch/(.*)$ /$1 break;
      proxy_pass http://mobilecdn.kugou.com;
    }
}

重启nginx即可

nginx -s reload
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].