Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

登陆后菜单加载/展示不全 #223

Closed
hhw2444 opened this issue Apr 13, 2024 · 8 comments
Closed

登陆后菜单加载/展示不全 #223

hhw2444 opened this issue Apr 13, 2024 · 8 comments
Labels

Comments

@hhw2444
Copy link

hhw2444 commented Apr 13, 2024

如题
数据库已配好

@hhw2444
Copy link
Author

hhw2444 commented Apr 13, 2024

微信图片_20240413144612 微信图片_20240413144637

@zds-s
Copy link
Member

zds-s commented Apr 13, 2024 via email

@zds-s
Copy link
Member

zds-s commented Apr 13, 2024 via email

@hhw2444
Copy link
Author

hhw2444 commented Apr 13, 2024

解决了,谢谢

@zds-s zds-s transferred this issue from mineadmin/MineAdmin-Vue Apr 13, 2024
@zds-s zds-s pinned this issue Apr 13, 2024
@zds-s zds-s changed the title superAdmin登录进去,菜单只有首页 superAdmin登录进去,菜单加载不全 Apr 13, 2024
@zds-s zds-s added the question label Apr 13, 2024
@zds-s zds-s changed the title superAdmin登录进去,菜单加载不全 登陆后菜单加载/展示不全 Apr 13, 2024
@zds-s zds-s closed this as completed Apr 15, 2024
@kurumii
Copy link

kurumii commented Jun 1, 2024

请问下怎么解决的?已经清过 getinfo 接口的永久缓存以及检查env 的超管id 和你数据库超管id是一致的 @hhw2444 @zds-s

@kurumii
Copy link

kurumii commented Jun 1, 2024

请问下怎么解决的?已经清过 getinfo 接口的永久缓存以及检查env 的超管id 和你数据库超管id是一致的 @hhw2444 @zds-s

以为ADMIN_ROLE 是超管ID,翻了源码,才发现是SUPER_ADMIN

@zds-s
Copy link
Member

zds-s commented Jun 1, 2024 via email

@kurumii
Copy link

kurumii commented Jun 1, 2024

role 是超管角色id,你是新系统安装成功 role id 和数据库就不一致吗?

---原始邮件--- 发件人: @.> 发送时间: 2024年6月1日(周六) 晚上8:52 收件人: @.>; 抄送: @.@.>; 主题: Re: [mineadmin/MineAdmin] 登陆后菜单加载/展示不全 (Issue #223) 请问下怎么解决的?已经清过 getinfo 接口的永久缓存以及检查env 的超管id 和你数据库超管id是一致的 @hhw2444 @zds-s 以为ADMIN_ROLE 是超管ID,翻了源码,才发现是SUPER_ADMIN — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

ADMIN_ROLE 跟数据库里面的ID是一样的,但是源码的判断逻辑,是拿SUPER_ADMIN做判断的,应该是isSuperAdmin方法判断里面少了 ADMIN_ROLE 的判断

SystemUserService.class 文件:

  /**
     * 获取缓存用户信息.
     */
    #[Cacheable(prefix: 'loginInfo', value: 'userId_#{id}', ttl: 0)]
    protected function getCacheInfo(int $id): array
    {
        $user = $this->mapper->getModel()->find($id);
        $user->addHidden('deleted_at', 'password');
        $data['user'] = $user->toArray();
        if (user()->isSuperAdmin()) {
            $data['roles'] = ['superAdmin'];
            $data['routers'] = $this->sysMenuService->mapper->getSuperAdminRouters();
            $data['codes'] = ['*'];
        } else {
            $roles = $this->sysRoleService->mapper->getMenuIdsByRoleIds($user->roles()->pluck('id')->toArray());
            $ids = $this->filterMenuIds($roles);
            $data['roles'] = $user->roles()->pluck('code')->toArray();
            $data['routers'] = $this->sysMenuService->mapper->getRoutersByIds($ids);
            $data['codes'] = $this->sysMenuService->mapper->getMenuCode($ids);
        }

        return $data;
    }

LoginUser.class 文件

    /**
     * 是否为超级管理员(创始人),用户禁用对创始人没用.
     */
    public function isSuperAdmin(): bool
    {
        return env('SUPER_ADMIN') == $this->getId();
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants