moshaorui 4 months ago
parent
commit
1598fd565c

+ 21 - 36
app/Admin/Actions/Grid/AppearanceImport.php

@@ -2,8 +2,7 @@
 
 namespace App\Admin\Actions\Grid;
 
-use App\Admin\Forms\InquiryAssignment as InquiryAssignmentForm;
-use Dcat\Admin\Grid\BatchAction;
+use App\Admin\Forms\AppearanceImPortForm;
 use Dcat\Admin\Grid\RowAction;
 use Dcat\Admin\Widgets\Modal;
 use Illuminate\Http\Request;
@@ -24,6 +23,22 @@ class AppearanceImport extends RowAction
         return admin_trans_label('import_tmpl');
     }
 
+    /**
+     * 初始化操作
+     */
+    public function render()
+    {
+        $form = AppearanceImPortForm::make()->payload(['id' => $this->getKey()]);
+        // 实例化表单类
+        return Modal::make()
+            ->lg()
+            ->title($this->title)
+            ->body($form)
+            // 因为此处使用了表单异步加载功能,所以一定要用 onLoad 方法
+            ->button($this->title());
+    }
+
+
     public function confirm()
     {
         return [
@@ -31,9 +46,11 @@ class AppearanceImport extends RowAction
             $this->row->title,
         ];
     }
+
     /*
      * 处理请求
      */
+    /*
     public function handle(Request $request)
     {
         $appearanceId = $this->getKey();
@@ -54,6 +71,8 @@ class AppearanceImport extends RowAction
         // 返回响应结果并刷新页面
         return $this->response()->success("Successfully imported")->refresh();
     }
+    */
+
     /**
      * 设置要POST到接口的数据
      *
@@ -68,39 +87,5 @@ class AppearanceImport extends RowAction
         ];
     }
 
-    private function readDirectory($dirPath) {
-        // 检查目录是否存在
-        if (!is_dir($dirPath)) {
-            return;
-        }
-
-        // 打开目录
-        $dir = opendir($dirPath);
-
-        // 读取目录内容
-        while (($file = readdir($dir)) !== false) {
-            // 忽略当前目录和上级目录
-            if ($file == '.' || $file == '..') {
-                continue;
-            }
 
-            // 获取文件或文件夹的完整路径
-            $fullPath = $dirPath . '/' . $file;
-
-            // 如果是文件夹,递归读取
-            if (is_dir($fullPath)) {
-                $this->readDirectory($fullPath); // 递归调用
-            } else {
-                // 如果是文件,读取文件内容
-                $content = file_get_contents($fullPath);
-                $filePath = str_replace($this->sourcePath, '', $dirPath);
-                $fileName = basename($fullPath);
-                // 插入数据库
-                DistAppearanceTemplate::insertTemplateContent(config('dictionary.base_dist_id'), $this->appearanceId, $filePath,$fileName, $content);
-            }
-        }
-
-        // 关闭目录
-        closedir($dir);
-    }
 }

+ 61 - 53
app/Admin/Controllers/DistAdminDistributorController.php

@@ -44,31 +44,20 @@ class DistAdminDistributorController extends AdminController
             $grid->view('admin.grid.table');
 
             $grid->column('id')->sortable();
-            $grid->column('company_name')->width('30%');
-            $grid->column('site_name');
-            $grid->column('domain_type',admin_trans_label('domain'))->display(function ($domainType) {
-                $title = "";
-                if ($domainType == 0) {
-                    $title = $this->secondary_domain;
-                } else {
-                    $title = $this->custom_domain;
-                }
-                return "<span style='color:#586cb1'>$title</span>";
-            });
-
+            $grid->column('client_code',admin_trans_label('client_code'))->width('15%');
+            $grid->column('distr_email',admin_trans_label('email'));
+            $grid->column('dist_contact_number',admin_trans_label('contact_number'));
+            $grid->column('secondary_domain');
             $grid->column('country',);
-            $grid->column('appearance.title' ,admin_trans_field('appearance'));
-            $grid->column('remark');
             $grid->column('enabled')->switch();
-            $grid->column('updated_at')->sortable();
+            $grid->column('created_at')->sortable();
             // 过滤
             $grid->filter(function (Grid\Filter $filter) {
                 $filter->panel();
                 $filter->expand();
-                $filter->equal('company_name', )->width(2);
-                $filter->equal('site_name')->width(2);
-                $filter->equal('domain')->width(2);
-                $filter->equal('enabled', )->select(admin_trans_array(config('dictionary.enabled')))->width(2);
+                $filter->equal('dist_code',admin_trans_label('client_code') )->width(2);
+                $filter->equal('secondary_domain')->width(2);
+                $filter->equal('enabled')->select(admin_trans_array(config('dictionary.enabled')))->width(2);
             });
             // 排序
             $grid->model()->orderBy("id",'desc');
@@ -96,7 +85,15 @@ class DistAdminDistributorController extends AdminController
     protected function detail($id)
     {
         return Show::make($id, DistAdminDistributor::with(['appearance']), function (Show $show) {
-            $show->field('id');
+            $show->field('dist_code',admin_trans_label('client_code'));
+            $show->field('distr_email',admin_trans_label('email'));
+            $show->field('dist_contact_number',admin_trans_label('contact_number'));
+            $show->field('secondary_domain');
+            $show->field('country');
+            $show->field('enabled')->using(admin_trans_array(config('dictionary.enabled')));
+            $show->field('created_at');
+            $show->field('updated_at');
+            /*
             $show->field('company_name');
             $show->field('company_address');
             $show->field('site_name');
@@ -132,6 +129,7 @@ class DistAdminDistributorController extends AdminController
             $show->field('seo_title');
             $show->field('seo_keywords');
             $show->field('seo_description');
+            */
             // 按钮
             $show->disableDeleteButton();
 
