This commit is contained in:
Wisp X 2022-03-23 17:27:51 +08:00
parent 979b628f59
commit df2ed46ab2
3 changed files with 74 additions and 71 deletions

View File

@ -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 ?: []);
});
}

View File

@ -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,
]
];

View File

@ -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,