作者 lyh

gxAiblog自动发布

@@ -147,7 +147,7 @@ class AiVideoTask extends Command @@ -147,7 +147,7 @@ class AiVideoTask extends Command
147 if($route != $result['data']['url']){ 147 if($route != $result['data']['url']){
148 $aiVideoService->updateDetail(['url'=>$route,'task_id'=>$item['task_id']]); 148 $aiVideoService->updateDetail(['url'=>$route,'task_id'=>$item['task_id']]);
149 } 149 }
150 - $description = explode(",",$result['data']['content']); 150 + $description = explode(".",$result['data']['content']);
151 $saveData = [ 151 $saveData = [
152 'title'=>$result['data']['title'], 152 'title'=>$result['data']['title'],
153 'image'=>$result['data']['thumb'], 153 'image'=>$result['data']['thumb'],
@@ -60,14 +60,14 @@ class lyhDemo extends Command @@ -60,14 +60,14 @@ class lyhDemo extends Command
60 if(!empty($aiLists)){ 60 if(!empty($aiLists)){
61 foreach ($aiLists as $item){ 61 foreach ($aiLists as $item){
62 if(!empty($item['seo_description'])){ 62 if(!empty($item['seo_description'])){
63 - $arr = explode('.',$item['seo_description']);  
64 - if($arr[0].'.' != $item['seo_description']){  
65 - echo '进入'.PHP_EOL; 63 + //查看当前是否包含句号。
  64 + $result = $this->hasAnyPeriod($item['seo_description']);
  65 + if($result === false){
66 $text = $this->trimToLastFullWord($item['seo_description']); 66 $text = $this->trimToLastFullWord($item['seo_description']);
67 }else{ 67 }else{
  68 + $arr = explode('.',$item['seo_description']);
68 $text = $arr[0].'.'; 69 $text = $arr[0].'.';
69 } 70 }
70 - dd($text);  
71 $aiBlogModel->edit(['seo_description'=>$text],['id'=>$item['id']]); 71 $aiBlogModel->edit(['seo_description'=>$text],['id'=>$item['id']]);
72 } 72 }
73 } 73 }
@@ -87,4 +87,8 @@ class lyhDemo extends Command @@ -87,4 +87,8 @@ class lyhDemo extends Command
87 } 87 }
88 return trim($text); // fallback 88 return trim($text); // fallback
89 } 89 }
  90 +
  91 + public function hasAnyPeriod($text) {
  92 + return strpos($text, '.') !== false || mb_strpos($text, '。') !== false;
  93 + }
90 } 94 }