作者 lyh

gx

@@ -419,28 +419,18 @@ if (!function_exists('getImageUrl')) { @@ -419,28 +419,18 @@ if (!function_exists('getImageUrl')) {
419 * @method :post 419 * @method :post
420 * @time :2023/7/20 16:46 420 * @time :2023/7/20 16:46
421 */ 421 */
422 - function getImageUrl($hash){  
423 - if(is_array($hash)){  
424 - foreach ($hash as $v){ 422 + function getImageUrl($path,$location = 1){
  423 + if(is_array($path)){
  424 + foreach ($path as $v){
425 $url[] = getImageUrl($v); 425 $url[] = getImageUrl($v);
426 } 426 }
427 }else{ 427 }else{
428 - $imageModel = new Image();  
429 - if (strpos($hash, '.') !== false) {  
430 - $info = $imageModel->read(['path'=>['like','%'.$hash.'%']]); 428 + if($location == 1){
  429 + $cos = config('filesystems.disks.cos');
  430 + $cosCdn = $cos['cdn'];
  431 + $url = $cosCdn.$path;
431 }else{ 432 }else{
432 - $info = $imageModel->read(['hash'=>$hash]);  
433 - }  
434 - if(!empty($info)){  
435 - if($info['is_cos'] == 1){  
436 - $cos = config('filesystems.disks.cos');  
437 - $cosCdn = $cos['cdn'];  
438 - $url = $cosCdn.$info['path'];  
439 - }else{  
440 - $url = url($info['path']);  
441 - }  
442 - }else{  
443 - $url = $hash; 433 + $url = url($path);
444 } 434 }
445 } 435 }
446 return $url; 436 return $url;
@@ -454,28 +444,18 @@ if (!function_exists('getFileUrl')) { @@ -454,28 +444,18 @@ if (!function_exists('getFileUrl')) {
454 * @method :post 444 * @method :post
455 * @time :2023/7/20 16:46 445 * @time :2023/7/20 16:46
456 */ 446 */
457 - function getFileUrl($hash){  
458 - if(is_array($hash)){  
459 - foreach ($hash as $v){ 447 + function getFileUrl($path,$location = 1){
  448 + if(is_array($path)){
  449 + foreach ($path as $v){
460 $url[] = getFileUrl($v); 450 $url[] = getFileUrl($v);
461 } 451 }
462 }else{ 452 }else{
463 - $fileModel = new File();  
464 - if (strpos($hash, '.') !== false) {  
465 - $info = $fileModel->read(['path'=>['like','%'.$hash.'%']]);  
466 - }else{  
467 - $info = $fileModel->read(['hash'=>$hash]);  
468 - }  
469 - if(!empty($info)){  
470 - if($info['is_cos'] == 1){  
471 - $cos = config('filesystems.disks.cos');  
472 - $cosCdn = $cos['cdn'];  
473 - $url = $cosCdn.'/upload'.$info['path'];  
474 - }else{  
475 - $url = url('upload'.$info['path']);  
476 - } 453 + if($location == 1){
  454 + $cos = config('filesystems.disks.cos');
  455 + $cosCdn = $cos['cdn'];
  456 + $url = $cosCdn.$path['path'];
477 }else{ 457 }else{
478 - $url = $hash; 458 + $url = url($path['path']);
479 } 459 }
480 } 460 }
481 return $url; 461 return $url;