当前位置:网站首页>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 .
边栏推荐
- 下载url-loader,用limit指定图片大小后,显示不出图片
- User login - and create and verify SMS verification code
- 原生token生成加密、解密
- Gallerycms download, installation and configuration
- Introduction of C language base conversion and original complement inverse code point operation
- User registration login
- 进制的特性
- JS中数组的遍历方法有哪些
- JS中arguments类数组
- pytorch安装新坑
猜你喜欢

First knowledge of C language - string + escape character + comment

Xiaomi mall project_ register

Gallerycms download, installation and configuration

Elment UI usage

块,行内块元素之间存在间隙

页面的配置

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)

初始C语言——关键字static的作用

布局的搭建及天气预报的显示

初识C语言——什么是C语言
随机推荐
Looking at the PK of alphago and Li Shishi from a deep perspective
JS中apply、call、bind的区别
2021 Niuke multi school training camp 5 (question b)
Makefile is easy to understand and explain
洛谷陶陶摘苹果
用户页面管理
一本通顺序结构程序设计题解(第一章)
页面的配置
XSS知识点
First knowledge of C language - why does every C program have a main function
C language string function: strlen, strcpy, strcat
Asynchronous data SMS verification code
My first blog
Share a multiple-choice question about variables (including global variables, local variables, the scope of variables, and life cycle knowledge points)
c语言字符串函数上:strlen、strcpy、strcat
Hi3516dv300 environment setup
Introduction to C language functions
深度优先搜索(dfs)简介
Introduction of C language base conversion and original complement inverse code point operation
背景图片相关应用-铺满,自适应