toshcn/yii2-ant-menu

一个为ant design 设计的菜单组件

Installs: 8

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

dev-master / 1.0.x-dev 2018-07-27 09:11 UTC

This package is not auto-updated.

Last update: 2025-07-06 10:02:37 UTC


README

一个为ant design 设计的菜单组件

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist toshcn/yii2-ant-menu "*"

or add

"toshcn/yii2-ant-menu": "*"

to the require section of your composer.json file.

Usage

配置应用组件:如common->config->main.php

'components' => [
    'menuManager' => [
        'class' => 'toshcn\yii2\menu\MenuManager',
        'cache' = 'cache',
        'cacheKey' => 'menu_cache_key',
        'expire' => 3600,
        'userTable' => '{{%user}}',
        'superAdminGroupId' => 1
    ],
]

配置命令行: 基础模板在config->console.php,高级模板在console->config->main.php

'controllerMap' => [
    'menu' => [
        'class' => 'toshcn\yii2\menu\commands\Menu',
    ],
],

运行数据迁移:

php yii migrate --migrationPath=@vendor/toshcn/yii2-ant-menu/src/migrations

为用户表添加group_id字段

php yii menu/add-user-group-id-column

添加一个用户组:

Yii::$app->menuManager->addGroup('user', '用户组说明:普通用户组');

添加一个菜单:

$parentId = 0;
Yii::$app->menuManager->addMenu('menu_name', 'path', $parentId, 'icon');

给用户组分配一个菜单:

$menuId = 1;
$groupId = 1;
Yii::$app->menuManger->assignMenu($menuId, $groupId);