作者 刘锟

update

@@ -33,13 +33,15 @@ class ThumbProjectImage extends Command @@ -33,13 +33,15 @@ class ThumbProjectImage extends Command
33 //指定项目 33 //指定项目
34 $this->output('project_id:' . $project_id . ' | start'); 34 $this->output('project_id:' . $project_id . ' | start');
35 35
36 - ProjectServer::useProject($project_id); 36 + $project_info = ProjectServer::useProject($project_id);
37 37
38 - Product::select(['id', 'thumb'])->chunk(100, function ($products) { 38 + if ($project_info) {
  39 + $thumb_w = $project_info->deploy_build->thumb_w ?? 0;
  40 + Product::select(['id', 'thumb'])->chunk(100, function ($products) use ($thumb_w) {
39 foreach ($products as $product) { 41 foreach ($products as $product) {
40 $thumb = $product->thumb; 42 $thumb = $product->thumb;
41 if (isset($thumb['url']) && $thumb['url']) { 43 if (isset($thumb['url']) && $thumb['url']) {
42 - $thumb['url'] = thumbImageByUrl($thumb['url']); 44 + $thumb['url'] = thumbImageByUrl($thumb['url'], $thumb_w);
43 $product->timestamps = false; 45 $product->timestamps = false;
44 $product->thumb = Arr::a2s($thumb); 46 $product->thumb = Arr::a2s($thumb);
45 $product->save(); 47 $product->save();
@@ -48,6 +50,7 @@ class ThumbProjectImage extends Command @@ -48,6 +50,7 @@ class ThumbProjectImage extends Command
48 }); 50 });
49 51
50 DB::disconnect('custom_mysql'); 52 DB::disconnect('custom_mysql');
  53 + }
51 54
52 $this->output('project_id:' . $project_id . ' | end'); 55 $this->output('project_id:' . $project_id . ' | end');
53 } else { 56 } else {
@@ -59,13 +62,15 @@ class ThumbProjectImage extends Command @@ -59,13 +62,15 @@ class ThumbProjectImage extends Command
59 62
60 $this->output('project_id:' . $project_id . ' | start'); 63 $this->output('project_id:' . $project_id . ' | start');
61 64
62 - ProjectServer::useProject($project_id); 65 + $project_info = ProjectServer::useProject($project_id);
63 66
64 - Product::select(['id', 'thumb'])->chunk(100, function ($products) { 67 + if ($project_info) {
  68 + $thumb_w = $project_info->deploy_build->thumb_w ?? 0;
  69 + Product::select(['id', 'thumb'])->chunk(100, function ($products) use ($thumb_w) {
65 foreach ($products as $product) { 70 foreach ($products as $product) {
66 $thumb = $product->thumb; 71 $thumb = $product->thumb;
67 if (isset($thumb['url']) && $thumb['url']) { 72 if (isset($thumb['url']) && $thumb['url']) {
68 - $thumb['url'] = thumbImageByUrl($thumb['url']); 73 + $thumb['url'] = thumbImageByUrl($thumb['url'], $thumb_w);
69 $product->timestamps = false; 74 $product->timestamps = false;
70 $product->thumb = Arr::a2s($thumb); 75 $product->thumb = Arr::a2s($thumb);
71 $product->save(); 76 $product->save();
@@ -74,6 +79,7 @@ class ThumbProjectImage extends Command @@ -74,6 +79,7 @@ class ThumbProjectImage extends Command
74 }); 79 });
75 80
76 DB::disconnect('custom_mysql'); 81 DB::disconnect('custom_mysql');
  82 + }
77 83
78 $this->output('project_id:' . $project_id . ' | end'); 84 $this->output('project_id:' . $project_id . ' | end');
79 } 85 }
@@ -1482,6 +1482,10 @@ function thumbImageByUrl($url, $width = 360) @@ -1482,6 +1482,10 @@ function thumbImageByUrl($url, $width = 360)
1482 return $url; 1482 return $url;
1483 } 1483 }
1484 1484
  1485 + if ($width == 0) {
  1486 + return $url;
  1487 + }
  1488 +
1485 if (strpos($url, '_thumb') !== false) { 1489 if (strpos($url, '_thumb') !== false) {
1486 return $url; 1490 return $url;
1487 } 1491 }
@@ -1521,7 +1525,7 @@ function thumbImageByUrl($url, $width = 360) @@ -1521,7 +1525,7 @@ function thumbImageByUrl($url, $width = 360)
1521 return $url; 1525 return $url;
1522 } 1526 }
1523 1527
1524 -if(!function_exists('httpGetSsl')){ 1528 +if (!function_exists('httpGetSsl')) {
1525 /** 1529 /**
1526 * 获取通配符证书 1530 * 获取通配符证书
1527 * @param $domain 1531 * @param $domain
@@ -1529,15 +1533,16 @@ if(!function_exists('httpGetSsl')){ @@ -1529,15 +1533,16 @@ if(!function_exists('httpGetSsl')){
1529 * @author Akun 1533 * @author Akun
1530 * @date 2025/04/21 16:51 1534 * @date 2025/04/21 16:51
1531 */ 1535 */
1532 - function httpGetSsl($domain){ 1536 + function httpGetSsl($domain)
  1537 + {
1533 $header = array( 1538 $header = array(
1534 "Accept:application/json", 1539 "Accept:application/json",
1535 "Content-Type:application/json;charset=utf-8", 1540 "Content-Type:application/json;charset=utf-8",
1536 - "X-CmerApi-Host:".env('GET_SSL_HOST'),  
1537 - "Apikey:".env('GET_SSL_KEY'), 1541 + "X-CmerApi-Host:" . env('GET_SSL_HOST'),
  1542 + "Apikey:" . env('GET_SSL_KEY'),
1538 ); 1543 );
1539 $ch = curl_init(); 1544 $ch = curl_init();
1540 - curl_setopt($ch, CURLOPT_URL, env('GET_SSL_URL').'?domain='.$domain); 1545 + curl_setopt($ch, CURLOPT_URL, env('GET_SSL_URL') . '?domain=' . $domain);
1541 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); 1546 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
1542 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 1547 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1543 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 1548 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);