作者 张关杰

gx

  1 +<?php
  2 +
  3 +namespace App\Console\Commands;
  4 +
  5 +use App\Http\Logic\Aside\Project\DomainInfoLogic;
  6 +use App\Models\Com\UpdateNotify;
  7 +use App\Models\Devops\DevopsTask as DevopsTaskModel;
  8 +use App\Models\Devops\DevopsTaskLog;
  9 +use App\Models\Domain\DomainInfo;
  10 +use App\Models\File\File;
  11 +use App\Models\File\Image;
  12 +use App\Models\Product\CategoryRelated;
  13 +use App\Models\Product\Product;
  14 +use App\Models\Project\Project;
  15 +use App\Models\RouteMap\RouteMap;
  16 +use App\Models\Template\BCustomTemplate;
  17 +use App\Services\ProjectServer;
  18 +use Illuminate\Console\Command;
  19 +use Illuminate\Database\QueryException;
  20 +use Illuminate\Support\Facades\DB;
  21 +
  22 +/**
  23 + * 测试
  24 + * Class Traffic
  25 + * @package App\Console\Commands
  26 + * @author zbj
  27 + * @date 2023/5/18
  28 + */
  29 +class Test extends Command
  30 +{
  31 + /**
  32 + * The name and signature of the console command.
  33 + *
  34 + * @var string
  35 + */
  36 + protected $signature = 'test';
  37 +
  38 + /**
  39 + * The console command description.
  40 + *
  41 + * @var string
  42 + */
  43 + protected $description = '测试';
  44 +
  45 + /**
  46 + * Create a new command instance.
  47 + *
  48 + * @return void
  49 + */
  50 + public function __construct()
  51 + {
  52 + parent::__construct();
  53 + }
  54 +
  55 + /**
  56 + * @return bool
  57 + */
  58 + public function handle()
  59 + {
  60 + $projects = Project::all();
  61 + foreach ($projects as $project){
  62 + echo "project " . $project->id;
  63 +
  64 + if(!ProjectServer::useProject($project->id)){
  65 + echo '-->' . '未配置数据库' . PHP_EOL;
  66 + continue;
  67 + }
  68 +
  69 + try {
  70 + $page = BCustomTemplate::where('url', '404')->first();
  71 + if(!$page){
  72 + $page = new BCustomTemplate();
  73 + }
  74 + $page->project_id = $project->id;
  75 + $page->name = '404';
  76 + $page->status = 1;
  77 + $page->url = '404';
  78 + $page->html = '<main>
  79 + <section data-section="section" data-screen="screen-large" class="section-404-wrap-block section-block-error404"
  80 + id="sectionIdyxqu938">
  81 + <div class="layout" data-unable="demo01-error404">
  82 + <img src="https://ecdn6.globalso.com/upload/m/image_other/2023-10/6528a87e594db30162.png" />
  83 + </div>
  84 + <p style="text-align: center">SORRY. THE PAGE HAS EITHER MOVED OR CANNOT BE FOUND.</p>
  85 + <style>
  86 + .section-block-error404 .layout {
  87 + height: 700px;
  88 + display: flex;
  89 + align-items: center;
  90 + justify-content: center;
  91 + }
  92 + .section-block-error404 img {
  93 + width: 400px;
  94 + }
  95 + @media only screen and (max-width:500) {
  96 + .section-block-error404 img {
  97 + max-width: 100%;
  98 + }
  99 + }
  100 + </style>
  101 + <script>
  102 + </script>
  103 + </section>
  104 + </main>';
  105 + $page->html_style = '<style id="globalsojs-styles"></style>';
  106 + $page->description = 'Sorry. The page has either moved or cannot be found.';
  107 + $page->title = '404-Page not found';
  108 + $page->save();
  109 +
  110 + $domain = (new DomainInfo())->getDomain($project['deploy_optimize']['domain']);
  111 + $url = $domain.'api/delHtml/?project_id='.$project->id.'&route=404';
  112 + curlGet($url);
  113 + }catch (QueryException | \Exception $e){
  114 + echo '-->' . $e->getMessage() . PHP_EOL;
  115 + continue;
  116 + }
  117 + echo '-->成功:' . PHP_EOL;
  118 + }
  119 + }
  120 +
  121 +}