Skip to content

Commit

Permalink
增加resource_path()下目录的命令空间,增加发布基础blade文件到resource_path()下
Browse files Browse the repository at this point in the history
  • Loading branch information
imzhi committed Jul 12, 2019
1 parent 79e0c88 commit ead624d
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 36 deletions.
5 changes: 5 additions & 0 deletions config/jfadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@
'middleware' => ['web', 'jfadmin'],
'domain' => env('JFA_ROUTE_DOMAIN'),
],

'view' => [
'directory' => resource_path('views/jfadmin'),
'namespace' => 'jfadmin',
],
];
24 changes: 2 additions & 22 deletions resources/assets/jfadmin/jfadmin.css
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
#side-menu .fa {
width: 13px;
}

.wrapper-content {
padding: 5px 0;
}

.p-l-n {
padding-left: 0;
}

.p-l-m {
padding-left: 20px;
}

.p-r-n {
padding-right: 0;
}

.golden-table thead th {
white-space: nowrap;
}
Expand All @@ -30,8 +10,8 @@
}

.golden-table tbody tr td.td-break {
overflow: inherit;
text-overflow: inherit;
/*overflow: inherit;*/
/*text-overflow: inherit;*/
white-space: inherit;
word-wrap: break-word;
word-break: break-all;
Expand Down
Empty file modified resources/assets/jfadmin/jfadmin.js
100755 → 100644
Empty file.
Empty file.
8 changes: 0 additions & 8 deletions resources/views/home/index.blade.php

This file was deleted.

13 changes: 12 additions & 1 deletion src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,27 @@ protected function initDatabase()
protected function initDirectory()
{
$directory = config('jfadmin.directory');
$view_directory = config('jfadmin.view.directory');

$this->makeDir($directory);

$this->makeDir("{$directory}/Controllers");

$this->makeDir("{$view_directory}/home");

$this->makeDir("{$view_directory}/layouts");

$this->createFile("{$directory}/routes.php", 'routes');

$this->createFile("{$directory}/Controllers/HomeController.php", 'HomeController', function ($content) {
return str_replace('DummyNamespace', config('jfadmin.route.namespace'), $content);
});

$this->createFile("{$view_directory}/layouts/base.blade.php", 'base.blade');

$this->createFile("{$view_directory}/layouts/pagination.blade.php", 'pagination.blade');

$this->createFile("{$view_directory}/home/index.blade.php", 'index.blade');
}

protected function makeDir($path = '')
Expand All @@ -93,7 +104,7 @@ protected function createFile($path, $stub, $callback = null)
$file = str_replace(base_path(), '', $path);
if (file_exists($path)) {
$this->comment("file \"{$file}\" already init");
// return false;
return false;
}

$file_content = $this->getStub($stub);
Expand Down
2 changes: 2 additions & 0 deletions src/Console/UninstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public function handle()

$this->delDir(public_path('vendor/jfadmin'));

$this->delDir(config('jfadmin.view.directory'));

$this->info('uninstall successfully');
}

Expand Down
22 changes: 20 additions & 2 deletions src/Console/stubs/HomeController.stub
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace DummyNamespace;
namespace App\JFAdmin\Controllers;

use App\Http\Controllers\Controller;

Expand All @@ -11,7 +11,25 @@ class HomeController extends Controller
*/
protected function showIndex()
{
$envs = [
['name' => 'PHP version', 'value' => PHP_VERSION],
['name' => 'Laravel version', 'value' => app()->version()],
['name' => 'CGI', 'value' => php_sapi_name()],
['name' => 'Uname', 'value' => php_uname()],
['name' => 'Server', 'value' => array_get($_SERVER, 'SERVER_SOFTWARE')],

['name' => 'Cache driver', 'value' => config('cache.default')],
['name' => 'Session driver', 'value' => config('session.driver')],
['name' => 'Queue driver', 'value' => config('queue.default')],

['name' => 'Timezone', 'value' => config('app.timezone')],
['name' => 'Locale', 'value' => config('app.locale')],
['name' => 'Env', 'value' => config('app.env')],
['name' => 'URL', 'value' => config('app.url')],
];
$json = file_get_contents(base_path('composer.json'));
$dependencies = json_decode($json, true)['require'];
$nav_id = 'home.index';
return view('jfadmin::home.index', compact('nav_id'));
return view('jfadmin::home.index', compact('envs', 'dependencies', 'nav_id'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
@yield('content')
<div class="footer">
<div>
<strong>Copyright</strong> 聚丰 &copy; 2018
<strong>Powered by <a href="https://github.com/imzhi/jf-admin" target="_blank">jf-admin</a></strong>
</div>
</div>
</div>
Expand Down
80 changes: 80 additions & 0 deletions src/Console/stubs/index.blade.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
@extends('jfadmin::layouts.base')

@section('title', '首页')

@section('content')
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-md-6">
<div class="ibox">
<div class="ibox-title">
<h5>环境参数</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content clearfix">
<div class="table-responsive">
<table class="table table-bordered table-hover golden-table">
<thead>
<tr>
<th width="40%">参数名称</th>
<th width="60%">参数值</th>
</tr>
</thead>
<tbody>
@foreach($envs as $item)
<tr>
<td>{{ $item['name'] }}</td>
<td class="td-break">{{ $item['value'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="ibox">
<div class="ibox-title">
<h5>引入扩展包</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content clearfix">
<div class="table-responsive">
<table class="table table-bordered table-hover golden-table">
<thead>
<tr>
<th width="40%">名称</th>
<th width="60%">版本</th>
</tr>
</thead>
<tbody>
@foreach($dependencies as $key => $item)
<tr>
<td>{{ $key }}</td>
<td>{{ $item }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
File renamed without changes.
6 changes: 4 additions & 2 deletions src/JFAdminServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ class JFAdminServiceProvider extends ServiceProvider
*/
public function boot()
{
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'jfadmin');
$this->loadViewsFrom(__DIR__ . '/../resources/views', config('jfadmin.view.namespace'));

if (file_exists($routes = config('jfadmin.directory') . '/routes.php')) {
$this->loadRoutesFrom($routes);
}

View::composer('jfadmin::*', function ($view) {
View::addNamespace('jfadmin', config('jfadmin.view.directory'));

View::composer(config('jfadmin.view.namespace') . '::*', function ($view) {
$view->with('admin_user', Auth::guard('admin_user')->user());
});

Expand Down

0 comments on commit ead624d

Please sign in to comment.