正在显示
3 个修改的文件
包含
43 行增加
和
8 行删除
| @@ -10,6 +10,7 @@ namespace App\Console\Commands\Test; | @@ -10,6 +10,7 @@ namespace App\Console\Commands\Test; | ||
| 10 | use App\Helper\Common; | 10 | use App\Helper\Common; |
| 11 | use App\Models\Blog\Blog; | 11 | use App\Models\Blog\Blog; |
| 12 | use App\Models\Devops\ServerConfig; | 12 | use App\Models\Devops\ServerConfig; |
| 13 | +use App\Models\Domain\DomainInfo; | ||
| 13 | use App\Models\File\Image; | 14 | use App\Models\File\Image; |
| 14 | use App\Models\Manage\BelongingGroup; | 15 | use App\Models\Manage\BelongingGroup; |
| 15 | use App\Models\Manage\Dept; | 16 | use App\Models\Manage\Dept; |
| @@ -43,10 +44,10 @@ class Demo extends Command | @@ -43,10 +44,10 @@ class Demo extends Command | ||
| 43 | * | 44 | * |
| 44 | * @return void | 45 | * @return void |
| 45 | */ | 46 | */ |
| 46 | - public function __construct() | ||
| 47 | - { | ||
| 48 | - parent::__construct(); | ||
| 49 | - } | 47 | +// public function __construct() |
| 48 | +// { | ||
| 49 | +// parent::__construct(); | ||
| 50 | +// } | ||
| 50 | 51 | ||
| 51 | public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60) | 52 | public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60) |
| 52 | { | 53 | { |
| @@ -77,6 +78,7 @@ class Demo extends Command | @@ -77,6 +78,7 @@ class Demo extends Command | ||
| 77 | */ | 78 | */ |
| 78 | public function handle() | 79 | public function handle() |
| 79 | { | 80 | { |
| 81 | + return $this->domain(); | ||
| 80 | $result = app(SyncService::class)->projectAcceptAddress(1); | 82 | $result = app(SyncService::class)->projectAcceptAddress(1); |
| 81 | dd($result); | 83 | dd($result); |
| 82 | $data = [ | 84 | $data = [ |
| @@ -293,4 +295,26 @@ class Demo extends Command | @@ -293,4 +295,26 @@ class Demo extends Command | ||
| 293 | } | 295 | } |
| 294 | dd(1); | 296 | dd(1); |
| 295 | } | 297 | } |
| 298 | + | ||
| 299 | + /** | ||
| 300 | + * @remark :获取域名 | ||
| 301 | + * @name :domain | ||
| 302 | + * @author :lyh | ||
| 303 | + * @method :post | ||
| 304 | + * @time :2023/11/29 18:47 | ||
| 305 | + */ | ||
| 306 | + public function domain(){ | ||
| 307 | + $domainModel = new DomainInfo(); | ||
| 308 | + $lists = $domainModel->list(); | ||
| 309 | + foreach ($lists as $k => $v){ | ||
| 310 | + if($v['project_id'] != 0){ | ||
| 311 | + echo date('Y-m-d H:i:s') . ' start: ' . $v['project_id'] . PHP_EOL; | ||
| 312 | + $domain = 'https://'.$v['domain'].'/'; | ||
| 313 | + $url = $domain.'/api/update_robots/?project_id='.$v['project_id']; | ||
| 314 | + http_get($url); | ||
| 315 | + echo date('Y-m-d H:i:s') . ' end: ' . $v['project_id'] . PHP_EOL; | ||
| 316 | + } | ||
| 317 | + } | ||
| 318 | + return true; | ||
| 319 | + } | ||
| 296 | } | 320 | } |
| @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Aside\Optimize; | @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Aside\Optimize; | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Http\Controllers\Aside\BaseController; | 6 | use App\Http\Controllers\Aside\BaseController; |
| 7 | use App\Http\Logic\Aside\Optimize\OptimizeLogic; | 7 | use App\Http\Logic\Aside\Optimize\OptimizeLogic; |
| 8 | +use App\Http\Logic\Aside\Project\ProjectLogic; | ||
| 8 | use App\Models\Ai\AiPrefix; | 9 | use App\Models\Ai\AiPrefix; |
| 9 | use App\Models\ASide\APublicModel; | 10 | use App\Models\ASide\APublicModel; |
| 10 | use App\Models\Channel\Channel; | 11 | use App\Models\Channel\Channel; |
| @@ -241,12 +242,23 @@ class OptimizeController extends BaseController | @@ -241,12 +242,23 @@ class OptimizeController extends BaseController | ||
| 241 | 'robots.required' => 'robots不能为空', | 242 | 'robots.required' => 'robots不能为空', |
| 242 | 'project_id.required' => 'project_id不能为空', | 243 | 'project_id.required' => 'project_id不能为空', |
| 243 | ]); | 244 | ]); |
| 245 | + //TODO::通知C端 | ||
| 246 | + $projectLogic = new ProjectLogic(); | ||
| 247 | + $project = $projectLogic->getProjectInfo($this->param['project_id']); | ||
| 248 | + $domain = !empty($project['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : ''; | ||
| 249 | + if(empty($domain)){ | ||
| 250 | + $domain = $project['deploy_build']['test_domain']; | ||
| 251 | + } | ||
| 252 | + $url = $domain.'/api/update_robots/?project_id='.$this->param['project_id']; | ||
| 253 | + $res = http_get($url); | ||
| 254 | + if(empty($res) || $res['status'] != 200){ | ||
| 255 | + $this->response('生成robots失败,请联系开发人员',Code::SYSTEM_ERROR); | ||
| 256 | + } | ||
| 244 | $projectModel = new Project(); | 257 | $projectModel = new Project(); |
| 245 | $rs = $projectModel->edit(['robots'=>$this->param['robots']],['id'=>$this->param['project_id']]); | 258 | $rs = $projectModel->edit(['robots'=>$this->param['robots']],['id'=>$this->param['project_id']]); |
| 246 | if($rs === false){ | 259 | if($rs === false){ |
| 247 | $this->response('系统错误,请联系管理员',Code::SYSTEM_ERROR); | 260 | $this->response('系统错误,请联系管理员',Code::SYSTEM_ERROR); |
| 248 | } | 261 | } |
| 249 | - //TODO::通知C端 | ||
| 250 | $this->response('success'); | 262 | $this->response('success'); |
| 251 | } | 263 | } |
| 252 | } | 264 | } |
| @@ -277,8 +277,7 @@ class BTemplateLogic extends BaseLogic | @@ -277,8 +277,7 @@ class BTemplateLogic extends BaseLogic | ||
| 277 | 'footer_html'=>$param['footer_html'], | 277 | 'footer_html'=>$param['footer_html'], |
| 278 | 'footer_css'=>$param['footer_css'], | 278 | 'footer_css'=>$param['footer_css'], |
| 279 | ]; | 279 | ]; |
| 280 | - $other = str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")); | ||
| 281 | - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($other, true) . PHP_EOL, FILE_APPEND); | 280 | + $other = str_replace('<header','',characterTruncation($param['html'],'/<link id="google-fonts-link".*?<header/s')); |
| 282 | if($info === false){ | 281 | if($info === false){ |
| 283 | $data['template_id'] = $param['template_id']; | 282 | $data['template_id'] = $param['template_id']; |
| 284 | $data['project_id'] = $this->user['project_id']; | 283 | $data['project_id'] = $this->user['project_id']; |
| @@ -336,7 +335,7 @@ class BTemplateLogic extends BaseLogic | @@ -336,7 +335,7 @@ class BTemplateLogic extends BaseLogic | ||
| 336 | 'main_css'=>$param['main_css'], | 335 | 'main_css'=>$param['main_css'], |
| 337 | 'footer_html'=>$param['footer_html'], | 336 | 'footer_html'=>$param['footer_html'], |
| 338 | 'footer_css'=>$param['footer_css'], | 337 | 'footer_css'=>$param['footer_css'], |
| 339 | - 'other'=> str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")) | 338 | + 'other'=> str_replace('<header','',characterTruncation($param['html'],'/<link id="google-fonts-link".*?<header/s')) |
| 340 | ]; | 339 | ]; |
| 341 | $bTemplateLogModel = new BTemplateLog(); | 340 | $bTemplateLogModel = new BTemplateLog(); |
| 342 | return $bTemplateLogModel->add($data); | 341 | return $bTemplateLogModel->add($data); |
-
请 注册 或 登录 后发表评论