角色组编辑页面

This commit is contained in:
Wisp X 2022-01-22 13:16:15 +08:00
parent 3ac70a772c
commit 5662f86aae
8 changed files with 335 additions and 28 deletions

View File

@ -7,6 +7,7 @@ use App\Enums\GroupConfigKey;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\GroupRequest;
use App\Models\Group;
use App\Utils;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
@ -56,7 +57,15 @@ class GroupController extends Controller
public function edit(Request $request): View
{
$group = Group::query()->findOrFail($request->route('id'));
if ($request->route('id') == 0) {
$group = new Group([
'id' => 0,
'name' => '系统默认组',
'configs' => Utils::config(ConfigKey::GroupConfigs),
]);
} else {
$group = Group::query()->findOrFail($request->route('id'));
}
return view('admin.group.edit', compact('group'));
}

View File

@ -15,7 +15,7 @@ class GroupRequest extends FormRequest
public function rules()
{
$requiredIfReview = function ($driver) {
return Rule::requiredIf($this->input('configs.is_enable_review') && $this->input('configs.scan_configs.driver') === $driver);
return Rule::requiredIf($this->input('configs.is_enable_scan') && $this->input('configs.scan_configs.driver') === $driver);
};
$requiredIfWatermark = function ($driver) {
@ -37,12 +37,12 @@ class GroupRequest extends FormRequest
'configs.file_naming_rule' => 'max:400',
'configs.accepted_file_suffixes' => 'required|array|in:jpeg,jpg,png,gif,tif,bmp,ico,psd,webp',
'configs.is_enable_review' => 'boolean',
'configs.is_enable_scan' => 'boolean',
'configs.scanned_action' => [
'exclude_if:configs.is_enable_review,false',
'exclude_if:configs.is_enable_scan,false',
'in:mark,delete',
],
'configs.scan_configs.driver' => ['exclude_if:configs.is_enable_review,false', 'in:aliyun',],
'configs.scan_configs.driver' => ['exclude_if:configs.is_enable_scan,false', 'in:aliyun',],
'configs.scan_configs.drivers.aliyun.access_key_id' => [$requiredIfReview('aliyun')],
'configs.scan_configs.drivers.aliyun.access_key_secret' => [$requiredIfReview('aliyun')],
'configs.scan_configs.drivers.aliyun.biz_type' => [$requiredIfReview('aliyun')],
@ -105,7 +105,7 @@ class GroupRequest extends FormRequest
'configs.file_naming_rule' => '文件命名规则',
'configs.accepted_file_suffixes' => '允许上传的文件后缀',
'configs.is_enable_review' => '是否启用图片审核',
'configs.is_enable_scan' => '是否启用图片审核',
'configs.scanned_action' => '图片审核动作',
'configs.scan_configs.driver' => '图片审核驱动',
'configs.scan_configs.drivers.aliyun.access_key_id' => 'AccessKeyId',

View File

@ -42,7 +42,7 @@ return [
GroupConfigKey::ScanConfigs => [
'driver' => 'aliyun',
'drivers' => [
'aluyun' => [
'aliyun' => [
AliyunOption::AccessKeyId => '',
AliyunOption::AccessKeySecret => '',
AliyunOption::RegionId => '',

View File

@ -1,13 +1,6 @@
<x-app-layout>
<div class="my-6 md:my-10">
@if(! ini_get('file_uploads'))
<p class="bg-red-500 p-2 mb-2 rounded text-sm text-white">
<i class="fas fa-exclamation-circle"></i> 系统监测到运行环境关闭了 HTTP 上传文件权限(file_uploads=off),请更改 PHP 此项配置,否则无法上传文件。
</p>
@endif
<p class="bg-yellow-500 p-2 mb-4 rounded text-sm text-white">
<i class="fas fa-exclamation-circle"></i> 系统运行环境允许上传大小的最大值为 {{ ini_get('upload_max_filesize') }},最大 POST 数据大小为 {{ ini_get('post_max_size') }},上传文件大小不得超过这两项配置值。
</p>
@include('admin.group.tips')
<div class="mt-5 md:mt-0 md:col-span-2">
<ul id="tabs" class="flex space-x-2 text-sm">
@ -35,47 +28,47 @@
<div class="col-span-6">
<label for="maximum_file_size" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>最大文件大小(KB)</label>
<input type="number" name="configs[maximum_file_size]" id="maximum_file_size" autocomplete="maximum_file_size" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入上传文件的最大限制单位kb" value="{{ $default->get(\App\Enums\GroupConfigKey::MaximumFileSize) }}">
<input type="number" name="configs[maximum_file_size]" id="maximum_file_size" autocomplete="maximum_file_size" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入上传文件的最大限制单位kb" value="{{ $default->get('maximum_file_size') }}">
</div>
<div class="col-span-6 sm:col-span-3">
<label for="concurrent_upload_num" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>并发上传限制</label>
<input type="number" name="configs[concurrent_upload_num]" id="concurrent_upload_num" autocomplete="concurrent_upload_num" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入并发上传数量" value="{{ $default->get(\App\Enums\GroupConfigKey::ConcurrentUploadNum) }}">
<input type="number" name="configs[concurrent_upload_num]" id="concurrent_upload_num" autocomplete="concurrent_upload_num" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入并发上传数量" value="{{ $default->get('concurrent_upload_num') }}">
</div>
<div class="col-span-6 sm:col-span-3">
<label for="limit_per_minute" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>每分钟上传限制</label>
<input type="number" name="configs[limit_per_minute]" id="limit_per_minute" autocomplete="limit_per_minute" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入每分钟可以上传的图片数量" value="{{ $default->get(\App\Enums\GroupConfigKey::LimitPerMinute) }}">
<input type="number" name="configs[limit_per_minute]" id="limit_per_minute" autocomplete="limit_per_minute" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入每分钟可以上传的图片数量" value="{{ $default->get('limit_per_minute') }}">
</div>
<div class="col-span-6 sm:col-span-3">
<label for="limit_per_hour" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>每小时上传限制</label>
<input type="number" name="configs[limit_per_hour]" id="limit_per_hour" autocomplete="limit_per_hour" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入每小时可以上传的图片数量" value="{{ $default->get(\App\Enums\GroupConfigKey::LimitPerHour) }}">
<input type="number" name="configs[limit_per_hour]" id="limit_per_hour" autocomplete="limit_per_hour" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入每小时可以上传的图片数量" value="{{ $default->get('limit_per_hour') }}">
</div>
<div class="col-span-6 sm:col-span-3">
<label for="limit_per_day" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>每天上传限制</label>
<input type="number" name="configs[limit_per_day]" id="limit_per_day" autocomplete="limit_per_day" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入每天可以上传的图片数量" value="{{ $default->get(\App\Enums\GroupConfigKey::LimitPerDay) }}">
<input type="number" name="configs[limit_per_day]" id="limit_per_day" autocomplete="limit_per_day" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入每天可以上传的图片数量" value="{{ $default->get('limit_per_day') }}">
</div>
<div class="col-span-6 sm:col-span-3">
<label for="limit_per_week" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>每周上传限制</label>
<input type="number" name="configs[limit_per_week]" id="limit_per_week" autocomplete="limit_per_week" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入每周可以上传的图片数量" value="{{ $default->get(\App\Enums\GroupConfigKey::LimitPerWeek) }}">
<input type="number" name="configs[limit_per_week]" id="limit_per_week" autocomplete="limit_per_week" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入每周可以上传的图片数量" value="{{ $default->get('limit_per_week') }}">
</div>
<div class="col-span-6 sm:col-span-3">
<label for="limit_per_month" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>每月上传限制</label>
<input type="number" name="configs[limit_per_month]" id="limit_per_month" autocomplete="limit_per_month" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入每月可以上传的图片数量" value="{{ $default->get(\App\Enums\GroupConfigKey::LimitPerMonth) }}">
<input type="number" name="configs[limit_per_month]" id="limit_per_month" autocomplete="limit_per_month" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入每月可以上传的图片数量" value="{{ $default->get('limit_per_month') }}">
</div>
<div class="col-span-6 sm:col-span-3">
<label for="path_naming_rule" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>路径命名规则</label>
<input type="text" name="configs[path_naming_rule]" id="path_naming_rule" autocomplete="path_naming_rule" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入路径命名规则" value="{{ $default->get(\App\Enums\GroupConfigKey::PathNamingRule) }}">
<input type="text" name="configs[path_naming_rule]" id="path_naming_rule" autocomplete="path_naming_rule" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入路径命名规则" value="{{ $default->get('path_naming_rule') }}">
</div>
<div class="col-span-6 sm:col-span-3">
<label for="file_naming_rule" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>文件命名规则</label>
<input type="text" name="configs[file_naming_rule]" id="file_naming_rule" autocomplete="file_naming_rule" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入文件命名规则" value="{{ $default->get(\App\Enums\GroupConfigKey::FileNamingRule) }}">
<input type="text" name="configs[file_naming_rule]" id="file_naming_rule" autocomplete="file_naming_rule" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入文件命名规则" value="{{ $default->get('file_naming_rule') }}">
</div>
<div class="col-span-6">
@ -86,7 +79,7 @@
<div class="col-span-6">
<x-fieldset title="允许上传的图片类型">
@foreach($default->get(\App\Enums\GroupConfigKey::AcceptedFileSuffixes) as $extension)
@foreach($default->get('accepted_file_suffixes') as $extension)
<x-fieldset-checkbox id="configs[accepted_file_suffixes]_{{ $extension }}" name="configs[accepted_file_suffixes][]" value="{{ $extension }}" checked>
{{ strtoupper($extension) }}
</x-fieldset-checkbox>
@ -98,7 +91,7 @@
<div data-tab="review" class="hidden grid grid-cols-6 gap-6">
<div class="col-span-6 mb-4">
<x-fieldset title="图片审核" faq="设置上传是否需要应用第三方审查,违规的图片会被标记为不健康的图片,或直接被删除。">
<x-switch id="configs[is_enable_review]" name="configs[is_enable_review]" value="1"></x-switch>
<x-switch id="configs[is_enable_scan]" name="configs[is_enable_scan]" value="1"></x-switch>
</x-fieldset>
</div>
<div class="col-span-6 mb-4">

View File

@ -1,5 +1,292 @@
<x-app-layout>
<div class="my-6 md:my-10">
edit
@include('admin.group.tips')
<div class="mt-5 md:mt-0 md:col-span-2">
<ul id="tabs" class="flex space-x-2 text-sm">
<li class="group">
<a data-target="basic" href="javascript:void(0)" class="block rounded-t-lg px-3 py-2 bg-white group-hover:bg-white">常规配置</a>
</li>
<li class="group">
<a data-target="review" href="javascript:void(0)" class="block rounded-t-lg px-3 py-2 bg-gray-200 group-hover:bg-white">图片审核</a>
</li>
<li class="group">
<a data-target="protection" href="javascript:void(0)" class="block rounded-t-lg px-3 py-2 bg-gray-200 group-hover:bg-white">原图保护</a>
</li>
<li class="group">
<a data-target="watermark" href="javascript:void(0)" class="block rounded-t-lg px-3 py-2 bg-gray-200 group-hover:bg-white">水印配置</a>
</li>
</ul>
<form action="{{ route('admin.group.update', ['id' => $group->id ?: '0']) }}" method="POST">
<div class="overflow-hidden rounded-md rounded-l-none">
<div class="px-4 py-5 bg-white sm:p-6">
<div data-tab="basic" class="grid grid-cols-6 gap-6">
<div class="col-span-6">
<label for="name" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>组名称</label>
@if($group->id == 0)
<input type="text" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md bg-gray-100" value="{{ $group->name }}" disabled readonly>
@else
<input type="text" name="name" id="name" autocomplete="name" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入组名称" value="{{ $group->name }}">
@endif
</div>
<div class="col-span-6">
<label for="maximum_file_size" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>最大文件大小(KB)</label>
<input type="number" name="configs[maximum_file_size]" id="maximum_file_size" autocomplete="maximum_file_size" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入上传文件的最大限制单位kb" value="{{ $group->configs['maximum_file_size'] }}">
</div>
<div class="col-span-6 sm:col-span-3">
<label for="concurrent_upload_num" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>并发上传限制</label>
<input type="number" name="configs[concurrent_upload_num]" id="concurrent_upload_num" autocomplete="concurrent_upload_num" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入并发上传数量" value="{{ $group->configs['concurrent_upload_num'] }}">
</div>
<div class="col-span-6 sm:col-span-3">
<label for="limit_per_minute" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>每分钟上传限制</label>
<input type="number" name="configs[limit_per_minute]" id="limit_per_minute" autocomplete="limit_per_minute" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入每分钟可以上传的图片数量" value="{{ $group->configs['limit_per_minute'] }}">
</div>
<div class="col-span-6 sm:col-span-3">
<label for="limit_per_hour" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>每小时上传限制</label>
<input type="number" name="configs[limit_per_hour]" id="limit_per_hour" autocomplete="limit_per_hour" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入每小时可以上传的图片数量" value="{{ $group->configs['limit_per_hour'] }}">
</div>
<div class="col-span-6 sm:col-span-3">
<label for="limit_per_day" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>每天上传限制</label>
<input type="number" name="configs[limit_per_day]" id="limit_per_day" autocomplete="limit_per_day" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入每天可以上传的图片数量" value="{{ $group->configs['limit_per_day'] }}">
</div>
<div class="col-span-6 sm:col-span-3">
<label for="limit_per_week" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>每周上传限制</label>
<input type="number" name="configs[limit_per_week]" id="limit_per_week" autocomplete="limit_per_week" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入每周可以上传的图片数量" value="{{ $group->configs['limit_per_week'] }}">
</div>
<div class="col-span-6 sm:col-span-3">
<label for="limit_per_month" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>每月上传限制</label>
<input type="number" name="configs[limit_per_month]" id="limit_per_month" autocomplete="limit_per_month" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入每月可以上传的图片数量" value="{{ $group->configs['limit_per_month'] }}">
</div>
<div class="col-span-6 sm:col-span-3">
<label for="path_naming_rule" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>路径命名规则</label>
<input type="text" name="configs[path_naming_rule]" id="path_naming_rule" autocomplete="path_naming_rule" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入路径命名规则" value="{{ $group->configs['path_naming_rule'] }}">
</div>
<div class="col-span-6 sm:col-span-3">
<label for="file_naming_rule" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>文件命名规则</label>
<input type="text" name="configs[file_naming_rule]" id="file_naming_rule" autocomplete="file_naming_rule" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入文件命名规则" value="{{ $group->configs['file_naming_rule'] }}">
</div>
@if($group->id)
<div class="col-span-6">
<x-fieldset title="是否默认" faq="设置默认后,新用户注册以后将会属于该默认角色组。">
<x-switch id="is_default" name="is_default" value="1" :checked="(bool)$group->is_default"></x-switch>
</x-fieldset>
</div>
@endif
<div class="col-span-6">
<x-fieldset title="允许上传的图片类型">
@foreach($default['accepted_file_suffixes'] as $extension)
<x-fieldset-checkbox id="configs[accepted_file_suffixes]_{{ $extension }}" name="configs[accepted_file_suffixes][]" value="{{ $extension }}" :checked="in_array($extension, $group->configs['accepted_file_suffixes'])">
{{ strtoupper($extension) }}
</x-fieldset-checkbox>
@endforeach
</x-fieldset>
</div>
</div>
<div data-tab="review" class="hidden grid grid-cols-6 gap-6">
<div class="col-span-6 mb-4">
<x-fieldset title="图片审核" faq="设置上传是否需要应用第三方审查,违规的图片会被标记为不健康的图片,或直接被删除。">
<x-switch id="configs[is_enable_scan]" name="configs[is_enable_scan]" value="1" :checked="(bool)$group->configs['is_enable_scan']"></x-switch>
</x-fieldset>
</div>
<div class="col-span-6 mb-4">
<x-fieldset title="审核动作">
<x-fieldset-radio id="configs[scanned_action]_mark" name="configs[scanned_action]" value="mark" :checked="$group->configs['scanned_action'] === 'mark'">标记为不健康</x-fieldset-radio>
<x-fieldset-radio id="configs[scanned_action]_delete" name="configs[scanned_action]" value="delete" :checked="$group->configs['scanned_action'] === 'delete'">直接删除</x-fieldset-radio>
</x-fieldset>
</div>
<div class="col-span-6 mb-4">
<x-fieldset title="审核驱动">
<x-fieldset-radio id="configs[scan_configs][driver]" name="configs[scan_configs][driver]" data-select="scan" value="aliyun" :checked="$group->configs['scan_configs']['driver'] === 'aliyun'">阿里云</x-fieldset-radio>
</x-fieldset>
</div>
<div class="hidden mb-4" data-scan-driver="aliyun">
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[scan_configs][drivers][aliyun][access_key_id]" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>AccessKeyId</label>
<input type="text" name="configs[scan_configs][drivers][aliyun][access_key_id]" id="configs[scan_configs][drivers][aliyun][access_key_id]" autocomplete="access_key_id" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入 AccessKeyId" value="{{ $group->configs['scan_configs']['drivers']['aliyun']['access_key_id'] }}">
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[scan_configs][drivers][aliyun][access_key_secret]" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>AccessKeySecret</label>
<input type="text" name="configs[scan_configs][drivers][aliyun][access_key_secret]" id="configs[scan_configs][drivers][aliyun][access_key_secret]" autocomplete="access_key_id" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入 AccessKeySecret" value="{{ $group->configs['scan_configs']['drivers']['aliyun']['access_key_secret'] }}">
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[scan_configs][drivers][aliyun][biz_type]" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>场景名称</label>
<input type="text" name="configs[scan_configs][drivers][aliyun][biz_type]" id="configs[scan_configs][drivers][aliyun][biz_type]" autocomplete="biz_type" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入业务场景名称" value="{{ $group->configs['scan_configs']['drivers']['aliyun']['biz_type'] }}">
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[scan_configs][drivers][aliyun][region_id]" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>地域节点</label>
<input type="text" name="configs[scan_configs][drivers][aliyun][region_id]" id="configs[scan_configs][drivers][aliyun][region_id]" autocomplete="region_id" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入地域节点例如cn-shanghai" value="{{ $group->configs['scan_configs']['drivers']['aliyun']['region_id'] }}">
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<x-fieldset title="审核场景">
@foreach($scanAliyunScenes as $key => $scene)
<x-fieldset-checkbox id="configs[scan_configs][drivers][aliyun][scenes][]_{{ $key }}" name="configs[scan_configs][drivers][aliyun][scenes][]" value="{{ $key }}" :checked="in_array($scene, $group->configs['scan_configs']['drivers']['aliyun']['scenes'])">{{ $scene }}</x-fieldset-checkbox>
@endforeach
</x-fieldset>
</div>
</div>
</div>
<div data-tab="protection" class="hidden grid grid-cols-6 gap-6">
<div class="col-span-6 mb-4">
<x-fieldset title="原图保护" faq="设置该角色组下的用户上传的图片是否应用原图保护功能,开启后图片<b>不返回直链</b>">
<x-switch id="configs[is_enable_original_protection]" name="configs[is_enable_original_protection]" value="1" :checked="(bool)$group->configs['is_enable_original_protection']"></x-switch>
</x-fieldset>
</div>
<div class="col-span-6 mb-4">
<label for="configs[image_cache_ttl]" class="block text-sm font-medium text-gray-700">图片缓存时间()</label>
<input type="number" name="configs[image_cache_ttl]" id="configs[image_cache_ttl]" autocomplete="image_cache_ttl" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入受保护图片的缓存时间不填或填0表示不缓存" value="{{ $group->configs['image_cache_ttl'] }}">
</div>
</div>
<div data-tab="watermark" class="hidden grid grid-cols-6 gap-6">
<p class="mb-3 text-red-600 text-sm"><i class="fas fa-exclamation"></i> 开启水印功能前请注意考虑图片版权问题。</p>
<div class="col-span-6 mb-4">
<x-fieldset title="开启水印" faq="请注意,水印功能仅在开启了「原图保护」功能的情况下生效。">
<x-switch id="configs[is_enable_watermark]" name="configs[is_enable_watermark]" value="1" :checked="(bool)$group->configs['is_enable_watermark']"></x-switch>
</x-fieldset>
<div class="col-span-6 mt-4 mb-4">
<x-fieldset title="水印类型">
<x-fieldset-radio id="configs[watermark_configs][driver]_font" name="configs[watermark_configs][driver]" data-select="watermark" value="font" :checked="$group->configs['watermark_configs']['driver'] === 'font'">文字水印</x-fieldset-radio>
<x-fieldset-radio id="configs[watermark_configs][driver]_image" name="configs[watermark_configs][driver]" data-select="watermark" value="image" :checked="$group->configs['watermark_configs']['driver'] === 'image'">图片水印</x-fieldset-radio>
</x-fieldset>
</div>
<div class="mb-4 hidden" data-watermark-driver="font">
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[watermark_configs][drivers][font][font]" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>字体文件</label>
<input type="text" name="configs[watermark_configs][drivers][font][font]" id="configs[watermark_configs][drivers][font][font]" autocomplete="text" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入字体文件路径例如fonts/lsky.ttf" value="{{ $group->configs['watermark_configs']['drivers']['font']['font'] }}">
<small class="text-yellow-500">请将下载的字体文件放置程序根目录的 storage/app/public 目录下</small>
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[watermark_configs][drivers][font][position]" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>水印位置</label>
<select id="configs[watermark_configs][drivers][font][position]" name="configs[watermark_configs][drivers][font][position]" autocomplete="position" class="mt-1 block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
@foreach($positions as $key => $position)
<option value="{{ $key }}" {{ $group->configs['watermark_configs']['drivers']['font']['position'] === $key ? 'selected' : '' }}>{{ $position }}</option>
@endforeach
</select>
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[watermark_configs][drivers][font][text]" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>水印文字</label>
<input type="text" name="configs[watermark_configs][drivers][font][text]" id="configs[watermark_configs][drivers][font][text]" autocomplete="text" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入水印文字" value="{{ $group->configs['watermark_configs']['drivers']['font']['text'] }}">
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[watermark_configs][drivers][font][color]" class="block text-sm font-medium text-gray-700">字体颜色</label>
<input type="text" name="configs[watermark_configs][drivers][font][color]" id="configs[watermark_configs][drivers][font][color]" autocomplete="color" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入字体颜色,例如:#ffffff" value="{{ $group->configs['watermark_configs']['drivers']['font']['color'] }}">
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[watermark_configs][drivers][font][size]" class="block text-sm font-medium text-gray-700">字体大小</label>
<input type="number" name="configs[watermark_configs][drivers][font][size]" id="configs[watermark_configs][drivers][font][size]" autocomplete="size" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入字体大小,默认 14" value="{{ $group->configs['watermark_configs']['drivers']['font']['size'] }}">
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[watermark_configs][drivers][font][angle]" class="block text-sm font-medium text-gray-700">旋转角度</label>
<input type="number" name="configs[watermark_configs][drivers][font][angle]" id="configs[watermark_configs][drivers][font][angle]" autocomplete="angle" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入旋转角度,默认 0可以为" value="{{ $group->configs['watermark_configs']['drivers']['font']['angle'] }}">
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[watermark_configs][drivers][font][x]" class="block text-sm font-medium text-gray-700">X轴偏移量</label>
<input type="number" name="configs[watermark_configs][drivers][font][x]" id="configs[watermark_configs][drivers][font][x]" autocomplete="x" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="X轴偏移量" value="{{ $group->configs['watermark_configs']['drivers']['font']['x'] }}">
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[watermark_configs][drivers][font][y]" class="block text-sm font-medium text-gray-700">Y轴偏移量</label>
<input type="number" name="configs[watermark_configs][drivers][font][y]" id="configs[watermark_configs][drivers][font][y]" autocomplete="y" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="Y轴偏移量" value="{{ $group->configs['watermark_configs']['drivers']['font']['y'] }}">
</div>
</div>
<div class="mb-4 hidden" data-watermark-driver="image">
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[watermark_configs][drivers][image][image]" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>水印图片</label>
<input type="text" name="configs[watermark_configs][drivers][image][image]" id="configs[watermark_configs][drivers][image][image]" autocomplete="image" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入水印路径例如images/lsky.png" value="{{ $group->configs['watermark_configs']['drivers']['image']['image'] }}">
<small class="text-yellow-500">请将水印图片放置程序根目录的 storage/app/public 目录下</small>
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[watermark_configs][drivers][image][position]" class="block text-sm font-medium text-gray-700"><span class="text-red-600">*</span>水印位置</label>
<select id="configs[watermark_configs][drivers][image][position]" name="configs[watermark_configs][drivers][image][position]" autocomplete="position" class="mt-1 block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
@foreach($positions as $key => $position)
<option value="{{ $key }}" {{ $group->configs['watermark_configs']['drivers']['image']['position'] === $key ? 'selected' : '' }}>{{ $position }}</option>
@endforeach
</select>
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[watermark_configs][drivers][image][width]" class="block text-sm font-medium text-gray-700">图片宽度</label>
<input type="number" name="configs[watermark_configs][drivers][image][width]" id="configs[watermark_configs][drivers][image][width]" autocomplete="width" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入水印图片宽度" value="{{ $group->configs['watermark_configs']['drivers']['image']['width'] }}">
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[watermark_configs][drivers][image][height]" class="block text-sm font-medium text-gray-700">图片高度</label>
<input type="number" name="configs[watermark_configs][drivers][image][height]" id="configs[watermark_configs][drivers][image][height]" autocomplete="height" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入水印图片高度" value="{{ $group->configs['watermark_configs']['drivers']['image']['height'] }}">
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[watermark_configs][drivers][image][opacity]" class="block text-sm font-medium text-gray-700">不透明度</label>
<input type="number" name="configs[watermark_configs][drivers][image][opacity]" id="configs[watermark_configs][drivers][image][opacity]" autocomplete="opacity" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入不透明度,取值 0 - 100" value="{{ $group->configs['watermark_configs']['drivers']['image']['opacity'] }}">
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[watermark_configs][drivers][image][rotate]" class="block text-sm font-medium text-gray-700">旋转角度</label>
<input type="number" name="configs[watermark_configs][drivers][image][rotate]" id="configs[watermark_configs][drivers][image][rotate]" autocomplete="rotate" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="请输入旋转角度,默认 0" value="{{ $group->configs['watermark_configs']['drivers']['image']['rotate'] }}">
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[watermark_configs][drivers][image][x]" class="block text-sm font-medium text-gray-700">X轴偏移量</label>
<input type="number" name="configs[watermark_configs][drivers][image][x]" id="configs[watermark_configs][drivers][image][x]" autocomplete="x" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="X轴偏移量" value="{{ $group->configs['watermark_configs']['drivers']['image']['x'] }}">
</div>
<div class="col-span-6 sm:col-span-3 mb-4">
<label for="configs[watermark_configs][drivers][image][y]" class="block text-sm font-medium text-gray-700">Y轴偏移量</label>
<input type="number" name="configs[watermark_configs][drivers][image][y]" id="configs[watermark_configs][drivers][image][y]" autocomplete="y" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" placeholder="Y轴偏移量" value="{{ $group->configs['watermark_configs']['drivers']['image']['y'] }}">
</div>
</div>
</div>
</div>
</div>
<div class="px-4 py-3 bg-gray-50 text-right sm:px-6">
<x-button type="button" class="bg-gray-500" onclick="history.go(-1)">取消</x-button>
<x-button>确认创建</x-button>
</div>
</div>
</form>
</div>
</div>
@push('scripts')
<script>
// tabs select
$('[data-target]').click(function () {
$('[data-tab]').hide();
$('[data-target]').removeClass('bg-white').addClass('bg-gray-200');
$(`[data-tab=${$(this).data('target')}]`).show();
$(this).removeClass('bg-gray-200').addClass('bg-white');
});
// 设置选中驱动
let setSelected = function () {
$('[data-select]').each(function () {
$(`[data-${$(this).data('select')}-driver=${$(this).val()}]`)[this.checked ? 'show' : 'hide']();
});
};
setSelected();
$('[data-select]').click(function () {
setSelected();
});
$('form').submit(function (e) {
e.preventDefault();
axios.put(this.action, $(this).serialize()).then(response => {
if (response.data.status) {
toastr.success(response.data.message);
} else {
toastr.error(response.data.message);
}
});
});
</script>
@endpush
</x-app-layout>

View File

@ -10,6 +10,16 @@
</div>
<x-table :columns="['ID', '名称', '是否默认', '用户数量', '策略数量', '操作']">
<tr data-id="0">
<td class="px-6 py-4 whitespace-nowrap">-</td>
<td class="px-6 py-4 whitespace-nowrap name">系统默认组</td>
<td class="px-6 py-4 whitespace-nowrap">-</td>
<td class="px-6 py-4 whitespace-nowrap">-</td>
<td class="px-6 py-4 whitespace-nowrap">-</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium space-x-2">
<a href="{{ route('admin.group.edit', ['id' => 0]) }}" class="text-indigo-600 hover:text-indigo-900">编辑</a>
</td>
</tr>
@foreach($groups as $group)
<tr data-id="{{ $group->id }}">
<td class="px-6 py-4 whitespace-nowrap">{{ $group->id }}</td>

View File

@ -0,0 +1,8 @@
@if(! ini_get('file_uploads'))
<p class="bg-red-500 p-2 mb-2 rounded text-sm text-white">
<i class="fas fa-exclamation-circle"></i> 当前系统监测到运行环境关闭了 HTTP 上传文件权限(file_uploads=off),请更改 PHP 此项配置,否则无法上传文件。
</p>
@endif
<p class="bg-yellow-500 p-2 mb-4 rounded text-sm text-white">
<i class="fas fa-exclamation-circle"></i> 系统运行环境允许上传大小的最大值为 {{ ini_get('upload_max_filesize') }},最大 POST 数据大小为 {{ ini_get('post_max_size') }},上传文件大小不得超过这两项配置值。
</p>

View File

@ -1,4 +1,4 @@
<div class="flex items-center h-5 space-x-2 mr-4">
<input type="checkbox" {{ $attributes->merge(['name' => $name, 'class' => 'focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded']) }}>
<input type="checkbox" {{ $attributes->merge(['name' => $name, 'class' => 'focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded']) }}/>
<label {{ isset($id) ? "for={$id}" : '' }} class="font-medium text-sm text-gray-700">{{ $slot }}</label>
</div>