Commit 337715d2 authored by jason.xing's avatar jason.xing

init

parent e868d298
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). ### 环境
## Available Scripts * node v10.15.3
* npm v6.4.1
* ant v3.18.1
* react v16.8.3
* mobx v5.9.4
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.<br> ### 脚手架
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br> * [Create React App](https://github.com/facebook/create-react-app)
You will also see any lint errors in the console.
### `npm test` * 启动打包方式
Launches the test runner in the interactive watch mode.<br> ```bash
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. # 项目启动
npm run start
# 项目打包
npm run build
```
### `npm run build`
Builds the app for production to the `build` folder.<br>
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.<br> ### webpack config
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. * 配置文件 /config-overrides.js
* 自定义的webpack配置参考 [customize-cra](https://github.com/arackaf/customize-cra) 文档
* 暴露[Create React App](https://github.com/facebook/create-react-app) webpack配置 npm eject(强烈不推荐暴露)
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. ### 多语言
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. * plugin [i18next](https://www.i18next.com/) [react-i18next](https://react.i18next.com/)
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. * 使用方式
1. src/i18n文件夹下添加语言文件,例 zh_Hans.js
2. src/i18n/i18n.js 引入上面添加的语言文件,并注入 resource
3. 语言切换和语言模块使用方式参考 [react-i18next](https://react.i18next.com/)
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/). ### 路由配置
### Code Splitting * plugin [react router v4](https://reacttraining.com/react-router/web/guides/quick-start)
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting * 添加路由 src/router/navRouter中配置路由信息
### Analyzing the Bundle Size ```javascript
{
key: 'overall',
name: '总览',
path: '/overall',
icon: 'home',
hidden:true,
permission:[], // 填入当前路由需要的权限 当不满足权限
component: Loadable({
loader: () => import('../page/overall/overall'),
loading: () => <JFLoading/>
}),
routes:[ // menu的二级菜单 当设置二级菜单时 一级菜单的链接失效
...
]
}
```
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
### Making a Progressive Web App
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
### Advanced Configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration ### 数据管理
### Deployment * 引入[mobx](https://cn.mobx.js.org/)工具, 借助[mobx-react](https://github.com/mobxjs/mobx-react)与react结合使用
* 装饰器([Decorator](http://es6.ruanyifeng.com/#docs/decorator))文档
* mobx store创建方式
* /src/store文件夹下创建对应界面的store(理论上每个界面对应一个store)
* 将上面创建的store在index.js中导出
```javascript
export {overallStore} from "./overallStore";
```
* 修改store中的属性的方法必须使用 @action 进行修饰
```javascript
@action
test = () => {
this.count++;
};
```
* 异步方法在mobx中的处理方式使用 generator的方式
```javascript
// 设置选中的site
@action
setSelectedSite = flow(function* (site){ // 使用mobx提供的flow方法包装generator
this.selectedSite = site;
this.layoutLoading = true;
try{
let siteDetail = yield this._getSiteDetail(site.siteId);
this.siteDetail = siteDetail.data;
}catch (e) { // 使用try catch 捕获异步请求的异常
Message.alert(e);
}
this.layoutLoading = false;
}.bind(this)); // 使用bind this 将generator与当前类的实例进行绑定
```
### css编写
* 项目中所有的css均通过[sass](https://sass-lang.com/guide)语法进行编写
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
### `npm run build` fails to minify
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
...@@ -8,7 +8,7 @@ import { Provider } from 'mobx-react'; ...@@ -8,7 +8,7 @@ import { Provider } from 'mobx-react';
import { rootRouter } from './router/rootRouter'; import { rootRouter } from './router/rootRouter';
import NotFound from './page/404'; import NotFound from './page/404';
import {routerStore} from "./store/routerStore"; import {routerStore} from "./store/routerStore";
import mobxStore from './store/index'; import * as mobxStore from './store/index';
const history = syncHistoryWithStore(browserHistory, routerStore); const history = syncHistoryWithStore(browserHistory, routerStore);
......
import {routerStore} from "./routerStore"; export {routerStore} from "./routerStore";
import {userStore} from "./userStore"; export {userStore} from "./userStore";
import {appStore} from "./appStore"; export {appStore} from "./appStore";
import {overallStore} from "./overallStore"; export {overallStore} from "./overallStore";
export default {
appStore,
routerStore,
userStore,
overallStore
};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment