iview / iview/iview-admin

权限代码优化

Open
#576 1 comment 4 reactions 0 assignees View on GitHub
Dominant language
Vue
Stars
16.4k
Forks
4.7k
PR merge metrics
No merged PRs in 30d

Description

由于在项目中需要两个左边的nav菜单,原先代码中的菜单权限控制只有两层,我优化了代码让路由可以无限嵌套给菜单使用
iview-admin/src/store/modules/app.js
>let accessCode = parseInt(Cookies.get('access'));
>state.menuList = Util.filterUnaccess(appRouter,accessCode);

/src/libs/util.js
>util.filterUnaccess=function (arr,currentAccess){
> let arrout=[];
> for (let index=0;index if (arr[index].children!=undefined&&arr[index].children.length!=0){
> arr[index].children=this.filterUnaccess(arr[index].children,currentAccess);
> }
> if (arr[index].access===undefined||this.showThisRoute(arr[index].access,currentAccess)){
> arrout.push(arr[index]);
> }
> }
> return arrout;
>}

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with iview-admin/src/store/modules/app.js and /src/libs/util.js, reading how menuList is built and how filterUnaccess and showThisRoute currently handle route access. Verify the behavior with nested appRouter entries and confirm that menus can be nested beyond two levels while inaccessible routes remain filtered.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
authorization, frontend
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.