mirror of
https://github.com/lsky-org/lsky-pro.git
synced 2025-01-07 03:16:46 +08:00
✨ 本地策略符号链接功配置
This commit is contained in:
parent
de43341a31
commit
8fd4ae7bc8
@ -21,6 +21,8 @@ class StrategyRequest extends FormRequest
|
||||
'key' => 'required|integer',
|
||||
'configs.root' => 'max:1000',
|
||||
'configs.domain' => 'required|url',
|
||||
|
||||
'configs.symlink' => 'required_if:key,1',
|
||||
];
|
||||
}
|
||||
|
||||
@ -29,8 +31,18 @@ class StrategyRequest extends FormRequest
|
||||
return [
|
||||
'name' => '名称',
|
||||
'intro' => '简介',
|
||||
'key' => '策略',
|
||||
'configs.root' => '储存路径',
|
||||
'configs.domain' => '访问域名',
|
||||
|
||||
'configs.symlink' => '符号链接'
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'configs.symlink.required_if' => '请输入符号链接',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
@ -58,11 +59,14 @@ class Strategy extends Model
|
||||
{
|
||||
static::saving(function (self $strategy) {
|
||||
$strategy->configs['root'] = $strategy->configs->get('root', '');
|
||||
$strategy->configs['domain'] = rtrim($strategy->configs->get('domain', env('APP_URL')), '/').'/uploads';
|
||||
$strategy->configs['symlink'] = $strategy->configs->get('symlink', '');
|
||||
$strategy->configs['domain'] = rtrim($strategy->configs->get('domain', env('APP_URL')), '/').'/'.$strategy->configs['symlink'];
|
||||
|
||||
// 本地储存,创建符号链接
|
||||
if ($strategy->key === StrategyKey::Local) {
|
||||
// TODO
|
||||
// 本地储存,创建/修改符号链接
|
||||
if ($strategy->key == StrategyKey::Local && $strategy->configs['root']) {
|
||||
// TODO 删除已存在的符号链接
|
||||
|
||||
(new Filesystem())->link($strategy->configs['root'], public_path($strategy->configs['symlink']));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ return [
|
||||
'uploads' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/uploads'),
|
||||
'url' => env('APP_URL').'/uploads',
|
||||
'url' => env('APP_URL').'/i',
|
||||
'visibility' => 'public',
|
||||
],
|
||||
],
|
||||
@ -55,6 +55,6 @@ return [
|
||||
*/
|
||||
|
||||
'links' => [
|
||||
public_path('uploads') => storage_path('app/uploads'),
|
||||
public_path('i') => storage_path('app/uploads'),
|
||||
],
|
||||
];
|
||||
|
20
public/css/app.css
vendored
20
public/css/app.css
vendored
@ -1595,6 +1595,26 @@ select {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(71 85 105 / var(--tw-text-opacity));
|
||||
}
|
||||
.text-rose-500 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(244 63 94 / var(--tw-text-opacity));
|
||||
}
|
||||
.text-rose-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(253 164 175 / var(--tw-text-opacity));
|
||||
}
|
||||
.text-rose-400 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(251 113 133 / var(--tw-text-opacity));
|
||||
}
|
||||
.text-orange-400 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(251 146 60 / var(--tw-text-opacity));
|
||||
}
|
||||
.text-orange-500 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(249 115 22 / var(--tw-text-opacity));
|
||||
}
|
||||
.underline {
|
||||
-webkit-text-decoration-line: underline;
|
||||
text-decoration-line: underline;
|
||||
|
@ -1 +0,0 @@
|
||||
/Users/wispx/Develop/Projects/lsky-pro/storage/app/uploads
|
@ -41,17 +41,21 @@
|
||||
<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>
|
||||
<x-input type="text" name="configs[root]" id="configs[root]" autocomplete="text" placeholder="图片保存位置,可为空" />
|
||||
<small class="text-yellow-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">
|
||||
<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>
|
||||
<div class="mt-1 flex rounded-md shadow-sm">
|
||||
<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)://" />
|
||||
<span class="mt-1 inline-flex items-center px-3 rounded-r-md border border-l-0 border-gray-300 bg-gray-50 text-gray-500 text-sm">/uploads</span>
|
||||
</div>
|
||||
<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)://" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -41,17 +41,21 @@
|
||||
<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>
|
||||
<x-input type="text" name="configs[root]" id="configs[root]" autocomplete="text" placeholder="图片保存位置,可为空" value="{{ $strategy->configs['root'] }}" />
|
||||
<small class="text-yellow-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">
|
||||
<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>
|
||||
<div class="mt-1 flex rounded-md shadow-sm">
|
||||
<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'] }}" />
|
||||
<span class="mt-1 inline-flex items-center px-3 rounded-r-md border border-l-0 border-gray-300 bg-gray-50 text-gray-500 text-sm">/uploads</span>
|
||||
</div>
|
||||
<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'] }}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user