前言本篇开始做 「网易云音乐PC」我的项目,倡议最好有以下根底react、redux、redux-thunk、react-router,上一章只是对我的项目进行初步介绍意识,本章节会带你实现:网易云的根本骨架构造并实现应用redux-immutable重构redux
<details><summary>本章节实现后果如下</summary>
<img src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/f6680e5c03844424827672caa46dabba~tplv-k3u1fbpfcp-zoom-1.image" style="zoom:80%;" /></details>
我的项目初始化前言-vscode&chrome插件(可选)如果曾经装置过了能够抉择跳过,以下都是可选的,当然不装置也没问题为了更便捷的开发我的项目,举荐装置以下vscode插件
ESLint: 代码格调查看工具,帮忙咱们标准代码书写vscode-styled-components: 在编写styled-components中语法高亮显示和款式组件的path-alias: 别名门路有对应的智能提醒ES7 React/Redux/GraphQL/React-Native snippets: 代码片段chrome插件
Redux DevTools: 不便调试redux数据FeHelper: 对服务器返回的json数据进行丑化1.我的项目目录划分应用create-react-app脚手架初始化我的项目构造: create-react-app music163_xxx目录构造也能够依照本人习惯的构造来划分│─src ├─assets 寄存公共资源css和图片 ├─css 全局css ├─img ├─common 公共的一些常量 ├─components 公共组件 ├─pages 路由映射组件 ├─router 前端路由配置 ├─service 网络配置和申请 └─store 全局的store配置 └─utils 工具函数 └─hooks 自定义hook2.我的项目款式抉择我的项目款式重置抉择:
[ ] reset.css[x] normalize.css + custom.css(也就是自定义的css)装置normalize.css: yarn add normalize.css
在全局css文件引入: src->assets->css-> normalize.css↓首先下载我的项目资源(都是我的项目应用到的一些背景图和精灵图)
如果下载github文件慢,参考我的这篇文章减速????加载文件上面的全局CSS是用于页面初始化,如果你的css把握的不错,那么倡议间接拷贝????
将上面????css拷贝到全局自定义的css文件当中(src -> assets -> css -> reset.css)定义的挺多的都是一些精灵图背景精灵图的类名都是对应的图片文件名/* reset.css (自定义的css) */@import '~normalize.css';/* 后续有阐明,先跳过即可(装置完antd再导入的) *//* @import '~antd/dist/antd.css'; *//* 款式的重置 */body, html, h1, h2, h3, h4, h5, h6, ul, ol, li, dl, dt, dd, header, menu, section, p, input, td, th, ins { padding: 0; margin: 0;}ul, ol, li { list-style: none;}a { text-decoration: none; color: #666;}a:hover { color: #666; text-decoration: underline;}i, em { font-style: normal;}input, textarea, button, select, a { outline: none; border: none;}table { border-collapse: collapse; border-spacing: 0;}img { border: none; vertical-align: middle;}/* 全局款式 */body, textarea, select, input, button { font-size: 12px; color: #333; font-family: Arial, Helvetica, sans-serif; background-color: #f5f5f5;}.text-nowrap { white-space: nowrap; text-overflow: ellipsis; overflow: hidden;}.w1100 { width: 1100px; margin: 0 auto;}.w980 { width: 980px; margin: 0 auto;}.text-indent { text-indent: -9999px;}.inline-block { display: inline-block;}.sprite_01 { background: url(../img/sprite_01.png) no-repeat 0 9999px;}.sprite_02 { background: url(../img/sprite_02.png) no-repeat 0 9999px;}.sprite_cover { background: url(../img/sprite_cover.png) no-repeat 0 9999px;}.sprite_icon { background: url(../img/sprite_icon.png) no-repeat 0 9999px;}.sprite_icon2 { background: url(../img/sprite_icon2.png) no-repeat 0 9999px;}.sprite_button { background: url(../img/sprite_button.png) no-repeat 0 9999px;}.sprite_button2 { background: url(../img/sprite_button2.png) no-repeat 0 9999px;}.sprite_table { background: url(../img/sprite_table.png) no-repeat 0 9999px;}.my_music { background: url(../img/mymusic.png) no-repeat 0 9999px;}.not-login { background: url(../img/notlogin.jpg) no-repeat 0 9999px;}.image_cover { position: absolute; left: 0; right: 0; top: 0; bottom: 0; text-indent: -9999px; background: url(../img/sprite_cover.png) no-repeat -145px -57px;}.sprite_player { background: url(../img/playbar_sprite.png) no-repeat 0 9999px;}.lyric-css .ant-message-notice-content { position: fixed; left: 50%; bottom: 50px; transform: translateX(-50%); background-color: rgba(0,0,0,.5); color: #f5f5f5;}.wrap-bg2 { background: url(../img/wrap3.png) repeat-y center 0;;}3.配置门路别名第一步:装置craco:
...