moshaorui 4 달 전
부모
커밋
c51e8e2ee1
4개의 변경된 파일23개의 추가작업 그리고 12개의 파일을 삭제
  1. 0 9
      app/Admin/Controllers/DistAdminDistributorController.php
  2. 3 3
      app/Distributor/Controllers/SitePagesController.php
  3. 2 0
      app/Traits/DistSlugTrait.php
  4. 18 0
      app/helpers.php

+ 0 - 9
app/Admin/Controllers/DistAdminDistributorController.php

@@ -50,10 +50,6 @@ class DistAdminDistributorController extends AdminController
             $grid->column('id')->sortable();
             $grid->column('client_code',admin_trans_label('client_code'))->width('15%');
             $grid->column('dist_email',admin_trans_label('email'));
-//            $grid->column('dist_contact_number',admin_trans_label('contact_number'));
-//            $grid->column('domain_type')->using(admin_trans_array(config('dictionary.domain_type')));
-//            $grid->column('secondary_domain');
-//            $grid->column('custom_domain');
             $grid->column('country',);
             $grid->column('enabled')->switch();
             $grid->column('created_at')->sortable();
@@ -72,7 +68,6 @@ class DistAdminDistributorController extends AdminController
             $grid->enableDialogCreate();
             $grid->disableEditButton();
             $grid->disableDeleteButton();
-            //$grid->disableBatchDelete();
             //批量操作
             $grid->batchActions(function (Grid\Tools\BatchActions $batch) {
                 $batch->disableDelete();
@@ -98,15 +93,11 @@ class DistAdminDistributorController extends AdminController
             $show->field('country_alpha_2');
             $show->field('country_lang');
             $show->field('address');
-//            $show->field('domain_type')->using([0=>admin_trans_field('secondary_domain'),1=>admin_trans_field('custom_domain')]);
-//            $show->field('secondary_domain');
-//            $show->field('custom_domain');
             $show->field('created_at');
             $show->field('updated_at');
             $show->field('enabled')->using(admin_trans_array(config('dictionary.enabled')));
             // 按钮
             $show->disableDeleteButton();
-
         });
     }
 

+ 3 - 3
app/Distributor/Controllers/SitePagesController.php

@@ -67,13 +67,13 @@ class SitePagesController extends AdminDistController
             $grid->column('id')->display(function () {
                 return $this->_index+1;
             });
-            $grid->column('title')->width('20%');
-            $grid->column('pagesTag',admin_trans_label('tags'))->pluck('name')->label();
+            $grid->column('title')->width('30%');
+            $grid->column('pagesTag',admin_trans_label('tags'))->pluck('name')->label()->width('15%');
             $grid->column('cover_image')->display(function ($image) {
                 // 开始生成 HTML
                 $dataImages = [$image];
                 return CommonHelper::displayImage($dataImages,100);
-            });
+            })->width('10%');
             //发布日期
             $grid->column('post_date')->display(function ($date) {
                 $dateTime = new DateTime($date);

+ 2 - 0
app/Traits/DistSlugTrait.php

@@ -19,6 +19,8 @@ trait DistSlugTrait
      * 生成slug
      */
     public static function generateSlug($slug,$id=0) {
+        //截取50个字符
+        $slug = truncateString($slug, 50);
         $self = new self();
         $model = $self->model();
         $slug = generateSlug($slug);

+ 18 - 0
app/helpers.php

@@ -307,3 +307,21 @@ if (!function_exists('curlGet')) {
     }
 
 }
+
+/*
+ * 截取字符函数
+ */
+if (!function_exists('truncateString')) {
+    function truncateString($string, $length = 30, $append = '') {
+        // 检查字符串长度是否超过指定长度
+        if (mb_strlen($string, 'UTF-8') > $length) {
+            // 截取字符串
+            $truncated = mb_substr($string, 0, $length, 'UTF-8');
+            // 添加省略号
+            return $truncated . $append;
+        }
+        // 如果字符串长度小于或等于指定长度,直接返回原字符串
+        return $string;
+    }
+}
+