소스 검색

Apply fixes from StyleCI

jqhph 5 년 전
부모
커밋
e1363db3af
61개의 변경된 파일1426개의 추가작업 그리고 1452개의 파일을 삭제
  1. 1 1
      src/Actions/Action.php
  2. 0 3
      src/Actions/HasActionHandler.php
  3. 1 1
      src/Admin.php
  4. 1 1
      src/AdminServiceProvider.php
  5. 323 324
      src/Color.php
  6. 2 2
      src/Console/Development/LinkCommand.php
  7. 1 1
      src/Contracts/TreeRepository.php
  8. 32 32
      src/Contracts/UploadField.php
  9. 0 1
      src/Controllers/Dashboard.php
  10. 1 2
      src/Controllers/ExtensionController.php
  11. 59 59
      src/Controllers/ValueController.php
  12. 1 1
      src/Form.php
  13. 2 2
      src/Form/Builder.php
  14. 1 1
      src/Form/Concerns/HasFiles.php
  15. 1 1
      src/Form/Field/File.php
  16. 0 2
      src/Form/Field/Icon.php
  17. 0 1
      src/Form/Field/Select.php
  18. 0 1
      src/Form/Field/Tree.php
  19. 1 1
      src/Form/Field/WebUploader.php
  20. 1 1
      src/Form/Step/Builder.php
  21. 0 1
      src/Grid/Displayers/Checkbox.php
  22. 0 1
      src/Grid/Displayers/Radio.php
  23. 1 1
      src/Grid/Tools/PerPageSelector.php
  24. 714 714
      src/Layout/Asset.php
  25. 1 2
      src/Layout/Content.php
  26. 1 1
      src/Middleware/LogOperation.php
  27. 2 2
      src/Repositories/EloquentRepository.php
  28. 1 1
      src/Repositories/Repository.php
  29. 107 107
      src/Support/JavaScript.php
  30. 43 43
      src/Traits/HasAuthorization.php
  31. 3 4
      src/Traits/InteractsWithApi.php
  32. 4 5
      src/Widgets/ApexCharts/Chart.php
  33. 0 2
      src/Widgets/Card.php
  34. 2 2
      src/Widgets/Chart/Chart.php
  35. 0 3
      src/Widgets/Color.php
  36. 2 2
      src/Widgets/DialogForm.php
  37. 2 4
      src/Widgets/Metrics/BarChartCard.php
  38. 7 7
      src/Widgets/Metrics/Card.php
  39. 6 6
      src/Widgets/Metrics/DonutChartCard.php
  40. 5 5
      src/Widgets/Metrics/LineChartCard.php
  41. 6 6
      src/Widgets/Metrics/RadialBarChartCard.php
  42. 1 3
      src/Widgets/Metrics/RoundChartCard.php
  43. 8 9
      src/Widgets/Metrics/SingleRoundChartCard.php
  44. 0 1
      src/Widgets/Sparkline/Sparkline.php
  45. 1 1
      src/Widgets/Tab.php
  46. 0 1
      src/Widgets/Tree.php
  47. 1 1
      tests/Browser/Components/Form/Field/MultipleSelect2.php
  48. 4 4
      tests/Browser/Components/Form/Field/Select2.php
  49. 6 6
      tests/Browser/Components/Form/Field/Tree.php
  50. 4 4
      tests/Browser/Components/Form/MenuCreationForm.php
  51. 20 20
      tests/Browser/Components/Grid/Actions/BatchDelete.php
  52. 2 2
      tests/Browser/Components/Grid/Actions/Delete.php
  53. 2 2
      tests/Browser/Components/Grid/BatchActions.php
  54. 3 3
      tests/Browser/Components/Grid/RowSelector.php
  55. 1 1
      tests/Browser/MenuTest.php
  56. 1 1
      tests/Browser/OperationLogTest.php
  57. 1 1
      tests/Browser/Pages/MenuPage.php
  58. 5 3
      tests/BrowserExtension.php
  59. 1 2
      tests/ChromeProcess.php
  60. 1 1
      tests/resources/seeds/UserTableSeeder.php
  61. 29 29
      tests/resources/stubs/ComposerConfigCommand.php

+ 1 - 1
src/Actions/Action.php

@@ -7,7 +7,7 @@ use Dcat\Admin\Traits\HasHtmlAttributes;
 use Illuminate\Contracts\Support\Renderable;
 
 /**
- * Class Action
+ * Class Action.
  *
  * @method string href
  */

+ 0 - 3
src/Actions/HasActionHandler.php

@@ -3,10 +3,7 @@
 namespace Dcat\Admin\Actions;
 
 use Dcat\Admin\Admin;
-use Dcat\Admin\Models\HasPermissions;
 use Dcat\Admin\Traits\HasAuthorization;
-use Illuminate\Contracts\Auth\Authenticatable;
-use Illuminate\Database\Eloquent\Model;
 
 trait HasActionHandler
 {

+ 1 - 1
src/Admin.php

@@ -227,7 +227,7 @@ class Admin
     }
 
     /**
-     * 注册api路由
+     * 注册api路由.
      *
      * @return void
      */

+ 1 - 1
src/AdminServiceProvider.php

@@ -108,7 +108,7 @@ class AdminServiceProvider extends ServiceProvider
     }
 
     /**
-     * 是否强制使用https
+     * 是否强制使用https.
      *
      * @return void
      */

+ 323 - 324
src/Color.php

