add configurable "Explore" menu

This commit is contained in:
Pig Fang 2019-06-28 23:47:30 +08:00
parent 7cb3e246a8
commit cd84f1f8a6
7 changed files with 33 additions and 2 deletions

View File

@ -0,0 +1,20 @@
<?php
namespace App\Events;
class ConfigureExploreMenu extends Event
{
public $menu;
/**
* Create a new event instance.
*
* @param array $menu
* @return void
*/
public function __construct(array &$menu)
{
// Pass array by reference
$this->menu = &$menu;
}
}

View File

@ -5,6 +5,7 @@ namespace App\Services;
use Event;
use Closure;
use App\Events;
use Illuminate\Support\Str;
class Hook
{
@ -23,7 +24,7 @@ class Hook
*/
public static function addMenuItem($category, $position, array $menu)
{
$class = $category == 'user' ? Events\ConfigureUserMenu::class : Events\ConfigureAdminMenu::class;
$class = 'App\Events\Configure'.Str::title($category).'Menu';
Event::listen($class, function ($event) use ($menu, $position, $category) {
$new = [];

View File

@ -3,6 +3,7 @@
use Carbon\Carbon;
use App\Models\User;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
if (! function_exists('webpack_assets')) {
function webpack_assets($relativeUri)
@ -95,6 +96,9 @@ if (! function_exists('bs_menu')) {
case 'user':
event(new App\Events\ConfigureUserMenu($menu));
break;
case 'explore':
event(new App\Events\ConfigureExploreMenu($menu));
break;
case 'admin':
event(new App\Events\ConfigureAdminMenu($menu));
break;

View File

@ -38,4 +38,8 @@ $menu['admin'] = [
['title' => 'general.check-update', 'link' => 'admin/update', 'icon' => 'fa-arrow-up'],
];
$menu['explore'] = [
['title' => 'general.skinlib', 'link' => 'skinlib', 'icon' => 'fa-archive'],
];
return $menu;

View File

@ -2,6 +2,7 @@
- Supported Chrome's `theme-color`.
- Allowed to customize HTTP status code for rejecting accessing private texture.
- Added configurable "Explore" menu.
## Tweaked

View File

@ -2,6 +2,7 @@
- 支持 Chrome 的 `theme-color` 属性
- 允许自定义拒绝访问私有材质时返回的 HTTP 状态码
- 添加可自定义的「浏览」菜单
## 调整

View File

@ -62,7 +62,7 @@
{!! bs_menu('user') !!}
<li class="header">@lang('general.explore')</li>
<li><a href="{{ url('skinlib') }}"><i class="fas fa-archive"></i> &nbsp;<span>@lang('general.skinlib')</span></a></li>
{!! bs_menu('explore') !!}
@admin($user)
<li class="header">@lang('general.manage')</li>