folder structure

After successful initialization, a complete development framework has been generated for you. The following is the directory structure of the entire project, which provides various functions and pits covering middle and back-end development.

โ”œโ”€โ”€ config # umi configuration, including routing, construction and other configurations
โ”œโ”€โ”€ mock # local mock data
โ”œโ”€โ”€ public
โ”‚ โ””โ”€โ”€ favicon.png # Favicon
โ”œโ”€โ”€ src
โ”‚ โ”œโ”€โ”€ assets # Local static resources
โ”‚ โ”œโ”€โ”€ components # Business common components
โ”‚ โ”œโ”€โ”€ e2e # Integration test case
โ”‚ โ”œโ”€โ”€ layouts # General layout
โ”‚ โ”œโ”€โ”€ models # Global dva model
โ”‚ โ”œโ”€โ”€ pages # Business page entry and common templates
โ”‚ โ”œโ”€โ”€ services # Background interface services
โ”‚ โ”œโ”€โ”€ utils # tool library
โ”‚ โ”œโ”€โ”€ locales # Internationalized resources
โ”‚ โ”œโ”€โ”€ global.less # global style
โ”‚ โ””โ”€โ”€ global.ts # Global JS
โ”œโ”€โ”€ tests # test tools
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ package.json

Page code structure recommendation

In order to make the project code organization more standardized and make it easier for development to locate the relevant page component code, we have defined a set of specifications, which are currently only used as recommended guidelines, not mandatory.

src
โ”œโ”€โ”€ components
โ””โ”€โ”€ pages
โ”œโ”€โ”€ Welcome // No other routing components should be included under routing components. Based on this convention, routing components and non-routing components can be clearly distinguished
| โ”œโ”€โ”€ components // You can do more in-depth organization for complex pages, but it is recommended not to exceed three levels
| โ”œโ”€โ”€ Form.tsx
| โ”œโ”€โ”€ index.tsx // code of page component
| โ””โ”€โ”€ index.less // page style
โ”œโ”€โ”€ Order // No other routing components should be included under routing components. Based on this agreement, routing components and non-routing components can be clearly distinguished
| โ”œโ”€โ”€ index.tsx
| โ””โ”€โ”€ index.less
โ”œโ”€โ”€ User
| โ”œโ”€โ”€ components // public component collection under group
| โ”œโ”€โ”€ Login // page under group Login
| โ”œโ”€โ”€ Register // page under group Register
| โ””โ”€โ”€ util.ts // There can be some shared methods here, do not recommend and restrict, do your own organization depending on the business scenario
โ””โ”€โ”€ * // Other page component codes

All routing components (components that will be configured in the routing configuration) are recommended to be flattened to the first level under pages with the big hump name (complex projects can increase the group level and place pages under the group). It is not recommended to nest routing components inside routing components-it is not convenient to distinguish whether a component is a routing component, and it is not convenient to quickly locate the routing component globally.

We recommend splitting routing components into more fine-grained components as much as possible. For components that may be used on multiple pages, we recommend putting them in src/components. For components that are only dependent on a single page, we recommend It can be maintained near the routing component folder.