Browse Source

开启菜单缓存

moshaorui 5 months ago
parent
commit
448cff8942

+ 5 - 3
app/Admin/Actions/Grid/AppearanceImport.php

@@ -49,6 +49,7 @@ class AppearanceImport extends RowAction
         DistAppearanceTemplate::deleteTemplates(0, $appearanceId);
         // 导入模板
         $this->readDirectory($path);
+        // 更新状态
         DistAppearance::setStatusToImported($appearanceId);
         // 返回响应结果并刷新页面
         return $this->response()->success("Successfully imported")->refresh();
@@ -90,15 +91,16 @@ class AppearanceImport extends RowAction
                 //echo "文件夹: $fullPath<br />";
                 //插数据库
                 $filePath = str_replace($this->sourcePath, '', $fullPath);
-                $newParentId = DistAppearanceTemplate::insertTemplateFolder(0, $this->appearanceId, $filePath, $parentId);
+                $fileName = basename($fullPath);
+                $newParentId = DistAppearanceTemplate::insertTemplateFolder(0, $this->appearanceId, $filePath,$fileName, $parentId);
                 $this->readDirectory($fullPath,$newParentId); // 递归调用
             } else {
                 // 如果是文件,读取文件内容
                 $content = file_get_contents($fullPath);
                 $filePath = str_replace($this->sourcePath, '', $fullPath);
-                $filePath = str_replace('/' .$file, '', $filePath);
+                $fileName = basename($fullPath);
                 // 插入数据库
-                DistAppearanceTemplate::insertTemplateContent(0, $this->appearanceId, $filePath,$file, $parentId, $content);
+                DistAppearanceTemplate::insertTemplateContent(0, $this->appearanceId, $filePath,$fileName, $parentId, $content);
             }
         }
 

+ 6 - 2
app/Admin/Controllers/DistAppearanceTemplateController.php

@@ -58,7 +58,9 @@ class DistAppearanceTemplateController extends AdminController
             $file_name = $value['file_name'];
             if ($value['file_type'] == 1) {
                 $fa = 'fa-angle-right';
-                $file_name = '<a href="#" class="file-action" file_id="'. $value['id'].'">'. $file_name.'</a>';
+                $file_name = '<a href="#" class="file-action" file_id="'. $value['id'].'" title="'.$file_name.'">'. $file_name.'</a>';
+            }  else {
+                $file_name = '<span class="custom-blue-bold">'. $file_name.'</span>';
             }
             $html .= '<li class="list-group-item has-submenu">';
             $html .= '<i class="fa '.$fa.'"></i> '. $file_name;
