|
@@ -57,36 +57,51 @@ class CustomTemplateLogic extends BaseLogic |
|
@@ -57,36 +57,51 @@ class CustomTemplateLogic extends BaseLogic |
|
57
|
* @time :2023/6/29 16:21
|
57
|
* @time :2023/6/29 16:21
|
|
58
|
*/
|
58
|
*/
|
|
59
|
public function customTemplateSave(){
|
59
|
public function customTemplateSave(){
|
|
|
|
60
|
+ $this->param['url'] = str_replace_url($this->param['url']);
|
|
|
|
61
|
+ try {
|
|
60
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
62
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
61
|
if(isset($this->param['html']) && !empty($this->param['html'])){
|
63
|
if(isset($this->param['html']) && !empty($this->param['html'])){
|
|
62
|
$html = $this->param['html'];
|
64
|
$html = $this->param['html'];
|
|
63
|
$this->param['html'] = characterTruncation($html,'/<main>(.*?)<\/main>/s');
|
65
|
$this->param['html'] = characterTruncation($html,'/<main>(.*?)<\/main>/s');
|
|
64
|
$this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
|
66
|
$this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
|
|
65
|
}
|
67
|
}
|
|
66
|
- $id = $this->param['id'];
|
|
|
|
67
|
- $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
68
|
- if($rs === false){
|
|
|
|
69
|
- $this->fail('error');
|
|
|
|
70
|
- }
|
68
|
+ //查看路由是否更新
|
|
|
|
69
|
+ $id = $this->editCustomRoute($this->param['id'],$this->param['url']);
|
|
|
|
70
|
+ $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
|
|
|
|
71
|
+ $this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
71
|
}else{
|
72
|
}else{
|
|
72
|
$this->param['project_id'] = $this->user['project_id'];
|
73
|
$this->param['project_id'] = $this->user['project_id'];
|
|
73
|
$id = $this->model->addReturnId($this->param);
|
74
|
$id = $this->model->addReturnId($this->param);
|
|
74
|
- if($id === false){
|
|
|
|
75
|
- $this->fail('error');
|
75
|
+ $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
|
|
|
|
76
|
+ $this->model->edit(['url'=>$route],['id'=>$route]);
|
|
76
|
}
|
77
|
}
|
|
|
|
78
|
+ }catch (\Exception $e){
|
|
|
|
79
|
+ $this->fail('error');
|
|
77
|
}
|
80
|
}
|
|
78
|
- //路由映射
|
|
|
|
79
|
- if(isset($this->param['url']) && !empty($this->param['url'])){
|
|
|
|
80
|
- $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
|
|
|
|
81
|
//TODO::通知网站更新
|
81
|
//TODO::通知网站更新
|
|
|
|
82
|
+ $data = ['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PAGE, 'route'=>$route];
|
|
|
|
83
|
+ $this->updateNotify($data);
|
|
|
|
84
|
+ return $this->success();
|
|
|
|
85
|
+ }
|
|
|
|
86
|
+
|
|
|
|
87
|
+ /**
|
|
|
|
88
|
+ * @remark :查看路由是否更新
|
|
|
|
89
|
+ * @name :editProduct
|
|
|
|
90
|
+ * @author :lyh
|
|
|
|
91
|
+ * @method :post
|
|
|
|
92
|
+ * @time :2023/9/7 10:02
|
|
|
|
93
|
+ */
|
|
|
|
94
|
+ public function editCustomRoute($id,$route){
|
|
|
|
95
|
+ $info = $this->model->read(['id'=>$this->param['id']]);
|
|
|
|
96
|
+ if($info['route'] != $route){
|
|
|
|
97
|
+ //生成一条删除路由记录
|
|
82
|
$data = [
|
98
|
$data = [
|
|
83
|
- 'project_id'=>$this->user['project_id'],
|
|
|
|
84
|
- 'type'=>RouteMap::SOURCE_PAGE,
|
99
|
+ 'source'=>RouteMap::SOURCE_PRODUCT,
|
|
85
|
'route'=>$route,
|
100
|
'route'=>$route,
|
|
86
|
];
|
101
|
];
|
|
87
|
- $this->updateNotify($data);
|
102
|
+ $this->setRouteDeleteSave($data);
|
|
88
|
}
|
103
|
}
|
|
89
|
- return $this->success();
|
104
|
+ return $id;
|
|
90
|
}
|
105
|
}
|
|
91
|
|
106
|
|
|
92
|
/**
|
107
|
/**
|