├── .env ├── .eslintrc.js ├── .gitignore ├── .travis.yml ├── README.md ├── config ├── env.js ├── jest │ ├── cssTransform.js │ └── fileTransform.js ├── paths.js ├── polyfills.js ├── webpack.config.dev.js ├── webpack.config.prod.js └── webpackDevServer.config.js ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo.svg └── manifest.json ├── scripts ├── build.js ├── start.js └── test.js ├── src ├── App.js ├── App.test.js ├── axios │ └── index.js ├── components │ ├── backtotop │ │ ├── Type1.jsx │ │ ├── Type2.jsx │ │ ├── Type3.jsx │ │ └── Type4.jsx │ ├── chart │ │ └── index.jsx │ ├── map │ │ ├── TencentMap.jsx │ │ └── spot_location.png │ ├── taglist │ │ └── index.js │ └── wysiwyg │ │ └── index.js ├── index.css ├── index.js ├── redux │ ├── actions │ │ ├── index.js │ │ ├── login.js │ │ ├── type.js │ │ └── ui.js │ ├── reducers │ │ ├── all.js │ │ └── index.js │ └── store.js ├── registerServiceWorker.js ├── router │ ├── index.js │ └── menus.js ├── utils │ ├── debounce.js │ └── index.js └── views │ ├── components │ ├── backtotop │ │ └── index.js │ ├── chart │ │ ├── keyboard │ │ │ └── index.js │ │ ├── linechart │ │ │ └── index.js │ │ └── mixchart │ │ │ └── index.js │ ├── drag │ │ ├── components │ │ │ ├── Header.jsx │ │ │ ├── LeftItem.jsx │ │ │ └── RightItem.jsx │ │ ├── index.js │ │ ├── index.less │ │ └── server.js │ ├── map │ │ └── index.js │ └── wysiwyg │ │ └── index.js │ ├── dashboard │ ├── chartData.js │ ├── component │ │ ├── AntdCard.jsx │ │ ├── LineChart.jsx │ │ └── PanelGroup.jsx │ ├── index.js │ └── index.module.less │ ├── error │ ├── 401 │ │ └── index.js │ ├── 404 │ │ └── index.js │ └── index.module.less │ ├── form │ └── index.js │ ├── layout │ ├── Content.jsx │ ├── Header.jsx │ ├── index.js │ ├── index.less │ ├── sider │ │ ├── Menu.jsx │ │ └── index.js │ └── tags │ │ ├── component │ │ ├── Dropdown.jsx │ │ └── Tag.jsx │ │ └── index.js │ ├── login │ ├── index.js │ ├── index.less │ └── params.js │ ├── map │ └── index.js │ ├── permission │ ├── intercept │ │ └── index.js │ └── toggle │ │ └── index.js │ └── table │ ├── basic │ └── index.js │ ├── dynamic │ ├── component │ │ ├── FixedTable.jsx │ │ └── SortedTable.jsx │ └── index.js │ └── edit │ └── index.js └── static ├── css ├── main.41f2bccb.css └── main.41f2bccb.css.map ├── dashboard.gif ├── js ├── main.e49e6188.js └── main.e49e6188.js.map ├── login.gif ├── permission.gif ├── table.gif └── tags.gif /.env: -------------------------------------------------------------------------------- 1 | PORT=3303 -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "env": { 3 | "browser": true, 4 | "commonjs": true, 5 | "es6": true 6 | }, 7 | "extends": "eslint:recommended", 8 | "globals": { 9 | "$": true, 10 | "process": true, 11 | "__dirname": true 12 | }, 13 | "parser": "babel-eslint", 14 | "parserOptions": { 15 | "ecmaFeatures": { 16 | "experimentalObjectRestSpread": true, 17 | "jsx": true 18 | }, 19 | "sourceType": "module", 20 | "ecmaVersion": 7 21 | }, 22 | "plugins": [ 23 | "react" 24 | ], 25 | "rules": { 26 | "quotes": [2, "single"], //单引号 27 | "no-console": 0, //不禁用console 28 | "no-debugger":0, //禁用debugger 29 | "no-var": 0, //对var警告 30 | // "semi": [2, "never"], //不强制使用分号 31 | "no-irregular-whitespace": 0, //不规则的空白不允许 32 | "no-trailing-spaces": 1, //一行结束后面有空格就发出警告 33 | "eol-last": 0, //文件以单一的换行符结束 34 | "no-unused-vars": [1, {"vars": "all", "args": "after-used"}], //不能有声明后未被使用的变量或参数 35 | "no-underscore-dangle": 0, //标识符不能以_开头或结尾 36 | // "no-alert": 2, //禁止使用alert confirm prompt 37 | "no-lone-blocks": 0, //禁止不必要的嵌套块 38 | "no-class-assign": 2, //禁止给类赋值 39 | "no-cond-assign": 2, //禁止在条件表达式中使用赋值语句 40 | "no-const-assign": 2, //禁止修改const声明的变量 41 | "no-delete-var": 2, //不能对var声明的变量使用delete操作符 42 | "no-dupe-keys": 2, //在创建对象字面量时不允许键重复 43 | "no-duplicate-case": 2, //switch中的case标签不能重复 44 | "no-dupe-args": 2, //函数参数不能重复 45 | "no-empty": 2, //块语句中的内容不能为空 46 | "no-func-assign": 2, //禁止重复的函数声明 47 | "no-invalid-this": 0, //禁止无效的this,只能用在构造器,类,对象字面量 48 | "no-redeclare": 2, //禁止重复声明变量 49 | "no-spaced-func": 2, //函数调用时 函数名与()之间不能有空格 50 | "no-this-before-super": 0, //在调用super()之前不能使用this或super 51 | "no-undef": 2, //不能有未定义的变量 52 | "no-use-before-define": 0, //未定义前不能使用 53 | "camelcase": 0, //强制驼峰法命名 54 | // "jsx-quotes": [1, "prefer"], //强制在JSX属性(jsx-quotes)中一致使用双引号 55 | "react/display-name": 0, //防止在React组件定义中丢失displayName 56 | "react/forbid-prop-types": [2, {"forbid": ["any"]}], //禁止某些propTypes 57 | "react/jsx-boolean-value": 2, //在JSX中强制布尔属性符号 58 | "react/jsx-closing-bracket-location": 1, //在JSX中验证右括号位置 59 | "react/jsx-curly-spacing": [2, {"when": "never", "children": true}], //在JSX属性和表达式中加强或禁止大括号内的空格。 60 | "react/jsx-indent-props": [1, 4], //验证JSX中的props缩进 61 | "react/jsx-key": 2, //在数组或迭代器中验证JSX具有key属性 62 | "react/jsx-max-props-per-line": [1, {"maximum": 1}], // 限制JSX中单行上的props的最大数量 63 | "react/jsx-no-bind": 0, //JSX中不允许使用箭头函数和bind 64 | "react/jsx-no-duplicate-props": 2, //防止在JSX中重复的props 65 | "react/jsx-no-literals": 0, //防止使用未包装的JSX字符串 66 | "react/jsx-no-undef": 1, //在JSX中禁止未声明的变量 67 | "react/jsx-pascal-case": 0, //为用户定义的JSX组件强制使用PascalCase 68 | "react/jsx-sort-props": 2, //强化props按字母排序 69 | "react/jsx-uses-react": 1, //防止反应被错误地标记为未使用 70 | "react/jsx-uses-vars": 2, //防止在JSX中使用的变量被错误地标记为未使用 71 | "react/no-danger": 0, //防止使用危险的JSX属性 72 | "react/no-did-mount-set-state": 0, //防止在componentDidMount中使用setState 73 | "react/no-did-update-set-state": 1, //防止在componentDidUpdate中使用setState 74 | "react/no-direct-mutation-state": 2, //防止this.state的直接变异 75 | "react/no-multi-comp": 2, //防止每个文件有多个组件定义 76 | "react/no-set-state": 0, //防止使用setState 77 | "react/no-unknown-property": 2, //防止使用未知的DOM属性 78 | "react/prefer-es6-class": 2, //为React组件强制执行ES5或ES6类 79 | "react/prop-types": 0, //防止在React组件定义中丢失props验证 80 | "react/react-in-jsx-scope": 2, //使用JSX时防止丢失React 81 | "react/self-closing-comp": 0, //防止没有children的组件的额外结束标签 82 | "react/sort-comp": 2, //强制组件方法顺序 83 | "no-extra-boolean-cast": 0, //禁止不必要的bool转换 84 | "react/no-array-index-key": 0, //防止在数组中遍历中使用数组key做索引 85 | "react/no-deprecated": 1, //不使用弃用的方法 86 | "react/jsx-equals-spacing": 2, //在JSX属性中强制或禁止等号周围的空格 87 | "no-unreachable": 0, //不能有无法执行的代码 88 | "comma-dangle": 0, //对象字面量项尾不能有逗号 89 | "no-mixed-spaces-and-tabs": 0, //禁止混用tab和空格 90 | "prefer-arrow-callback": 0, //比较喜欢箭头回调 91 | "arrow-parens": 0, //箭头函数用小括号括起来 92 | "arrow-spacing": 0 //=>的前/后括号 93 | }, 94 | "settings": { 95 | "import/ignore": [ 96 | "node_modules" 97 | ] 98 | } 99 | }; -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | */node_modules 6 | client/node_modules 7 | server/node_modules 8 | mqtt/node_modules 9 | 10 | # testing 11 | /coverage 12 | 13 | # production 14 | /build 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | .idea 28 | package-lock.json 29 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "6" 4 | script: 5 | - yarn 6 | - yarn build -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-admin-antd 2 | 3 | ### 前言 4 | 5 | > 基于react和antd的后台管理系统,支持响应式,IE10+ 6 | 7 | - [预览地址](http://www.1994sx.top/react-antd-admin)(已增加响应式,可手机预览😄) 8 | - 该项目基于[create-react-app](https://github.com/facebook/create-react-app)创建 9 | ### 依赖模块 10 | - [react@16.3.2](https://facebook.github.io/react/) 11 | - [react-router@4.2.2](https://react-guide.github.io/react-router-cn/)(注意,v4和v3的使用区别差距较大,坑也比较多,自行斟酌) 12 | - [react-redux]() 状态管理库;用redux-logger打印日志,方便调试;用redux-thunk实现异步操作 13 | - [css-modules@4.7.2](https://react-guide.github.io/react-router-cn/)(避免样式命名冲突,书写方式也更简单 14 | 一般小项目用不到) 15 | - [antd@3.0.1](https://ant.design/index-cn)(蚂蚁金服开源的react ui组件框架,精美简约) 16 | - [axios@0.16.1](https://github.com/mzabriskie/axios)(一个常用的http请求库,可以实现全局请求拦截,响应拦截) 17 | - [echarts@4.1.0](https://github.com/apache/incubator-echarts)(可视化图表,习惯用这个了,同款推荐 [echarts-for-react](https://github.com/hustcc/echarts-for-react)) 18 | - [react-draft-wysiwyg@1.12.13](https://github.com/jpuri/react-draft-wysiwyg)(基于react的富文本封装) 19 | - [react-sortable-hoc@0.7.2](https://github.com/clauderic/react-sortable-hoc)(简单的拖拽模块) 20 | - [react-transition-group@2.3.1](https://github.com/reactjs/react-transition-group)(用来实现过渡效果,如果你用过vue的transition,这玩意也差不多) 21 | - [react-particles-js@2.2.0](https://github.com/Wufe/react-particles-js)(用来实现登录页背景的粒子效果) 22 | 23 | 24 | ### 项目截图 25 | #### 首页 26 |  27 | 28 | #### 标签页缓存功能 29 |  30 | 31 | #### 权限切换 32 |  33 | 34 | #### 登录页 35 |  36 | 37 | #### 表格编辑 38 |  39 | 40 | 41 | 42 | 43 | 44 | ### 代码目录 45 | ```js 46 | +-- build/ ---打包的文件目录 47 | +-- config/ ---npm run eject 后的配置文件目录 48 | +-- node_modules/ ---npm下载文件目录 49 | +-- public/ 50 | | --- index.html ---首页入口html文件 51 | | --- images ---项目图片 52 | +-- src/ ---主要代码 53 | | +-- axios ---http请求库 54 | | | --- index.js 55 | | +-- components ---所有可复用组件,公用组件 56 | | | +-- backtotop ---返回顶部组件 57 | | | | --- ... 58 | | | +-- chart ---图表组件 59 | | | | --- ... 60 | | | +-- taglist --- 标签按钮 61 | | | | --- ... 62 | | | +-- map ---腾讯地图 63 | | | | --- ... 64 | | | +-- wysiwyg --- 富文本 65 | | +-- utils --- 工具文件存放目录 66 | | +-- views --- 路由页面,对应左侧菜单栏,每一个文件夹都是一个页面 67 | | +-- router --- 路由相关 68 | | | +-- index.js --- content视图区的(src/views/layout/Content.jsx)的路由配置 69 | | | | --- ... 70 | | | +-- menus.js --- 左侧菜单栏的路由配置 71 | | | | --- ... 72 | | +-- redux --- 状态管理 73 | | | +-- store.js --- store对象 74 | | | | --- ... 75 | | | +-- action --- 所有action 76 | | | | --- ... 77 | | | +-- reducers --- 所有reducers 78 | | --- App.js --- 组件入口文件 79 | | --- index.js --- 项目入口文件 80 | --- .env --- 启动项目自定义端口配置文件 81 | --- .eslintrc.js --- 自定义eslint配置文件,包括增加的react jsx语法限制 82 | --- package.json 83 | ``` 84 | ### 文档 85 | 86 | #### 路由 87 | 88 | - 路由的跳转事件的三种获取方式 89 | 90 | 1. withRouter 高阶函数 91 | ```js 92 | import { withRouter } from 'react-router-dom' 93 | const Component = props=>{ 94 | const {history} = props 95 | return ( 96 |