✨ 原图保护功能
This commit is contained in:
@@ -17,5 +17,5 @@ final class KodoOption
|
||||
const Bucket = 'bucket';
|
||||
|
||||
/** @var string 是否启用获取原始 url 功能 */
|
||||
const IsEnableOriginUrl = 'is_enable_origin_url';
|
||||
const IsEnableOriginalProtection = 'is_enable_origin_url';
|
||||
}
|
||||
|
||||
@@ -10,6 +10,6 @@ final class LocalOption
|
||||
/** @var string 根目录 */
|
||||
const Root = 'root';
|
||||
|
||||
/** @var string 是否启用获取原始 url 功能 */
|
||||
const IsEnableOriginUrl = 'is_enable_origin_url';
|
||||
/** @var string 是否启用原图保护功能 */
|
||||
const IsEnableOriginalProtection = 'is_enable_original_protection';
|
||||
}
|
||||
|
||||
@@ -119,12 +119,11 @@ class Image extends Model
|
||||
if (!$this->strategy) {
|
||||
return Storage::disk('uploads')->url($this->pathname);
|
||||
}
|
||||
// 是否启用了获取图片直链功能
|
||||
if ($this->strategy->configs->get(LocalOption::IsEnableOriginUrl)) {
|
||||
return rtrim($this->strategy->configs->get(LocalOption::Domain), '/').'/'.$this->pathname;
|
||||
} else {
|
||||
// 原图保护
|
||||
// 是否启用原图保护功能
|
||||
if ($this->strategy->configs->get(LocalOption::IsEnableOriginalProtection)) {
|
||||
return asset("{$this->key}.{$this->extension}");
|
||||
} else {
|
||||
return rtrim($this->strategy->configs->get(LocalOption::Domain), '/').'/'.$this->pathname;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class Strategy extends Model
|
||||
static::creating(function (self $strategy) {
|
||||
$strategy->configs = collect([
|
||||
LocalOption::Domain => env('APP_URL'),
|
||||
LocalOption::IsEnableOriginUrl => true,
|
||||
LocalOption::IsEnableOriginalProtection => true,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user