un-pany / v3-admin-vite

☀️ A vue3 admin template | vue3 admin/element plus admin/vite admin/vue3 template/vue3 后台/vue3 模板/vue3 后台管理系统
https://un-pany.github.io/v3-admin-vite
MIT License
5.39k stars 915 forks source link

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

Closed jujiale closed 11 months ago

jujiale commented 11 months ago

hello: I am a novice in vue3, when I learn this project, I suffered a question that I hope be solved by yours https://github.com/un-pany/v3-admin-vite/blob/4d3d4e1057aee4dde50c4f4a9690e616913b20b8/src/views/dashboard/index.vue#L6-L7

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

jujiale commented 11 months ago

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