@@ -146,6 +144,15 @@ class DistAdminDistributorController extends AdminController
     protected function form()
     {
         return Form::make(new DistAdminDistributor(), function (Form $form) {
+            $form->text('dist_code',admin_trans_label('client_code'))->width(9,3)->required();
+            $form->text('distr_email',admin_trans_label('email'))->width(9,3);
+            $form->text('dist_contact_number',admin_trans_label('contact_number'))->width(9,3);
+            $form->text('secondary_domain')->width(9,3)
+                ->required()
+                ->help('Please enter the domain name, such as demo.'.env('TOP_DOMAIN'));
+            $form->text('country')->width(9,3)->required();
+            $form->switch('enabled')->width(9,3)->default(1);
+            /*
             $form->text('company_name')->width(9,3)->required();
             $form->text('company_address',)->width(9,3);
             $form->text('site_name')->width(9,3)->required();
@@ -183,46 +190,47 @@ class DistAdminDistributorController extends AdminController
             $form->text('seo_title')->width(9,3)->required();
             $form->text('seo_keywords')->width(9,3);
             $form->textarea('seo_description')->width(9,3);
+            */
 
             //保存前回调
-            $form->saving(function (Form $form) {
-                if (!$form->isCreating()) {
-                    //如果appearance_id有变化,则更新模版与变量
-                    if ($form->model()->appearance_id != $form->input('appearance_id')) {
-                        $id = $form->model()->id;
-                        //更新模版与变量
-                        DistAppearance::switchTheme($form->input('appearance_id'), $id);
-                    }
-                }
-            });
+//            $form->saving(function (Form $form) {
+//                if (!$form->isCreating()) {
+//                    //如果appearance_id有变化,则更新模版与变量
+//                    if ($form->model()->appearance_id != $form->input('appearance_id')) {
+//                        $id = $form->model()->id;
+//                        //更新模版与变量
+//                        DistAppearance::switchTheme($form->input('appearance_id'), $id);
+//                    }
+//                }
+//            });
             //保存后回调
-            $form->saved(function (Form $form, $result) {
-                if ($form->isCreating()) {
-                    //创建后创建默认分类
-                    $newId = $form->getKey();
-                    $appearanceId = $form->input('appearance_id');
-                    //初始化分销商
-                    DistAdminDistributor::initDist($appearanceId,$newId);
-                    //更新模版与变量
-                    DistAppearance::switchTheme($appearanceId, $newId);
-                }
-            });
+//            $form->saved(function (Form $form, $result) {
+//                if ($form->isCreating()) {
+//                    //创建后创建默认分类
+//                    $newId = $form->getKey();
+//                    $appearanceId = $form->input('appearance_id');
+//                    //初始化分销商
+//                    DistAdminDistributor::initDist($appearanceId,$newId);
+//                    //更新模版与变量
+//                    DistAppearance::switchTheme($appearanceId, $newId);
+//                }
+//            });
         });
     }
 
     /*
      * 新增事件事务
      */
-    public function store()
-    {
-        try {
-            DB::beginTransaction();
-            $result =  parent::store();
-            DB::commit();
-            return $result;
-        } catch (\Exception $e) {
-            DB::rollBack();
-            throw $e;
-        }
-    }
+//    public function store()
+//    {
+//        try {
+//            DB::beginTransaction();
+//            $result =  parent::store();
+//            DB::commit();
+//            return $result;
+//        } catch (\Exception $e) {
+//            DB::rollBack();
+//            throw $e;
+//        }
+//    }
 }

+ 3 - 4
app/Admin/Controllers/DistAdminUserController.php

@@ -39,9 +39,9 @@ class DistAdminUserController extends AdminController
             $grid->view('admin.grid.table');
             //设置列表
             $grid->column('id')->sortable();
+            $grid->column('distributor.client_code',admin_trans_label('distributor_code'))->width('15%');
             $grid->column('username');
             $grid->column('name');
-            $grid->column('distributor.company_name',admin_trans_label('distributor_company_name'))->width('30%');
             $grid->column('language')->using(config('dictionary.languages'));
             $grid->column('enabled')->switch();
             $grid->column('created_at');
@@ -52,7 +52,7 @@ class DistAdminUserController extends AdminController
                 $filter->expand();
                 $filter->equal('username')->width(2);
                 $filter->equal('name',)->width(2);
-                $filter->like('distributor.company_name', admin_trans_label('company_name'))->width(2);
+                $filter->like('distributor.client_code', admin_trans_label('distributor_code'))->width(2);
                 $filter->equal('enabled', )->select(admin_trans_array(config('dictionary.enabled')))->width(2);
             });
             //排序
