原图保护功能

This commit is contained in:
Wisp X
2022-01-17 13:49:20 +08:00
parent 84a4698e97
commit 7aa085d19f
4 changed files with 8 additions and 9 deletions
+1 -1
View File
@@ -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';
}
+2 -2
View File
@@ -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';
}
+4 -5
View File
@@ -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;
}
});
}
+1 -1
View File
@@ -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,
]);
});
}