作者 lyh

gx

@@ -366,6 +366,7 @@ class ImageController extends Controller @@ -366,6 +366,7 @@ class ImageController extends Controller
366 * @time :2024/8/24 11:03 366 * @time :2024/8/24 11:03
367 */ 367 */
368 public function getProjectConfig($project_id = 0){ 368 public function getProjectConfig($project_id = 0){
  369 + $str = '';
369 $imageSettingModel = new ImageSetting(); 370 $imageSettingModel = new ImageSetting();
370 $settingInfo = $imageSettingModel->read(['project_id'=>$project_id]); 371 $settingInfo = $imageSettingModel->read(['project_id'=>$project_id]);
371 if($settingInfo !== false){ 372 if($settingInfo !== false){
@@ -377,7 +378,8 @@ class ImageController extends Controller @@ -377,7 +378,8 @@ class ImageController extends Controller
377 } 378 }
378 $image_data[$k] = $v; 379 $image_data[$k] = $v;
379 } 380 }
380 - return $image_data; 381 + $str = 'watermark/1/'.implode('/',$image_data);
  382 + return $str;
381 } 383 }
382 if($settingInfo['status'] == 2 && !empty($settingInfo['str_data'])){ 384 if($settingInfo['status'] == 2 && !empty($settingInfo['str_data'])){
383 $str_data = json_decode($settingInfo['str_data'],true); 385 $str_data = json_decode($settingInfo['str_data'],true);
@@ -398,9 +400,10 @@ class ImageController extends Controller @@ -398,9 +400,10 @@ class ImageController extends Controller
398 $str_data[$k] = $v; 400 $str_data[$k] = $v;
399 } 401 }
400 } 402 }
401 - return $str_data; 403 + $str = 'watermark/2/'.implode('/',$str_data);
  404 + return $str;
402 } 405 }
403 - return null; 406 + return $str;
404 } 407 }
405 408
406 /** 409 /**
@@ -23,7 +23,7 @@ class CosService @@ -23,7 +23,7 @@ class CosService
23 * @method :post 23 * @method :post
24 * @time :2023/7/19 15:28 24 * @time :2023/7/19 15:28
25 */ 25 */
26 - public function uploadFile(&$files,$path,$filename, $binary = false,$watermarkOptions = null) 26 + public function uploadFile(&$files,$path,$filename, $binary = false,$watermarkOptions = '')
27 { 27 {
28 $cos = config('filesystems.disks.cos'); 28 $cos = config('filesystems.disks.cos');
29 $cosClient = new Client([ 29 $cosClient = new Client([
@@ -41,14 +41,13 @@ class CosService @@ -41,14 +41,13 @@ class CosService
41 'Body' => $Body, 41 'Body' => $Body,
42 ]; 42 ];
43 //水印 43 //水印
44 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($watermarkOptions, true) . PHP_EOL, FILE_APPEND);  
45 if ($watermarkOptions) { 44 if ($watermarkOptions) {
46 $options['PicOperations'] = json_encode([ 45 $options['PicOperations'] = json_encode([
47 'is_pic_info' => 1, 46 'is_pic_info' => 1,
48 'rules' => [ 47 'rules' => [
49 [ 48 [
50 'fileid' => $key, // 使用相同的文件名保存 49 'fileid' => $key, // 使用相同的文件名保存
51 - 'rule' => 'watermark/2/'.implode('/',$watermarkOptions), 50 + 'rule' => $watermarkOptions,
52 ] 51 ]
53 ] 52 ]
54 ], true); 53 ], true);