当前位置:网站首页>Permission display - dynamic list on the left
Permission display - dynamic list on the left
2022-07-27 05:39:00 【My name is Lili】
1: Modify the login interface
If this user exists , Then go and see if she has a role => If there is id But there is no role , I'll put what your role is that I found in the role Library , Then assign it to you , then If not id That is super administrator , therefore , Just do it so that he can see the list of all the characters .
2: Under the transformation config Of menuConfig Menu list
isPublic:true// Open , No matter who you are, you can visit the home page
3: stay Appnavbar In the left list component of
establish hasAuth Method - According to your current user role , Then generate the list of permissions on the left that you want to show

Then there is the link of displaying the menu bar , I want to add a judgment in front if it corresponds to menus Is it true

bug describe : For example, I logged in to learn management , Then at this time, others also logged in and modified my permission to learn management , If you don't log in again, the permission remains unchanged , That shouldn't be . What needs to be done is that your permission has been modified, so you should log out . Log back in
Solutions : Every time I jump to the page and send a request , We have to judge , Have my user permissions been modified , If it's modified , You need to log back in .
Get ready :
1: Transform the login interface in the background interface --- Judge if user The object is , Then, let's judge whether she has role attributes ,id There is - Query your current role list according to your role ,( If user There is , But there is no role list ) Add the role I got to you . without id Super administrator , hold menus Show it all .
2: Add one in the menu configuration ispublic, Make the homepage public , No matter which user logs in , Can display the home page
3: Add hasAuth Method -- Judge the user you are currently logged in , Permission list and memoryUtils Whether the contents stored in it are the same . If the user name is admin Or the current item Is it public or In the current user index stay menu Is there... In it , If it exists, it can be displayed ---return true--- Then this first level list , Call it recursively --
If two of them can't get in, return one false.
4: Show the menu bar before getMenuNodes In the method Add a judgment before doing others
// Add one to judge whether the current user owns item The corresponding permissions (hasAuth) Is the true , The return is true, Show the corresponding menu bar
This completes the list display
Real solution bug:
1: Progressiveness judgment adds a permission list interface in the background , Get your current role list .
2: Create a method in the request interceptor in the foreground , Then get your current role permission list ,
// Get the latest permission list from the backend
// Compare the latest permission list with the currently logged in user permission list
// Judge whether the array length of the two permission lists is consistent =》 // Then if the length is equal , It depends on whether each term is equal
If =-1 It proves to be modified , Just empty the cache user, Let him log in again ======== The same length is not equal - Clear it directly and log in again .
Next, build the interface of school management .
边栏推荐
猜你喜欢

First knowledge of C language -- what is C language

Hi3516DV300环境搭建

Share a multiple-choice question about the process of program compilation (including a brief discussion on the compilation process, the formation and merging process of symbol tables)

Carmaker quick start lesson 4 developing 48V P1 hybrid system

Program environment and preprocessing (Part 1): how does a program run successfully?

First acquaintance with C language - first acquaintance with pointer

node 安装调试

封装JWT

First knowledge of C language -- constants and variables

Xiaomi mall project_ register
随机推荐
JS如何判断一个对象是否属于一个类
GCC compilation options
Introduction to C language pointer
图片上传的逻辑
Program environment and preprocessing (Part 1): how does a program run successfully?
JS中apply、call、bind的区别
First acquaintance with C language - first acquaintance with pointer
下载url-loader,用limit指定图片大小后,显示不出图片
自我理解思考
时间复杂度与空间复杂度
C language string introduction and related operation functions
elment-ui使用方法
信息学奥赛一本通1176题——谁考了第k名
DNSmasq使用总结
初识C语言——常见的数据类型
qsort — c语言中自带的排序函数(附带void*、回调函数知识点
程序环境和预处理(下):#define、#undef、命令行编译、条件编译、文件包含(超全整理,建议收藏!!!
C language string function: strlen, strcpy, strcat
原生token生成加密、解密
JS中原型及原型链