後臺框架模板,前端使用 layui 框架,實現了完善的 RBAC 許可權控制

liangjj發表於2018-12-11

logo.png

return [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=localhost;dbname=admin',
    'username' => 'root',
    'password' => '123456',
    'charset' => 'utf8',

    // Schema cache options (for production environment)
    //'enableSchemaCache' => true,
    //'schemaCacheDuration' => 60,
    //'schemaCache' => 'cache',
];

系統截圖:

1.png2.png3.png4.png5.png6.png7.png8.png9.png10.png

選單配置:config/menu.php

return [
    'menu'=>[
        'data'=> ['label'=>'主頁','items'=>[
                ['label' => '主頁',
                    'items' => [
                        ['label' => '主頁概覽', 'url' => ['/site']]
                    ]
                ]
            ]
        ],
        'setting'=> ['label'=>'系統設定', 'items'=>[
                ['label' => '許可權管理',
                    'items' => [
                        ['label' => '使用者管理', 'url' => ['/admin/user']],
                        ['label' => '角色管理', 'url' => ['/admin/roles']],
                        ['label' => '許可權列表', 'url' => ['/admin/permission']],
                        ['label' => '路由列表', 'url' => ['/admin/route']],
                        ['label' => '規則列表', 'url' => ['/admin/rule']]
                    ]
                ],
                ['label' => '個人中心',
                    'items' => [
                        ['label' => '修改密碼', 'url' => ['/admin/personal/reset-password']],
                    ]
                ]
            ]
        ]
    ]
];

許可權配置:config/permission.php

return [
    [
        'label' => 'root 許可權',
        'items' => [
            [
                'label' =>  'root',
                'items' =>  [
                    ['url'=>'/*','label'=>Html::tag('b','root',['style'=>'color:red;']),'items' => [
                        ['url'=>'/*','label'=>Html::tag('b','root許可權',['style'=>'color:red;'])],
                    ]]
                ]
            ]
        ]
    ],
    [
        'label' => '基礎許可權',
        'items' => [
            [
                'label' =>  '基礎許可權',
                'items' =>  [
                    ['label'=>'後臺首頁','items' => [
                        ['url'=>'/site','label'=>'首頁'],
                        ['url'=>'/site/main','label'=>'首頁-關鍵報表'],
                        ['url'=>'/filter','label'=>'篩選'],
                    ]]
                ]
            ]
        ]
    ],
    [
        'label' => '系統設定',
        'items' => [
            [
                'label' =>  '許可權管理',
                'items' =>  [
                    [
                        'label' =>  '使用者管理',
                        'items' =>  [
                            ['url'=>'/admin/user','label'=>'首頁'],
                            ['url'=>'/admin/user/create','label'=>'新增使用者'],
                            ['url'=>'/admin/user/view', 'label'=>'使用者授權'],
                            ['url'=>'/admin/user/delete','label'=>'刪除使用者'],
                            ['url'=>'/admin/user/update','label'=>'修改使用者'],
                            ['url'=>'/admin/user/change-name','label'=>'快捷修改使用者名稱'],
                            ['url'=>'/admin/user/change-time','label'=>'快捷修改建立時間'],
                        ]
                    ],
                    ['label'=>'角色管理','items' => [
                        ['url'=>'/admin/roles','label'=>'首頁'],
                        ['url'=>'/admin/roles/create','label'=>'新增角色'],
                        ['url'=>'/admin/roles/view', 'label'=>'修改角色許可權'],
                        ['url'=>'/admin/roles/delete','label'=>'刪除角色'],
                        ['url'=>'/admin/roles/update','label'=>'修改角色名'],
                    ]],
                    [
                        'label' =>  '許可權組管理',
                        'items' =>  [
                            ['url'=>'/admin/permission','label'=>'首頁'],
                            ['url'=>'/admin/permission/create','label'=>'新增許可權組'],
                            ['url'=>'/admin/permission/view', 'label'=>'修改許可權組許可權'],
                            ['url'=>'/admin/permission/delete','label'=>'刪除許可權組'],
                            ['url'=>'/admin/permission/update','label'=>'修改許可權組名稱'],
                        ]
                    ],
                    [
                        'label' =>  '路由管理',
                        'items' =>  [
                            ['url'=>'/admin/route','label'=>'首頁'],
                            ['url'=>'/admin/route/delete','label'=>'路由刪除'],
                            ['url'=>'/admin/route/update','label'=>'路由修改'],
                        ]
                    ],
                    [
                        'label' =>  '規則管理',
                        'items' =>  [
                            ['url'=>'/admin/rule','label'=>'首頁'],
                            ['url'=>'/admin/rule/delete','label'=>'刪除規則'],
                            ['url'=>'/admin/rule/update','label'=>'修改規則'],
                            ['url'=>'/admin/rule/create','label'=>'新增規則'],
                        ]
                    ]
                ]
            ],
            [
                'label' => '個人中心',
                'items' => [
                    [
                        'label' =>  '修改密碼',
                        'items' =>  [
                            ['url'=>'/admin/personal/reset-password','label'=>'首頁']
                        ]
                    ]
                ]
            ]
        ]
    ]
];
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章