From ead624d6215786803f70a2fe8dd018c5c389872e Mon Sep 17 00:00:00 2001 From: imzhi Date: Fri, 12 Jul 2019 18:04:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0resource=5Fpath()=E4=B8=8B?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E7=9A=84=E5=91=BD=E4=BB=A4=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=8F=91=E5=B8=83=E5=9F=BA=E7=A1=80?= =?UTF-8?q?blade=E6=96=87=E4=BB=B6=E5=88=B0resource=5Fpath()=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/jfadmin.php | 5 ++ resources/assets/jfadmin/jfadmin.css | 24 +----- resources/assets/jfadmin/jfadmin.js | 0 .../sweetalert2/dist/sweetalert2.all.min.js | 0 resources/views/home/index.blade.php | 8 -- src/Console/InstallCommand.php | 13 ++- src/Console/UninstallCommand.php | 2 + src/Console/stubs/HomeController.stub | 22 ++++- .../Console/stubs/base.blade.stub | 2 +- src/Console/stubs/index.blade.stub | 80 +++++++++++++++++++ .../Console/stubs/pagination.blade.stub | 0 src/JFAdminServiceProvider.php | 6 +- 12 files changed, 126 insertions(+), 36 deletions(-) mode change 100755 => 100644 resources/assets/jfadmin/jfadmin.js mode change 100755 => 100644 resources/assets/jfadmin/plugins/sweetalert2/dist/sweetalert2.all.min.js delete mode 100755 resources/views/home/index.blade.php rename resources/views/layouts/base.blade.php => src/Console/stubs/base.blade.stub (98%) create mode 100755 src/Console/stubs/index.blade.stub rename resources/views/layouts/pagination.blade.php => src/Console/stubs/pagination.blade.stub (100%) diff --git a/config/jfadmin.php b/config/jfadmin.php index 3c48f4d..cf9bd25 100755 --- a/config/jfadmin.php +++ b/config/jfadmin.php @@ -35,4 +35,9 @@ 'middleware' => ['web', 'jfadmin'], 'domain' => env('JFA_ROUTE_DOMAIN'), ], + + 'view' => [ + 'directory' => resource_path('views/jfadmin'), + 'namespace' => 'jfadmin', + ], ]; diff --git a/resources/assets/jfadmin/jfadmin.css b/resources/assets/jfadmin/jfadmin.css index f7ee9e7..e959462 100755 --- a/resources/assets/jfadmin/jfadmin.css +++ b/resources/assets/jfadmin/jfadmin.css @@ -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; } @@ -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; diff --git a/resources/assets/jfadmin/jfadmin.js b/resources/assets/jfadmin/jfadmin.js old mode 100755 new mode 100644 diff --git a/resources/assets/jfadmin/plugins/sweetalert2/dist/sweetalert2.all.min.js b/resources/assets/jfadmin/plugins/sweetalert2/dist/sweetalert2.all.min.js old mode 100755 new mode 100644 diff --git a/resources/views/home/index.blade.php b/resources/views/home/index.blade.php deleted file mode 100755 index d774a75..0000000 --- a/resources/views/home/index.blade.php +++ /dev/null @@ -1,8 +0,0 @@ -@extends('jfadmin::layouts.base') - -@section('title', '首页') - -@section('content') -
-
-@endsection diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index 9cf2f7c..6437312 100755 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -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 = '') @@ -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); diff --git a/src/Console/UninstallCommand.php b/src/Console/UninstallCommand.php index a2feb80..3a788df 100755 --- a/src/Console/UninstallCommand.php +++ b/src/Console/UninstallCommand.php @@ -52,6 +52,8 @@ public function handle() $this->delDir(public_path('vendor/jfadmin')); + $this->delDir(config('jfadmin.view.directory')); + $this->info('uninstall successfully'); } diff --git a/src/Console/stubs/HomeController.stub b/src/Console/stubs/HomeController.stub index dd455f0..d860516 100755 --- a/src/Console/stubs/HomeController.stub +++ b/src/Console/stubs/HomeController.stub @@ -1,6 +1,6 @@ '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')); } } diff --git a/resources/views/layouts/base.blade.php b/src/Console/stubs/base.blade.stub similarity index 98% rename from resources/views/layouts/base.blade.php rename to src/Console/stubs/base.blade.stub index b3603ef..527b7f5 100755 --- a/resources/views/layouts/base.blade.php +++ b/src/Console/stubs/base.blade.stub @@ -119,7 +119,7 @@ @yield('content') diff --git a/src/Console/stubs/index.blade.stub b/src/Console/stubs/index.blade.stub new file mode 100755 index 0000000..8840784 --- /dev/null +++ b/src/Console/stubs/index.blade.stub @@ -0,0 +1,80 @@ +@extends('jfadmin::layouts.base') + +@section('title', '首页') + +@section('content') +
+
+
+
+
+
环境参数
+ +
+
+
+ + + + + + + + + @foreach($envs as $item) + + + + + @endforeach + +
参数名称参数值
{{ $item['name'] }}{{ $item['value'] }}
+
+
+
+
+
+
+
+
引入扩展包
+ +
+
+
+ + + + + + + + + @foreach($dependencies as $key => $item) + + + + + @endforeach + +
名称版本
{{ $key }}{{ $item }}
+
+
+
+
+
+
+@endsection diff --git a/resources/views/layouts/pagination.blade.php b/src/Console/stubs/pagination.blade.stub similarity index 100% rename from resources/views/layouts/pagination.blade.php rename to src/Console/stubs/pagination.blade.stub diff --git a/src/JFAdminServiceProvider.php b/src/JFAdminServiceProvider.php index a5c978a..d4a4aa8 100755 --- a/src/JFAdminServiceProvider.php +++ b/src/JFAdminServiceProvider.php @@ -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()); });