# 弘则研究买方研选平台前端 v1.0

该项目致力于构建一个数据分析、研究输出、逻辑沉淀、知识管理的投研平台。项目前端基于 React17 构建，UI 组件库使用 Antd

## 编码规范

参考 `.eslintrc.js` 及 `.prettierrc.js` 中的预设

```
[
   'react-app', // default from cra
    'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
    'plugin:@typescript-eslint/recommended', // Uses the recommended rules from @typescript-eslint/eslint-plugin
    'plugin:react-hooks/recommended', // Uses the recommended rules from react-hooks
    'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
    'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
  ]
```

### 组件

- 一律使用函数组件，禁止使用类组件

- 一律使用 hooks

- 原则上一个文件只写一个组件

- 组件 props 必须以 Interface 的形式显式声明

### 代码风格

- 两格缩进

- 不使用分号

- 一律使用箭头函数而非函数表达式

### 其他请参考

- [TypeScript Handbook（中文版）](https://zhongsp.gitbooks.io/typescript-handbook/content/doc/wiki/coding_guidelines.html)
- [Airbnb React/JSX Style Guide](https://github.com/airbnb/javascript/tree/master/react)

## 参考文档

## 项目规范

- 版本管理系统基于[Git](https://git-scm.com/book/zh)工作流模式[GitHub flow](https://guides.github.com/introduction/flow/)
- 项目包括
  - 两个长期分支（basic branch） - master：主分支，用于线上生产环境 - debug：开发分支，包括新开发及不稳定特性
    **长期分支仅项目负责人可操作**
  - 若干功能分支（feature branch） - author_feature：成员 author 处理 feature 的分支 - zk_route：成员 zk 处理路由系统的分支 - ...
    **功能分支以 author_feature 的规则命名，项目成员可操作**

工作流为

1. **团队**讨论并提出 feature/bug，**项目负责人**在 mfyx 项目中建立 issue，并标记相应标签
2. **团队**基于项目进度和优先级考虑确定工作内容，**项目负责人**将`To Do`版相应 issue 手动移至`In Process`版中，并 assign 对应成员推进
3. 相应**成员**在 develop 分支检出新分支 author_feature，并在此分支进行开发工作
4. **成员**开发时需编写对应测试代码，遵循代码规范（如在开发过程中 develop 分支更新，并且更新存在对此特性的影响，建议拉取 develop 后 merge 同步）
5. **成员**完成功能后，在准备提交 Pull Request 前，保证代码通过测试并通过 lint 检查
6. **成员**提交 Pull Request 并链接对应 issue（此时`In Process`版中的 issue 将会自动迁移到`Review In Process`）
7. **项目负责人**review 此 Pull Request， 经过 review-suggestion-change-commit-push-review-...的流程后，**项目负责人**merge PR 或者关闭 PR（此时`Review In Process`版中 issue 将会自动迁移到`Done`，并关闭 issue）
8. **成员**删除本地及远程 author_feature 分支

## Available Scripts

首先添加 `.env.development` 文件，并设置`API_BASEURL`属性，用于实例化`axios instance`，后端地址暂为`http://192.168.200.166:2999/api/`

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
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.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `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.

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.