@@ -1,324 +1,323 @@
-<?php
-
-namespace Dcat\Admin;
-
-use Dcat\Admin\Support\Helper;
-
-/**
- * Class Color
- *
- * @package Dcat\Admin
- *
- * @method string primary(int $amt = 0)
- * @method string primaryDarker(int $amt = 0)
- * @method string link(int $amt = 0)
- * @method string info(int $amt = 0)
- * @method string success(int $amt = 0)
- * @method string danger(int $amt = 0)
- * @method string warning(int $amt = 0)
- * @method string indigo(int $amt = 0)
- * @method string blue(int $amt = 0)
- * @method string red(int $amt = 0)
- * @method string orange(int $amt = 0)
- * @method string green(int $amt = 0)
- * @method string cyan(int $amt = 0)
- * @method string purple(int $amt = 0)
- * @method string custom(int $amt = 0)
- * @method string pink(int $amt = 0)
- * @method string dark(int $amt = 0)
- * @method string white(int $amt = 0)
- * @method string white50(int $amt = 0)
- * @method string blue1(int $amt = 0)
- * @method string blue2(int $amt = 0)
- * @method string orange1(int $amt = 0)
- * @method string orange2(int $amt = 0)
- * @method string yellow(int $amt = 0)
- * @method string indigoDarker(int $amt = 0)
- * @method string redDarker(int $amt = 0)
- * @method string blueDarker(int $amt = 0)
- * @method string cyanDarker(int $amt = 0)
- * @method string gray(int $amt = 0)
- * @method string light(int $amt = 0)
- * @method string tear(int $amt = 0)
- * @method string tear1(int $amt = 0)
- * @method string dark20(int $amt = 0)
- * @method string dark30(int $amt = 0)
- * @method string dark35(int $amt = 0)
- * @method string dark40(int $amt = 0)
- * @method string dark50(int $amt = 0)
- * @method string dark60(int $amt = 0)
- * @method string dark70(int $amt = 0)
- * @method string dark80(int $amt = 0)
- * @method string dark90(int $amt = 0)
- * @method string dark90half(int $amt = 0)
- * @method string font(int $amt = 0)
- * @method string grayBg(int $amt = 0)
- * @method string border(int $amt = 0)
- * @method string inputBorder(int $amt = 0)
- */
-class Color
-{
-    /**
-     * 颜色
-     *
-     * @var array
-     */
-    protected static $colors = [
-        'cyan' => [
-            'css' => [
-
-            ],
-            'colors' => [
-                'primary'        => 'cyan',
-                'primary-darker' => 'cyan-darker',
-                'link'           => 'cyan-darker',
-            ],
-        ],
-        'indigo' => [
-            'css' => [
-
-            ],
-            'colors' => [
-                'primary'        => 'indigo',
-                'primary-darker' => 'indigo-darker',
-                'link'           => 'indigo-darker',
-            ],
-        ],
-    ];
-
-    /**
-     * 默认颜色
-     *
-     * @var array
-     */
-    protected static $default = [
-        'info'    => 'blue',
-        'success' => 'green',
-        'danger'  => 'red',
-        'warning' => 'orange',
-        'indigo'  => '#5c6bc6',
-        'blue'    => '#3085d6',
-        'red'     => '#ea5455',
-        'orange'  => '#ff9f43',
-        'green'   => '#21b978',
-        'cyan'    => '#7367f0',
-        'purple'  => '#5b69bc',
-        'custom'  => '#59a9f8',
-        'pink'    => '#ff8acc',
-        'dark'    => '#22292f',
-        'white'   => '#fff',
-        'white50' => 'hsla(0,0%,100%,.5)',
-
-         // 其他蓝色
-        'blue1' => '#007ee5',
-        'blue2' => '#4199de',
-
-        // 橘色
-        'orange1' => '#ffcc80',
-        'orange2' => '#F99037',
-
-        // 黄色
-        'yellow' => '#edc30e',
-
-        'indigo-darker' => '#495abf',
-        'red-darker'    => '#bd4147',
-        'blue-darker'   => '#236bb0',
-        'cyan-darker'   => '#6355ee',
-
-        // 灰色
-        'gray' => '#b9c3cd',
-        // 轻灰
-        'light' => '#f7f7f9',
-
-        // 水鸭色
-        'tear'  => '#01847f',
-        'tear1' => '#00b5b5',
-
-        // 深色
-        'dark20' => '#f6fbff',
-        'dark30' => '#f4f7fa',
-        'dark35' => '#e7eef7',
-        'dark40' => '#ebf0f3',
-        'dark50' => '#d3dde5',
-        'dark60' => '#bacad6',
-        'dark70' => '#b3b9bf',
-        'dark80' => '#7c858e',
-        'dark85' => '#5c7089',
-        'dark90' => '#252d37',
-
-        // 文本通用颜色
-        'font' => '#414750',
-
-        // 灰色背景
-        'gray-bg' => '#f1f1f1',
-
-        // 边框颜色
-        'border' => '#ebeff2',
-
-        // 表单边框
-        'input-border' => '#d9d9d9',
-    ];
-
-    /**
-     * 主题名称.
-     *
-     * @var string
-     */
-    protected $name;
-
-    /**
-     * @var array
-     */
-    protected $currentColors = [];
-
-    /**
-     * @var array
-     */
-    protected $realColors;
-
-    /**
-     * Color constructor.
-     *
-     * @param string $name
-     */
-    public function __construct($name = null)
-    {
-        $this->name = ($name ?: config('admin.layout.color')) ?: 'indigo';
-
-        $this->currentColors = array_merge(
-            static::$default,
-            static::$colors[$this->name]['colors'] ?? []
-        );
-    }
-
-    /**
-     * @return string
-     */
-    public function name()
-    {
-        return $this->name;
-    }
-
-    /**
-     * 获取css文件路径.
-     *
-     * @return array
-     */
-    public function css()
-    {
-        return static::$colors[$this->name]['css'];
-    }
-
-    /**
-     * 获取颜色.
-     *
-     * @param array  $colorName
-     * @param string $default
-     *
-     * @return string
-     */
-    public function get(string $colorName, string $default = null)
-    {
-        if ($this->realColors) {
-            return $this->realColors[$colorName] ?? $default;
-        }
-
-        $result = $this->currentColors[$colorName] ?? $default;
-
-        if ($result && ! empty($this->currentColors[$result])) {
-            return $this->get($result, $default);
-        }
-
-        return $result;
-    }
-
-    /**
-     * 获取所有颜色.
-     *
-     * @return array
-     */
-    public function all()
-    {
-        if ($this->realColors === null) {
-            foreach ($this->currentColors as $key => &$color) {
-                $color = $this->get($key);
-            }
-
-            $this->realColors = &$this->currentColors;
-        }
-
-        return $this->realColors;
-    }
-
-    /**
-     * 颜色转亮.
-     *
-     * @param string $color
-     * @param int    $amt
-     *
-     * @return string
-     */
-    public function lighten(string $color, int $amt)
-    {
-        return Helper::colorLighten($this->get($color, $color), $amt);
-    }
-
-    /**
-     * 颜色转暗.
-     *
-     * @param string $color
-     * @param int    $amt
-     *
-     * @return string
-     */
-    public function darken(string $color, int $amt)
-    {
-        return Helper::colorDarken($this->get($color, $color), $amt);
-    }
-
-    /**
-     * 颜色透明度转化.
-     *
-     * @param string       $color
-     * @param float|string $alpha
-     *
-     * @return string
-     */
-    public function alpha(string $color, $alpha)
-    {
-        return Helper::colorAlpha($this->get($color, $color), $alpha);
-    }
-
-    /**
-     * 获取颜色.
-     *
-     * @param string $method
-     * @param array $arguments
-     *
-     * @return string
-     */
-    public function __call(string $method, array $arguments = [])
-    {
-        return $this->darken(
-            Helper::slug($method),
-            $arguments[0] ?? 0
-        );
-    }
-
-    /**
-     * 扩展颜色.
-     *
-     * @param string       $name
-     * @param string|array $skinPath
-     * @param array        $colors
-     *
-     * @return void
-     */
-    public static function extend(string $name, $skinPath, array $colors)
-    {
-        static::$colors[$name] = [
-            'css'    => array_filter((array) $skinPath),
-            'colors' => $colors,
-        ];
-    }
-}
+<?php
+
+namespace Dcat\Admin;
+
+use Dcat\Admin\Support\Helper;
+
+/**
+ * Class Color.
+ *
+ *
+ * @method string primary(int $amt = 0)
+ * @method string primaryDarker(int $amt = 0)
+ * @method string link(int $amt = 0)
+ * @method string info(int $amt = 0)
+ * @method string success(int $amt = 0)
+ * @method string danger(int $amt = 0)
+ * @method string warning(int $amt = 0)
+ * @method string indigo(int $amt = 0)
+ * @method string blue(int $amt = 0)
+ * @method string red(int $amt = 0)
+ * @method string orange(int $amt = 0)
+ * @method string green(int $amt = 0)
+ * @method string cyan(int $amt = 0)
+ * @method string purple(int $amt = 0)
+ * @method string custom(int $amt = 0)
+ * @method string pink(int $amt = 0)
+ * @method string dark(int $amt = 0)
+ * @method string white(int $amt = 0)
+ * @method string white50(int $amt = 0)
+ * @method string blue1(int $amt = 0)
+ * @method string blue2(int $amt = 0)
+ * @method string orange1(int $amt = 0)
+ * @method string orange2(int $amt = 0)
+ * @method string yellow(int $amt = 0)
+ * @method string indigoDarker(int $amt = 0)
+ * @method string redDarker(int $amt = 0)
+ * @method string blueDarker(int $amt = 0)
+ * @method string cyanDarker(int $amt = 0)
+ * @method string gray(int $amt = 0)
+ * @method string light(int $amt = 0)
+ * @method string tear(int $amt = 0)
+ * @method string tear1(int $amt = 0)
+ * @method string dark20(int $amt = 0)
+ * @method string dark30(int $amt = 0)
+ * @method string dark35(int $amt = 0)
+ * @method string dark40(int $amt = 0)
+ * @method string dark50(int $amt = 0)
+ * @method string dark60(int $amt = 0)
+ * @method string dark70(int $amt = 0)
+ * @method string dark80(int $amt = 0)
+ * @method string dark90(int $amt = 0)
+ * @method string dark90half(int $amt = 0)
+ * @method string font(int $amt = 0)
+ * @method string grayBg(int $amt = 0)
+ * @method string border(int $amt = 0)
+ * @method string inputBorder(int $amt = 0)
+ */
+class Color
+{
+    /**
+     * 颜色.
+     *
+     * @var array
+     */
+    protected static $colors = [
+        'cyan' => [
+            'css' => [
+
+            ],
+            'colors' => [
+                'primary'        => 'cyan',
+                'primary-darker' => 'cyan-darker',
+                'link'           => 'cyan-darker',
+            ],
+        ],
+        'indigo' => [
+            'css' => [
+
+            ],
+            'colors' => [
+                'primary'        => 'indigo',
+                'primary-darker' => 'indigo-darker',
+                'link'           => 'indigo-darker',
+            ],
+        ],
+    ];
+
+    /**
+     * 默认颜色.
+     *
+     * @var array
+     */
+    protected static $default = [
+        'info'    => 'blue',
+        'success' => 'green',
+        'danger'  => 'red',
+        'warning' => 'orange',
+        'indigo'  => '#5c6bc6',
+        'blue'    => '#3085d6',
+        'red'     => '#ea5455',
+        'orange'  => '#ff9f43',
+        'green'   => '#21b978',
+        'cyan'    => '#7367f0',
+        'purple'  => '#5b69bc',
+        'custom'  => '#59a9f8',
+        'pink'    => '#ff8acc',
+        'dark'    => '#22292f',
+        'white'   => '#fff',
+        'white50' => 'hsla(0,0%,100%,.5)',
+
+        // 其他蓝色
+        'blue1' => '#007ee5',
+        'blue2' => '#4199de',
+
+        // 橘色
+        'orange1' => '#ffcc80',
+        'orange2' => '#F99037',
+
+        // 黄色
+        'yellow' => '#edc30e',
+
+        'indigo-darker' => '#495abf',
+        'red-darker'    => '#bd4147',
+        'blue-darker'   => '#236bb0',
+        'cyan-darker'   => '#6355ee',
+
+        // 灰色
+        'gray' => '#b9c3cd',
+        // 轻灰
+        'light' => '#f7f7f9',
+
+        // 水鸭色
+        'tear'  => '#01847f',
+        'tear1' => '#00b5b5',
+
+        // 深色
+        'dark20' => '#f6fbff',
+        'dark30' => '#f4f7fa',
+        'dark35' => '#e7eef7',
+        'dark40' => '#ebf0f3',
+        'dark50' => '#d3dde5',
+        'dark60' => '#bacad6',
+        'dark70' => '#b3b9bf',
+        'dark80' => '#7c858e',
+        'dark85' => '#5c7089',
+        'dark90' => '#252d37',
+
+        // 文本通用颜色
+        'font' => '#414750',
+
+        // 灰色背景
+        'gray-bg' => '#f1f1f1',
+
+        // 边框颜色
+        'border' => '#ebeff2',
+
+        // 表单边框
+        'input-border' => '#d9d9d9',
+    ];
+
+    /**
+     * 主题名称.
+     *
+     * @var string
+     */
+    protected $name;
+
+    /**
+     * @var array
+     */
+    protected $currentColors = [];
+
+    /**
+     * @var array
+     */
+    protected $realColors;
+
+    /**
+     * Color constructor.
+     *
+     * @param string $name
+     */
+    public function __construct($name = null)
+    {
+        $this->name = ($name ?: config('admin.layout.color')) ?: 'indigo';
+
+        $this->currentColors = array_merge(
+            static::$default,
+            static::$colors[$this->name]['colors'] ?? []
+        );
+    }
+
+    /**
+     * @return string
+     */
+    public function name()
+    {
+        return $this->name;
+    }
+
+    /**
+     * 获取css文件路径.
+     *
+     * @return array
+     */
+    public function css()
+    {
+        return static::$colors[$this->name]['css'];
+    }
+
+    /**
+     * 获取颜色.
+     *
+     * @param array  $colorName
+     * @param string $default
+     *
+     * @return string
+     */
+    public function get(string $colorName, string $default = null)
+    {
+        if ($this->realColors) {
+            return $this->realColors[$colorName] ?? $default;
+        }
+
+        $result = $this->currentColors[$colorName] ?? $default;
+
+        if ($result && ! empty($this->currentColors[$result])) {
+            return $this->get($result, $default);
+        }
+
+        return $result;
+    }
+
+    /**
+     * 获取所有颜色.
+     *
+     * @return array
+     */
+    public function all()
+    {
+        if ($this->realColors === null) {
+            foreach ($this->currentColors as $key => &$color) {
+                $color = $this->get($key);
+            }
+
+            $this->realColors = &$this->currentColors;
+        }
+
+        return $this->realColors;
+    }
+
+    /**
+     * 颜色转亮.
+     *
+     * @param string $color
+     * @param int    $amt
+     *
+     * @return string
+     */
+    public function lighten(string $color, int $amt)
+    {
+        return Helper::colorLighten($this->get($color, $color), $amt);
+    }
+
+    /**
+     * 颜色转暗.
+     *
+     * @param string $color
+     * @param int    $amt
+     *
+     * @return string
+     */
+    public function darken(string $color, int $amt)
+    {
+        return Helper::colorDarken($this->get($color, $color), $amt);
+    }
+
+    /**
+     * 颜色透明度转化.
+     *
+     * @param string       $color
+     * @param float|string $alpha
+     *
+     * @return string
+     */
+    public function alpha(string $color, $alpha)
+    {
+        return Helper::colorAlpha($this->get($color, $color), $alpha);
+    }
+
+    /**
+     * 获取颜色.
+     *
+     * @param string $method
+     * @param array $arguments
+     *
+     * @return string
+     */
+    public function __call(string $method, array $arguments = [])
+    {
+        return $this->darken(
+            Helper::slug($method),
+            $arguments[0] ?? 0
+        );
+    }
+
+    /**
+     * 扩展颜色.
+     *
+     * @param string       $name
+     * @param string|array $skinPath
+     * @param array        $colors
+     *
+     * @return void
+     */
+    public static function extend(string $name, $skinPath, array $colors)
+    {
+        static::$colors[$name] = [
+            'css'    => array_filter((array) $skinPath),
+            'colors' => $colors,
+        ];
+    }
+}

+ 2 - 2
src/Console/Development/LinkCommand.php

@@ -3,8 +3,8 @@
 namespace Dcat\Admin\Console\Development;
 
 use Dcat\Admin\Admin;
-use Illuminate\Filesystem\Filesystem;
 use Illuminate\Console\Command;
+use Illuminate\Filesystem\Filesystem;
 
 class LinkCommand extends Command
 {
@@ -79,7 +79,7 @@ class LinkCommand extends Command
             return;
         }
 
-        $distPath = realpath(__DIR__ . '/../../../resources/pre-dist');
+        $distPath = realpath(__DIR__.'/../../../resources/pre-dist');
 
         $files->link(
             $distPath, $publicPath

+ 1 - 1
src/Contracts/TreeRepository.php

@@ -20,7 +20,7 @@ interface TreeRepository
     public function getPrimaryKeyColumn();
 
     /**
-     * 获取父级ID字段名称
+     * 获取父级ID字段名称.
      *
      * @return string
      */

+ 32 - 32
src/Contracts/UploadField.php

@@ -1,32 +1,32 @@
-<?php
-
-namespace Dcat\Admin\Contracts;
-
-use Symfony\Component\HttpFoundation\File\UploadedFile;
-use Symfony\Component\HttpFoundation\Response;
-
-interface UploadField
-{
-    /**
-     * Upload File.
-     *
-     * @param UploadedFile $file
-     *
-     * @return Response
-     */
-    public function upload(UploadedFile $file);
-
-    /**
-     * Destroy original files.
-     *
-     * @return void.
-     */
-    public function destroy();
-
-    /**
-     * Destroy files.
-     *
-     * @param string|array $path
-     */
-    public function deleteFile($path);
-}
+<?php
+
+namespace Dcat\Admin\Contracts;
+
+use Symfony\Component\HttpFoundation\File\UploadedFile;
+use Symfony\Component\HttpFoundation\Response;
+
+interface UploadField
+{
+    /**
+     * Upload File.
+     *
+     * @param UploadedFile $file
+     *
+     * @return Response
+     */
+    public function upload(UploadedFile $file);
+
+    /**
+     * Destroy original files.
+     *
+     * @return void.
+     */
+    public function destroy();
+
+    /**
+     * Destroy files.
+     *
+     * @param string|array $path
+     */
+    public function deleteFile($path);
+}

+ 0 - 1
src/Controllers/Dashboard.php

@@ -3,7 +3,6 @@
 namespace Dcat\Admin\Controllers;
 
 use Dcat\Admin\Admin;
-use Dcat\Admin\Widgets\Card;
 use Dcat\Admin\Widgets\Tab;
 use Illuminate\Support\Arr;
 

+ 1 - 2
src/Controllers/ExtensionController.php

@@ -10,7 +10,6 @@ use Dcat\Admin\Models\Repositories\Extension;
 use Dcat\Admin\Support\Helper;
 use Dcat\Admin\Support\StringOutput;
 use Dcat\Admin\Widgets\Alert;
-use Dcat\Admin\Widgets\Box;
 use Dcat\Admin\Widgets\Table;
 use Dcat\Admin\Widgets\Terminal;
 use Illuminate\Routing\Controller;
@@ -179,7 +178,7 @@ class ExtensionController extends Controller
     }
 
     /**
-     * 创建扩展
+     * 创建扩展.
      *
      * @return string
      */

