An open API service indexing awesome lists of open source software.

https://github.com/rimsila/next-dev-template

An out-of-box UI solution for enterprise applications as a React boilerplate using React 17x, typescript 4x, umi 3x antd 4.x ,ahooks , antd pro-component and @next-dev library (core/component/hooks/provider).
https://github.com/rimsila/next-dev-template

antd cli dev-boilerplate enterprise-applications react-generator-cli umi

Last synced: 4 months ago
JSON representation

An out-of-box UI solution for enterprise applications as a React boilerplate using React 17x, typescript 4x, umi 3x antd 4.x ,ahooks , antd pro-component and @next-dev library (core/component/hooks/provider).

Awesome Lists containing this project

README

        

Welcome to Next-dev-Boilerplate

An out-of-box UI solution for enterprise applications as a React boilerplate using React 17x, typescript 4x, [umi 3x](https://umijs.org/docs#create-react-app) antd 4.x ,ahooks , antd pro-component and @next-dev library (core/component/hooks/provider).

An out-of-box UI solution for enterprise applications as a React boilerplate.

![Github Action](https://github.com/ant-design/ant-design-pro/workflows/Node%20CI/badge.svg) ![Deploy](https://github.com/ant-design/ant-design-pro/workflows/Deploy%20CI/badge.svg) [![Dependencies](https://img.shields.io/david/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro) [![Gitter](https://img.shields.io/gitter/room/ant-design/pro-english.svg?style=flat-square&logoWidth=20&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgd2lkdGg9IjEyMzUiIGhlaWdodD0iNjUwIiB2aWV3Qm94PSIwIDAgNzQxMCAzOTAwIj4NCjxyZWN0IHdpZHRoPSI3NDEwIiBoZWlnaHQ9IjM5MDAiIGZpbGw9IiNiMjIyMzQiLz4NCjxwYXRoIGQ9Ik0wLDQ1MEg3NDEwbTAsNjAwSDBtMCw2MDBINzQxMG0wLDYwMEgwbTAsNjAwSDc0MTBtMCw2MDBIMCIgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjMwMCIvPg0KPHJlY3Qgd2lkdGg9IjI5NjQiIGhlaWdodD0iMjEwMCIgZmlsbD0iIzNjM2I2ZSIvPg0KPGcgZmlsbD0iI2ZmZiI%2BDQo8ZyBpZD0iczE4Ij4NCjxnIGlkPSJzOSI%2BDQo8ZyBpZD0iczUiPg0KPGcgaWQ9InM0Ij4NCjxwYXRoIGlkPSJzIiBkPSJNMjQ3LDkwIDMxNy41MzQyMzAsMzA3LjA4MjAzOSAxMzIuODczMjE4LDE3Mi45MTc5NjFIMzYxLjEyNjc4MkwxNzYuNDY1NzcwLDMwNy4wODIwMzl6Ii8%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzIiB5PSI0MjAiLz4NCjx1c2UgeGxpbms6aHJlZj0iI3MiIHk9Ijg0MCIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgeT0iMTI2MCIvPg0KPC9nPg0KPHVzZSB4bGluazpocmVmPSIjcyIgeT0iMTY4MCIvPg0KPC9nPg0KPHVzZSB4bGluazpocmVmPSIjczQiIHg9IjI0NyIgeT0iMjEwIi8%2BDQo8L2c%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzOSIgeD0iNDk0Ii8%2BDQo8L2c%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzMTgiIHg9Ijk4OCIvPg0KPHVzZSB4bGluazpocmVmPSIjczkiIHg9IjE5NzYiLz4NCjx1c2UgeGxpbms6aHJlZj0iI3M1IiB4PSIyNDcwIi8%2BDQo8L2c%2BDQo8L3N2Zz4%3D)](https://gitter.im/ant-design/pro-english?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)[![Build With Umi](https://img.shields.io/badge/build%20with-umi-028fe4.svg?style=flat-square)](http://umijs.org/) ![](https://badgen.net/badge/icon/Ant%20Design?icon=https://gw.alipayobjects.com/zos/antfincdn/Pp4WPgVDB3/KDpgvguMpGfqaHPjicRK.svg&label)

![](https://user-images.githubusercontent.com/8186664/44953195-581e3d80-aec4-11e8-8dcb-54b9db38ec11.png)

# Contents

- [Project Structure](#Structure)
- [Doc and Demo](#Document)
- [Features](#Features)
- [Installations](#Installation)
- [Development / Script](#Development)
- [Generator Antd Pro Templates](#Templates)
- [Custom Generator CLI](#Generator/CLI)
- [Tutorial / Usage](#Tutorial)
- [Contributing](#Contributing)

## Features

[Back Contents](#Contents)

- :bulb: **TypeScript**: A language for application-scale JavaScript
- :scroll: **Blocks**: Build page with block template
- :gem: **Neat Design**: Follow [Ant Design specification](http://ant.design/)
- :triangular_ruler: **Common Templates**: Typical templates for enterprise applications
- :rocket: **State of The Art Development**: Newest development stack of React/umi/dva/antd
- :iphone: **Responsive**: Designed for variable screen sizes
- :art: **Theming**: Customizable theme with simple config
- :globe_with_meridians: **International**: Built-in i18n solution
- :gear: **Best Practices**: Solid workflow to make your code healthy
- :1234: **Mock development**: Easy to use mock development solution
- :white_check_mark: **UI Test**: Fly safely with unit and e2e tests

## Document

[Back Contents](#Contents)

- next-dev-boilerplate Preview: https://next-dev-boilerplate.vercel.app the every first time it will slow and it will remove photo except db we store on MLab and token because we use `Heroku` as free services.
- next-dev library(processing): https://rimsila.github.io/next-dev/
- Antd Pro Preview: https://preview.pro.ant.design/
- Antd Pro Documentation: http://pro.ant.design/docs/getting-started -Antd Pro FAQ: http://pro.ant.design/docs/faq

## Installation

[Back Contents](#Contents)

- `Node Js`: required >=10.x: it is a JavaScript runtime environment download [Here](https://nodejs.org/en/download/).

- `Yarn`: is package manager. shouldn't use mixup with npm the same one project.

```bash
$ npm install -g yarn
```

- `serve`: for run production local.
```bash
$ yarn global add serve
```
- `Yalc`: (required only who want to develop library see in .yalc folder) for develop npm library local and it separate project library (next-dev).

```bash
$ yarn global add yalc
```

- `yeoman generator`: (required only who want to use CLI auto crete starter template)
```bash
$ yarn global add yo
```

## Development

[Back Contents](#Contents)

use Gitpod, a free online dev environment for GitHub.

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/rimsila/next-dev-boilerplate)

Or clone locally:

```bash
$ git clone https://github.com/rimsila/next-dev-boilerplate.git
$ cd next-dev-boilerplate

# install project node_module
$ yarn install

# start development
$ yarn start

```

Open your browser and visit http://127.0.0.1:9000 or http://localhost:9000

## Templates

[Back Contents](#Contents)

```
- Dashboard
- Analytic
- Monitor
- Workspace
- Form
- Basic Form
- Step Form
- Advanced From
- List
- Standard Table
- Standard List
- Card List
- Search List (Project/Applications/Article)
- Profile
- Simple Profile
- Advanced Profile
- Account
- Account Center
- Account Settings
- Result
- Success
- Failed
- Exception
- 403
- 404
- 500
- User
- Login
- Register
- Register Result
```

- Usage Template

```bash
$ yarn create umi # or npm create umi

# Choose ant-design-pro:
Select the boilerplate type (Use arrow keys)

block - Create a umi block.
library - Create a library with umi.
plugin - Create a umi plugin.

```

## Generator/CLI

[Back Contents](#Contents)

-(coming soon)

- we using Yeoman generator for build different React components, creating a skeleton for the different files.

- create page with auto config route / page access / locale

```bash
yarn page
```

- create model / CRUD

```bash
yarn model
or
yarn modelCr
```

- create service / CRUD

```bash
yarn com
```

- create global component / specifics page folder / locale

```bash
yarn com
```

## Structure

[Back Contents](#Contents)

```
Next-Dev-Boilerplate
|
├── config -- Configuration files (routes, themes, plugins, etc.)
│ └── plugin.config.ts --Plug-in configuration (such as less merge, unpacking)
│ └── router.ts --Routing configuration (route, access page etc.)
│ └── theme.config.ts --Theme configuration
│ └── defaultSettings.ts - layout (theme color, title, whether to enable pwa, icon remote ,address)
|
├── src
│ ├── components
│ │ │
│ │ ├── global -- For global component like button, tabs etc.
│ │ │ └── Button
│ │ │ ├── index.tsx
│ │ │ └── SubButton.tsx
│ │ │
│ │ └── pages -- Components for specific page also can share for another page
│ │ │ ├── auth
│ │ │ │ └── login
│ │ │ │ └── index.tsx
│ │ │ │ └── subLogin
│ │ │ │ └── SubLogin.tsx
│ │ │ └── dashboard
│ │ │ └── index.tsx
│ │ │ └── useDashBoard.tsx -- can use inline custom hook for logic
│ │ │ └── report
│ │ │ └── SubReport.tsx
│ │ └──index.ts -- export both components and pages as global share
│ │
│ └── hooks -- common custom hook (router etc )
│ └── utils --common utilize (request,func, also extend from @next-dev/core)
│ └── locales-- i18n localization (common locale can extend from @next-dev/provider)
│ └── typings.d.ts -- global type for whole project
│ └── themes -- style variable, mixin (can extend from @next-dev/component/styles)
│ └── constants -- all constants common use here (env , routeApi, routePath)
│ └── assets --resource file (image,font etc.)
│ └── global.less -- global style file (will be automatically use)
│ │
│ └── pages -- import page from component/pages it already dynamic import in config
│ │ ├── document.ejs -- the same CRA public/index.html
│ │ ├── login
│ │ ├── dashboard
│ │ └─ 404.tsx --page not found
│ │
│ └── models -- global model start with useName (context with selector avoid re-render)
│ └── services -- all api services here (services/userApi.ts)
│ └── e2e -- e2e test
│ └── app.tsx -- Root app but work only runtime (init core / provider / initGlobal State /layout)
│ └── access.ts -- authority role permission to page
│ └── wrappers -- is a HOC we use in route.ts

└── .umirc.ts -- Project Configuration also import from config
└── tsconfig.jsons -- config for ts compile
└── .env

```

## 🖥 Environment Support

[Back Contents](#Contents)

- Modern browsers and Internet Explorer 11 (with [polyfills](https://stackoverflow.com/questions/57020976/polyfills-in-2019-for-ie11))
- Server-side Rendering
- [Electron](https://www.electronjs.org/)

| [IE / Edge](http://godban.github.io/browsers-support-badges/)
IE / Edge | [Firefox](http://godban.github.io/browsers-support-badges/)
Firefox | [Chrome](http://godban.github.io/browsers-support-badges/)
Chrome | [Safari](http://godban.github.io/browsers-support-badges/)
Safari | [Electron](http://godban.github.io/browsers-support-badges/)
Electron |
| --- | --- | --- | --- | --- |
| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions |

## Contributing

[Back Contents](#Contents)

Any type of contribution is welcome, here are some examples of how you may contribute to this project:

- Use Ant Design Pro in your daily work.
- Submit [issues](https://github.com/rimsila/next-dev-boilerplate/issues) to report bugs or ask questions.
- Propose [pull requests](https://github.com/rimsila/next-dev-boilerplate/pulls) to improve our code.

## Tutorial

[Back Contents](#Contents)

### State Management / useRequest + Axios

- `useRequest + nextRequest( Custom Axios)`: useRequest with ahook provided loading refetch,data,onSuccess, onError etc and `nextRequest` it a utilize base on `Axios` it include global handler error and success, refresh token, global auth header, etc.
- `Example`

```tsx
//services/global.d.ts
export type IRegister = {
email: string;
password: string;
};

//services/users.ts
import { httpRequest } from '@/utils/httpRequest';

export const usersApi = {
register: (data: IRegister) => nextRequest.post("user/register, data),
};

//see the usage in Global State section

```

- Global State

- `useModel` must be inside folder model: it is a custom hooks that provide developer the ability to consume hooks model as global state and it can better performance with re-render on demand by it will select only what we need see the example bellow:

```tsx | pure
//models/useAuth.tsx see full example in folder model
export default function useAuthModel() {
/**
* register then redirect to login page
*/

// * ------------ request async --------------
const {
run: runRegister, // call func with param of register api
data: registerData,
loading: loadingRegister, //loading
refresh: refreshRegister, // re-call runRegister
} = useRequest(usersApi.register, {
manual: true, // call runRegister manual
onSuccess: (res) => {
if (res?.status === 1) {
history.push('/login');
}
},
});

// * ------------ onSubmitRegister --------------
const onSubmitRegister = (value: any) => {
const registerModel = {
fullName: value?.user,
email: value?.email,
password: value?.password,
confirmPassword: value['confirm-password'],
};
runRegister(registerModel);
};

return {
onSubmitRegister,
registerData,
loadingRegister,
};
}

//page/register.tsx
import { useModel } from 'umi';

/** @note
* useModel(name of file in model folder)
* for better performance should user updater function (like redux-selector) like bellow it will select
* only what we need to re-render on demand
*/
const { loadingRegister, logOut } = useModel('useAuth', (model) => ({
loadingRegister: model.loadingRegister,
logOut: model.logOut,
}));

//usage in component
console.log(loadingRegister);
//output: false->true->false
Log out;
```