|
@@ -419,16 +419,26 @@ if (!function_exists('getImageUrl')) { |
|
@@ -419,16 +419,26 @@ 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($path,$location = 1){
|
|
|
|
423
|
- if(is_array($path)){
|
|
|
|
424
|
- foreach ($path as $v){
|
422
|
+ function getImageUrl($hash){
|
|
|
|
423
|
+ if(is_array($hash)){
|
|
|
|
424
|
+ foreach ($hash as $v){
|
|
425
|
$url[] = getImageUrl($v);
|
425
|
$url[] = getImageUrl($v);
|
|
426
|
}
|
426
|
}
|
|
427
|
}else{
|
427
|
}else{
|
|
428
|
- if($location == 1){
|
|
|
|
429
|
- $cos = config('filesystems.disks.cos');
|
|
|
|
430
|
- $cosCdn = $cos['cdn'];
|
|
|
|
431
|
- $url = $cosCdn.$path;
|
428
|
+ $imageModel = new Image();
|
|
|
|
429
|
+ if (strpos($hash, '.') !== false) {
|
|
|
|
430
|
+ $info = $imageModel->read(['path'=>['like','%'.$hash.'%']]);
|
|
|
|
431
|
+ }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
|
+ }
|
|
432
|
}else{
|
442
|
}else{
|
|
433
|
$url = url($path);
|
443
|
$url = url($path);
|
|
434
|
}
|
444
|
}
|
|
@@ -436,7 +446,6 @@ if (!function_exists('getImageUrl')) { |
|
@@ -436,7 +446,6 @@ if (!function_exists('getImageUrl')) { |
|
436
|
return $url;
|
446
|
return $url;
|
|
437
|
}
|
447
|
}
|
|
438
|
}
|
448
|
}
|
|
439
|
-
|
|
|
|
440
|
if (!function_exists('getFileUrl')) {
|
449
|
if (!function_exists('getFileUrl')) {
|
|
441
|
/**
|
450
|
/**
|
|
442
|
* @remark :获取文件链接
|
451
|
* @remark :获取文件链接
|
|
@@ -445,18 +454,28 @@ if (!function_exists('getFileUrl')) { |
|
@@ -445,18 +454,28 @@ if (!function_exists('getFileUrl')) { |
|
445
|
* @method :post
|
454
|
* @method :post
|
|
446
|
* @time :2023/7/20 16:46
|
455
|
* @time :2023/7/20 16:46
|
|
447
|
*/
|
456
|
*/
|
|
448
|
- function getFileUrl($path,$location = 1){
|
|
|
|
449
|
- if(is_array($path)){
|
|
|
|
450
|
- foreach ($path as $v){
|
457
|
+ function getFileUrl($hash){
|
|
|
|
458
|
+ if(is_array($hash)){
|
|
|
|
459
|
+ foreach ($hash as $v){
|
|
451
|
$url[] = getFileUrl($v);
|
460
|
$url[] = getFileUrl($v);
|
|
452
|
}
|
461
|
}
|
|
453
|
}else{
|
462
|
}else{
|
|
454
|
- if($location == 1){
|
|
|
|
455
|
- $cos = config('filesystems.disks.cos');
|
|
|
|
456
|
- $cosCdn = $cos['cdn'];
|
|
|
|
457
|
- $url = $cosCdn.$path['path'];
|
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
|
+ }
|
|
458
|
}else{
|
477
|
}else{
|
|
459
|
- $url = url($path['path']);
|
478
|
+ $url = $hash;
|
|
460
|
}
|
479
|
}
|
|
461
|
}
|
480
|
}
|
|
462
|
return $url;
|
481
|
return $url;
|