Procházet zdrojové kódy

laravel octane 1.x

jqh před 4 roky
rodič
revize
50fa92c062

+ 9 - 5
src/Application.php

@@ -39,7 +39,11 @@ class Application
     public function __construct(Container $app)
     {
         $this->container = $app;
-        $this->apps = (array) config('admin.multi_app');
+    }
+
+    public function getApps()
+    {
+        return $this->apps ?: ($this->apps = (array) config('admin.multi_app'));
     }
 
     /**
@@ -81,7 +85,7 @@ class Application
     {
         $this->registerRoute(static::DEFAULT);
 
-        if ($this->apps) {
+        if ($this->getApps()) {
             $this->registerMultiAppRoutes();
 
             $this->switch(static::DEFAULT);
@@ -97,8 +101,8 @@ class Application
     {
         $this->loadRoutesFrom($pathOrCallback, static::DEFAULT);
 
-        if ($this->apps) {
-            foreach ($this->apps as $app => $enable) {
+        if ($apps = $this->getApps()) {
+            foreach ($apps as $app => $enable) {
                 if ($enable) {
                     $this->switch($app);
 
@@ -112,7 +116,7 @@ class Application
 
     protected function registerMultiAppRoutes()
     {
-        foreach ($this->apps as $app => $enable) {
+        foreach ($this->getApps() as $app => $enable) {
             if ($enable) {
                 $this->registerRoute($app);
             }

+ 7 - 15
src/Layout/Asset.php

@@ -256,19 +256,6 @@ class Asset
         '@nunito',
     ];
 
-    /**
-     * @var bool
-     */
-    protected $isPjax = false;
-
-    /**
-     * Assets constructor.
-     */
-    public function __construct()
-    {
-        $this->isPjax = request()->pjax();
-    }
-
     /**
      * 初始化主题样式.
      */
@@ -653,12 +640,17 @@ class Asset
         ));
     }
 
+    protected function isPjax()
+    {
+        return request()->pjax();
+    }
+
     /**
      * 合并基础css脚本.
      */
     protected function mergeBaseCss()
     {
-        if ($this->isPjax) {
+        if ($this->isPjax()) {
             return;
         }
 
@@ -712,7 +704,7 @@ class Asset
      */
     protected function mergeBaseJs()
     {
-        if ($this->isPjax) {
+        if ($this->isPjax()) {
             return;
         }
 

+ 11 - 10
src/Layout/Menu.php

@@ -8,9 +8,6 @@ use Lang;
 
 class Menu
 {
-    /**
-     * @var array
-     */
     protected static $helperNodes = [
         [
             'id'        => 1,
@@ -42,14 +39,8 @@ class Menu
         ],
     ];
 
-    /**
-     * @var string
-     */
     protected $view = 'admin::partials.menu';
 
-    /**
-     * Register menu.
-     */
     public function register()
     {
         if (! admin_has_default_section(Admin::SECTION['LEFT_SIDEBAR_MENU'])) {
@@ -66,6 +57,8 @@ class Menu
     }
 
     /**
+     * 增加菜单节点.
+     *
      * @param array $nodes
      * @param int   $priority
      *
@@ -79,7 +72,7 @@ class Menu
     }
 
     /**
-     * Build html.
+     * 转化为HTML.
      *
      * @param array $nodes
      *
@@ -99,6 +92,8 @@ class Menu
     }
 
     /**
+     * 设置菜单视图.
+     *
      * @param string $view
      *
      * @return $this
@@ -111,6 +106,8 @@ class Menu
     }
 
     /**
+     * 渲染视图.
+     *
      * @param array $item
      *
      * @return string
@@ -121,6 +118,8 @@ class Menu
     }
 
     /**
+     * 判断是否选中.
+     *
      * @param array       $item
      * @param null|string $path
      *
@@ -155,6 +154,8 @@ class Menu
     }
 
     /**
+     * 判断节点是否可见.
+     *
      * @param array $item
      *
      * @return bool

+ 0 - 6
src/Octane/Listeners/FlushAdminState.php

@@ -30,12 +30,6 @@ class FlushAdminState
         $this->app = $container;
     }
 
-    /**
-     * Handle the event.
-     *
-     * @param  mixed  $event
-     * @return void
-     */
     public function handle($event): void
     {
         $provider = new AdminServiceProvider($this->app);