作者 lyh

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6

... ... @@ -246,6 +246,7 @@ class OptimizeController extends BaseController
if($rs === false){
$this->response('系统错误,请联系管理员',Code::SYSTEM_ERROR);
}
//TODO::通知C端
$this->response('success');
}
}
... ...
... ... @@ -24,7 +24,7 @@ class BTemplateModuleController extends BaseController
*/
public function lists(BTemplateModuleLogic $BTemplateModuleLogic){
if(!isset($this->map['test_model'])){
$this->map['test_model'] = 0;
$this->map['test_model'] = ['in',[0,1]];
}
$data = [];
$list = $BTemplateModuleLogic->ModuleList($this->map,$this->order);
... ...
... ... @@ -60,6 +60,10 @@ class BTemplateLogLogic extends BaseLogic
$commonData = $this->setCommonParam($info);
$commonTemplateModel = new BTemplateCommon();
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>1,'project_id'=>$this->user['project_id']]);
//更新所有界面的other
if(!empty($info['other'])){
$commonTemplateModel->edit(['other'=>$info['other']],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id']]);
}
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
... ... @@ -93,7 +97,7 @@ class BTemplateLogLogic extends BaseLogic
'head_html'=>$info['head_html'],
'head_css'=>$info['head_css'],
'footer_html'=>$info['footer_html'],
'footer_css'=>$info['footer_css'],
'footer_css'=>$info['footer_css']
];
return $this->success($data);
}
... ... @@ -110,12 +114,22 @@ class BTemplateLogLogic extends BaseLogic
if($info === false){
$this->fail('当前数据不存在,或已被删除');
}
if(empty($info['other'])){
$info['other'] = str_replace('<header','',characterTruncation($info['text'],"/<link id=\"google-fonts-link\"(.*?)<header/s"));;
}
$html = $info['head_css'].$info['main_css'].$info['footer_css'].$info['other'].
$info['head_html'].$info['main_html'].$info['footer_html'];
$serviceSettingModel = new ServiceSettingModel();
$list = $serviceSettingModel->list(['type'=>2],'created_at');
$data = [
'info' => $info,
'header_footer'=>$list,
];
return $this->success($data);
//拼接html
foreach ($list as $v){
if($v['key'] == 'head'){
$html = $v['values'].$html;
}
if($v['key'] == 'footer'){
$html = $html.$v['values'];
}
}
return $this->success(['html'=>$html]);
}
}
... ...
... ... @@ -335,6 +335,7 @@ class BTemplateLogic extends BaseLogic
'main_css'=>$param['main_css'],
'footer_html'=>$param['footer_html'],
'footer_css'=>$param['footer_css'],
'other'=> str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s"))
];
$bTemplateLogModel = new BTemplateLog();
return $bTemplateLogModel->add($data);
... ...
... ... @@ -8,6 +8,7 @@ use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BCustomTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateLog;
use App\Models\Template\Setting;
use App\Models\Template\BTemplate;
... ... @@ -94,9 +95,16 @@ class CustomTemplateLogic extends BaseLogic
$html = $this->param['html'];
$info = $this->model->read(['id'=>$this->param['id']],['id','is_visualization','url']);
if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){//非定制项目+可视化页面
$this->saveCommonTemplate($html);
//获取设置的默认模版
$bSettingModel = new Setting();
$bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($bSettingInfo === false){
$this->fail('请先选择模版');
}
$this->saveCommonTemplate($html,$bSettingInfo['template_id']);
$this->param['html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s');
$this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
$this->setTemplateLog($bSettingInfo['template_id'],$html,$this->param['id']);
}
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
... ... @@ -108,19 +116,44 @@ class CustomTemplateLogic extends BaseLogic
}
/**
* @remark :生成记录
* @name :setTemplateLog
* @author :lyh
* @method :post
* @time :2023/8/23 11:16
*/
public function setTemplateLog($template_id,$html,$source_id){
$data = [
'template_id'=>$template_id,
'project_id'=>$this->user['project_id'],
'operator_id'=>$this->user['id'],
'text'=>$html,
'source'=>9,
'source_id'=>$source_id,
'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'),
'main_css' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
'other'=> str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s"))
];
$bTemplateLogModel = new BTemplateLog();
return $bTemplateLogModel->add($data);
}
/**
* @remark :保存头部公共数据
* @name :saveCommonTemplate
* @author :lyh
* @method :post
* @time :2023/10/13 14:27
*/
public function saveCommonTemplate($html){
public function saveCommonTemplate($html,$template_id){
$type = $this->getType();
//获取设置的默认模版
$bSettingModel = new Setting();
$bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
$templateCommonModel = new BTemplateCommon();
$info = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>$type]);
$info = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);
$data = [
'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
... ... @@ -129,7 +162,7 @@ class CustomTemplateLogic extends BaseLogic
];
$other = str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s"));
if($info === false){
$data['template_id'] = $bSettingInfo['template_id'];
$data['template_id'] = $template_id;
$data['project_id'] = $this->user['project_id'];
$data['type'] = $type;
$templateCommonModel->add($data);
... ...