+ 59 - 59
src/Controllers/ValueController.php

@@ -1,59 +1,59 @@
-<?php
-
-namespace Dcat\Admin\Controllers;
-
-use Exception;
-use Illuminate\Http\Request;
-
-class ValueController
-{
-    /**
-     * @param Request $request
-     *
-     * @return mixed
-     */
-    public function handle(Request $request)
-    {
-        $instance = $this->resolve($request);
-
-        if (! $instance->passesAuthorization()) {
-            return $instance->failedAuthorization();
-        }
-
-        $response = $instance->handle($request);
-
-        if ($response) {
-            return $response;
-        }
-
-        if (method_exists($instance, 'valueResult')) {
-            return $instance->valueResult();
-        }
-    }
-
-    /**
-     * @param Request $request
-     *
-     * @throws Exception
-     *
-     * @return \Dcat\Admin\Traits\InteractsWithApi
-     */
-    protected function resolve(Request $request)
-    {
-        if (! $key = $request->get('_key')) {
-            throw new Exception('Invalid request.');
-        }
-
-        if (! class_exists($key)) {
-            throw new Exception("Class [{$key}] does not exist.");
-        }
-
-        $instance = app($key);
-
-        if (! method_exists($instance, 'handle')) {
-            throw new Exception("The method '{$key}::handle()' does not exist.");
-        }
-
-        return $instance;
-    }
-}
+<?php
+
+namespace Dcat\Admin\Controllers;
+
+use Exception;
+use Illuminate\Http\Request;
+
+class ValueController
+{
+    /**
+     * @param Request $request
+     *
+     * @return mixed
+     */
+    public function handle(Request $request)
+    {
+        $instance = $this->resolve($request);
+
+        if (! $instance->passesAuthorization()) {
+            return $instance->failedAuthorization();
+        }
+
+        $response = $instance->handle($request);
+
+        if ($response) {
+            return $response;
+        }
+
+        if (method_exists($instance, 'valueResult')) {
+            return $instance->valueResult();
+        }
+    }
+
+    /**
+     * @param Request $request
+     *
+     * @throws Exception
+     *
+     * @return \Dcat\Admin\Traits\InteractsWithApi
+     */
+    protected function resolve(Request $request)
+    {
+        if (! $key = $request->get('_key')) {
+            throw new Exception('Invalid request.');
+        }
+
+        if (! class_exists($key)) {
+            throw new Exception("Class [{$key}] does not exist.");
+        }
+
+        $instance = app($key);
+
+        if (! method_exists($instance, 'handle')) {
+            throw new Exception("The method '{$key}::handle()' does not exist.");
+        }
+
+        return $instance;
+    }
+}

+ 1 - 1
src/Form.php