@@ -77,7 +77,6 @@ class DistAdminUserController extends AdminController
     {
         return Show::make($id, DistAdminUser::with(['distributor']), function (Show $show) {
             $show->row(function ($show) {
-                $show->width(6)->field('id');
                 $show->width(6)->field('username');
                 $show->width(6)->field('name');
                 $show->width(6)->field('language')->using(config('dictionary.languages'));
@@ -127,7 +126,7 @@ class DistAdminUserController extends AdminController
             $form->selectTable('dist_id', admin_trans_label('distributor'))
                 ->title('distId')
                 ->from(DistDistributorTable::make())
-                ->model(DistAdminDistributor::class, 'id', 'company_name')
+                ->model(DistAdminDistributor::class, 'id', 'client_code')
                 ->required();
             $form->switch('enabled')->default(1);
             //保存前回调

+ 206 - 0
app/Admin/Controllers/DistSiteController.php

@@ -0,0 +1,206 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Admin\Actions\Grid\InitAppearance;
+use App\Admin\Repositories\DistAdminDistributor;
+use App\Admin\Repositories\DistAppearance;
+use App\Libraries\CommonHelper;
+use Dcat\Admin\Form;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Http\Controllers\AdminController;
+use Dcat\Admin\Layout\Content;
+use Dcat\Admin\Show;
+use Illuminate\Support\Facades\DB;
+
+class DistSiteController extends AdminController
+{
+    /**
+     * page index
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header(admin_trans( 'admin.site_management'))
+            ->description('')
+            ->breadcrumb(['text'=>'list','url'=>''])
+            ->body($this->grid());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+
+        return Grid::make(DistAdminDistributor::with(['appearance']), function (Grid $grid) {
+            //默认分页条数
+            $grid->paginate(config('admin.per_page'));
+            //指定视图,去掉删除按钮
+            $grid->view('admin.grid.table');
+
+            $grid->column('id')->sortable();
+            $grid->column('client_code',admin_trans_label('distributor_code'))->width('15%');
+            $grid->column('site_name');
+            $grid->column('appearance.title' ,admin_trans_field('appearance'));
+            $grid->column('secondary_domain');
+            $grid->column('custom_domain');
+            $grid->column('updated_at')->sortable();
+            // 过滤
+            $grid->filter(function (Grid\Filter $filter) {
+                $filter->panel();
+                $filter->expand();
+                $filter->equal('dist_code',admin_trans_label('client_code') )->width(2);
+                $filter->equal('site_name' )->width(2);
+            });
+            // 排序
+            $grid->model()->where('enabled',1)->orderBy("id",'desc');
+            //按钮
+            $grid->enableDialogCreate();
+            $grid->disableDeleteButton();
+            $grid->disableCreateButton();
+            //批量操作
+            $grid->batchActions(function (Grid\Tools\BatchActions $batch) {
+                $batch->disableDelete();
+            });
+        });
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     *
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        return Show::make($id, DistAdminDistributor::with(['appearance']), function (Show $show) {
+            $show->field('site_name');
+            $show->field('appearance.title' ,admin_trans_field('appearance'));
+            $show->field('copy_right');
+            $show->field('logo')->as(function ($image) {
+                // 开始生成 HTML
+                $dataImages = [$image];
+                return CommonHelper::displayImage($dataImages,100);
+            })->unescape();
+            $show->field('domain_type',admin_trans_label('domain_type'))->using(admin_trans_array(config('dictionary.domain_type')));
+            $show->field('secondary_domain');
+            $show->field('custom_domain');
+//            $show->field('domain_type',admin_trans_label('domain'))->as(function ($domainType) {
+//                $title = "";
+//                if ($domainType == 0) {
+//                    $title = $this->secondary_domain;
+//                } else {
+//                    $title = $this->custom_domain;
+//                }
+//                return "<span style='color:#586cb1'>$title</span>";
+//            })->unescape();
+
+            $show->field('seo_title');
+            $show->field('seo_keywords');
+            $show->field('seo_description');
+            $show->divider();
+            $show->field('company_name');
+            $show->field('company_address');
+            $show->field('country');
+            $show->field('contact_number');
+            $show->field('service_hotline');
+            $show->field('whats_app');
+            $show->field('facebook');
+            $show->field('instagram');
+            $show->field('youtube');
+            $show->field('linkedin');
+            $show->field('tiktok');
+            $show->field('remark');
+            $show->field('enabled')->using(admin_trans_array(config('dictionary.enabled')));
+            $show->field('created_at');
+            $show->field('updated_at');
+
+            // 按钮
+            $show->disableDeleteButton();
+
+
+        });
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        return Form::make(new DistAdminDistributor(), function (Form $form) {
+            $form->column(6, function (Form $form) {
+                $form->text('site_name')->width(9,3)->required();
+                $form->text('seo_title')->width(9,3)->required();
+                $form->text('seo_keywords')->width(9,3);
+                $form->textarea('seo_description')->width(9,3);
+                $form->select('appearance_id',admin_trans_field('appearance'))->width(9,3)->options(DistAppearance::selectOptions())->required();
+                $form->image("logo")
+                    ->autoUpload()
+                    ->uniqueName()
+                    ->accept(config('distributor.upload.oss_image.accept'))
+                    ->maxSize(config('distributor.upload.oss_image.max_size'))
+                    ->dir(config("distributor.upload.directory.image").'/logo')
+                    ->width(4,3);
+                $form->textarea('statistics_js')->width(9,3);
+            });
+            $form->column(6, function (Form $form) {
+                $form->text('company_name')->width(9,3);
+                $form->text('company_address',)->width(9,3);
+                $form->text('service_hotline')->width(9,3);
+                $form->text('whats_app')->width(9,3);
+                $form->text('facebook')->width(9,3);
+                $form->text('instagram')->width(9,3);
+                $form->text('youtube')->width(9,3);
+                $form->text('linkedin')->width(9,3);
+                $form->text('tiktok')->width(9,3);
+                $form->text('copy_right')->width(9,3);
+            });
+            //保存前回调
+            $form->saving(function (Form $form) {
+                if (!$form->isCreating()) {
+                    //如果appearance_id有变化,则更新模版与变量
+                    if ($form->model()->appearance_id != $form->input('appearance_id')) {
+                        $id = $form->model()->id;
+                        //更新模版与变量
+                        DistAppearance::switchTheme($form->input('appearance_id'), $id);
+                    }
+                }
+            });
+            //保存后回调
+            $form->saved(function (Form $form, $result) {
+                if ($form->isCreating()) {
+                    //创建后创建默认分类
+                    $newId = $form->getKey();
+                    $appearanceId = $form->input('appearance_id');
+                    //初始化分销商
+                    DistAdminDistributor::initDist($appearanceId,$newId);
+                    //更新模版与变量
+                    DistAppearance::switchTheme($appearanceId, $newId);
+                }
+            });
+            $form->disableDeleteButton();
+        });
+    }
+
+    /*
+     * 新增事件事务
+     */
+    public function store()
+    {
+        try {
+            DB::beginTransaction();
+            $result =  parent::store();
+            DB::commit();
+            return $result;
+        } catch (\Exception $e) {
+            DB::rollBack();
+            throw $e;
+        }
+    }
+}

+ 20 - 15
app/Admin/Controllers/HomeController.php

@@ -22,27 +22,32 @@ class HomeController extends Controller
     public function index(Content $content)
     {
 
-        $alert = Alert::make('','Prime Admin');
+        $alert = Alert::make('','Welcome to Mietubl');
                 $content =  $content
                     ->view('admin.layouts.content')
                     ->header('Prime Admin')
-                    ->description('description')
-                    ->row($alert->info())
+                    ->description('')
+                   // ->row($alert->info())
                     ->row(function (Row $row) {
-                        $row->column(6, function (Column $column) {
-                           // $column->row(Dashboard::author());
-                            $column->row(new Examples\Tickets());
+                        $row->column(12, function (Column $column) {
+                            $column->row(\App\Distributor\Controllers\Dashboard::title());
                         });
 
-                        $row->column(6, function (Column $column) {
-                            $column->row(function (Row $row) {
-                                $row->column(6, new Examples\NewUsers());
-                                $row->column(6, new Examples\NewDevices());
-                            });
-
-                            $column->row(new Examples\Sessions());
-                            $column->row(new Examples\ProductOrders());
-                        });
+//                        $row->column(6, function (Column $column) {
+////                            $column->row(function (Row $row) {
+////                                $row->column(6, new Examples\NewUsers());
+////                                $row->column(6, new Examples\NewDevices());
+////                            });
+//                           // $column->row(Dashboard::author());
+//                            //$column->row(new Examples\Tickets());
+//                        });
+//
+//                        $row->column(6, function (Column $column) {
+//
+//
+//                        //    $column->row(new Examples\Sessions());
+//                            //$column->row(new Examples\ProductOrders());
+//                        });
                     });
 
         return $content;

+ 1 - 0
app/Admin/Forms/AceLeft.php

@@ -18,6 +18,7 @@ class AceLeft extends Form
             ->setLabelClass('d-flex')
             ->title('Select Distributor')
             ->placeholder('Select Distributor')
+            ->model(DistAdminDistributor::class, 'id', 'client_code')
             ->from(DistDistributorTable::make());
 
         //主题选择

+ 217 - 0
app/Admin/Forms/AppearanceImPortForm.php

@@ -0,0 +1,217 @@
+<?php
+
+namespace App\Admin\Forms;
+
+use App\Admin\Renderable\DistDistributorTable;
+use App\Admin\Repositories\DistAppearance;
+use App\Admin\Repositories\DistAppearanceTemplate;
+use App\Admin\Repositories\DistInquiry;
+use Dcat\Admin\Models\DistAdminUser;
+use Dcat\Admin\Widgets\Form;
+use Dcat\Admin\Contracts\LazyRenderable;
+use Dcat\Admin\Traits\LazyWidget;
+use ZipArchive;
+
+class AppearanceImPortForm extends Form implements LazyRenderable
+{
+    use LazyWidget;
+
+    protected $appearanceId = 0;
+
+    // 处理请求
+    public function handle(array $input)
+    {
+        // 获取外部传递参数
+        $appearanceId = $this->payload['id'] ?? null;
+        $file = $input['file'] ?? null;
+        $appearanceRs = DistAppearance::getOneById($appearanceId);
+        if ($file && $appearanceRs) {
+            $folder = $appearanceRs->folder;
+            $extractPath = resource_path().'/appearance/tmp';
+            $path = resource_path().'/appearance/'.$folder;
+            //解压
+            $unzip = $this->unzip($file,$extractPath,$path);
+            if (!$unzip['status']) {
+                return $this->response()->error($unzip['error']);
+            }
+            //导入模板
+            if (!is_dir($path)) {
+                return $this->response()->error("The directory does not exist")->refresh();
+            }
+            $this->sourcePath = $path;
+            $this->appearanceId = $appearanceId;
+            // 清空旧的
+            DistAppearanceTemplate::deleteTemplates($appearanceId, config('dictionary.base_dist_id'));
+            // 导入模板
+            $this->readDirectory($path);
+            // 更新状态
+            DistAppearance::setStatusToImported($appearanceId);
+            return $this->response()->success('allocation successful')->refresh();
+        }
+        return $this->response()->error('No file data');
+    }
+
+    /*
+     * 下载并解压
+     */
+
+    private function unzip($savePath,$extractPath,$trulyPath)
+    {
+        // 检查 $extractPath 是否存在且是否是一个目录
+        if (!is_dir($extractPath)) {
+            mkdir($extractPath, 0755, true);
+        }
+
+        if (!is_dir($trulyPath)) {
+            mkdir($trulyPath, 0755, true);
+        }
+
+        $savePath = storage_path().'/app/'.$savePath;
+        // 检查是否支持 ZipArchive 扩展
+        if (!extension_loaded('zip')) {
+            return ['status' => false, 'error' => 'ZipArchive 扩展未加载'];
+        }
+        // 保存文件到本地
+        $zip = new ZipArchive;
+        if ($zip->open($savePath) !== TRUE) {
+            return ['status' => false, 'error' => 'ZipArchive 解压失败'];
+        }
+        if ($zip->extractTo($extractPath) !== TRUE) {
+            return ['status' => false, 'error' => "解压文件到 $extractPath 失败。"];
+        }
+        $zip->close();
+        //判断tmp下是否只有一个文件夹,如果是,移动到trulyPath
+        // 递归删除 $trulyPath 下的所有文件和文件夹
+        $deleteDirectoryContents = $this->deleteDirectoryContents($trulyPath);
+        if ($deleteDirectoryContents) {
+            return ['status' => false, 'error' => $deleteDirectoryContents];
+        }
+
+        // 获取 $extractPath 下的所有文件和文件夹
+        $items = scandir($extractPath);
+        // 过滤掉 '.' 和 '..'
+        $items = array_diff($items, ['.', '..']);
+        // 判断 $extractPath 是否只有一个文件夹
+        if (count($items) != 1 || !is_dir($extractPath . '\\' . reset($items))) {
+            return ['status' => false, 'error' => "Error: unzip file does not contain exactly one folder."];
+        }
+        // 获取文件夹名称
+        $folderName = reset($items);
+        $folderPath = $extractPath . '\\' . $folderName;
+        // 获取文件夹下的所有文件和文件夹
+        $folderContents = scandir($folderPath);
+        $folderContents = array_diff($folderContents, ['.', '..']);
+        // 将文件夹中的所有内容移动到 $trulyPath
+        foreach ($folderContents as $fileOrDir) {
+            $sourcePath = $folderPath . '\\' . $fileOrDir;
+            $destinationPath = $trulyPath . '\\' . $fileOrDir;
+            // 如果是文件,移动文件
+            if (is_file($sourcePath)) {
+                if (!rename($sourcePath, $destinationPath)) {
+                    return ['status' => false, 'error' => "Error: Failed to move file $fileOrDir\n"];
+                }
+            }
+            // 如果是目录,递归移动目录内容
+            elseif (is_dir($sourcePath)) {
+                // 创建目标文件夹
+                if (!mkdir($destinationPath)) {
+                    return ['status' => false, 'error' => "Error: Failed to create folder $fileOrDir\n"];
+                }
+                // 递归移动文件夹内容
+                $folderFiles = scandir($sourcePath);
+                $folderFiles = array_diff($folderFiles, ['.', '..']);
+                foreach ($folderFiles as $subFile) {
+                    $subSourcePath = $sourcePath . '\\' . $subFile;
+                    $subDestinationPath = $destinationPath . '\\' . $subFile;
+                    if (!rename($subSourcePath, $subDestinationPath)) {
+                        return ['status' => false, 'error' => "Error: Failed to move subfolder file $subFile\n"];
+                    }
+                }
+            }
+        }
+        // 删除原文件夹及其内容
+        rmdir($folderPath);
+        return ['status' => true];
+    }
+
+    // 递归删除文件夹及其内容
+    private function deleteDirectoryContents($dir)
+    {
+        // 获取目录下所有文件和文件夹
+        $items = scandir($dir);
+
+        // 过滤掉 '.' 和 '..'
+        $items = array_diff($items, ['.', '..']);
+
+        // 循环遍历目录下的每一项
+        foreach ($items as $item) {
+            $itemPath = $dir . '\\' . $item;
+
+            // 如果是文件,删除文件
+            if (is_file($itemPath)) {
+                if (!unlink($itemPath)) {
+                    return "Error: Failed to delete file $itemPath\n";
+                }
+            }
+            // 如果是目录,递归删除该目录
+            elseif (is_dir($itemPath)) {
+                deleteDirectoryContents($itemPath); // 递归删除目录内容
+                if (!rmdir($itemPath)) {
+                    return "Error: Failed to delete directory $itemPath\n";
+                }
+            }
+        }
+    }
+
+
+
+    public function form()
+    {
+        $this->file('file')
+            ->disk('local') // 使用本地存储
+            ->uniqueName()
+            ->autoUpload()
+            ->required()
+            ->accept('zip')
+            ->dir(config("admin.upload.directory.file").'/tmp/')
+            ->help('Please upload a zip file');
+
+    }
+    private function readDirectory($dirPath) {
+        // 检查目录是否存在
+        if (!is_dir($dirPath)) {
+            return;
+        }
+
+        // 打开目录
+        $dir = opendir($dirPath);
+
+        // 读取目录内容
+        while (($file = readdir($dir)) !== false) {
+            // 忽略当前目录和上级目录
+            if ($file == '.' || $file == '..') {
+                continue;
+            }
+
+            // 获取文件或文件夹的完整路径
+            $fullPath = $dirPath . '/' . $file;
+
+            // 如果是文件夹,递归读取
+            if (is_dir($fullPath)) {
+                $this->readDirectory($fullPath); // 递归调用
+            } else {
+                // 如果是文件,读取文件内容
+                $content = file_get_contents($fullPath);
+                $filePath = str_replace($this->sourcePath, '', $dirPath);
+                $fileName = basename($fullPath);
+                // 插入数据库
+                DistAppearanceTemplate::insertTemplateContent(config('dictionary.base_dist_id'), $this->appearanceId, $filePath,$fileName, $content);
+            }
+        }
+
+        // 关闭目录
+        closedir($dir);
+    }
+
+
+}

+ 6 - 28
app/Admin/Renderable/DistDistributorTable.php

@@ -12,37 +12,15 @@ class DistDistributorTable extends LazyRenderable
     {
         return Grid::make(DistAdminDistributor::with(['appearance']), function (Grid $grid) {
             $grid->view('admin.grid.table');
-
             $grid->column('id')->width('5%');
-            $grid->column('company_name', 'Company Name')->width('25%');
-            $grid->column('appearance.title' ,admin_trans_field('appearance'))->width('15%');
-           // $grid->column('country', 'Country');
-            $grid->column('site_name');
-            $grid->column('domain_type',admin_trans_label('domain'))->display(function ($domainType) {
-                $title = "";
-                if ($domainType == 0) {
-                    $title = $this->secondary_domain;
-                } else {
-                    $title = $this->custom_domain;
-                }
-                return "<span style='color:#586cb1'>$title</span>";
-            });
-            $grid->actions(function (Grid\Displayers\Actions $actions) {
-                $actions->disableDelete();
-                $actions->disableEdit();
-                $actions->disableQuickEdit();
-                $actions->disableView();
-                $url = $actions->row->domain_type == 0 ? $actions->row->secondary_domain : $actions->row->custom_domain;
-                $url = 'http://'.$url.':'.env('DIST_SITE_PORT');
-                $actions->prepend('<a href="'.$url.'" target="_blank"><i class="fa fa-paper-plane"></i> 浏览</a>');
-            });
-
-            $grid->rowSelector()->titleColumn('company_name');
-            $grid->quickSearch(['company_name']);
+            $grid->column('client_code', admin_trans_label('client_code'))->width('25%');
+            $grid->column('distr_email',admin_trans_label('email'));
+            $grid->column('dist_contact_number',admin_trans_label('contact_number'));
+            $grid->column('country');
+            $grid->disableActions();
             $grid->paginate(10);
             $grid->filter(function (Grid\Filter $filter) {
-                $filter->like('company_name')->width(4);
-                $filter->like('site_name')->width(4);
+                $filter->like('client_code')->width(4);
             });
             $grid->model()->where('enabled', 1);
         });

+ 1 - 1
app/Admin/Renderable/DistUserTable.php

@@ -15,7 +15,7 @@ class DistUserTable extends LazyRenderable
         return Grid::make(new DistAdminUser(), function (Grid $grid) {
             $grid->column('id');
             $grid->column('username');
-            $grid->column('name','Company Name');
+            $grid->column('name');
             $grid->column('created_at');
             $grid->column('updated_at');
 

+ 2 - 0
app/Admin/routes.php

@@ -29,6 +29,8 @@ Route::group([
     $router->resource('dist-admin-distributor', 'DistAdminDistributorController');
     //分销商用户管理
     $router->resource('dist-admin-user', 'DistAdminUserController');
+    //分销商站点
+    $router->resource('dist-site', 'DistSiteController');
     //询价管理
     $router->resource('dist-inquiry', 'DistInquiryController');
     //外观管理

+ 81 - 56
app/Distributor/Controllers/SettingsController.php

@@ -18,38 +18,67 @@ class SettingsController extends Controller
 
     public function index(Content $content)
     {
-        return $content->title(admin_trans( 'admin.settings'))
-            ->body(
-<<<HTML
-<div class="card">{$this->form()->render()}</div>
-HTML
-            );
+        $formTab = isset($_GET['tab']) ? $_GET['tab'] : 0;
+        if ($formTab == 0) {
+            return $content->title(admin_trans( 'admin.settings'))
+                ->body($this->form1());
+        } else {
+            return $content->title(admin_trans( 'admin.settings'))
+                ->body($this->form2());
+        }
+
     }
 
-    protected function form()
+    /*
+     * 域名配置
+     */
+    protected function form1()
     {
-        $formTab = isset($_GET['tab']) ? $_GET['tab'] : 0;
-        $formTab1 = ($formTab == 0);
-        $formTab2 = ($formTab != 0);
         $distInfo = DistAdminDistributor::getInfo();
-        $form = new Form();
-        $form->tab('domain', function (Form $form) use ($distInfo) {
-            //查分销商信息
-            $secondaryDomain = $distInfo->secondary_domain ? $distInfo->secondary_domain : '';
-            $customDomain = $distInfo->custom_domain ? $distInfo->custom_domain : '';
-            $form->radio('domain_type')
-                ->when(0, function (Form $form) use ($secondaryDomain) {
-                    $form->text('secondary_domain')->width(4,2)->value($secondaryDomain)->readOnly();
-                })
-                ->when(1, function (Form $form) use ($customDomain){
-                    $form->text('custom_domain')->width(4,2)->value($customDomain)->help('Please enter the domain name, such as www.example.com,and bind the domain name to the IP address '.env('DIST_SITE_IP'));
-                })
-                ->options([0=>admin_trans_field('secondary_domain'),1=>admin_trans_field('custom_domain')])
-                ->value($distInfo->domain_type)
-                ->required();
-        },$formTab1);
-        $form->tab('site', function (Form $form) use ($distInfo) {
-            $form->setFormId('tab-form-2');
+        $form = new \Dcat\Admin\Form();
+        $form->title(admin_trans_label('domain'));
+        //提交URL
+        $form->action('/dist-settings');
+        $form->hidden('act')->value('domain');
+        //查分销商信息
+        $secondaryDomain = $distInfo->secondary_domain ? $distInfo->secondary_domain : '';
+        $customDomain = $distInfo->custom_domain ? $distInfo->custom_domain : '';
+        $form->radio('domain_type')
+            ->when(0, function (\Dcat\Admin\Form $form) use ($secondaryDomain) {
+                $form->text('secondary_domain')->width(4,2)->value($secondaryDomain)->readOnly();
+            })
+            ->when(1, function (\Dcat\Admin\Form $form) use ($customDomain){
+                $form->text('custom_domain')->width(4,2)->value($customDomain)->help('Please enter the domain name, such as www.example.com,and bind the domain name to the IP address '.env('DIST_SITE_IP'));
+            })
+            ->options([0=>admin_trans_field('secondary_domain'),1=>admin_trans_field('custom_domain')])
+            ->value($distInfo->domain_type)
+            ->required();
+        //按钮
+        $form->disableListButton();
+        $form->disableViewCheck();
+        $form->disableEditingCheck();
+        $form->disableCreatingCheck();
+        return $form;
+    }
+
+    /*
+     * 站点配置
+     */
+    protected function form2()
+    {
+        $distInfo = DistAdminDistributor::getInfo();
+        $form = new \Dcat\Admin\Form();
+        $form->title(admin_trans_label('site'));
+        //提交URL
+        $form->action('/dist-settings');
+        //字段
+        $form->hidden('act')->value('site');
+
+        $form->column(6, function (\Dcat\Admin\Form $form) use ($distInfo) {
+            $form->text('site_name')->value($distInfo->site_name)->required();
+            $form->text('seo_title')->value($distInfo->seo_title)->required();
+            $form->text('seo_keywords')->value($distInfo->seo_keywords);
+            $form->textarea('seo_description')->value($distInfo->seo_description);
             $form->image("logo")
                 ->autoUpload()
                 ->uniqueName()
@@ -57,11 +86,14 @@ HTML
                 ->maxSize(config('distributor.upload.oss_image.max_size'))
                 ->dir(config("distributor.upload.directory.image").'/logo')
                 ->url('/dist-settings/upload')
-                ->default($distInfo->logo);
-            $form->text('site_name')->value($distInfo->site_name)->required();
-            $form->text('company_name')->value($distInfo->company_name)->required();
+                ->default($distInfo->logo)->width(4,2);
+
+
+        });
+
+        $form->column(6, function (\Dcat\Admin\Form $form) use ($distInfo) {
+            $form->text('company_name')->value($distInfo->company_name);
             $form->text('company_address')->value($distInfo->company_address);
-            $form->text('contact_number')->value($distInfo->contact_number);
             $form->text('service_hotline')->value($distInfo->service_hotline);
             $form->text('whats_app')->value($distInfo->whats_app);
             $form->text('facebook')->value($distInfo->facebook);
@@ -70,11 +102,11 @@ HTML
             $form->text('linkedin')->value($distInfo->linkedin);
             $form->text('tiktok')->value($distInfo->tiktok);
             $form->text('copy_right')->value($distInfo->copy_right);
-            $form->text('seo_title')->value($distInfo->seo_title)->required();
-            $form->text('seo_keywords')->value($distInfo->seo_keywords);
-            $form->textarea('seo_description')->value($distInfo->seo_description);
-        },$formTab2);
-
+        });
+        $form->disableListButton();
+        $form->disableViewCheck();
+        $form->disableEditingCheck();
+        $form->disableCreatingCheck();
         return $form;
     }
 
@@ -84,26 +116,19 @@ HTML
      */
     public function store(Request $request)  {
         $form = new Form();
-        $domainType = $request->input('domain_type');
-        $customDomain = $request->input('custom_domain');
-        if (!in_array($domainType, [0,1])) {
-            return $form->response()->error('Invalid argument');
-        }
-        /*
-        if ($domainType == 1) {
-            if (str_starts_with($customDomain,env('TOP_DOMAIN'))) {
-                return $form->response()->error('Error in domain format');
+        $act = $request->input('act');
+        if ($act == 'domain') {
+            $domainType = $request->input('domain_type');
+            $customDomain = $request->input('custom_domain');
+            if (!in_array($domainType, [0,1])) {
+                return $form->response()->error('Invalid argument');
             }
-            if (!isDomainOnly($customDomain)) {
-                return $form->response()->error('Error in domain format');
-            }
-        }*/
-        $customDomain = $this->removeHttpAndPort($customDomain);
-        DistAdminDistributor::updateDomain($domainType,$customDomain);
-
-        //站点配置
-        DistAdminDistributor::updateInfo($request->all());
-
+            $customDomain = $this->removeHttpAndPort($customDomain);
+            DistAdminDistributor::updateDomain($domainType,$customDomain);
+        } else {
+            //站点配置
+            DistAdminDistributor::updateInfo($request->all());
+        }
         return $form->response()->success('Success');
     }
 

+ 7 - 6
app/Distributor/Controllers/SiteMenuController.php

@@ -53,12 +53,13 @@ class SiteMenuController extends AdminDistController
             $tree->maxDepth(2);
             //标题显示
             $tree->branch(function ($branch) {
-                $arr[] = $branch['title'];
-                if ($branch['uri']) {
-                   // $arr[] = SiteMenu::generateUri($branch['menu_type'], $branch['menu_config'],false);
-                    $arr[] =  $branch['uri'];
-                }
-                return implode(' - ', $arr);
+//                $arr[] = $branch['title'];
+//                if ($branch['uri']) {
+//                   // $arr[] = SiteMenu::generateUri($branch['menu_type'], $branch['menu_config'],false);
+//                    $arr[] =  $branch['uri'];
+//                }
+//                return implode(' - ', $arr);
+                return $branch['title'];
             });
             //是否显示操作
             $tree->actions(function (Tree\Actions $actions) {

+ 0 - 1
app/Distributor/Repositories/DistAdminDistributor.php

@@ -70,7 +70,6 @@ class DistAdminDistributor extends EloquentRepository
         $row->site_name = $info['site_name'];
         $row->company_name = $info['company_name'];
         $row->company_address = $info['company_address'];
-        $row->contact_number = $info['contact_number'];
         $row->service_hotline = $info['service_hotline'];
         $row->whats_app = $info['whats_app'];
         $row->facebook = $info['facebook'];

+ 12 - 2
app/Libraries/CommonHelper.php

@@ -22,14 +22,24 @@ class CommonHelper
             // 默认显示 100x100 的图片
             $thumbnailImages = array_map(function ($imageUrl) use ($boxSize) {
                 $imageUrl= CommonHelper::ossUrl($imageUrl);
+                $extension = pathinfo($imageUrl, PATHINFO_EXTENSION);
+                if ($extension == 'svg') {
+                    return $imageUrl;
+                } else {
+                    return $imageUrl . "?x-oss-process=image/resize,m_pad,h_{$boxSize},w_{$boxSize},color_ffffff";
+                }
 
-                return $imageUrl . "?x-oss-process=image/resize,m_pad,h_{$boxSize},w_{$boxSize},color_ffffff";
             }, $images);
 
             // 生成点击查看大图的链接
             $largeImages = array_map(function ($imageUrl) use ($imgSize) {
                 $imageUrl= CommonHelper::ossUrl($imageUrl);
-                return $imageUrl . "?x-oss-process=image/resize,m_lfit,w_{$imgSize},h_{$imgSize}";
+                $extension = pathinfo($imageUrl, PATHINFO_EXTENSION);
+                if ($extension == 'svg') {
+                    return $imageUrl;
+                } else {
+                    return $imageUrl . "?x-oss-process=image/resize,m_lfit,w_{$imgSize},h_{$imgSize}";
+                }
             }, $images);
 
             // 显示缩略图,并添加点击查看大图的功能

+ 5 - 1
config/dictionary.php

@@ -87,7 +87,11 @@ return [
     'freight_forwarder' => [
         0 => 'No',
         1 => 'Yes',
-    ]
+    ],
+    'domain_type' => [
+        0 => 'secondary_domain',
+        1 => 'custom_domain',
+    ],
 
 
 ];

+ 1 - 0
lang/zh_CN/admin.php

@@ -248,4 +248,5 @@ return [
     'pages'  => '文章',
     'pages_tag'  => '标签',
     'product_import'  => '产品导入',
+    'site_management'  => '站点管理',
 ];

+ 9 - 0
lang/zh_CN/global.php

@@ -84,6 +84,8 @@ return [
         'seo_keywords'         => 'SEO关健字',
         'logo'                  => 'LOGO',
         'referer_url'           => '来源URL',
+        'file'                  => '文件',
+        'statistics_js'         => '统计代码',
     ],
     'labels' => [
         'list'         => '列表',
@@ -148,6 +150,13 @@ return [
         'clear_cache'           => '清除缓存',
         'site_url'                  => '站点URL',
         'browse'                => '浏览',
+        'client_code'           => '客户编码',
+        'distributor_code'      => '分销商编码',
+        'site'             => '站点',
+        'information'          => '信息',
+        'domain_type'          => '域名类型',
+        'custom_domain'        => '自定义域名',
+        'secondary_domain'    => '二级域名',
     ],
     'options' => [
         //

+ 1 - 0
lang/zh_CN/menu.php

@@ -37,6 +37,7 @@ return [
         'tag' => '标签',
         'site' => '站点',
         'user_setting' => '用户',
+        'information' => '信息',
         'clear_cache' => '清除缓存',
     ],
 ];

+ 6 - 5
resources/views/admin/pages-custom/ace.blade.php

@@ -8,10 +8,11 @@
     }
     .main-panel {
         background-color: #e9ecef; /* 右侧面板的背景色 */
-        height: 97vh; /* 高度占满 */
+        height: 95.8vh; /* 高度占满 */
     }
     .main-panel-header {
-        background-color: #fff;
+        background-color: #1e1e1e;
+        padding: 5px;
     }
     .main-card-body {
         max-height: 75vh; /* 设置最大高度 */
@@ -65,7 +66,7 @@
     }
 </style>
 
-<div class="container-fluid">
+<div class="container-fluid" style="padding: 0px;">
     <div class="row">
         <div class="col-2 left-panel"> <!-- 左侧20% -->
             {!!$leftForm!!}
@@ -73,10 +74,10 @@
             <div class="main-card-body"></div>
             <!-- 代码树 end-->
         </div>
-        <div class="col-10 main-panel"> <!-- 右侧80% -->
+        <div class="col-10 main-panel" style="padding-right: 0px;"> <!-- 右侧80% -->
             <div class="main-panel-header">
                 <button type="button" class="btn btn-primary btn-sm" id="save-btn" disabled>Save</button>
-                <button type="button" class="btn btn-success btn-sm" data-toggle="modal" id="variable-btn" data-target="#iframeModal" disabled>Variable Management</button>
+                <button type="button" class="btn btn-success btn-sm" data-toggle="modal" id="variable-btn" data-target="#iframeModal" disabled>Variable</button>
                 <button type="button" class="btn btn-success btn-sm float-right" id="publish-btn" disabled>Publish</button>
             </div>
             <div class="main-panel-content" id="editor" style="width: 100%; height: 100%;"></div>