✨ 策略增加原图保护功能
This commit is contained in:
@@ -15,4 +15,7 @@ final class KodoOption
|
||||
|
||||
/** @var string Bucket */
|
||||
const Bucket = 'bucket';
|
||||
|
||||
/** @var string 是否启用获取原始 url 功能 */
|
||||
const IsEnableOriginUrl = 'is_enable_origin_url';
|
||||
}
|
||||
|
||||
@@ -9,4 +9,7 @@ final class LocalOption
|
||||
|
||||
/** @var string 根目录 */
|
||||
const Root = 'root';
|
||||
|
||||
/** @var string 是否启用获取原始 url 功能 */
|
||||
const IsEnableOriginUrl = 'is_enable_origin_url';
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\Strategy\LocalOption;
|
||||
use App\Service\ImageService;
|
||||
use App\Utils;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
@@ -111,8 +113,12 @@ class Image extends Model
|
||||
if (!$this->strategy) {
|
||||
return Storage::disk('uploads')->url($this->pathname);
|
||||
}
|
||||
$domain = rtrim($this->strategy->configs->get('domain'), '/');
|
||||
return $domain.'/'.$this->pathname;
|
||||
// 是否启用了获取图片直链功能
|
||||
if ($this->strategy->configs->get(LocalOption::IsEnableOriginUrl)) {
|
||||
return rtrim($this->strategy->configs->get(LocalOption::Domain), '/').'/'.$this->pathname;
|
||||
} else {
|
||||
return asset($this->pathname);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user