作者 lyh

gx

@@ -104,7 +104,7 @@ class CustomTemplateController extends BaseController @@ -104,7 +104,7 @@ class CustomTemplateController extends BaseController
104 ],[ 104 ],[
105 'id.required' => 'ID不能为空', 105 'id.required' => 'ID不能为空',
106 ]); 106 ]);
107 - $customTemplateLogic->customTemplateSave(); 107 + $customTemplateLogic->saveHtml();
108 $this->response('success'); 108 $this->response('success');
109 } 109 }
110 } 110 }
@@ -58,25 +58,16 @@ class CustomTemplateLogic extends BaseLogic @@ -58,25 +58,16 @@ class CustomTemplateLogic extends BaseLogic
58 */ 58 */
59 public function customTemplateSave(){ 59 public function customTemplateSave(){
60 try { 60 try {
  61 + $this->param['url'] = str_replace_url($this->param['url']);
61 if(isset($this->param['id']) && !empty($this->param['id'])){ 62 if(isset($this->param['id']) && !empty($this->param['id'])){
62 - if(isset($this->param['html']) && !empty($this->param['html'])){  
63 - $html = $this->param['html'];  
64 - $this->param['html'] = characterTruncation($html,'/<main>(.*?)<\/main>/s');  
65 - $this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');  
66 - }  
67 - //查看路由是否更新  
68 - if(isset($this->param['url']) && !empty($this->param['url'])){  
69 - $this->param['url'] = str_replace_url($this->param['url']);  
70 - $id = $this->editCustomRoute($this->param['id'],$this->param['url']);  
71 - $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);  
72 - } 63 + $id = $this->editCustomRoute($this->param['id'],$this->param['url']);
73 $this->model->edit($this->param,['id'=>$this->param['id']]); 64 $this->model->edit($this->param,['id'=>$this->param['id']]);
74 }else{ 65 }else{
75 $this->param['project_id'] = $this->user['project_id']; 66 $this->param['project_id'] = $this->user['project_id'];
76 $id = $this->model->addReturnId($this->param); 67 $id = $this->model->addReturnId($this->param);
77 - $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);  
78 - $this->model->edit(['url'=>$route],['id'=>$route]);  
79 } 68 }
  69 + $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
  70 + $this->model->edit(['url'=>$route],['id'=>$route]);
80 }catch (\Exception $e){ 71 }catch (\Exception $e){
81 $this->fail('error'); 72 $this->fail('error');
82 } 73 }
@@ -87,6 +78,20 @@ class CustomTemplateLogic extends BaseLogic @@ -87,6 +78,20 @@ class CustomTemplateLogic extends BaseLogic
87 } 78 }
88 79
89 /** 80 /**
  81 + * @remark :可视化保存html
  82 + * @name :saveHtml
  83 + * @author :lyh
  84 + * @method :post
  85 + * @time :2023/9/16 17:13
  86 + */
  87 + public function saveHtml(){
  88 + $html = $this->param['html'];
  89 + $this->param['html'] = characterTruncation($html,'/<main>(.*?)<\/main>/s');
  90 + $this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
  91 + $this->model->edit($this->param,['id'=>$this->param['id']]);
  92 + }
  93 +
  94 + /**
90 * @remark :查看路由是否更新 95 * @remark :查看路由是否更新
91 * @name :editProduct 96 * @name :editProduct
92 * @author :lyh 97 * @author :lyh
@@ -36,7 +36,7 @@ class CustomTemplateRequest extends FormRequest @@ -36,7 +36,7 @@ class CustomTemplateRequest extends FormRequest
36 { 36 {
37 return [ 37 return [
38 'name.required'=>'模版名称不能为空', 38 'name.required'=>'模版名称不能为空',
39 - 'url.required'=>'自定义访问地址', 39 + 'url.required'=>'自定义访问地址不能为空',
40 // 'keywords.required'=>'页面关键字不能为空', 40 // 'keywords.required'=>'页面关键字不能为空',
41 // 'description.required'=>'页面描述不能为空', 41 // 'description.required'=>'页面描述不能为空',
42 // 'title.required'=>'标题不能为空', 42 // 'title.required'=>'标题不能为空',