From 5662f86aae7c83fe1aef3d1f33b245e5e0311a4a Mon Sep 17 00:00:00 2001 From: Wisp X Date: Sat, 22 Jan 2022 13:16:15 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E8=A7=92=E8=89=B2=E7=BB=84?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Admin/GroupController.php | 11 +- app/Http/Requests/Admin/GroupRequest.php | 10 +- config/convention.php | 2 +- resources/views/admin/group/add.blade.php | 31 +- resources/views/admin/group/edit.blade.php | 289 +++++++++++++++++- resources/views/admin/group/index.blade.php | 10 + resources/views/admin/group/tips.blade.php | 8 + .../components/fieldset-checkbox.blade.php | 2 +- 8 files changed, 335 insertions(+), 28 deletions(-) create mode 100644 resources/views/admin/group/tips.blade.php diff --git a/app/Http/Controllers/Admin/GroupController.php b/app/Http/Controllers/Admin/GroupController.php index c33b3a69..d0bb238a 100644 --- a/app/Http/Controllers/Admin/GroupController.php +++ b/app/Http/Controllers/Admin/GroupController.php @@ -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')); } diff --git a/app/Http/Requests/Admin/GroupRequest.php b/app/Http/Requests/Admin/GroupRequest.php index 957d0469..6b970b86 100644 --- a/app/Http/Requests/Admin/GroupRequest.php +++ b/app/Http/Requests/Admin/GroupRequest.php @@ -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', diff --git a/config/convention.php b/config/convention.php index dd505b44..9b432687 100644 --- a/config/convention.php +++ b/config/convention.php @@ -42,7 +42,7 @@ return [ GroupConfigKey::ScanConfigs => [ 'driver' => 'aliyun', 'drivers' => [ - 'aluyun' => [ + 'aliyun' => [ AliyunOption::AccessKeyId => '', AliyunOption::AccessKeySecret => '', AliyunOption::RegionId => '', diff --git a/resources/views/admin/group/add.blade.php b/resources/views/admin/group/add.blade.php index 3282e9a2..5e97082a 100644 --- a/resources/views/admin/group/add.blade.php +++ b/resources/views/admin/group/add.blade.php @@ -1,13 +1,6 @@
- @if(! ini_get('file_uploads')) -

- 系统监测到运行环境关闭了 HTTP 上传文件权限(file_uploads=off),请更改 PHP 此项配置,否则无法上传文件。 -

- @endif -

- 系统运行环境允许上传大小的最大值为 {{ ini_get('upload_max_filesize') }},最大 POST 数据大小为 {{ ini_get('post_max_size') }},上传文件大小不得超过这两项配置值。 -

+ @include('admin.group.tips')
    @@ -35,47 +28,47 @@
    - +
    - +
    - +
    - +
    - +
    - +
    - +
    - +
    - +
    @@ -86,7 +79,7 @@
    - @foreach($default->get(\App\Enums\GroupConfigKey::AcceptedFileSuffixes) as $extension) + @foreach($default->get('accepted_file_suffixes') as $extension) {{ strtoupper($extension) }} @@ -98,7 +91,7 @@