Vue and element set up background management system

1. I wrote a login.vue under src to get different users (there are three users a b c) and token) through axios in this component. Then store the token in the cache. Bring this token to you every time you send a request

ask? Is it better to store this token in vuex? .. Can you provide pseudo code if token is placed after vuex, how to write the code of each request header

2. After getting different users above, the left menu of the background management system should display different menus (there is only one level of menu, that is, a father"s menu, a father"s son"s menu)

ask how to write this kind of route. I hope there is a code for reference. The novice asks the master here for advice.

the blog Park found a description of the background project written by someone else, so I didn"t quite understand it, so I came here for help!

Apr.01,2021

1. Why does the token need to put the vuex, front and rear end before the separation of the front and rear end of the login session,? after the front and back end separation, it is obvious that the token corresponding to the sessionStorage is more appropriate, and this is a general solution, otherwise, where would you put the token if you don't use the ng or jquery, used by vue,?
2. If you're just the front end, you can't handle the second problem. The idea can be given to you: this thing is given to you by the back end, the front end calls the API to get the menu, gets the front-end route that the current user can access, and traverses it.


vuex refresh page to retrieve token? For example, https://panjiachen.github.io/. has route authentication


is not suitable for vuex, because the data in vuex will be emptied after the user refreshes the page. Since users actively trigger page refresh behavior on pc pages, it is more appropriate to put local caches such as cookie.

Menu