diff --git a/app/Models/User.php b/app/Models/User.php index 1d79845d..62c2c0c1 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -4,6 +4,7 @@ namespace App\Models; use App\Enums\ConfigKey; use App\Enums\ImagePermission; +use App\Enums\PastedAction; use App\Enums\UserConfigKey; use App\Utils; use Carbon\Carbon; @@ -100,13 +101,7 @@ class User extends Authenticatable implements MustVerifyEmail $user->group_id = Group::query()->where('is_default', true)->value('id'); // 初始容量 $user->capacity = Utils::config(ConfigKey::UserInitialCapacity); - - $user->configs = collect([ - UserConfigKey::DefaultAlbum => 0, - UserConfigKey::DefaultStrategy => 0, - UserConfigKey::DefaultPermission => ImagePermission::Private, - UserConfigKey::IsAutoClearPreview => false, - ])->merge($user->configs ?: []); + $user->configs = collect(config('convention.app.user'))->merge($user->configs ?: []); }); } diff --git a/config/convention.php b/config/convention.php index ddfe900e..b1cb161d 100644 --- a/config/convention.php +++ b/config/convention.php @@ -4,9 +4,12 @@ use App\Enums\ConfigKey; use App\Enums\GroupConfigKey; +use App\Enums\ImagePermission; use App\Enums\Mail\SmtpOption; +use App\Enums\PastedAction; use App\Enums\Scan\AliyunOption; use App\Enums\Scan\TencentOption; +use App\Enums\UserConfigKey; use App\Enums\Watermark\FontOption; use App\Enums\Watermark\ImageOption; @@ -38,66 +41,73 @@ return [ ] ], ], - ConfigKey::Group => [ - GroupConfigKey::MaximumFileSize => 5120, - GroupConfigKey::ConcurrentUploadNum => 3, - GroupConfigKey::IsEnableScan => 0, - GroupConfigKey::IsEnableWatermark => 0, - GroupConfigKey::IsEnableOriginalProtection => 0, - GroupConfigKey::ScannedAction => 'mark', // in mark or delete - GroupConfigKey::ScanConfigs => [ - 'driver' => 'tencent', - 'drivers' => [ - 'tencent' => [ - TencentOption::Endpoint => 'ims.tencentcloudapi.com', - TencentOption::SecretId => '', - TencentOption::SecretKey => '', - TencentOption::Region => '', - TencentOption::BizType => '' - ], - 'aliyun' => [ - AliyunOption::AccessKeyId => '', - AliyunOption::AccessKeySecret => '', - AliyunOption::RegionId => '', - AliyunOption::Scenes => ['porn'], - AliyunOption::BizType => '', - ], - ], - ], - GroupConfigKey::WatermarkConfigs => [ - 'driver' => 'font', - 'drivers' => [ - 'font' => [ - FontOption::Text => 'Lsky Pro', - FontOption::Position => 'bottom-right', - FontOption::Angle => 0, - FontOption::Size => 50, - FontOption::Font => '', - FontOption::Color => '#000000', - FontOption::X => 10, - FontOption::Y => 10, - ], - 'image' => [ - ImageOption::Image => '', - ImageOption::Position => 'bottom-right', - ImageOption::Opacity => 100, - ImageOption::Rotate => 0, - ImageOption::Width => 0, - ImageOption::Height => 0, - ImageOption::X => 10, - ImageOption::Y => 10, - ] - ], - ], - GroupConfigKey::LimitPerMinute => 20, - GroupConfigKey::LimitPerHour => 100, - GroupConfigKey::LimitPerDay => 300, - GroupConfigKey::LimitPerWeek => 600, - GroupConfigKey::LimitPerMonth => 999, - GroupConfigKey::AcceptedFileSuffixes => ['jpeg', 'jpg', 'png', 'gif', 'tif', 'bmp', 'ico', 'psd', 'webp'], - GroupConfigKey::PathNamingRule => '{Y}/{m}/{d}', - GroupConfigKey::FileNamingRule => '{uniqid}', - GroupConfigKey::ImageCacheTtl => 2626560, - ], ], + 'group' => [ + GroupConfigKey::MaximumFileSize => 5120, + GroupConfigKey::ConcurrentUploadNum => 3, + GroupConfigKey::IsEnableScan => 0, + GroupConfigKey::IsEnableWatermark => 0, + GroupConfigKey::IsEnableOriginalProtection => 0, + GroupConfigKey::ScannedAction => 'mark', // in mark or delete + GroupConfigKey::ScanConfigs => [ + 'driver' => 'tencent', + 'drivers' => [ + 'tencent' => [ + TencentOption::Endpoint => 'ims.tencentcloudapi.com', + TencentOption::SecretId => '', + TencentOption::SecretKey => '', + TencentOption::Region => '', + TencentOption::BizType => '' + ], + 'aliyun' => [ + AliyunOption::AccessKeyId => '', + AliyunOption::AccessKeySecret => '', + AliyunOption::RegionId => '', + AliyunOption::Scenes => ['porn'], + AliyunOption::BizType => '', + ], + ], + ], + GroupConfigKey::WatermarkConfigs => [ + 'driver' => 'font', + 'drivers' => [ + 'font' => [ + FontOption::Text => 'Lsky Pro', + FontOption::Position => 'bottom-right', + FontOption::Angle => 0, + FontOption::Size => 50, + FontOption::Font => '', + FontOption::Color => '#000000', + FontOption::X => 10, + FontOption::Y => 10, + ], + 'image' => [ + ImageOption::Image => '', + ImageOption::Position => 'bottom-right', + ImageOption::Opacity => 100, + ImageOption::Rotate => 0, + ImageOption::Width => 0, + ImageOption::Height => 0, + ImageOption::X => 10, + ImageOption::Y => 10, + ] + ], + ], + GroupConfigKey::LimitPerMinute => 20, + GroupConfigKey::LimitPerHour => 100, + GroupConfigKey::LimitPerDay => 300, + GroupConfigKey::LimitPerWeek => 600, + GroupConfigKey::LimitPerMonth => 999, + GroupConfigKey::AcceptedFileSuffixes => ['jpeg', 'jpg', 'png', 'gif', 'tif', 'bmp', 'ico', 'psd', 'webp'], + GroupConfigKey::PathNamingRule => '{Y}/{m}/{d}', + GroupConfigKey::FileNamingRule => '{uniqid}', + GroupConfigKey::ImageCacheTtl => 2626560, + ], + 'user' => [ + UserConfigKey::DefaultAlbum => 0, + UserConfigKey::DefaultStrategy => 0, + UserConfigKey::DefaultPermission => ImagePermission::Private, + UserConfigKey::PastedAction => PastedAction::Waiting, + UserConfigKey::IsAutoClearPreview => false, + ] ]; diff --git a/database/seeders/InstallSeeder.php b/database/seeders/InstallSeeder.php index d846a041..9f83d2fa 100644 --- a/database/seeders/InstallSeeder.php +++ b/database/seeders/InstallSeeder.php @@ -19,9 +19,7 @@ class InstallSeeder extends Seeder public function run() { $date = Carbon::now()->format('Y-m-d H:i:s'); - $array = collect(config('convention.app'))->except([ - ConfigKey::Group, - ])->transform(function ($value, $key) use ($date) { + $array = collect(config('convention.app'))->transform(function ($value, $key) use ($date) { return [ 'name' => $key, 'value' => is_array($value) ? json_encode($value, JSON_UNESCAPED_UNICODE) : $value,