@@ -78,7 +80,9 @@ class DistAppearanceTemplateController extends AdminController
                 $file_name = $v['file_name'];
                 if ($v['file_type'] == 1) {
                     $fa = 'fa-angle-right';
-                    $file_name = '<a href="#" class="file-action" file_id="'. $v['id'].'">'. $file_name.'</a>';
+                    $file_name = '<a href="#" class="file-action" file_id="'. $v['id'].'" title="'.$file_name.'">'. $file_name.'</a>';
+                } else {
+                    $file_name = '<span class="custom-blue-bold">'. $file_name.'</span>';
                 }
                 $html .= '<li class="list-group-item"><i class="fa '.$fa.'"></i> '. $file_name;
                 if (!empty($v['children'])) {

+ 2 - 0
app/Admin/Repositories/DistAppearance.php

@@ -3,6 +3,7 @@
 namespace App\Admin\Repositories;
 
 use App\Models\DistAppearance as Model;
+use Carbon\Carbon;
 use Dcat\Admin\Repositories\EloquentRepository;
 
 class DistAppearance extends EloquentRepository
@@ -31,6 +32,7 @@ class DistAppearance extends EloquentRepository
     {
         $row = Model::where('id', $id)->first();
         if ($row) {
+            $row->updated_at = Carbon::now();
             $row->imported = 1;
             $row->save();
         }

+ 3 - 3
app/Admin/Repositories/DistAppearanceTemplate.php

@@ -24,7 +24,7 @@ class DistAppearanceTemplate extends EloquentRepository
     }
     public static function getTemplateTree($appearance_id,$dist_id)
     {
-        $data = Model::where('appearance_id', $appearance_id)->where('dist_id', $dist_id)->get(['id', 'file_name', 'parent_id','file_type','file_path']);
+        $data = Model::where('appearance_id', $appearance_id)->where('dist_id', $dist_id)->orderBy('file_type', 'desc')->orderBy('file_path', 'asc')->get(['id', 'file_name', 'parent_id','file_type','file_path']);
         return self::buildTree($data->toArray(),0);
     }
 
@@ -70,12 +70,12 @@ class DistAppearanceTemplate extends EloquentRepository
     /*
      * 插入模版文件夹
      */
-    public static function insertTemplateFolder($distId,$appearanceId,$filePath,$parentId) {
+    public static function insertTemplateFolder($distId,$appearanceId,$filePath,$fileName,$parentId) {
         $self = new self();
         $model = $self->model();
         $model->dist_id = $distId;
         $model->appearance_id = $appearanceId;
-        $model->file_name = $filePath;
+        $model->file_name = $fileName;
         $model->parent_id = $parentId;
         $model->file_type = 0;
         $model->file_path = $filePath;

+ 1 - 1
config/admin.php

@@ -243,7 +243,7 @@ return [
     'menu' => [
         'cache' => [
             // enable cache or not
-            'enable' => false,
+            'enable' => true,
             'store'  => 'file',
         ],
 

+ 1 - 1
config/distributor.php

@@ -232,7 +232,7 @@ return [
     'menu' => [
         'cache' => [
             // enable cache or not
-            'enable' => false,
+            'enable' => true,
             'store'  => 'file',
         ],
 

File diff suppressed because it is too large
+ 0 - 0
public/vendor/ace/mode-css.js


File diff suppressed because it is too large
+ 0 - 0
public/vendor/ace/worker-css.js


+ 24 - 8
resources/views/admin/pages-custom/ace.blade.php

@@ -13,12 +13,16 @@
     .main-panel-header {
         background-color: #fff;
     }
-    .card-body {
-        max-height: 100vh; /* 设置最大高度 */
+    .main-card-body {
+        max-height: 75vh; /* 设置最大高度 */
         overflow-y: auto; /* 启用垂直滚动条 */
-        border-radius: 4px; /* 圆角 */
+        overflow-x: hidden; /* 隐藏水平滚动条 */
+        border-radius: 1px; /* 圆角 */
+    }
+    .main-card-body ul li {
+        white-space: nowrap;
+        padding: 0px;
     }
-
     #editor {
 
         background-color: #1e1e1e;
@@ -26,7 +30,6 @@
     .modal-body {
         background-color: #e9ecef;
     }
-
     .submenu {
         list-style: none;
         padding-left: 3px;
@@ -34,15 +37,18 @@
     .submenu .list-group-item {
         padding: 10px 0px 10px 20px;
     }
+    .custom-blue-bold {
+        color: #1e1e1e; /* Bootstrap 的 primary 颜色 */
+        font-weight: bold;
+    }
 </style>
 
-
 <div class="container-fluid">
     <div class="row">
         <div class="col-2 left-panel"> <!-- 左侧20% -->
             {!!$leftForm!!}
             <!-- 代码树 start-->
-            <div class="card-body"></div>
+            <div class="main-card-body"></div>
             <!-- 代码树 end-->
         </div>
         <div class="col-10 main-panel"> <!-- 右侧80% -->
@@ -78,6 +84,7 @@
 
 <script src="/vendor/ace/ace.js" type="text/javascript"></script>
 <script>
+    //https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.js
     // 创建 Ace 编辑器实例
     var editor = ace.edit("editor");
     // 设置语言
@@ -106,6 +113,15 @@
                 });
 
                 fileId = $(this).attr('file_id');
+                //得到文件名
+                fileName = $(this).html();
+                if (fileName.endsWith('.css')) {
+                    editor.getSession().setMode("ace/mode/css");
+                } else if (fileName.endsWith('.js')) {
+                    editor.getSession().setMode("ace/mode/javascript");
+                }else {
+                    editor.getSession().setMode("ace/mode/html");
+                }
                 //改变iframe的url
                 changeIframeUrl();
                 //编辑代码
@@ -140,7 +156,7 @@
                     dist_id: dist_id
                 },
                 success: function(response) {
-                    $('.card-body').html(response);
+                    $('.main-card-body').html(response);
                     actionclick();
                 }
             });

Some files were not shown because too many files changed in this diff