導(dǎo)入菜單
在安裝插件時(shí),webman-admin會(huì)自動(dòng)導(dǎo)入plugin/插件/config/menu.php
配置里的菜單,卸載插件時(shí)也會(huì)根據(jù)此配置刪除菜單。
menu.php 內(nèi)容類似如下
<?php
use plugin\queue\app\controller\redis\DelayController;
use plugin\queue\app\controller\redis\FailedController;
use plugin\queue\app\controller\redis\NormalController;
return [
[
'title' => '消息隊(duì)列',
'key' => 'queue',
'icon' => 'layui-icon-align-left',
'weight' => 0,
'type' => 0,
'children' => [
[
'title' => '正常隊(duì)列',
'key' => NormalController::class,
'href' => '/app/queue/redis/normal',
'type' => 1,
'weight' => 0,
],
[
'title' => '延遲隊(duì)列',
'key' => DelayController::class,
'href' => '/app/queue/redis/delay',
'type' => 1,
'weight' => 0,
],
[
'title' => '失敗隊(duì)列',
'key' => FailedController::class,
'href' => '/app/queue/redis/failed',
'type' => 1,
'weight' => 0,
]
]
]
];
字段說(shuō)明
各字段說(shuō)明如下
title
菜單名稱
type
類型,0為目錄,1為菜單,2為權(quán)限節(jié)點(diǎn)(權(quán)限節(jié)點(diǎn)會(huì)自動(dòng)生成,一般不用配置)
key
菜單標(biāo)識(shí),要求全局唯一。
- 一級(jí)目錄要求格式為
插件名
- 二級(jí)及以上目錄要求格式為
插件名-任意字符串
- 如果是菜單,則填寫(xiě)控制器類的名稱(帶命名空間)
href
url路徑,一般填寫(xiě)控制器對(duì)應(yīng)的url路徑
icon
顯示圖標(biāo),只有一級(jí)目錄或者頂級(jí)菜單才會(huì)顯示圖標(biāo)。目前只支持layui圖標(biāo),可選值參考layui圖標(biāo)
weight
權(quán)重,用來(lái)排序,值大的在前,值小的在后
測(cè)試安裝
如果你的應(yīng)用插件是使用 php webman app-plugin:create
命令生成的,則會(huì)生成一個(gè)plugin/插件名/api/Install.php
類,類里面install方法用于安裝菜單,uninstall方法用于卸載菜單。我們可以通過(guò)以下命令來(lái)測(cè)試install以及uninstall方法。
安裝菜單
php webman app-plugin:install 插件名
卸載菜單
php webman app-plugin:uninstall 插件名
提示
如果你的應(yīng)用插件需要在安裝或者卸載時(shí)觸發(fā)某個(gè)操作,可以寫(xiě)在Install
類里的install
或uninstall
方法中