Preface
Recently I wrote a background template with react
Client: github.com/Liangzhenqu...Server : github.com/Liangzhenqu...The client mainly uses the following:
- react
- react-router-dom - routing
- antd --UI
- fetch - request, can customize interception and response timeout.
- normalize.css - Smooth out browser differences
- nprogress - loading progress bar at the top, here I use it with Suspense
- customize-cra and react-app-rewired - do not expose configuration items under webpack configuration, mainly configure antd's global theme
- babel-plugin-import --antd load on demand
- eslint and prettier - specification code (vscode is required to install the plugin) More details can be viewed on GitHub
Focus on
- Route configuration, if no route is found, it will jump to 404 page
- token, determine whether you have permission to enter the system through the token obtained after logging in
- Judge whether the token is valid, if the token is invalid, it will jump to the login page
- Fetch interception, realize the unified addition of token to the request body and state processing after response interception
server side
The server side is a simple routing configuration and token generation
- 1. After the client requests, find out whether the user has a database, and then perform some encryption
- 2. Send the token to the client
summary
I just combined the knowledge I have learned and simply matched a template framework. There are many aspects that have not been handled well, mainly for some novices and peers. I feel good star, prevent getting lost, and welcome everyone to correct me.