Pārlūkot izejas kodu

Merge branch '20250210_lj_zhanqun' into dev

AI 1 mēnesi atpakaļ
vecāks
revīzija
1ce56bd01e
1 mainītis faili ar 8 papildinājumiem un 0 dzēšanām
  1. 8 0
      app/JsonRpc/NewsService.php

+ 8 - 0
app/JsonRpc/NewsService.php

@@ -292,11 +292,15 @@ class NewsService implements NewsServiceInterface
             unset($articleData['content']);
             //自动处理缩略图、关键字、描述
             if ($articleData['imgurl'] == '') {
+                //如果没有图,设置level=0
+                $articleData['level'] = '[0]';
                 //content中提取图片第一个图,正则提取
                 $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
                 preg_match_all($reg, $data['content'], $matches);
                 if (isset($matches[1][0])) {
                     $articleData['imgurl'] = $matches[1][0];
+                    //如果有图,设置level=3
+                    $articleData['level'] = '[3]';
                 }
             }
             if ($articleData['keyword'] == '') {
@@ -435,11 +439,15 @@ class NewsService implements NewsServiceInterface
             unset($articleData['pid']);
             //自动处理缩略图、关键字、描述
             if ($articleData['imgurl'] == '') {
+                //如果没有图,设置level=0
+                $articleData['level'] = '[0]';
                 //content中提取图片第一个图,正则提取
                 $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
                 preg_match_all($reg, $data['content'], $matches);
                 if (isset($matches[1][0])) {
                     $articleData['imgurl'] = $matches[1][0];
+                    //如果有图,设置level=3
+                    $articleData['level'] = '[3]';
                 }
             }
             if ($articleData['keyword'] == '') {