@@ -822,7 +822,7 @@ class Form implements Renderable
         if ($this->request->get('after-save') == 1) {
             // continue editing
             if ($this->builder->isEditing() && $this->isAjaxRequest()) {
-                return null;
+                return;
             }
 
             return rtrim($resourcesPath, '/')."/{$key}/edit";

+ 2 - 2
src/Form/Builder.php

@@ -3,11 +3,11 @@
 namespace Dcat\Admin\Form;
 
 use Closure;
-use Dcat\Admin\Form\Step\Builder as StepBuilder;
-use Dcat\Admin\Form\Step\Form as StepForm;
 use Dcat\Admin\Admin;
 use Dcat\Admin\Form;
 use Dcat\Admin\Form\Field\Hidden;
+use Dcat\Admin\Form\Step\Builder as StepBuilder;
+use Dcat\Admin\Form\Step\Form as StepForm;
 use Dcat\Admin\SimpleGrid;
 use Dcat\Admin\Support\Helper;
 use Dcat\Admin\Widgets\DialogForm;

+ 1 - 1
src/Form/Concerns/HasFiles.php

@@ -2,9 +2,9 @@
 
 namespace Dcat\Admin\Form\Concerns;
 
+use Dcat\Admin\Contracts\UploadField as UploadFieldInterface;
 use Dcat\Admin\Form\Builder;
 use Dcat\Admin\Form\Field;
-use Dcat\Admin\Contracts\UploadField as UploadFieldInterface;
 use Symfony\Component\HttpFoundation\File\UploadedFile;
 use Symfony\Component\HttpFoundation\Response;
 

+ 1 - 1
src/Form/Field/File.php

@@ -2,9 +2,9 @@
 
 namespace Dcat\Admin\Form\Field;
 
+use Dcat\Admin\Contracts\UploadField as UploadFieldInterface;
 use Dcat\Admin\Form\Field;
 use Dcat\Admin\Support\Helper;
-use Dcat\Admin\Contracts\UploadField as UploadFieldInterface;
 use Illuminate\Support\Arr;
 use Illuminate\Support\Facades\Validator;
 use Illuminate\Support\Str;

+ 0 - 2
src/Form/Field/Icon.php

@@ -2,8 +2,6 @@
 
 namespace Dcat\Admin\Form\Field;
 
-use Dcat\Admin\Admin;
-
 class Icon extends Text
 {
     public static $js = '@fontawesome-iconpicker';

+ 0 - 1
src/Form/Field/Select.php

@@ -14,7 +14,6 @@ class Select extends Field
     public static $js = '@select2';
     public static $css = '@select2';
 
-
     /**
      * @var array
      */

+ 0 - 1
src/Form/Field/Tree.php

@@ -2,7 +2,6 @@
 
 namespace Dcat\Admin\Form\Field;
 
-use Dcat\Admin\Admin;
 use Dcat\Admin\Form\Field;
 use Dcat\Admin\Support\Helper;
 use Dcat\Admin\Widgets\Checkbox as WidgetCheckbox;

+ 1 - 1
src/Form/Field/WebUploader.php

@@ -163,7 +163,7 @@ trait WebUploader
             'formData' => [
                 '_id'           => Str::random(),
                 '_token'        => csrf_token(),
-                'upload_column' => $this->column()
+                'upload_column' => $this->column(),
             ],
         ];
 

+ 1 - 1
src/Form/Step/Builder.php

@@ -4,8 +4,8 @@ namespace Dcat\Admin\Form\Step;
 
 use Closure;
 use Dcat\Admin\Admin;
-use Dcat\Admin\Form\StepForm as Form;
 use Dcat\Admin\Form as ParentForm;
+use Dcat\Admin\Form\StepForm as Form;
 use Illuminate\Support\Arr;
 
 class Builder

+ 0 - 1
src/Grid/Displayers/Checkbox.php

@@ -4,7 +4,6 @@ namespace Dcat\Admin\Grid\Displayers;
 
 use Dcat\Admin\Admin;
 use Illuminate\Contracts\Support\Arrayable;
-use Illuminate\Support\Str;
 
 class Checkbox extends AbstractDisplayer
 {

+ 0 - 1
src/Grid/Displayers/Radio.php

@@ -3,7 +3,6 @@
 namespace Dcat\Admin\Grid\Displayers;
 
 use Dcat\Admin\Admin;
-use Illuminate\Support\Str;
 
 class Radio extends AbstractDisplayer
 {

+ 1 - 1
src/Grid/Tools/PerPageSelector.php

@@ -80,7 +80,7 @@ class PerPageSelector implements Renderable
             return "<a href=\"$url\">$option</a>";
         })->toArray();
 
-        $dropdown =  Dropdown::make($options)->button($this->perPage)->render();
+        $dropdown = Dropdown::make($options)->button($this->perPage)->render();
 
         return <<<EOT
 <label class="pull-right d-none d-sm-inline" style="margin-right: 10px">

+ 714 - 714
src/Layout/Asset.php

@@ -1,717 +1,717 @@
-<?php
-
-namespace Dcat\Admin\Layout;
-
-class Asset
-{
-    /**
-     * 路径别名
-     *
-     * @var array
-     */
-    protected $pathAlias = [
-        // Dcat Admin静态资源路径别名
-        '@admin' => 'vendors/dcat-admin',
-
-        // Dcat Acmin扩展静态资源路径别名
-        '@extension' => 'vendors/dcat-admin-extensions',
-    ];
-
-    /**
-     * 别名.
-     *
-     * @var array
-     */
-    protected $alias = [
-        '@nunito' => [
-            'css' => ['https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,800,800i,900,900i'],
-        ],
-        '@montserrat' => [
-            'css' => ['https://fonts.googleapis.com/css?family=Montserrat:300,400,500,600'],
-        ],
-        '@dcat' => [
-            'js'  => '@admin/dcat/js/dcat-app.js',
-            'css' => '@admin/dcat/css/dcat-app.css',
-        ],
-        '@vendors' => [
-            'js'  => '@admin/vendors/js/vendors.min.js',
-            'css' => '@admin/vendors/css/vendors.min.css',
-        ],
-        '@bootstrap' => [
-            'css' => '@admin/css/bootstrap.css',
-        ],
-        '@bootstrap-extended' => [
-            'css' => '@admin/css/bootstrap-extended.css',
-        ],
-        '@default-colors' => [
-            'css' => '@admin/css/colors.css',
-        ],
-        '@menu' => [
-            'js' => '@admin/js/core/app-menu.js',
-        ],
-        '@app' => [
-            'js' => '@admin/js/core/app.js',
-        ],
-        '@components' => [
-            'css' => '@admin/css/components.css',
-        ],
-        '@palette-gradient' => [
-            'css' => '@admin/css/core/colors/palette-gradient.css',
-        ],
-        '@datatables' => [
-            'css' => '@admin/vendors/css/tables/datatable/datatables.min.css',
-        ],
-        '@data-list-view' => [
-            'css' => '@admin/css/pages/data-list-view.css',
-        ],
-        '@custom' => [
-            'css' => '@admin/css/custom-laravel.css',
-        ],
-        '@grid-extension' => [
-            'js' => '@admin/dcat/extra/grid-extend.js',
-        ],
-        '@resource-selector' => [
-            'js' => '@admin/dcat/extra/resource-selector.js',
-        ],
-        '@layer' => [
-            'js' => '@admin/dcat/plugins/layer/layer.js',
-        ],
-        '@pjax' => [
-            'js' => '@admin/dcat/plugins/jquery-pjax/jquery.pjax.min.js',
-        ],
-        '@toastr' => [
-            'js'  => '@admin/vendors/js/extensions/toastr.min.js',
-            'css' => '@admin/vendors/css/extensions/toastr.css',
-        ],
-        '@jquery.nestable' => [
-            'js'  => '@admin/dcat/plugins/nestable/jquery.nestable.min.js',
-            'css' => '@admin/dcat/plugins/nestable/nestable.css',
-        ],
-        '@validator' => [
-            'js' => '@admin/dcat/plugins/bootstrap-validator/validator.min.js',
-        ],
-        '@select2' => [
-            'js'  => '@admin/vendors/js/forms/select/select2.full.min.js',
-            'css' => '@admin/vendors/css/forms/select/select2.min.css',
-        ],
-        '@bootstrap-datetimepicker' => [
-            'js'  => '@admin/dcat/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js',
-            'css' => '@admin/dcat/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css',
-        ],
-        '@moment' => [
-            'js' => [
-                '@admin/dcat/plugins/moment/moment.min.js',
-            ],
-        ],
-        '@moment-timezone' => [
-            'js' => [
-                '@admin/dcat/plugins/moment/moment-timezone-with-data.min.js',
-            ],
-        ],
-        '@rwd-table' => [
-            'js'  => '@admin/dcat/plugins/RWD-Table-Patterns/dist/js/rwd-table.min.js',
-            'css' => '@admin/dcat/plugins/RWD-Table-Patterns/dist/css/rwd-table.min.css',
-        ],
-        '@jstree' => [
-            'js'  => '@admin/dcat/plugins/jstree-theme/jstree.min.js',
-            'css' => '@admin/dcat/plugins/jstree-theme/themes/proton/style.min.css',
-        ],
-        '@switchery' => [
-            'js'  => '@admin/dcat/plugins/switchery/switchery.min.js',
-            'css' => '@admin/dcat/plugins/switchery/switchery.min.css',
-        ],
-        '@webuploader' => [
-            'js' => [
-                '@admin/dcat/plugins/webuploader/webuploader.min.js',
-                '@admin/dcat/extra/upload.js',
-            ],
-            'css' => '@admin/dcat/extra/upload.css',
-        ],
-        '@chartjs' => [
-            'js' => '@admin/dcat/plugins/chart.js/chart.bundle.min.js',
-        ],
-        '@jquery.sparkline' => [
-            'js' => '@admin/dcat/plugins/jquery.sparkline/jquery.sparkline.min.js',
-        ],
-        '@jquery.bootstrap-duallistbox' => [
-            'js'  => '@admin/dcat/plugins/bootstrap-duallistbox/dist/jquery.bootstrap-duallistbox.min.js',
-            'css' => '@admin/dcat/plugins/bootstrap-duallistbox/dist/bootstrap-duallistbox.min.css',
-        ],
-        '@number-input' => [
-            'js' => '@admin/dcat/plugins/number-input/bootstrap-number-input.js',
-        ],
-        '@ionslider' => [
-            'js' => [
-                '@admin/dcat/plugins/ionslider/ion.rangeSlider.min.js',
-            ],
-            'css' => [
-                '@admin/dcat/plugins/ionslider/ion.rangeSlider.css',
-                '@admin/dcat/plugins/ionslider/ion.rangeSlider.skinNice.css',
-            ],
-        ],
-        '@editor-md' => [
-            'js' => [
-                '@admin/dcat/plugins/editor-md/lib/raphael.min.js',
-                '@admin/dcat/plugins/editor-md/lib/marked.min.js',
-                '@admin/dcat/plugins/editor-md/lib/prettify.min.js',
-                '@admin/dcat/plugins/editor-md/lib/underscore.min.js',
-                '@admin/dcat/plugins/editor-md/lib/sequence-diagram.min.js',
-                '@admin/dcat/plugins/editor-md/lib/flowchart.min.js',
-                '@admin/dcat/plugins/editor-md/lib/jquery.flowchart.min.js',
-                '@admin/dcat/plugins/editor-md/editormd.min.js',
-            ],
-            'css' => [
-                '@admin/dcat/plugins/editor-md/css/editormd.preview.min.css',
-                '@admin/dcat/extra/markdown.css',
-            ],
-        ],
-        '@jquery.inputmask' => [
-            'js' => '@admin/dcat/plugins/input-mask/jquery.inputmask.bundle.min.js',
-        ],
-        '@apex-charts' => [
-            'js' => '@admin/vendors/js/charts/apexcharts.min.js',
-        ],
-        '@smart-wizard' => [
-            'js' => '@admin/dcat/plugins/SmartWizard/dist/js/jquery.smartWizard.min.js',
-            'css' => '@admin/dcat/extra/step.css',
-        ],
-        '@fontawesome-iconpicker' => [
-            'js' => '@admin/dcat/plugins/fontawesome-iconpicker/dist/js/fontawesome-iconpicker.js',
-            'css' => '@admin/dcat/plugins/fontawesome-iconpicker/dist/css/fontawesome-iconpicker.min.css',
-        ],
-    ];
-
-    /**
-     * js代码.
-     *
-     * @var array
-     */
-    protected $script = [];
-
-    /**
-     * css代码.
-     *
-     * @var array
-     */
-    protected $style = [];
-
-    /**
-     * css脚本路径.
-     *
-     * @var array
-     */
-    protected $css = [];
-
-    /**
-     * js脚本路径.
-     *
-     * @var array
-     */
-    protected $js = [];
-
-    /**
-     * 在head标签内加载的js脚本.
-     *
-     * @var array
-     */
-    protected $headerJs = [
-        'vendors' => '@vendors',
-        'dcat'    => '@dcat',
-    ];
-
-    /**
-     * 基础css.
-     *
-     * @var array
-     */
-    protected $baseCss = [
-        'vendors'            => '@vendors',
-        'bootstrap'          => '@bootstrap',
-        'bootstrap-extended' => '@bootstrap-extended',
-        'toastr'             => '@toastr',
-        'components'         => '@components',
-        'palette-gradient'   => '@palette-gradient',
-        'colors'             => '@default-colors',
-        //'custom'             => 'custom',
-
-        'datatables'     => '@datatables',
-        'data-list-view' => '@data-list-view',
-        'dcat'           => '@dcat',
-    ];
-
-    /**
-     * 基础js.
-     *
-     * @var array
-     */
-    protected $baseJs = [
-        'menu'      => '@menu',
-        'app'       => '@app',
-        'toastr'    => '@toastr',
-        'pjax'      => '@pjax',
-        'validator' => '@validator',
-        'layer'     => '@layer',
-    ];
-
-    /**
-     * @var array
-     */
-    public $fonts = [
-        '@nunito',
-        '@montserrat',
-    ];
-
-    /**
-     * @var bool
-     */
-    protected $isPjax = false;
-
-    /**
-     * @var bool
-     */
-    protected $usingFullPage = false;
-
-    /**
-     * @var array
-     */
-    protected $themeCssMap = [
-        'dark'      => 'dark-layout',
-        'semi-dark' => 'semi-dark-layout',
-    ];
-
-    /**
-     * Assets constructor.
-     */
-    public function __construct()
-    {
-        $this->isPjax = request()->pjax();
-    }
-
-    /**
-     * 设置或获取别名.
-     *
-     * @param string|array $name
-     * @param string|array $js
-     * @param string|array $css
-     *
-     * @return void|array
-     */
-    public function alias($name, $js = null, $css = null)
-    {
-        if (is_array($name)) {
-            foreach ($name as $key => $value) {
-                $this->alias($key, $value['js'] ?? [], $value['css'] ?? []);
-            }
-
-            return;
-        }
-
-        if ($js === null && $css === null) {
-            return $this->alias[$name] ?? [];
-        }
-
-        if (strpos($name, '@') !== 0) {
-            $name = '@'.$name;
-        }
-
-        $this->alias[$name] = [
-            'js'  => $js,
-            'css' => $css,
-        ];
-    }
-
-    /**
-     * 使用全页面(无菜单和导航栏).
-     *
-     * @param bool $value
-     *
-     * @return $this
-     */
-    public function full(bool $value = true)
-    {
-        $this->usingFullPage = $value;
-
-        return $this;
-    }
-
-    /**
-     * 根据别名设置需要载入的js和css脚本.
-     *
-     * @param string $alias
-     * @param string $type
-     */
-    public function collect(string $alias, string $type = '')
-    {
-        if (strpos($alias, '@') !== 0) {
-            $alias = '@'.$alias;
-        }
-
-        if ($type === 'js') {
-            $this->js($this->alias[$alias]['js'] ?? null);
-
-            return;
-        } elseif ($type === 'css') {
-            $this->css($this->alias[$alias]['css'] ?? null);
-
-            return;
-        }
-
-        $this->js($this->alias[$alias]['js'] ?? null);
-        $this->css($this->alias[$alias]['css'] ?? null);
-    }
-
-    /**
-     * 设置需要载入的css脚本.
-     *
-     * @param string|array $css
-     */
-    public function css($css)
-    {
-        if (! $css) {
-            return;
-        }
-        $this->css = array_merge(
-            $this->css,
-            (array) $css
-        );
-    }
-
-    /**
-     * 设置需要载入的基础css脚本.
-     *
-     * @param array $css
-     */
-    public function baseCss(array $css)
-    {
-        $this->baseCss = $css;
-    }
-
-    /**
-     * 设置需要载入的js脚本.
-     *
-     * @param string|array $js
-     */
-    public function js($js)
-    {
-        if (! $js) {
-            return;
-        }
-        $this->js = array_merge(
-            $this->js,
-            (array) $js
-        );
-    }
-
-    /**
-     * 根据别名获取资源路径.
-     *
-     * @param string $path
-     * @param string $type
-     *
-     * @return string|array|null
-     */
-    public function get($path, string $type = 'js')
-    {
-        if (empty($this->alias[$path])) {
-            return $this->url($path);
-        }
-
-        $paths = isset($this->alias[$path][$type]) ? (array) $this->alias[$path][$type] : null;
-
-        if (! $paths) {
-            return $paths;
-        }
-
-        foreach ($paths as &$value) {
-            $value = $this->url($value);
-        }
-
-        return $paths;
-    }
-
-    /**
-     * 获取静态资源完整URL.
-     *
-     * @param string $path
-     *
-     * @return string
-     */
-    public function url($path)
-    {
-        if (! $path) {
-            return $path;
-        }
-
-        $path = $this->getRealPath($path);
-
-        if (strpos($path, '//') === false) {
-            $path = config('admin.assets_server').'/'.trim($path, '/');
-        }
-
-        return (config('admin.https') || config('admin.secure')) ? secure_asset($path) : asset($path);
-    }
-
-    /**
-     * 获取真实路径.
-     *
-     * @param string|null $path
-     *
-     * @return string|null
-     */
-    public function getRealPath(?string $path)
-    {
-        if (! $this->hasAlias($path)) {
-            return $path;
-        }
-
-        return implode(
-            '/',
-            array_map(
-                function ($v) {
-                    $v = $this->pathAlias[$v] ?? $v;
-
-                    if (! $this->hasAlias($v)) {
-                        return $v;
-                    }
-
-                    return $this->getRealPath($v);
-                },
-                explode('/', $path)
-            )
-        );
-    }
-
-    /**
-     * 判断是否含有别名
-     *
-     * @param string $value
-     *
-     * @return bool
-     */
-    protected function hasAlias($value)
-    {
-        return $value && mb_strpos($value, '@') !== false;
-    }
-
-    /**
-     * 设置在head标签内加载的js.
-     *
-     * @param string|array $js
-     */
-    public function headerJs($js)
-    {
-        if (! $js) {
-            return;
-        }
-        $this->headerJs = array_merge($this->headerJs, (array) $js);
-    }
-
-    /**
-     * 设置基础js脚本.
-     *
-     * @param array $js
-     */
-    public function baseJs(array $js)
-    {
-        $this->baseJs = $js;
-    }
-
-    /**
-     * 设置js代码.
-     *
-     * @param string|array $script
-     */
-    public function script($script)
-    {
-        if (! $script) {
-            return;
-        }
-        $this->script = array_merge($this->script, (array) $script);
-    }
-
-    /**
-     * 设置css代码.
-     *
-     * @param string $style
-     */
-    public function style($style)
-    {
-        if (! $style) {
-            return;
-        }
-        $this->style = array_merge($this->style, (array) $style);
-    }
-
-    /**
-     * 增加布局css文件.
-     */
-    protected function addLayoutCss()
-    {
-        if ($this->usingFullPage) {
-            return;
-        }
-
-        if (config('admin.layout.main_layout_type') === 'horizontal') {
-            $this->baseCss[] = '@admin/css/core/menu/menu-types/horizontal-menu.css';
-        }
-
-        $this->baseCss[] = '@admin/css/core/menu/menu-types/vertical-menu.css';
-    }
-
-    /**
-     * 主题css文件.
-     */
-    protected function addThemeCss()
-    {
-        if (! $theme = config('admin.layout.theme')) {
-            return;
-        }
-
-        $css = $this->themeCssMap[$theme] ?? $theme;
-
-        if ($css === 'light') {
-            return;
-        }
-
-        $this->baseCss[] = "@admin/css/themes/{$css}.css";
-    }
-
-    /**
-     * 字体css脚本路径.
-     */
-    protected function addFontCss()
-    {
-        $this->fonts && (
-            $this->baseCss = array_merge(
-                $this->baseCss,
-                (array) $this->fonts
-            )
-        );
-    }
-
-    /**
-     * 合并基础css脚本.
-     */
-    protected function mergeBaseCss()
-    {
-        if ($this->isPjax) {
-            return;
-        }
-
-        $this->addLayoutCss();
-        $this->addThemeCss();
-        $this->addFontCss();
-
-        $this->css = array_merge($this->baseCss, $this->css);
-    }
-
-    /**
-     * @return string
-     */
-    public function renderCss()
-    {
-        $this->mergeBaseCss();
-
-        $html = '';
-
-        foreach (array_unique($this->css) as &$v) {
-            if (! $paths = $this->get($v, 'css')) {
-                continue;
-            }
-
-            foreach ((array) $paths as $path) {
-                $html .= "<link rel=\"stylesheet\" href=\"{$path}\">";
-            }
-        }
-
-        return $html;
-    }
-
-    /**
-     * 合并基础js脚本.
-     */
-    protected function mergeBaseJs()
-    {
-        if ($this->isPjax) {
-            return;
-        }
-
-        if ($this->usingFullPage) {
-            unset($this->baseJs['menu']);
-        }
-
-        $this->js = array_merge($this->baseJs, $this->js);
-    }
-
-    /**
-     * @return string
-     */
-    public function renderJs()
-    {
-        $this->mergeBaseJs();
-
-        $html = '';
-
-        foreach (array_unique($this->js) as &$v) {
-            if (! $paths = $this->get($v, 'js')) {
-                continue;
-            }
-
-            foreach ((array) $paths as $path) {
-                $html .= "<script src=\"{$path}\"></script>";
-            }
-        }
-
-        return $html;
-    }
-
-    /**
-     * @return string
-     */
-    public function renderHeaderJs()
-    {
-        $html = '';
-
-        foreach (array_unique($this->headerJs) as &$v) {
-            if (! $paths = $this->get($v, 'js')) {
-                continue;
-            }
-
-            foreach ((array) $paths as $path) {
-                $html .= "<script src=\"{$path}\"></script>";
-            }
-        }
-
-        return $html;
-    }
-
-    /**
-     * @return string
-     */
-    public function renderScript()
-    {
-        $script = implode(';', array_unique($this->script));
-
-        return <<<HTML
+<?php
+
+namespace Dcat\Admin\Layout;
+
+class Asset
+{
+    /**
+     * 路径别名.
+     *
+     * @var array
+     */
+    protected $pathAlias = [
+        // Dcat Admin静态资源路径别名
+        '@admin' => 'vendors/dcat-admin',
+
+        // Dcat Acmin扩展静态资源路径别名
+        '@extension' => 'vendors/dcat-admin-extensions',
+    ];
+
+    /**
+     * 别名.
+     *
+     * @var array
+     */
+    protected $alias = [
+        '@nunito' => [
+            'css' => ['https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,800,800i,900,900i'],
+        ],
+        '@montserrat' => [
+            'css' => ['https://fonts.googleapis.com/css?family=Montserrat:300,400,500,600'],
+        ],
+        '@dcat' => [
+            'js'  => '@admin/dcat/js/dcat-app.js',
+            'css' => '@admin/dcat/css/dcat-app.css',
+        ],
+        '@vendors' => [
+            'js'  => '@admin/vendors/js/vendors.min.js',
+            'css' => '@admin/vendors/css/vendors.min.css',
+        ],
+        '@bootstrap' => [
+            'css' => '@admin/css/bootstrap.css',
+        ],
+        '@bootstrap-extended' => [
+            'css' => '@admin/css/bootstrap-extended.css',
+        ],
+        '@default-colors' => [
+            'css' => '@admin/css/colors.css',
+        ],
+        '@menu' => [
+            'js' => '@admin/js/core/app-menu.js',
+        ],
+        '@app' => [
+            'js' => '@admin/js/core/app.js',
+        ],
+        '@components' => [
+            'css' => '@admin/css/components.css',
+        ],
+        '@palette-gradient' => [
+            'css' => '@admin/css/core/colors/palette-gradient.css',
+        ],
+        '@datatables' => [
+            'css' => '@admin/vendors/css/tables/datatable/datatables.min.css',
+        ],
+        '@data-list-view' => [
+            'css' => '@admin/css/pages/data-list-view.css',
+        ],
+        '@custom' => [
+            'css' => '@admin/css/custom-laravel.css',
+        ],
+        '@grid-extension' => [
+            'js' => '@admin/dcat/extra/grid-extend.js',
+        ],
+        '@resource-selector' => [
+            'js' => '@admin/dcat/extra/resource-selector.js',
+        ],
+        '@layer' => [
+            'js' => '@admin/dcat/plugins/layer/layer.js',
+        ],
+        '@pjax' => [
+            'js' => '@admin/dcat/plugins/jquery-pjax/jquery.pjax.min.js',
+        ],
+        '@toastr' => [
+            'js'  => '@admin/vendors/js/extensions/toastr.min.js',
+            'css' => '@admin/vendors/css/extensions/toastr.css',
+        ],
+        '@jquery.nestable' => [
+            'js'  => '@admin/dcat/plugins/nestable/jquery.nestable.min.js',
+            'css' => '@admin/dcat/plugins/nestable/nestable.css',
+        ],
+        '@validator' => [
+            'js' => '@admin/dcat/plugins/bootstrap-validator/validator.min.js',
+        ],
+        '@select2' => [
+            'js'  => '@admin/vendors/js/forms/select/select2.full.min.js',
+            'css' => '@admin/vendors/css/forms/select/select2.min.css',
+        ],
+        '@bootstrap-datetimepicker' => [
+            'js'  => '@admin/dcat/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js',
+            'css' => '@admin/dcat/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css',
+        ],
+        '@moment' => [
+            'js' => [
+                '@admin/dcat/plugins/moment/moment.min.js',
+            ],
+        ],
+        '@moment-timezone' => [
+            'js' => [
+                '@admin/dcat/plugins/moment/moment-timezone-with-data.min.js',
+            ],
+        ],
+        '@rwd-table' => [
+            'js'  => '@admin/dcat/plugins/RWD-Table-Patterns/dist/js/rwd-table.min.js',
+            'css' => '@admin/dcat/plugins/RWD-Table-Patterns/dist/css/rwd-table.min.css',
+        ],
+        '@jstree' => [
+            'js'  => '@admin/dcat/plugins/jstree-theme/jstree.min.js',
+            'css' => '@admin/dcat/plugins/jstree-theme/themes/proton/style.min.css',
+        ],
+        '@switchery' => [
+            'js'  => '@admin/dcat/plugins/switchery/switchery.min.js',
+            'css' => '@admin/dcat/plugins/switchery/switchery.min.css',
+        ],
+        '@webuploader' => [
+            'js' => [
+                '@admin/dcat/plugins/webuploader/webuploader.min.js',
+                '@admin/dcat/extra/upload.js',
+            ],
+            'css' => '@admin/dcat/extra/upload.css',
+        ],
+        '@chartjs' => [
+            'js' => '@admin/dcat/plugins/chart.js/chart.bundle.min.js',
+        ],
+        '@jquery.sparkline' => [
+            'js' => '@admin/dcat/plugins/jquery.sparkline/jquery.sparkline.min.js',
+        ],
+        '@jquery.bootstrap-duallistbox' => [
+            'js'  => '@admin/dcat/plugins/bootstrap-duallistbox/dist/jquery.bootstrap-duallistbox.min.js',
+            'css' => '@admin/dcat/plugins/bootstrap-duallistbox/dist/bootstrap-duallistbox.min.css',
+        ],
+        '@number-input' => [
+            'js' => '@admin/dcat/plugins/number-input/bootstrap-number-input.js',
+        ],
+        '@ionslider' => [
+            'js' => [
+                '@admin/dcat/plugins/ionslider/ion.rangeSlider.min.js',
+            ],
+            'css' => [
+                '@admin/dcat/plugins/ionslider/ion.rangeSlider.css',
+                '@admin/dcat/plugins/ionslider/ion.rangeSlider.skinNice.css',
+            ],
+        ],
+        '@editor-md' => [
+            'js' => [
+                '@admin/dcat/plugins/editor-md/lib/raphael.min.js',
+                '@admin/dcat/plugins/editor-md/lib/marked.min.js',
+                '@admin/dcat/plugins/editor-md/lib/prettify.min.js',
+                '@admin/dcat/plugins/editor-md/lib/underscore.min.js',
+                '@admin/dcat/plugins/editor-md/lib/sequence-diagram.min.js',
+                '@admin/dcat/plugins/editor-md/lib/flowchart.min.js',
+                '@admin/dcat/plugins/editor-md/lib/jquery.flowchart.min.js',
+                '@admin/dcat/plugins/editor-md/editormd.min.js',
+            ],
+            'css' => [
+                '@admin/dcat/plugins/editor-md/css/editormd.preview.min.css',
+                '@admin/dcat/extra/markdown.css',
+            ],
+        ],
+        '@jquery.inputmask' => [
+            'js' => '@admin/dcat/plugins/input-mask/jquery.inputmask.bundle.min.js',
+        ],
+        '@apex-charts' => [
+            'js' => '@admin/vendors/js/charts/apexcharts.min.js',
+        ],
+        '@smart-wizard' => [
+            'js' => '@admin/dcat/plugins/SmartWizard/dist/js/jquery.smartWizard.min.js',
+            'css' => '@admin/dcat/extra/step.css',
+        ],
+        '@fontawesome-iconpicker' => [
+            'js' => '@admin/dcat/plugins/fontawesome-iconpicker/dist/js/fontawesome-iconpicker.js',
+            'css' => '@admin/dcat/plugins/fontawesome-iconpicker/dist/css/fontawesome-iconpicker.min.css',
+        ],
+    ];
+
+    /**
+     * js代码.
+     *
+     * @var array
+     */
+    protected $script = [];
+
+    /**
+     * css代码.
+     *
+     * @var array
+     */
+    protected $style = [];
+
+    /**
+     * css脚本路径.
+     *
+     * @var array
+     */
+    protected $css = [];
+
+    /**
+     * js脚本路径.
+     *
+     * @var array
+     */
+    protected $js = [];
+
+    /**
+     * 在head标签内加载的js脚本.
+     *
+     * @var array
+     */
+    protected $headerJs = [
+        'vendors' => '@vendors',
+        'dcat'    => '@dcat',
+    ];
+
+    /**
+     * 基础css.
+     *
+     * @var array
+     */
+    protected $baseCss = [
+        'vendors'            => '@vendors',
+        'bootstrap'          => '@bootstrap',
+        'bootstrap-extended' => '@bootstrap-extended',
+        'toastr'             => '@toastr',
+        'components'         => '@components',
+        'palette-gradient'   => '@palette-gradient',
+        'colors'             => '@default-colors',
+        //'custom'             => 'custom',
+
+        'datatables'     => '@datatables',
+        'data-list-view' => '@data-list-view',
+        'dcat'           => '@dcat',
+    ];
+
+    /**
+     * 基础js.
+     *
+     * @var array
+     */
+    protected $baseJs = [
+        'menu'      => '@menu',
+        'app'       => '@app',
+        'toastr'    => '@toastr',
+        'pjax'      => '@pjax',
+        'validator' => '@validator',
+        'layer'     => '@layer',
+    ];
+
+    /**
+     * @var array
+     */
+    public $fonts = [
+        '@nunito',
+        '@montserrat',
+    ];
+
+    /**
+     * @var bool
+     */
+    protected $isPjax = false;
+
+    /**
+     * @var bool
+     */
+    protected $usingFullPage = false;
+
+    /**
+     * @var array
+     */
+    protected $themeCssMap = [
+        'dark'      => 'dark-layout',
+        'semi-dark' => 'semi-dark-layout',
+    ];
+
+    /**
+     * Assets constructor.
+     */
+    public function __construct()
+    {
+        $this->isPjax = request()->pjax();
+    }
+
+    /**
+     * 设置或获取别名.
+     *
+     * @param string|array $name
+     * @param string|array $js
+     * @param string|array $css
+     *
+     * @return void|array
+     */
+    public function alias($name, $js = null, $css = null)
+    {
+        if (is_array($name)) {
+            foreach ($name as $key => $value) {
+                $this->alias($key, $value['js'] ?? [], $value['css'] ?? []);
+            }
+
+            return;
+        }
+
+        if ($js === null && $css === null) {
+            return $this->alias[$name] ?? [];
+        }
+
+        if (strpos($name, '@') !== 0) {
+            $name = '@'.$name;
+        }
+
+        $this->alias[$name] = [
+            'js'  => $js,
+            'css' => $css,
+        ];
+    }
+
+    /**
+     * 使用全页面(无菜单和导航栏).
+     *
+     * @param bool $value
+     *
+     * @return $this
+     */
+    public function full(bool $value = true)
+    {
+        $this->usingFullPage = $value;
+
+        return $this;
+    }
+
+    /**
+     * 根据别名设置需要载入的js和css脚本.
+     *
+     * @param string $alias
+     * @param string $type
+     */
+    public function collect(string $alias, string $type = '')
+    {
+        if (strpos($alias, '@') !== 0) {
+            $alias = '@'.$alias;
+        }
+
+        if ($type === 'js') {
+            $this->js($this->alias[$alias]['js'] ?? null);
+
+            return;
+        } elseif ($type === 'css') {
+            $this->css($this->alias[$alias]['css'] ?? null);
+
+            return;
+        }
+
+        $this->js($this->alias[$alias]['js'] ?? null);
+        $this->css($this->alias[$alias]['css'] ?? null);
+    }
+
+    /**
+     * 设置需要载入的css脚本.
+     *
+     * @param string|array $css
+     */
+    public function css($css)
+    {
+        if (! $css) {
+            return;
+        }
+        $this->css = array_merge(
+            $this->css,
+            (array) $css
+        );
+    }
+
+    /**
+     * 设置需要载入的基础css脚本.
+     *
+     * @param array $css
+     */
+    public function baseCss(array $css)
+    {
+        $this->baseCss = $css;
+    }
+
+    /**
+     * 设置需要载入的js脚本.
+     *
+     * @param string|array $js
+     */
+    public function js($js)
+    {
+        if (! $js) {
+            return;
+        }
+        $this->js = array_merge(
+            $this->js,
+            (array) $js
+        );
+    }
+
+    /**
+     * 根据别名获取资源路径.
+     *
+     * @param string $path
+     * @param string $type
+     *
+     * @return string|array|null
+     */
+    public function get($path, string $type = 'js')
+    {
+        if (empty($this->alias[$path])) {
+            return $this->url($path);
+        }
+
+        $paths = isset($this->alias[$path][$type]) ? (array) $this->alias[$path][$type] : null;
+
+        if (! $paths) {
+            return $paths;
+        }
+
+        foreach ($paths as &$value) {
+            $value = $this->url($value);
+        }
+
+        return $paths;
+    }
+
+    /**
+     * 获取静态资源完整URL.
+     *
+     * @param string $path
+     *
+     * @return string
+     */
+    public function url($path)
+    {
+        if (! $path) {
+            return $path;
+        }
+
+        $path = $this->getRealPath($path);
+
+        if (strpos($path, '//') === false) {
+            $path = config('admin.assets_server').'/'.trim($path, '/');
+        }
+
+        return (config('admin.https') || config('admin.secure')) ? secure_asset($path) : asset($path);
+    }
+
+    /**
+     * 获取真实路径.
+     *
+     * @param string|null $path
+     *
+     * @return string|null
+     */
+    public function getRealPath(?string $path)
+    {
+        if (! $this->hasAlias($path)) {
+            return $path;
+        }
+
+        return implode(
+            '/',
+            array_map(
+                function ($v) {
+                    $v = $this->pathAlias[$v] ?? $v;
+
+                    if (! $this->hasAlias($v)) {
+                        return $v;
+                    }
+
+                    return $this->getRealPath($v);
+                },
+                explode('/', $path)
+            )
+        );
+    }
+
+    /**
+     * 判断是否含有别名.
+     *
+     * @param string $value
+     *
+     * @return bool
+     */
+    protected function hasAlias($value)
+    {
+        return $value && mb_strpos($value, '@') !== false;
+    }
+
+    /**
+     * 设置在head标签内加载的js.
+     *
+     * @param string|array $js
+     */
+    public function headerJs($js)
+    {
+        if (! $js) {
+            return;
+        }
+        $this->headerJs = array_merge($this->headerJs, (array) $js);
+    }
+
+    /**
+     * 设置基础js脚本.
+     *
+     * @param array $js
+     */
+    public function baseJs(array $js)
+    {
+        $this->baseJs = $js;
+    }
+
+    /**
+     * 设置js代码.
+     *
+     * @param string|array $script
+     */
+    public function script($script)
+    {
+        if (! $script) {
+            return;
+        }
+        $this->script = array_merge($this->script, (array) $script);
+    }
+
+    /**
+     * 设置css代码.
+     *
+     * @param string $style
+     */
+    public function style($style)
+    {
+        if (! $style) {
+            return;
+        }
+        $this->style = array_merge($this->style, (array) $style);
+    }
+
+    /**
+     * 增加布局css文件.
+     */
+    protected function addLayoutCss()
+    {
+        if ($this->usingFullPage) {
+            return;
+        }
+
+        if (config('admin.layout.main_layout_type') === 'horizontal') {
+            $this->baseCss[] = '@admin/css/core/menu/menu-types/horizontal-menu.css';
+        }
+
+        $this->baseCss[] = '@admin/css/core/menu/menu-types/vertical-menu.css';
+    }
+
+    /**
+     * 主题css文件.
+     */
+    protected function addThemeCss()
+    {
+        if (! $theme = config('admin.layout.theme')) {
+            return;
+        }
+
+        $css = $this->themeCssMap[$theme] ?? $theme;
+
+        if ($css === 'light') {
+            return;
+        }
+
+        $this->baseCss[] = "@admin/css/themes/{$css}.css";
+    }
+
+    /**
+     * 字体css脚本路径.
+     */
+    protected function addFontCss()
+    {
+        $this->fonts && (
+            $this->baseCss = array_merge(
+                $this->baseCss,
+                (array) $this->fonts
+            )
+        );
+    }
+
+    /**
+     * 合并基础css脚本.
+     */
+    protected function mergeBaseCss()
+    {
+        if ($this->isPjax) {
+            return;
+        }
+
+        $this->addLayoutCss();
+        $this->addThemeCss();
+        $this->addFontCss();
+
+        $this->css = array_merge($this->baseCss, $this->css);
+    }
+
+    /**
+     * @return string
+     */
+    public function renderCss()
+    {
+        $this->mergeBaseCss();
+
+        $html = '';
+
+        foreach (array_unique($this->css) as &$v) {
+            if (! $paths = $this->get($v, 'css')) {
+                continue;
+            }
+
+            foreach ((array) $paths as $path) {
+                $html .= "<link rel=\"stylesheet\" href=\"{$path}\">";
+            }
+        }
+
+        return $html;
+    }
+
+    /**
+     * 合并基础js脚本.
+     */
+    protected function mergeBaseJs()
+    {
+        if ($this->isPjax) {
+            return;
+        }
+
+        if ($this->usingFullPage) {
+            unset($this->baseJs['menu']);
+        }
+
+        $this->js = array_merge($this->baseJs, $this->js);
+    }
+
+    /**
+     * @return string
+     */
+    public function renderJs()
+    {
+        $this->mergeBaseJs();
+
+        $html = '';
+
+        foreach (array_unique($this->js) as &$v) {
+            if (! $paths = $this->get($v, 'js')) {
+                continue;
+            }
+
+            foreach ((array) $paths as $path) {
+                $html .= "<script src=\"{$path}\"></script>";
+            }
+        }
+
+        return $html;
+    }
+
+    /**
+     * @return string
+     */
+    public function renderHeaderJs()
+    {
+        $html = '';
+
+        foreach (array_unique($this->headerJs) as &$v) {
+            if (! $paths = $this->get($v, 'js')) {
+                continue;
+            }
+
+            foreach ((array) $paths as $path) {
+                $html .= "<script src=\"{$path}\"></script>";
+            }
+        }
+
+        return $html;
+    }
+
+    /**
+     * @return string
+     */
+    public function renderScript()
+    {
+        $script = implode(';', array_unique($this->script));
+
+        return <<<HTML
 <script data-exec-on-popstate>
 Dcat.ready(function () { 
     try {
-        {$script}
-    } catch (e) {
-        console.error(e)
-    }
- });
- </script>
-HTML;
-    }
-
-    /**
-     * @return string
-     */
-    public function renderStyle()
-    {
-        $style = implode('', array_unique($this->style));
-
-        return "<style>$style</style>";
-    }
-}
+        {$script}
+    } catch (e) {
+        console.error(e)
+    }
+ });
+ </script>
+HTML;
+    }
+
+    /**
+     * @return string
+     */
+    public function renderStyle()
+    {
+        $style = implode('', array_unique($this->style));
+
+        return "<style>$style</style>";
+    }
+}

