作者 lyh

gx

@@ -41,7 +41,7 @@ class CustomTemplateLogic extends BaseLogic @@ -41,7 +41,7 @@ class CustomTemplateLogic extends BaseLogic
41 */ 41 */
42 public function customTemplateInfo(){ 42 public function customTemplateInfo(){
43 $info = $this->model->read(['id'=>$this->param['id']]); 43 $info = $this->model->read(['id'=>$this->param['id']]);
44 - $html = $this->getBodyHeaderFooter($info['html']); 44 + $html = $this->getBodyHeaderFooter($info['html'],$info['html_style']);
45 $info['html'] = $this->getHeadFooter($html); 45 $info['html'] = $this->getHeadFooter($html);
46 if($info === false){ 46 if($info === false){
47 $this->fail('error'); 47 $this->fail('error');
@@ -59,7 +59,8 @@ class CustomTemplateLogic extends BaseLogic @@ -59,7 +59,8 @@ class CustomTemplateLogic extends BaseLogic
59 public function customTemplateSave(){ 59 public function customTemplateSave(){
60 if(isset($this->param['id']) && !empty($this->param['id'])){ 60 if(isset($this->param['id']) && !empty($this->param['id'])){
61 if(isset($this->param['html']) && !empty($this->param['html'])){ 61 if(isset($this->param['html']) && !empty($this->param['html'])){
62 - $this->param['html'] = $this->getHeadFooter(characterTruncation($this->param['html'],'/<main>(.*?)<\/main>/s')); 62 + $this->param['html'] = characterTruncation($this->param['html'],'/<main>(.*?)<\/main>/s');
  63 + $this->param['html_style'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-styles">(.*?)<\/style>/s');
63 } 64 }
64 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); 65 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
65 }else{ 66 }else{
@@ -94,7 +95,7 @@ class CustomTemplateLogic extends BaseLogic @@ -94,7 +95,7 @@ class CustomTemplateLogic extends BaseLogic
94 * @method :post 95 * @method :post
95 * @time :2023/7/21 18:08 96 * @time :2023/7/21 18:08
96 */ 97 */
97 - public function getBodyHeaderFooter($preg_html){ 98 + public function getBodyHeaderFooter($preg_html,$html_style){
98 //获取设置的默认模版 99 //获取设置的默认模版
99 $bSettingModel = new BSetting(); 100 $bSettingModel = new BSetting();
100 $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]); 101 $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
@@ -107,14 +108,20 @@ class CustomTemplateLogic extends BaseLogic @@ -107,14 +108,20 @@ class CustomTemplateLogic extends BaseLogic
107 ]); 108 ]);
108 if(empty($preg_html)){ 109 if(empty($preg_html)){
109 $preg_html = "<main></main>"; 110 $preg_html = "<main></main>";
  111 + $html = preg_replace('/<style id="vvvebjs-styles">(.*?)<\/style>/s', "<style id='vvvebjs-styles'></style>", $TemplateInfo['html']);
  112 + }else{
  113 + $html = preg_replace('/<style id="vvvebjs-styles">(.*?)<\/style>/s',$html_style , $TemplateInfo['html']);
110 } 114 }
111 - //删除内容  
112 - $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $preg_html, $TemplateInfo['html']);  
113 - //删除样式  
114 - $html = preg_replace('/<style id="vvvebjs-styles">(.*?)<\/style>/s', "<style id='vvvebjs-styles'></style>", $html); 115 + //内容
  116 + $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $preg_html, $html);
115 return $html; 117 return $html;
116 } 118 }
117 119
  120 + public function setStyle($html){
  121 + //删除样式
  122 +
  123 + }
  124 +
118 /** 125 /**
119 * @remark :拼接获取公共头部底部 126 * @remark :拼接获取公共头部底部
120 * @name :getHeadFooter 127 * @name :getHeadFooter