Skip to content

Commit

Permalink
#
Browse files Browse the repository at this point in the history
  • Loading branch information
ichynul committed Feb 17, 2019
1 parent cfc312e commit 36b986b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 22 deletions.
33 changes: 16 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,35 @@ Add a config in `config/admin.php`:
```php
'extensions' => [
'iframe-tabs' => [
// Set to `false` if you want to disable this extension
// Set to `false` if you want to disable this extension
'enable' => true,
// Default page controller
'home_controller' => App\Admin\Controllers\HomeController::class . '@index',
// Default page uir after user login success
'home_uri' => '/admin',
'home_uri' => '/admin/dashboard',
// Default page tab-title
'home_title' => 'Home',
// Default page tab-title icon
'home_icon' => 'fa-home',
// wheath show icon befor titles for all tab
'use_icon' => true,
// layer.js path , if you do not user laravel-admin-ext\cropper , set another one
'layer_path' => '/vendor/laravel-admin-ext/cropper/layer/layer.js'
]
],

```

Edit exit menu `index`
```php
[
'title' => 'Index',
'icon' => 'fa-bar-chart',
//'uri' => '/', //old
'uri' => '/admin/dashboard', // new
]
```

Add a lang config in `resources/lang/{zh-CN}/admin.php`

```php
Expand All @@ -53,21 +67,6 @@ Add a lang config in `resources/lang/{zh-CN}/admin.php`

Open `http://your-host/admin/dashboard`

To make sure open dashboard page after user login successed ,you need to edit `App\Admin\Controllers\AuthController.php` :
add line `protected $redirectTo = '/admin/dashboard'`;
## Demo

```php
namespace App\Admin\Controllers;

use Encore\Admin\Controllers\AuthController as BaseAuthController;

class AuthController extends BaseAuthController
{
protected $redirectTo = '/admin/dashboard';
}
```

Thanks to https://github.com/bswsfhcw/AdminLTE-With-Iframe

License
Expand Down
5 changes: 3 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Ichynul\IframeTabs\Http\Controllers\IframeTabsController;
use Ichynul\IframeTabs\IframeTabs;

Route::get('/home', IframeTabsController::class . '@index')->name('admin.dashboard');
Route::get('/dashboard', IframeTabsController::class . '@index')->name('admin.dashboard');
Route::get('/', IframeTabsController::class . '@index')->name('admin.index');
Route::get('/dashboard', IframeTabs::config('home_action', IframeTabsController::class . '@default'))->name('admin.dashboard');
30 changes: 28 additions & 2 deletions src/Http/Controllers/IframeTabsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class IframeTabsController extends Controller
{
public function index(Content $content)
{
if (\Request::route()->getName() == 'admin.dashboard') {
if (\Request::route()->getName() == 'admin.index') {
$this->script();
}

Expand All @@ -28,12 +28,38 @@ public function index(Content $content)
return view('iframe-tabs::index', $items);
}

public function default(Content $content)
{
return $content
->header('Defautl page')
->description('Defautl page')
->body('Defautl page have not seted ,place edit config in `config/admin.php`'
. "<pre>'extensions' => [
'iframe-tabs' => [
// Set to `false` if you want to disable this extension
'enable' => true,
// Default page controller
'home_action' => App\Admin\Controllers\HomeController::class . '@index',//edit here
// Default page uir after user login success
'home_uri' => '/admin/dashboard',
// Default page tab-title
'home_title' => 'Home',
// Default page tab-title icon
'home_icon' => 'fa-home',
// wheath show icon befor titles for all tab
'use_icon' => true,
// layer.js path , if you do not user laravel-admin-ext\cropper , set another one
'layer_path' => '/vendor/laravel-admin-ext/cropper/layer/layer.js'
]
],</pre>");
}

protected function script()
{
$call_back = admin_base_path('configx/sort');
$refresh_current = trans('admin.iframe_tabss.refresh_current');
$open_in_new = trans('admin.iframe_tabss.open_in_new');
$home_uri = IframeTabs::config('home_uri', '/admin');
$home_uri = IframeTabs::config('home_uri', '/admin/dashboard');
$home_title = IframeTabs::config('home_title', 'Index');
$home_icon = IframeTabs::config('home_icon', 'fa-home');
$use_icon = IframeTabs::config('use_icon', true) ? 'true' : 'false';
Expand Down
2 changes: 1 addition & 1 deletion src/IframeTabsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function boot(IframeTabs $extension)
IframeTabs::routes(__DIR__ . '/../routes/web.php');
});
Admin::booted(function () {
if (\Request::route()->getName() == 'admin.dashboard') {
if (\Request::route()->getName() == 'admin.index') {
Admin::css('vendor/laravel-admin-ext/iframe-tabs/dashboard.css');
Admin::js('vendor/laravel-admin-ext/iframe-tabs/bootstrap-tab.js');
Admin::js('vendor/laravel-admin-ext/iframe-tabs/sidebarMenu.js');
Expand Down

0 comments on commit 36b986b

Please sign in to comment.