+ 1 - 2
src/Layout/Content.php

@@ -6,7 +6,6 @@ use Closure;
 use Dcat\Admin\Admin;
 use Dcat\Admin\Traits\HasBuilderEvents;
 use Illuminate\Contracts\Support\Renderable;
-use Illuminate\Support\Arr;
 use Illuminate\Support\ViewErrorBag;
 
 class Content implements Renderable
@@ -422,7 +421,7 @@ class Content implements Renderable
             'blank_page' => false,
             'direction' => env('MIX_CONTENT_DIRECTION', 'ltr'),
         ];
-        
+
         $data = array_merge(
             config('admin.layout') ?: [],
             $this->config

+ 1 - 1
src/Middleware/LogOperation.php

@@ -54,7 +54,7 @@ class LogOperation
             }
         }
 
-       return json_encode($input);
+        return json_encode($input);
     }
 
     /**

+ 2 - 2
src/Repositories/EloquentRepository.php

@@ -49,7 +49,7 @@ class EloquentRepository extends Repository implements TreeRepository
     }
 
     /**
-     * 初始化模型
+     * 初始化模型.
      *
      * @param EloquentModel|Builder|array|string $modelOrRelations
      */
@@ -503,7 +503,7 @@ class EloquentRepository extends Repository implements TreeRepository
     }
 
     /**
-     * 获取父级ID字段名称
+     * 获取父级ID字段名称.
      *
      * @return string
      */

