作者 邓超

自定义 解密

... ... @@ -26,7 +26,7 @@ class CustomController extends BaseController
'title' => ['required','max:200'],
'keywords' => ['required','max:200'],
'description' => ['required','max:250'],
'html' => ['required'],
// 'html' => ['required'],
'url' => ['required','max:200'],
'status' => ['required','in:0,1'],
],
... ... @@ -144,5 +144,33 @@ class CustomController extends BaseController
/**
* @param $id
* @return \Illuminate\Http\JsonResponse
* @author:dc
* @time 2023/5/10 14:10
*/
public function html($id)
{
$data = BCustom::_find($this->user['project_id'],$id);
if(!$data){
return $this->response('数据不存在','B_CUSTOM_NOTFOUND');
}
if($this->isPost()){
$html = $this->param['html']??'';
$data->html = $html;
$data->save();
}
return $this->response('',Code::SUCCESS,$data['html']);
}
}
... ...
... ... @@ -71,5 +71,30 @@ class TemplateController extends BaseController
}
/**
* 保存模板
* @author:dc
* @time 2023/5/10 10:53
*/
public function save(){
$html = '<header id="globalso-header" class="web_head sticky-top py-1 py-md-0" style="background-color: #318fff;">asdf</header>';
// 替换 header
$html = preg_replace("/<header(.*)id=\"globalso-header\"(.*)>([\s\S]*)<\/header>/iU",'',$html);
$html = preg_replace("/<main(.*)id=\"globalso-main\"(.*)>([\s\S]*)<\/main>/iU",'',$html);
$html = preg_replace("/<footer(.*)id=\"globalso-footer\"(.*)>([\s\S]*)<\/footer>/iU",'',$html);
}
}
... ...
... ... @@ -59,7 +59,7 @@ class BCustom extends Base
$model->description = $data['description'];
$model->url = $data['url'];
$model->status = $data['status'];
$model->html = $data['html'];
// $model->html = $data['html'];
$model->save();
... ...
... ... @@ -83,6 +83,7 @@ class BSetting extends \App\Models\Base{
DB::beginTransaction();
foreach ($aDataHtml as $item){
try {
// 插入子数据
BTemplateHtml::_insert($project_id,$item);
}catch (\Throwable $e){
DB::rollBack();
... ...
... ... @@ -234,6 +234,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::post('/create', [\App\Http\Controllers\Bside\CustomController::class, 'create'])->name('bside_custom_create');
Route::post('/update', [\App\Http\Controllers\Bside\CustomController::class, 'update'])->name('bside_custom_update');
Route::delete('/delete', [\App\Http\Controllers\Bside\CustomController::class, 'delete'])->name('bside_custom_delete');
Route::any('/html/{id}', [\App\Http\Controllers\Bside\CustomController::class, 'html'])->where('id','\d+')->name('bside_custom_delete');
});
... ...