Explorar el Código

fix: 添加cdn域名

Gosowong hace 2 años
padre
commit
0d57902b66

+ 2 - 1
crmeb/app/adminapi/controller/v1/setting/SystemStorage.php

@@ -202,6 +202,7 @@ class SystemStorage extends AuthController
     public function updateDomain($id)
     {
         $domain = $this->request->post('domain', '');
+        $cdn = $this->request->post('cdn', '');
         $data = $this->request->postMore([
             ['pri', ''],
             ['ca', '']
@@ -217,7 +218,7 @@ class SystemStorage extends AuthController
 //            return app('json')->fail('域名为HTTPS访问时,必须填写证书');
 //        }
 
-        $this->services->updateDomain($id, $domain);
+        $this->services->updateDomain($id, $domain, ['cdn' => $cdn]);
 
         return app('json')->success(100001);
     }

+ 1 - 0
crmeb/app/services/other/UploadService.php

@@ -95,6 +95,7 @@ class UploadService
             $config['uploadUrl'] = $res['domain'];
             $config['storageName'] = $res['name'];
             $config['storageRegion'] = $res['region'];
+            $config['cdn'] = $res['cdn'];
         }
 
         $thumb = SystemConfigService::more(['thumb_big_height', 'thumb_big_width', 'thumb_mid_height', 'thumb_mid_width', 'thumb_small_height', 'thumb_small_width',]);

+ 8 - 3
crmeb/app/services/system/config/SystemStorageServices.php

@@ -425,11 +425,11 @@ class SystemStorageServices extends BaseServices
      */
     public function getConfig(int $type)
     {
-        $res = ['name' => '', 'region' => '', 'domain' => ''];
+        $res = ['name' => '', 'region' => '', 'domain' => '', 'cdn' => ''];
         try {
             $config = $this->dao->get(['type' => $type, 'status' => 1, 'is_delete' => 0]);
             if ($config) {
-                return ['name' => $config->name, 'region' => $config->region, 'domain' => $config->domain];
+                return ['name' => $config->name, 'region' => $config->region, 'domain' => $config->domain, 'cdn' => $config->cdn];
             }
         } catch (\Throwable $e) {
         }
@@ -448,6 +448,7 @@ class SystemStorageServices extends BaseServices
         $domain = $this->dao->value(['id' => $id], 'domain');
         $rule = [
             FormBuilder::input('domain', '空间域名', $domain),
+            FormBuilder::input('cdn', 'cdn域名', $domain),
         ];
         return create_form('修改空间域名', $rule, '/system/config/storage/domain/' . $id);
     }
@@ -488,7 +489,11 @@ class SystemStorageServices extends BaseServices
                 $resDomain = $upload->getDomianInfo($domain);
                 $info->cname = $resDomain['cname'] ?? '';
             }
-            return $info->save();
+            $info->save();
+        }
+        if ($info->cdn != $data['cdn']) {
+            $info->cdn = $data['cdn'];
+            $info->save();
         }
 
         $this->cacheDriver()->clear();

+ 1 - 3
crmeb/crmeb/services/upload/extend/obs/Client.php

@@ -175,10 +175,8 @@ class Client extends BaseClient
      */
     public function putObject(string $key, $body, string $contentType = 'image/jpeg')
     {
-        $url = $this->uploadUrl ?: $this->getRequestUrl($this->bucketName, $this->region);
-
         $header = [
-            'Host' => $url,
+            'Host' => $this->getRequestUrl($this->bucketName, $this->region),
             'Content-Type' => $contentType,
             'Content-Length' => strlen($body),
         ];