正在显示
5 个修改的文件
包含
57 行增加
和
2 行删除
| @@ -26,7 +26,7 @@ class CustomController extends BaseController | @@ -26,7 +26,7 @@ class CustomController extends BaseController | ||
| 26 | 'title' => ['required','max:200'], | 26 | 'title' => ['required','max:200'], |
| 27 | 'keywords' => ['required','max:200'], | 27 | 'keywords' => ['required','max:200'], |
| 28 | 'description' => ['required','max:250'], | 28 | 'description' => ['required','max:250'], |
| 29 | - 'html' => ['required'], | 29 | +// 'html' => ['required'], |
| 30 | 'url' => ['required','max:200'], | 30 | 'url' => ['required','max:200'], |
| 31 | 'status' => ['required','in:0,1'], | 31 | 'status' => ['required','in:0,1'], |
| 32 | ], | 32 | ], |
| @@ -144,5 +144,33 @@ class CustomController extends BaseController | @@ -144,5 +144,33 @@ class CustomController extends BaseController | ||
| 144 | 144 | ||
| 145 | 145 | ||
| 146 | 146 | ||
| 147 | + /** | ||
| 148 | + * @param $id | ||
| 149 | + * @return \Illuminate\Http\JsonResponse | ||
| 150 | + * @author:dc | ||
| 151 | + * @time 2023/5/10 14:10 | ||
| 152 | + */ | ||
| 153 | + public function html($id) | ||
| 154 | + { | ||
| 155 | + $data = BCustom::_find($this->user['project_id'],$id); | ||
| 156 | + if(!$data){ | ||
| 157 | + return $this->response('数据不存在','B_CUSTOM_NOTFOUND'); | ||
| 158 | + } | ||
| 159 | + if($this->isPost()){ | ||
| 160 | + $html = $this->param['html']??''; | ||
| 161 | + | ||
| 162 | + $data->html = $html; | ||
| 163 | + | ||
| 164 | + $data->save(); | ||
| 165 | + | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + | ||
| 169 | + return $this->response('',Code::SUCCESS,$data['html']); | ||
| 170 | + | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + | ||
| 174 | + | ||
| 147 | 175 | ||
| 148 | } | 176 | } |
| @@ -71,5 +71,30 @@ class TemplateController extends BaseController | @@ -71,5 +71,30 @@ class TemplateController extends BaseController | ||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | 73 | ||
| 74 | + /** | ||
| 75 | + * 保存模板 | ||
| 76 | + * @author:dc | ||
| 77 | + * @time 2023/5/10 10:53 | ||
| 78 | + */ | ||
| 79 | + public function save(){ | ||
| 80 | + | ||
| 81 | + $html = '<header id="globalso-header" class="web_head sticky-top py-1 py-md-0" style="background-color: #318fff;">asdf</header>'; | ||
| 82 | + | ||
| 83 | + // 替换 header | ||
| 84 | + $html = preg_replace("/<header(.*)id=\"globalso-header\"(.*)>([\s\S]*)<\/header>/iU",'',$html); | ||
| 85 | + $html = preg_replace("/<main(.*)id=\"globalso-main\"(.*)>([\s\S]*)<\/main>/iU",'',$html); | ||
| 86 | + $html = preg_replace("/<footer(.*)id=\"globalso-footer\"(.*)>([\s\S]*)<\/footer>/iU",'',$html); | ||
| 87 | + | ||
| 88 | + | ||
| 89 | + | ||
| 90 | + | ||
| 91 | + | ||
| 92 | + | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + | ||
| 96 | + | ||
| 97 | + | ||
| 98 | + | ||
| 74 | 99 | ||
| 75 | } | 100 | } |
| @@ -59,7 +59,7 @@ class BCustom extends Base | @@ -59,7 +59,7 @@ class BCustom extends Base | ||
| 59 | $model->description = $data['description']; | 59 | $model->description = $data['description']; |
| 60 | $model->url = $data['url']; | 60 | $model->url = $data['url']; |
| 61 | $model->status = $data['status']; | 61 | $model->status = $data['status']; |
| 62 | - $model->html = $data['html']; | 62 | +// $model->html = $data['html']; |
| 63 | 63 | ||
| 64 | $model->save(); | 64 | $model->save(); |
| 65 | 65 |
| @@ -83,6 +83,7 @@ class BSetting extends \App\Models\Base{ | @@ -83,6 +83,7 @@ class BSetting extends \App\Models\Base{ | ||
| 83 | DB::beginTransaction(); | 83 | DB::beginTransaction(); |
| 84 | foreach ($aDataHtml as $item){ | 84 | foreach ($aDataHtml as $item){ |
| 85 | try { | 85 | try { |
| 86 | + // 插入子数据 | ||
| 86 | BTemplateHtml::_insert($project_id,$item); | 87 | BTemplateHtml::_insert($project_id,$item); |
| 87 | }catch (\Throwable $e){ | 88 | }catch (\Throwable $e){ |
| 88 | DB::rollBack(); | 89 | DB::rollBack(); |
| @@ -234,6 +234,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -234,6 +234,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 234 | Route::post('/create', [\App\Http\Controllers\Bside\CustomController::class, 'create'])->name('bside_custom_create'); | 234 | Route::post('/create', [\App\Http\Controllers\Bside\CustomController::class, 'create'])->name('bside_custom_create'); |
| 235 | Route::post('/update', [\App\Http\Controllers\Bside\CustomController::class, 'update'])->name('bside_custom_update'); | 235 | Route::post('/update', [\App\Http\Controllers\Bside\CustomController::class, 'update'])->name('bside_custom_update'); |
| 236 | Route::delete('/delete', [\App\Http\Controllers\Bside\CustomController::class, 'delete'])->name('bside_custom_delete'); | 236 | Route::delete('/delete', [\App\Http\Controllers\Bside\CustomController::class, 'delete'])->name('bside_custom_delete'); |
| 237 | + Route::any('/html/{id}', [\App\Http\Controllers\Bside\CustomController::class, 'html'])->where('id','\d+')->name('bside_custom_delete'); | ||
| 237 | }); | 238 | }); |
| 238 | 239 | ||
| 239 | 240 |
-
请 注册 或 登录 后发表评论