un-pany/v3-admin-vite

request help: in /src/views/dashboard/index.vue, when and how the roles was set

Closed this issue · 1 comments

hello:
I am a novice in vue3, when I learn this project, I suffered a question that I hope be solved by yours

const userStore = useUserStore()
const isAdmin = userStore.roles.includes("admin")

as above code, when use admin user to login, and login is successful, the userStore.roles.includes("admin") will return true, I want to know how and when, the username "admin", was set into userStore.roles.

I am learning vue3 recently, hope your relpy, thanks

it seems I have found the roles where it added, in /src/router/permisson.tsrouter.beforeEach as a intercepter, so when we visit any page, the router.beforeEach will be executed, it's inner logic added the roles