Implementation Roadmap of Login
The first is to take a look at the form of the interface given by the background and the request method. The account password must be sent to the background according to the rules to verify whether the account password is correct. If there is an error, if the background returns the token value correctly, Then, we need to store the token value locally, and when switching to the function page, we need to remind the user that the login is successful. In addition, each time when switching the page, we need to check whether the current token is still valid. If not, we need to remind the user and return to the login login page again. Log in again and return a new token value.
Search implementation idea
Have a look at the background to the interface of the form, and request, and then retrieve a value from the input value, the value request interface to the background, the background will be received value, and do a comparison, the data will be qualified data, returns, we just need to render the data returned to a person, if the input events like after If the server is under high pressure, we can use anti-shake and throttling to reduce the pressure on the server.
Add user implementation ideas
First of all is to have a look at the background to the interface of the form, and request, we need to add a user data according to certain format to the background, successful background will give the data include a unique id, and return a status code of success of forward, we can judge a status code is successful, will once again request a list of users interface, the user to update to the front desk On the view
An implementation idea for modifying state
In this article is to modify a data item, must first confirm that a modify, because the inside of the each item has a unique id, we modify the request of the state of the interface, with the unique id, and the modified state, to the background, this time, we don’t have any problem to the data, the background will also return to us a co request is successful De value, this time we make a judgment, do a success or failure of the prompt.
Example Modify user information
This article is to modify a data, to confirm that a modify, because the inside of the each item has a unique id, we modify the request of the state of the interface, with the unique id, and each item to be modified, the background after return a status code, we can judge a status code is successful, will once again request a list of users interface, update to the front desk on the view of the user If it is wrong, it will be prompted.
Delete user
Get the unique ID of the current data to the background, the background will delete this data, we request the user interface again, a synchronization of the view is ok.
Assigning user Roles
First have to know that a user to be assigned, is also the only to get to the current user id, in person is knowing where to assign to the current user, this time will request assigned user list, we selected from the list that we need to change to a, the id, rids, together to the background, this time we in the background to the code value To check if we have allocated successfully, success is updated to the view, failure is prompted
Unified encapsulation of AXIOS
Encapsulation axios is convenient to one of our projects in the late maintenance, the first is axios encapsulation interceptors, containing request interceptor, and response interceptors, request interceptor is data haven’t request as background, we can be set in this function we want to add public parameters, or the header is the first class, etc., the response to a stop The interceptor is the data that has been requested and we can make a judgment in this to return the data that we can use…. Create an API file import interceptor, request all interfaces here, for the purpose of easy maintenance, export an export, import where we need to call the interface can be used