|
...
|
...
|
@@ -57,36 +57,51 @@ class CustomTemplateLogic extends BaseLogic |
|
|
|
* @time :2023/6/29 16:21
|
|
|
|
*/
|
|
|
|
public function customTemplateSave(){
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
if(isset($this->param['html']) && !empty($this->param['html'])){
|
|
|
|
$html = $this->param['html'];
|
|
|
|
$this->param['html'] = characterTruncation($html,'/<main>(.*?)<\/main>/s');
|
|
|
|
$this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
|
|
|
|
}
|
|
|
|
$id = $this->param['id'];
|
|
|
|
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
if($rs === false){
|
|
|
|
$this->fail('error');
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$id = $this->model->addReturnId($this->param);
|
|
|
|
if($id === false){
|
|
|
|
$this->fail('error');
|
|
|
|
$this->param['url'] = str_replace_url($this->param['url']);
|
|
|
|
try {
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
if(isset($this->param['html']) && !empty($this->param['html'])){
|
|
|
|
$html = $this->param['html'];
|
|
|
|
$this->param['html'] = characterTruncation($html,'/<main>(.*?)<\/main>/s');
|
|
|
|
$this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
|
|
|
|
}
|
|
|
|
//查看路由是否更新
|
|
|
|
$id = $this->editCustomRoute($this->param['id'],$this->param['url']);
|
|
|
|
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
|
|
|
|
$this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
}else{
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$id = $this->model->addReturnId($this->param);
|
|
|
|
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
|
|
|
|
$this->model->edit(['url'=>$route],['id'=>$route]);
|
|
|
|
}
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('error');
|
|
|
|
}
|
|
|
|
//路由映射
|
|
|
|
if(isset($this->param['url']) && !empty($this->param['url'])){
|
|
|
|
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
|
|
|
|
//TODO::通知网站更新
|
|
|
|
//TODO::通知网站更新
|
|
|
|
$data = ['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PAGE, 'route'=>$route];
|
|
|
|
$this->updateNotify($data);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :查看路由是否更新
|
|
|
|
* @name :editProduct
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/7 10:02
|
|
|
|
*/
|
|
|
|
public function editCustomRoute($id,$route){
|
|
|
|
$info = $this->model->read(['id'=>$this->param['id']]);
|
|
|
|
if($info['route'] != $route){
|
|
|
|
//生成一条删除路由记录
|
|
|
|
$data = [
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'type'=>RouteMap::SOURCE_PAGE,
|
|
|
|
'source'=>RouteMap::SOURCE_PRODUCT,
|
|
|
|
'route'=>$route,
|
|
|
|
];
|
|
|
|
$this->updateNotify($data);
|
|
|
|
$this->setRouteDeleteSave($data);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
return $id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
|