+ 1 - 1
src/Repositories/Repository.php

@@ -191,7 +191,7 @@ abstract class Repository implements RepositoryInterface, TreeRepository
     }
 
     /**
-     *  获取父级ID字段名称
+     *  获取父级ID字段名称.
      *
      * @return string
      */

+ 107 - 107
src/Support/JavaScript.php

@@ -1,107 +1,107 @@
-<?php
-
-namespace Dcat\Admin\Support;
-
-use Illuminate\Contracts\Support\Arrayable;
-use Illuminate\Support\Str;
-
-class JavaScript
-{
-    protected static $scripts = [];
-
-    /**
-     * @var string
-     */
-    protected $id;
-
-    public function __construct($script)
-    {
-        $this->id = '@javascript:'.Str::random();
-
-        $this->value($script);
-    }
-
-    /**
-     * 设置或获取代码内容
-     *
-     * @param mixed $script
-     *
-     * @return mixed
-     */
-    public function value($script = null)
-    {
-        if ($script === null) {
-            return static::$scripts[$this->id];
-        }
-
-        static::$scripts[$this->id] = (string) value($script);
-    }
-
-    /**
-     * @param string|\Closure $script
-     * 
-     * @return string
-     */
-    public static function make($script)
-    {
-        return (string) new static($script);
-    }
-
-    /**
-     * 获取所有代码
-     * 
-     * @return array
-     */
-    public static function all()
-    {
-        return static::$scripts;
-    }
-
-    /**
-     * 删除代码.
-     *
-     * @param string $id
-     */
-    public static function delete(string $id)
-    {
-        unset(static::$scripts[$id]);
-    }
-    
-    /**
-     * 格式化为js代码.
-     *
-     * @param array|Arrayable $value
-     *
-     * @return string
-     */
-    public static function format($value)
-    {
-        if (! $value) {
-            return $value;
-        }
-
-        if (is_array($value) || is_object($value)) {
-            $value = json_encode(Helper::array($value));
-        }
-
-        foreach (static::all() as $id => $script) {
-            $id = "\"$id\"";
-            
-            if (mb_strpos($value, $id) !== false) {
-                $value = str_replace($id, $script, $value);
-
-                static::delete($id);
-            }
-        }
-
-        return $value;
-    }
-
-    /**
-     * @return string
-     */
-    public function __toString()
-    {
-        return $this->id;
-    }
-}
+<?php
+
+namespace Dcat\Admin\Support;
+
+use Illuminate\Contracts\Support\Arrayable;
+use Illuminate\Support\Str;
+
+class JavaScript
+{
+    protected static $scripts = [];
+
+    /**
+     * @var string
+     */
+    protected $id;
+
+    public function __construct($script)
+    {
+        $this->id = '@javascript:'.Str::random();
+
+        $this->value($script);
+    }
+
+    /**
+     * 设置或获取代码内容.
+     *
+     * @param mixed $script
+     *
+     * @return mixed
+     */
+    public function value($script = null)
+    {
+        if ($script === null) {
+            return static::$scripts[$this->id];
+        }
+
+        static::$scripts[$this->id] = (string) value($script);
+    }
+
+    /**
+     * @param string|\Closure $script
+     *
+     * @return string
+     */
+    public static function make($script)
+    {
+        return (string) new static($script);
+    }
+
+    /**
+     * 获取所有代码
+     *
+     * @return array
+     */
+    public static function all()
+    {
+        return static::$scripts;
+    }
+
+    /**
+     * 删除代码.
+     *
+     * @param string $id
+     */
+    public static function delete(string $id)
+    {
+        unset(static::$scripts[$id]);
+    }
+
+    /**
+     * 格式化为js代码.
+     *
+     * @param array|Arrayable $value
+     *
+     * @return string
+     */
+    public static function format($value)
+    {
+        if (! $value) {
+            return $value;
+        }
+
+        if (is_array($value) || is_object($value)) {
+            $value = json_encode(Helper::array($value));
+        }
+
+        foreach (static::all() as $id => $script) {
+            $id = "\"$id\"";
+
+            if (mb_strpos($value, $id) !== false) {
+                $value = str_replace($id, $script, $value);
+
+                static::delete($id);
+            }
+        }
+
+        return $value;
+    }
+
+    /**
+     * @return string
+     */
+    public function __toString()
+    {
+        return $this->id;
+    }
+}

