add support for multilevel menus

This commit is contained in:
printempw 2016-12-10 21:30:24 +08:00
parent 637189ddf6
commit 6ff4ad0c33
5 changed files with 30 additions and 8 deletions

View File

@ -98,7 +98,8 @@ Route::group(['middleware' => 'admin', 'prefix' => 'admin'], function ()
{
Route::get('/', 'AdminController@index');
Route::any('/plugins', 'AdminController@plugins');
Route::any('/plugins/manage', 'AdminController@plugins');
Route::any('/customize', 'AdminController@customize');
Route::any('/score', 'AdminController@score');
Route::any('/options', 'AdminController@options');

View File

@ -158,14 +158,28 @@ if (! function_exists('bs_menu')) {
throw new InvalidArgumentException;
}
$request = App::make('request');
foreach ($menu[$type] as $key => $value) {
echo ($request->is($value['link'])) ? '<li class="active">' : '<li>';
echo '<a href="'.url($value['link']).'"><i class="fa '.$value['icon'].'"></i> <span>'.trans($value['title']).'</span></a></li>';
echo bs_menu_render($menu[$type]);
}
function bs_menu_render($data)
{
$content = "";
foreach ($data as $key => $value) {
$content .= (app('request')->is(@$value['link'])) ? '<li class="active">' : '<li>';
if (isset($value['children'])) {
$content .= '<a href="#"><i class="fa '.$value['icon'].'"></i> <span>'.trans($value['title']).'</span><span class="pull-right-container"><i class="fa fa-angle-left pull-right"></i></span></a>';
// recurse
$content .= '<ul class="treeview-menu" style="display: none;">'.bs_menu_render($value['children']).'</ul>';
} else {
$content .= '<a href="'.url($value['link']).'"><i class="fa '.$value['icon'].'"></i> <span>'.trans($value['title']).'</span></a>';
}
$content .= '</li>';
}
return $content;
}
}

View File

@ -12,18 +12,21 @@ $menu['user'] = array(
['title' => 'general.dashboard', 'link' => 'user', 'icon' => 'fa-dashboard'],
['title' => 'general.my-closet', 'link' => 'user/closet', 'icon' => 'fa-star'],
['title' => 'general.player-manage', 'link' => 'user/player', 'icon' => 'fa-users'],
['title' => 'general.profile', 'link' => 'user/profile', 'icon' => 'fa-user']
['title' => 'general.profile', 'link' => 'user/profile', 'icon' => 'fa-user'],
);
$menu['admin'] = array(
['title' => 'general.dashboard', 'link' => 'admin', 'icon' => 'fa-dashboard'],
['title' => 'general.user-manage', 'link' => 'admin/users', 'icon' => 'fa-users'],
['title' => 'general.player-manage', 'link' => 'admin/players', 'icon' => 'fa-gamepad'],
['title' => 'general.plugin-manage', 'link' => 'admin/plugins', 'icon' => 'fa-plug'],
['title' => 'general.plugin-manage', 'icon' => 'fa-plug', 'children' => [
['title' => 'general.plugin-market', 'link' => 'admin/plugins/market', 'icon' => 'fa-shopping-bag'],
['title' => 'general.plugin-installed', 'link' => 'admin/plugins/manage', 'icon' => 'fa-download'],
]],
['title' => 'general.customize', 'link' => 'admin/customize', 'icon' => 'fa-paint-brush'],
['title' => 'general.score-options', 'link' => 'admin/score', 'icon' => 'fa-credit-card'],
['title' => 'general.options', 'link' => 'admin/options', 'icon' => 'fa-cog'],
['title' => 'general.check-update', 'link' => 'admin/update', 'icon' => 'fa-arrow-up']
['title' => 'general.check-update', 'link' => 'admin/update', 'icon' => 'fa-arrow-up'],
);
return $menu;

View File

@ -16,6 +16,8 @@ my-closet: Closet
player-manage: Player Manage
user-manage: User Manage
plugin-manage: Plugin Manage
plugin-market: Plugin Market
plugin-installed: Installed
customize: Customize
options: Options
import-v2: Import Data

View File

@ -16,6 +16,8 @@ my-closet: 我的衣柜
player-manage: 角色管理
user-manage: 用户管理
plugin-manage: 插件管理
plugin-market: 插件市场
plugin-installed: 已安装
customize: 个性化
options: 站点配置
import-v2: 导入数据