作者 邓超

自定义页面

@@ -136,6 +136,11 @@ class Handler extends ExceptionHandler @@ -136,6 +136,11 @@ class Handler extends ExceptionHandler
136 'code' => $code, 136 'code' => $code,
137 'message' => $message 137 'message' => $message
138 ]; 138 ];
  139 + // 调试模式
  140 + if(env('app_debug')){
  141 + $response['trace'] = $exception->getTrace();
  142 + }
  143 +
139 //加密返回 144 //加密返回
140 if (config('app.params_encrypt')) { 145 if (config('app.params_encrypt')) {
141 $k = config('app.params_encrypt_key'); 146 $k = config('app.params_encrypt_key');
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace App\Http\Controllers\Bside; 3 namespace App\Http\Controllers\Bside;
4 4
  5 +use App\Models\Template\AHeadFoot;
5 use App\Models\Template\BHeadFoot; 6 use App\Models\Template\BHeadFoot;
6 7
7 /** 8 /**
@@ -34,6 +35,49 @@ class TemplateController extends BaseController @@ -34,6 +35,49 @@ class TemplateController extends BaseController
34 } 35 }
35 36
36 37
  38 + /**
  39 + * 读取编辑的html
  40 + * @author:dc
  41 + * @time 2023/5/4 16:19
  42 + */
  43 + public function edit_html(){
  44 + $data = BHeadFoot::_getEditHtml($this->user['project_id']);
  45 +
  46 + if(!$data){
  47 + $data = AHeadFoot::_bDefault();
  48 + }
  49 +
  50 + return $this->success([
  51 + 'header' => $data[BHeadFoot::TYPE_HEADER]??'',
  52 + 'footer' => $data[BHeadFoot::TYPE_FOOTER]??'',
  53 + ]);
  54 + }
  55 +
  56 +
  57 + /**
  58 + * 获取系统的模板
  59 + * @author:dc
  60 + * @time 2023/5/4 16:21
  61 + */
  62 + public function system_all_html(){
  63 +
  64 + $data = AHeadFoot::_ball();
  65 +
  66 + $lists = [];
  67 + // 以名字为单位区分
  68 + foreach ($data as $datum){
  69 + if(empty($lists[$datum['name']])) $lists[$datum['name']] = [];
  70 + $lists[$datum['name']]['name'] = $datum['name'];
  71 + $lists[$datum['name']]['default'] = $datum['is_default'];
  72 + $lists[$datum['name']][$datum['type']==AHeadFoot::TYPE_HEADER?'header':'footer'] = $datum['html'];
  73 + }
  74 +
  75 +
  76 + return $this->success(array_values($lists));
  77 +
  78 + }
  79 +
  80 +
37 81
38 82
39 83
@@ -13,12 +13,40 @@ class AHeadFoot extends \App\Models\Base{ @@ -13,12 +13,40 @@ class AHeadFoot extends \App\Models\Base{
13 13
14 protected $table = 'gl_aside_template_header_footer'; 14 protected $table = 'gl_aside_template_header_footer';
15 15
16 - 16 +// 分开存 头底 为了方便后期可能会 改版为 随意搭配 头底部
17 const TYPE_HEADER = 'H'; 17 const TYPE_HEADER = 'H';
18 const TYPE_FOOTER = 'F'; 18 const TYPE_FOOTER = 'F';
19 19
20 const STATUS_ACTIVE = 1; 20 const STATUS_ACTIVE = 1;
21 const STATUS_DISABLED = 1; 21 const STATUS_DISABLED = 1;
22 22
  23 + const IS_DEFAULT = 1;
  24 +
  25 +
  26 + /**
  27 + * b 端 查询
  28 + * @return mixed
  29 + * @author:dc
  30 + * @time 2023/5/4 16:24
  31 + */
  32 + public static function _ball(){
  33 + return static::where('status',static::STATUS_ACTIVE)->get(['id','name','type','html','is_default']);
  34 + }
  35 +
  36 + /**
  37 + * b 端 读取默认的一个头部底部
  38 + * @return mixed
  39 + * @author:dc
  40 + * @time 2023/5/4 16:51
  41 + */
  42 + public static function _bDefault(){
  43 + return static::where(['status'=>static::STATUS_ACTIVE,'is_default'=>static::IS_DEFAULT])
  44 + ->get(['type','html'])
  45 + ->pluck('html','type')
  46 + ->toArray();
  47 + }
  48 +
  49 +
  50 +
23 51
24 } 52 }
@@ -31,4 +31,10 @@ class BHeadFoot extends \App\Models\Base{ @@ -31,4 +31,10 @@ class BHeadFoot extends \App\Models\Base{
31 return static::where(['project_id'=>$project_id,'is_use'=>1])->get(['html','type'])->pluck('html','type')->toArray(); 31 return static::where(['project_id'=>$project_id,'is_use'=>1])->get(['html','type'])->pluck('html','type')->toArray();
32 } 32 }
33 33
  34 + public static function _getEditHtml($project_id){
  35 + return static::where(['project_id'=>$project_id,'is_use'=>1])->get(['origin_html','type'])->pluck('origin_html','type')->toArray();
  36 + }
  37 +
  38 +
  39 +
34 } 40 }
@@ -165,6 +165,8 @@ Route::middleware(['bloginauth'])->group(function () { @@ -165,6 +165,8 @@ Route::middleware(['bloginauth'])->group(function () {
165 // 自定义页面 165 // 自定义页面
166 Route::prefix('template')->group(function () { 166 Route::prefix('template')->group(function () {
167 Route::get('/', [\App\Http\Controllers\Bside\TemplateController::class, 'index'])->name('template_header_footer'); 167 Route::get('/', [\App\Http\Controllers\Bside\TemplateController::class, 'index'])->name('template_header_footer');
  168 + Route::get('/edit', [\App\Http\Controllers\Bside\TemplateController::class, 'edit_html'])->name('template_header_footer_edit');
  169 + Route::get('/system', [\App\Http\Controllers\Bside\TemplateController::class, 'system_all_html'])->name('template_header_footer_system');
168 }); 170 });
169 171
170 172