+ 43 - 43
src/Traits/HasAuthorization.php

@@ -1,43 +1,43 @@
-<?php
-
-namespace Dcat\Admin\Traits;
-
-use Dcat\Admin\Admin;
-use Dcat\Admin\Models\HasPermissions;
-use Illuminate\Contracts\Auth\Authenticatable;
-use Illuminate\Database\Eloquent\Model;
-
-trait HasAuthorization
-{
-    /**
-     * 验证权限.
-     *
-     * @return bool
-     */
-    public function passesAuthorization(): bool
-    {
-        return $this->authorize(Admin::user());
-    }
-
-    /**
-     * 是否有权限判断.
-     *
-     * @param Model|Authenticatable|HasPermissions|null $user
-     *
-     * @return bool
-     */
-    protected function authorize($user): bool
-    {
-        return true;
-    }
-
-    /**
-     * 返回无权限信息.
-     *
-     * @return mixed
-     */
-    public function failedAuthorization()
-    {
-        abort(403, __('admin.deny'));
-    }
-}
+<?php
+
+namespace Dcat\Admin\Traits;
+
+use Dcat\Admin\Admin;
+use Dcat\Admin\Models\HasPermissions;
+use Illuminate\Contracts\Auth\Authenticatable;
+use Illuminate\Database\Eloquent\Model;
+
+trait HasAuthorization
+{
+    /**
+     * 验证权限.
+     *
+     * @return bool
+     */
+    public function passesAuthorization(): bool
+    {
+        return $this->authorize(Admin::user());
+    }
+
+    /**
+     * 是否有权限判断.
+     *
+     * @param Model|Authenticatable|HasPermissions|null $user
+     *
+     * @return bool
+     */
+    protected function authorize($user): bool
+    {
+        return true;
+    }
+
+    /**
+     * 返回无权限信息.
+     *
+     * @return mixed
+     */
+    public function failedAuthorization()
+    {
+        abort(403, __('admin.deny'));
+    }
+}

+ 3 - 4
src/Traits/InteractsWithApi.php

@@ -6,9 +6,8 @@ use Dcat\Admin\Support\Helper;
 use Illuminate\Http\Request;
 
 /**
- * Trait InteractsWithApi
+ * Trait InteractsWithApi.
  *
- * @package Dcat\Admin\Traits
  *
  * @method mixed handle(Request $request)
  * @method mixed valueResult()
@@ -83,7 +82,7 @@ trait InteractsWithApi
     }
 
     /**
-     * 获取请求方法
+     * 获取请求方法.
      *
      * @return string
      */
@@ -184,7 +183,7 @@ trait InteractsWithApi
     public function buildRequestScript()
     {
         if (! $this->allowBuildRequest()) {
-            return null;
+            return;
         }
 
         $fetching = implode(';', $this->requestScripts['fetching']);

+ 4 - 5
src/Widgets/ApexCharts/Chart.php

@@ -9,9 +9,8 @@ use Dcat\Admin\Widgets\Widget;
 use Illuminate\Support\Str;
 
 /**
- * Class Chart
+ * Class Chart.
  *
- * @package Dcat\Admin\Widgets\ApexCharts
  *
  * @see https://apexcharts.com/
  */
@@ -20,7 +19,7 @@ class Chart extends Widget
     use InteractsWithApi;
 
     public static $js = [
-        '@apex-charts'
+        '@apex-charts',
     ];
 
     protected $containerSelector;
@@ -46,7 +45,7 @@ class Chart extends Widget
     }
 
     /**
-     * 设置或获取图表容器选择器
+     * 设置或获取图表容器选择器.
      *
      * @param string|null $selector
      *
@@ -181,7 +180,7 @@ class Chart extends Widget
         return $this;
     }
 
-   /**
+    /**
      * @param array $value
      *
      * @return $this

+ 0 - 2
src/Widgets/Card.php

@@ -27,8 +27,6 @@ class Card extends Widget
      */
     protected $divider = false;
 
-
-
     public function __construct($title = '', $content = null)
     {
         if ($content === null) {

+ 2 - 2
src/Widgets/Chart/Chart.php

@@ -3,8 +3,8 @@
 namespace Dcat\Admin\Widgets\Chart;
 
 use Dcat\Admin\Admin;
-use Dcat\Admin\Widgets\Color;
 use Dcat\Admin\Traits\InteractsWithApi;
+use Dcat\Admin\Widgets\Color;
 use Dcat\Admin\Widgets\Widget;
 use Illuminate\Support\Str;
 
@@ -510,7 +510,7 @@ HTML;
 
     protected function generateId()
     {
-       return 'chart-'.$this->type.Str::random(8);
+        return 'chart-'.$this->type.Str::random(8);
     }
 
     public function getId()

+ 0 - 3
src/Widgets/Color.php

@@ -2,9 +2,6 @@
 
 namespace Dcat\Admin\Widgets;
 
-use Dcat\Admin\Support\Helper;
-use Illuminate\Support\Arr;
-
 class Color
 {
     public static $chartTheme = [

+ 2 - 2
src/Widgets/DialogForm.php

@@ -255,7 +255,7 @@ JS
     }
 
     /**
-     * 自动渲染
+     * 自动渲染.
      *
      * @return void
      */
@@ -269,7 +269,7 @@ JS
     }
 
     /**
-     * 配置选项初始化
+     * 配置选项初始化.
      *
      * @return void
      */

+ 2 - 4
src/Widgets/Metrics/BarChartCard.php

@@ -3,8 +3,6 @@
 namespace Dcat\Admin\Widgets\Metrics;
 
 use Dcat\Admin\Admin;
-use Dcat\Admin\Support\Helper;
-use Illuminate\Contracts\Support\Renderable;
 
 class BarChartCard extends RadialBarChartCard
 {
@@ -38,9 +36,9 @@ class BarChartCard extends RadialBarChartCard
     protected function defaultChartOptions()
     {
         $color = Admin::color();
-        
+
         $colors = [
-            $color->primary()
+            $color->primary(),
         ];
 
         return [

+ 7 - 7
src/Widgets/Metrics/Card.php

@@ -4,8 +4,8 @@ namespace Dcat\Admin\Widgets\Metrics;
 
 use Dcat\Admin\Admin;
 use Dcat\Admin\Support\Helper;
-use Dcat\Admin\Widgets\ApexCharts\Chart;
 use Dcat\Admin\Traits\InteractsWithApi;
+use Dcat\Admin\Widgets\ApexCharts\Chart;
 use Dcat\Admin\Widgets\Widget;
 use Illuminate\Support\Arr;
 use Illuminate\Support\Str;
@@ -32,17 +32,17 @@ class Card extends Widget
     ];
 
     /**
-     * @var string 
+     * @var string
      */
     protected $style = 'primary';
 
     /**
-     * @var int 
+     * @var int
      */
     protected $chartHeight = 70;
 
     /**
-     * @var array 
+     * @var array
      */
     protected $chartOptions = [];
 
@@ -196,7 +196,7 @@ class Card extends Widget
     }
 
     /**
-     * 设置最小高度
+     * 设置最小高度.
      *
      * @param string|int $value
      *
@@ -229,7 +229,7 @@ class Card extends Widget
     }
 
     /**
-     * 设置图表高度
+     * 设置图表高度.
      *
      * @param int $number
      *
@@ -261,7 +261,7 @@ class Card extends Widget
     }
 
     /**
-     * 设置图表颜色
+     * 设置图表颜色.
      *
      * @param string|array $colors
      *

+ 6 - 6
src/Widgets/Metrics/DonutChartCard.php

@@ -19,7 +19,7 @@ class DonutChartCard extends Card
     protected $contentWidth = [6, 6];
 
     /**
-     * 趋势图图表默认配置
+     * 趋势图图表默认配置.
      *
      * @return  array
      */
@@ -49,15 +49,15 @@ class DonutChartCard extends Card
             'plotOptions' => [
                 'pie' => [
                     'donut' => [
-                        'size' => '75%'
-                    ]
-                ]
-            ]
+                        'size' => '75%',
+                    ],
+                ],
+            ],
         ];
     }
 
     /**
-     * 初始化
+     * 初始化.
      */
     protected function init()
     {

+ 5 - 5
src/Widgets/Metrics/LineChartCard.php

@@ -5,14 +5,14 @@ namespace Dcat\Admin\Widgets\Metrics;
 class LineChartCard extends Card
 {
     /**
-     * 图表默认高度
+     * 图表默认高度.
      *
      * @var int
      */
     protected $chartHeight = 57;
 
     /**
-     * 图表默认配置
+     * 图表默认配置.
      *
      * @var array
      */
@@ -30,7 +30,7 @@ class LineChartCard extends Card
                 'padding' => [
                     'left' => 0,
                     'right' => 0,
-                ]
+                ],
             ],
         ],
         'tooltip' => [
@@ -57,7 +57,7 @@ class LineChartCard extends Card
         ],
         'stroke' => [
             'width' => 2.5,
-            'curve' => 'smooth'
+            'curve' => 'smooth',
         ],
         'fill' => [
             'opacity' => 0.1,
@@ -66,7 +66,7 @@ class LineChartCard extends Card
     ];
 
     /**
-     * 初始化
+     * 初始化.
      */
     protected function init()
     {

+ 6 - 6
src/Widgets/Metrics/RadialBarChartCard.php

@@ -45,7 +45,7 @@ class RadialBarChartCard extends Card
     protected $chartPullRight = false;
 
     /**
-     * 初始化
+     * 初始化.
      */
     public function init()
     {
@@ -87,9 +87,9 @@ class RadialBarChartCard extends Card
                         'value' => [
                             'offsetY' => 30,
                             'color' => $labelColor,
-                            'fontSize' => '2rem'
-                        ]
-                    ]
+                            'fontSize' => '2rem',
+                        ],
+                    ],
                 ],
             ],
             'fill' => [
@@ -102,11 +102,11 @@ class RadialBarChartCard extends Card
                     'inverseColors' => true,
                     'opacityFrom' => 1,
                     'opacityTo' => 1,
-                    'stops' => [0, 100]
+                    'stops' => [0, 100],
                 ],
             ],
             'stroke' => [
-                'dashArray' => 8
+                'dashArray' => 8,
             ],
         ];
     }

+ 1 - 3
src/Widgets/Metrics/RoundChartCard.php

@@ -3,9 +3,7 @@
 namespace Dcat\Admin\Widgets\Metrics;
 
 use Dcat\Admin\Admin;
-use Dcat\Admin\Support\Helper;
 use Dcat\Admin\Support\JavaScript;
-use Illuminate\Contracts\Support\Renderable;
 
 class RoundChartCard extends RadialBarChartCard
 {
@@ -108,7 +106,7 @@ class RoundChartCard extends RadialBarChartCard
     }
 
     /**
-     * 设置图表统计总数信息
+     * 设置图表统计总数信息.
      *
      * @param string $label
      * @param int $number

+ 8 - 9
src/Widgets/Metrics/SingleRoundChartCard.php

@@ -6,7 +6,6 @@ use Dcat\Admin\Admin;
 
 class SingleRoundChartCard extends RoundChartCard
 {
-
     /**
      * @var int
      */
@@ -36,7 +35,7 @@ class SingleRoundChartCard extends RoundChartCard
                     'blur' => 3,
                     'left' => 1,
                     'top' => 1,
-                    'opacity' => 0.1
+                    'opacity' => 0.1,
                 ],
             ],
             'colors' => $colors,
