mirror of
https://github.com/lsky-org/lsky-pro.git
synced 2025-01-09 04:19:32 +08:00
✨ Introducing new features.
This commit is contained in:
parent
8fd4ae7bc8
commit
2cab28a229
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\Strategy\LocalOption;
|
||||
use App\Enums\StrategyKey;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
@ -59,15 +58,20 @@ class Strategy extends Model
|
||||
{
|
||||
static::saving(function (self $strategy) {
|
||||
$strategy->configs['root'] = $strategy->configs->get('root', '');
|
||||
$strategy->configs['symlink'] = $strategy->configs->get('symlink', '');
|
||||
$strategy->configs['domain'] = rtrim($strategy->configs->get('domain', env('APP_URL')), '/').'/'.$strategy->configs['symlink'];
|
||||
$strategy->configs['domain'] = rtrim($strategy->configs->get('domain', env('APP_URL')), '/');
|
||||
|
||||
// 本地储存,创建/修改符号链接
|
||||
if ($strategy->key == StrategyKey::Local && $strategy->configs['root']) {
|
||||
// TODO 删除已存在的符号链接
|
||||
|
||||
(new Filesystem())->link($strategy->configs['root'], public_path($strategy->configs['symlink']));
|
||||
}
|
||||
// TODO 本地储存,创建/修改符号链接
|
||||
/*if ($strategy->key == StrategyKey::Local && $strategy->configs['root']) {
|
||||
$link = ($strategy->getOriginal('configs')['symlink'] ?? '');
|
||||
if ($link && $link !== $strategy->configs['symlink']) {
|
||||
// 删除已存在的符号链接
|
||||
@unlink($link);
|
||||
}
|
||||
$link = public_path($strategy->configs['symlink']);
|
||||
if (! realpath($link)) {
|
||||
(new Filesystem())->link($strategy->configs['root'], $link);
|
||||
}
|
||||
}*/
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -39,23 +39,19 @@
|
||||
|
||||
<div class="col-span-6">
|
||||
<div class="col-span-6 sm:col-span-3 mb-4">
|
||||
<label for="configs[root]" class="block text-sm font-medium text-gray-700">储存路径</label>
|
||||
<label for="configs[root]" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>储存路径</label>
|
||||
<x-input type="text" name="configs[root]" id="configs[root]" autocomplete="text" placeholder="图片保存位置,可为空" />
|
||||
<small class="text-orange-500"><i class="fas fa-exclamation"></i> 储存路径设置错误或没有读写权限可能会导致图片保存失败。如果储存路径与其他策略相同,那么请注意使用角色组的路径命名规则、文件命名规则来区分不同文件夹,否则可能会因为名称重复而导致图片物理文件被覆盖。</small>
|
||||
<small class="text-orange-500"><i class="fas fa-exclamation"></i> 储存路径为绝对路径,设置错误或没有读写权限可能会导致图片保存失败。如果储存路径与其他策略相同,那么请注意使用角色组的路径命名规则、文件命名规则来区分不同文件夹,否则可能会因为名称重复而导致图片物理文件被覆盖。</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-6 mb-4 hidden" data-driver="{{ \App\Enums\StrategyKey::Local }}">
|
||||
<div class="col-span-3 sm:col-span-2 mb-4">
|
||||
<label for="configs[symlink]" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>符号链接</label>
|
||||
<x-input type="text" name="configs[symlink]" id="configs[symlink]" class="mt-1 block w-full rounded-l-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50" placeholder="请输入符号链接名称" />
|
||||
<small class="text-orange-500"><i class="fas fa-exclamation"></i>
|
||||
符号链接相对 public 目录,假如填写的符号链接名称为 uploads,那么上传图片后返回的链接类似:http://domain.com/<span class="text-red-500">uploads</span>/20210104/abcdefg.jpg,符号链接不能与其他策略重复。
|
||||
</small>
|
||||
</div>
|
||||
<div class="col-span-3 sm:col-span-2 mb-4">
|
||||
<label for="configs[domain]" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>访问域名</label>
|
||||
<x-input type="text" name="configs[domain]" id="configs[domain]" class="mt-1 block w-full rounded-l-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50" placeholder="请输入图片访问域名,需要加 http(s)://" />
|
||||
<small class="text-orange-500"><i class="fas fa-exclamation"></i>
|
||||
注意:本地储存访问域名必须有一个后缀,例如 https://www.lsky.pro/<span class="text-red-600">uploads</span>/20220104/1.jpg 中的 uploads 就是后缀,系统会根据这个后缀生成符号链接。 符号链接相对 public 目录,不能与其他策略重复。
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -39,23 +39,19 @@
|
||||
|
||||
<div class="col-span-6">
|
||||
<div class="col-span-6 sm:col-span-3 mb-4">
|
||||
<label for="configs[root]" class="block text-sm font-medium text-gray-700">储存路径</label>
|
||||
<label for="configs[root]" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>储存路径</label>
|
||||
<x-input type="text" name="configs[root]" id="configs[root]" autocomplete="text" placeholder="图片保存位置,可为空" value="{{ $strategy->configs['root'] }}" />
|
||||
<small class="text-orange-500"><i class="fas fa-exclamation"></i> 储存路径设置错误或没有读写权限可能会导致图片保存失败。如果储存路径与其他策略相同,那么请注意使用角色组的路径命名规则、文件命名规则来区分不同文件夹,否则可能会因为名称重复而导致图片物理文件被覆盖。</small>
|
||||
<small class="text-orange-500"><i class="fas fa-exclamation"></i> 储存路径为绝对路径,设置错误或没有读写权限可能会导致图片保存失败。如果储存路径与其他策略相同,那么请注意使用角色组的路径命名规则、文件命名规则来区分不同文件夹,否则可能会因为名称重复而导致图片物理文件被覆盖。</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-6 mb-4 hidden" data-driver="{{ \App\Enums\StrategyKey::Local }}">
|
||||
<div class="col-span-3 sm:col-span-2 mb-4">
|
||||
<label for="configs[symlink]" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>符号链接</label>
|
||||
<x-input type="text" name="configs[symlink]" id="configs[symlink]" class="mt-1 block w-full rounded-l-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50" placeholder="请输入符号链接名称" value="{{ $strategy->configs['symlink'] ?? '' }}" />
|
||||
<small class="text-orange-500"><i class="fas fa-exclamation"></i>
|
||||
符号链接相对 public 目录,假如填写的符号链接名称为 uploads,那么上传图片后返回的链接类似:http://domain.com/<span class="text-red-500">uploads</span>/20210104/abcdefg.jpg,符号链接不能与其他策略重复。
|
||||
</small>
|
||||
</div>
|
||||
<div class="col-span-3 sm:col-span-2 mb-4">
|
||||
<label for="configs[domain]" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>访问域名</label>
|
||||
<x-input type="text" name="configs[domain]" id="configs[domain]" class="mt-1 block w-full rounded-l-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50" placeholder="请输入图片访问域名,需要加 http(s)://" value="{{ $strategy->configs['domain'] }}" />
|
||||
<small class="text-orange-500"><i class="fas fa-exclamation"></i>
|
||||
注意:本地储存访问域名必须有一个后缀,例如 https://www.lsky.pro/<span class="text-red-600">uploads</span>/20220104/1.jpg 中的 uploads 就是后缀,系统会根据这个后缀生成符号链接。 符号链接相对 public 目录,不能与其他策略重复。
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user