@@ -54,15 +53,15 @@ class SingleRoundChartCard extends RoundChartCard
                     ],
                     'dataLabels' => [
                         'name' => [
-                            'show' => false
+                            'show' => false,
                         ],
                         'value' => [
                             'offsetY' => 14,
                             'color' => $strokColor,
-                            'fontSize' => '2.8rem'
-                        ]
-                    ]
-                ]
+                            'fontSize' => '2.8rem',
+                        ],
+                    ],
+                ],
             ],
             'fill' => [
                 'type' => 'gradient',
@@ -74,12 +73,12 @@ class SingleRoundChartCard extends RoundChartCard
                     'inverseColors' => true,
                     'opacityFrom' => 1,
                     'opacityTo' => 1,
-                    'stops' => [0, 100]
+                    'stops' => [0, 100],
                 ],
             ],
             'series' => [100],
             'stroke' => [
-                'lineCap' => 'round'
+                'lineCap' => 'round',
             ],
         ];
     }

+ 0 - 1
src/Widgets/Sparkline/Sparkline.php

@@ -6,7 +6,6 @@ use Dcat\Admin\Admin;
 use Dcat\Admin\Support\Helper;
 use Dcat\Admin\Traits\InteractsWithApi;
 use Dcat\Admin\Widgets\Widget;
-use Illuminate\Contracts\Support\Arrayable;
 use Illuminate\Support\Str;
 
 /**

+ 1 - 1
src/Widgets/Tab.php

@@ -24,7 +24,7 @@ class Tab extends Widget
         'dropDown' => [],
         'active'   => 0,
         'padding'  => null,
-        'tabStyle' => ''
+        'tabStyle' => '',
     ];
 
     /**

+ 0 - 1
src/Widgets/Tree.php

@@ -2,7 +2,6 @@
 
 namespace Dcat\Admin\Widgets;
 
-use Dcat\Admin\Admin;
 use Dcat\Admin\Support\Helper;
 use Illuminate\Contracts\Support\Arrayable;
 use Illuminate\Support\Str;

+ 1 - 1
tests/Browser/Components/Form/Field/MultipleSelect2.php

@@ -7,7 +7,7 @@ use Laravel\Dusk\Browser;
 class MultipleSelect2 extends Select2
 {
     /**
-     * 选中下拉选框
+     * 选中下拉选框.
      *
      * @param  Browser $browser
      * @param  array   $values

+ 4 - 4
tests/Browser/Components/Form/Field/Select2.php

@@ -15,7 +15,7 @@ class Select2 extends Component
     }
 
     /**
-     * 获取组件的 root selector
+     * 获取组件的 root selector.
      *
      * @return string
      */
@@ -37,19 +37,19 @@ class Select2 extends Component
     }
 
     /**
-     * 读取组件的元素快捷方式
+     * 读取组件的元素快捷方式.
      *
      * @return array
      */
     public function elements()
     {
         return [
-            '@container' => '.select2'
+            '@container' => '.select2',
         ];
     }
 
     /**
-     * 选中下拉选框
+     * 选中下拉选框.
      *
      * @param  Browser  $browser
      * @param  mixed    $value

+ 6 - 6
tests/Browser/Components/Form/Field/Tree.php

@@ -15,7 +15,7 @@ class Tree extends Component
     }
 
     /**
-     * 获取组件的 root selector
+     * 获取组件的 root selector.
      *
      * @return string
      */
@@ -38,7 +38,7 @@ class Tree extends Component
     }
 
     /**
-     * 读取组件的元素快捷方式
+     * 读取组件的元素快捷方式.
      *
      * @return array
      */
@@ -52,7 +52,7 @@ class Tree extends Component
     }
 
     /**
-     * 选中下拉选框
+     * 选中下拉选框.
      *
      * @param Browser $browser
      * @param mixed   $values
@@ -75,7 +75,7 @@ JS
     }
 
     /**
-     * 展开所有选项
+     * 展开所有选项.
      *
      * @param Browser $browser
      */
@@ -88,7 +88,7 @@ JS
     }
 
     /**
-     * 选中所有
+     * 选中所有.
      *
      * @param Browser $browser
      *
@@ -105,7 +105,7 @@ JS
     }
 
     /**
-     * 取消选中所有
+     * 取消选中所有.
      *
      * @param Browser $browser
      *

+ 4 - 4
tests/Browser/Components/Form/MenuCreationForm.php

@@ -18,7 +18,7 @@ class MenuCreationForm extends Component
     }
 
     /**
-     * 获取组件的 css selector
+     * 获取组件的 css selector.
      *
      * @return string
      */
@@ -58,7 +58,7 @@ class MenuCreationForm extends Component
     }
 
     /**
-     * 注入表单
+     * 注入表单.
      *
      * @param Browser $browser
      * @param array $input
@@ -74,7 +74,7 @@ class MenuCreationForm extends Component
         ];
 
         $selectKeys = [
-            'parent_id'
+            'parent_id',
         ];
 
         $multipleSelectKeys = [
@@ -119,7 +119,7 @@ class MenuCreationForm extends Component
     }
 
     /**
-     * 读取组件的元素快捷方式
+     * 读取组件的元素快捷方式.
      *
      * @return array
      */

+ 20 - 20
tests/Browser/Components/Grid/Actions/BatchDelete.php

@@ -1,20 +1,20 @@
-<?php
-
-namespace Tests\Browser\Components\Grid\Actions;
-
-class BatchDelete extends Delete
-{
-    /**
-     * 读取组件的元素快捷方式
-     *
-     * @return array
-     */
-    public function elements()
-    {
-        return [
-            '@item' => 'a[data-action="batch-delete"]:visible',
-            '@confirm' => '.swal2-confirm',
-            '@cancel' => '.swal2-cancel',
-        ];
-    }
-}
+<?php
+
+namespace Tests\Browser\Components\Grid\Actions;
+
+class BatchDelete extends Delete
+{
+    /**
+     * 读取组件的元素快捷方式.
+     *
+     * @return array
+     */
+    public function elements()
+    {
+        return [
+            '@item' => 'a[data-action="batch-delete"]:visible',
+            '@confirm' => '.swal2-confirm',
+            '@cancel' => '.swal2-cancel',
+        ];
+    }
+}

+ 2 - 2
tests/Browser/Components/Grid/Actions/Delete.php

@@ -11,7 +11,7 @@ use Tests\Browser\Components\Component;
 class Delete extends Component
 {
     /**
-     * 获取组件的 root selector
+     * 获取组件的 root selector.
      *
      * @return string
      */
@@ -31,7 +31,7 @@ class Delete extends Component
     }
 
     /**
-     * 读取组件的元素快捷方式
+     * 读取组件的元素快捷方式.
      *
      * @return array
      */

+ 2 - 2
tests/Browser/Components/Grid/BatchActions.php

@@ -21,7 +21,7 @@ class BatchActions extends Component
     }
 
     /**
-     * 获取组件的 root selector
+     * 获取组件的 root selector.
      *
      * @return string
      */
@@ -41,7 +41,7 @@ class BatchActions extends Component
     }
 
     /**
-     * 读取组件的元素快捷方式
+     * 读取组件的元素快捷方式.
      *
      * @return array
      */

+ 3 - 3
tests/Browser/Components/Grid/RowSelector.php

@@ -11,7 +11,7 @@ use Tests\Browser\Components\Component;
 class RowSelector extends Component
 {
     /**
-     * 获取组件的 root selector
+     * 获取组件的 root selector.
      *
      * @return string
      */
@@ -32,7 +32,7 @@ class RowSelector extends Component
     }
 
     /**
-     * 读取组件的元素快捷方式
+     * 读取组件的元素快捷方式.
      *
      * @return array
      */
@@ -68,7 +68,7 @@ JS
     }
 
     /**
-     * 选中所有
+     * 选中所有.
      *
      * @param Browser $browser
      *

+ 1 - 1
tests/Browser/MenuTest.php

@@ -4,9 +4,9 @@ namespace Tests\Browser;
 
 use Dcat\Admin\Models\Menu;
 use Laravel\Dusk\Browser;
-use Tests\Browser\Components\Form\MenuEditForm;
 use Tests\Browser\Components\Form\Field\MultipleSelect2;
 use Tests\Browser\Components\Form\Field\Select2;
+use Tests\Browser\Components\Form\MenuEditForm;
 use Tests\Browser\Pages\MenuEditPage;
 use Tests\Browser\Pages\MenuPage;
 use Tests\TestCase;

+ 1 - 1
tests/Browser/OperationLogTest.php

@@ -5,8 +5,8 @@ namespace Tests\Browser;
 use Dcat\Admin\Models\OperationLog;
 use Laravel\Dusk\Browser;
 use Tests\Browser\Components\Grid\Actions\BatchDelete;
-use Tests\Browser\Components\Grid\BatchActions;
 use Tests\Browser\Components\Grid\Actions\Delete;
+use Tests\Browser\Components\Grid\BatchActions;
 use Tests\Browser\Components\Grid\RowSelector;
 use Tests\TestCase;
 

+ 1 - 1
tests/Browser/Pages/MenuPage.php

@@ -58,7 +58,7 @@ class MenuPage extends Page
     }
 
     /**
-     * 创建
+     * 创建.
      *
      * @param Browser $browser
      * @param array $input

+ 5 - 3
tests/BrowserExtension.php

@@ -26,7 +26,7 @@ trait BrowserExtension
                 $text = Arr::wrap($text);
                 $message = $this->formatTimeOutMessage('Waited %s seconds for text', implode("', '", $text));
 
-                return $this->waitUsing($seconds, 100, function () use ($text, $callback)  {
+                return $this->waitUsing($seconds, 100, function () use ($text, $callback) {
                     $results = Str::contains($this->resolver->findOrFail('')->getText(), $text);
 
                     if ($results) {
@@ -59,7 +59,8 @@ trait BrowserExtension
 
             'wait' => function ($seconds, \Closure $callback = null) {
                 try {
-                    $this->waitUsing($seconds, 200, function () {});
+                    $this->waitUsing($seconds, 200, function () {
+                    });
                 } catch (TimeoutException $e) {
                     $callback && $callback();
                 }
@@ -78,7 +79,8 @@ trait BrowserExtension
                 return $this;
             },
             'assert' => function (Component $component) {
-                return $this->with($component, function () {});
+                return $this->with($component, function () {
+                });
             },
         ];
 

+ 1 - 2
tests/ChromeProcess.php

@@ -12,8 +12,7 @@ class ChromeProcess extends BaseChromeProcess
 
         if ($this->onWindows()) {
             $this->driver = realpath(__DIR__.'/resources/drivers/chromedriver-win.exe');
-        }
-        elseif ($this->onMac()) {
+        } elseif ($this->onMac()) {
             $this->driver = realpath(__DIR__.'/resources/drivers/chromedriver-mac');
         }
         //else {

+ 1 - 1
tests/resources/seeds/UserTableSeeder.php

@@ -2,10 +2,10 @@
 
 namespace Tests\Seeds;
 
+use Illuminate\Database\Seeder;
 use Tests\Models\Profile;
 use Tests\Models\Tag;
 use Tests\Models\User;
-use Illuminate\Database\Seeder;
 
 class UserTableSeeder extends Seeder
 {

+ 29 - 29
tests/resources/stubs/ComposerConfigCommand.php

@@ -1,29 +1,29 @@
-<?php
-
-namespace App;
-
-use Illuminate\Console\Command;
-
-class ComposerConfigCommand extends Command
-{
-    protected $signature = 'admin:composer-config';
-
-    public function handle()
-    {
-        $composer = base_path('composer.json');
-
-        /* @var \Illuminate\Filesystem\Filesystem $files */
-        $files = app('files');
-
-        $contents = json_decode($files->get($composer), true);
-
-        $contents['repositories'] = [
-            [
-                'type' => 'path',
-                'url'  => './dcat-admin',
-            ],
-        ];
-
-        $files->put($composer, str_replace('\\/', '/', json_encode($contents)));
-    }
-}
+<?php
+
+namespace App;
+
+use Illuminate\Console\Command;
+
+class ComposerConfigCommand extends Command
+{
+    protected $signature = 'admin:composer-config';
+
+    public function handle()
+    {
+        $composer = base_path('composer.json');
+
+        /* @var \Illuminate\Filesystem\Filesystem $files */
+        $files = app('files');
+
+        $contents = json_decode($files->get($composer), true);
+
+        $contents['repositories'] = [
+            [
+                'type' => 'path',
+                'url'  => './dcat-admin',
+            ],
+        ];
+
+        $files->put($composer, str_replace('\\/', '/', json_encode($contents)));
+    }
+}