更新功能:数据字典和定时任务

This commit is contained in:
2026-02-18 10:43:25 +08:00
parent 6623c656f4
commit 790b3140a7
15 changed files with 2847 additions and 25 deletions

View File

@@ -5,7 +5,8 @@ namespace App\Services\System;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Intervention\Image\Facades\Image;
use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Gd\Driver;
class UploadService
{
@@ -17,6 +18,7 @@ class UploadService
public function __construct()
{
$this->disk = Storage::disk('public');
$this->imageManager = new ImageManager(new Driver());
}
public function upload(UploadedFile $file, string $directory = 'uploads', array $options = []): array
@@ -135,17 +137,14 @@ class UploadService
$width = $options['width'] ?? null;
$height = $options['height'] ?? null;
$image = Image::make($file);
$image = $this->imageManager->read($file);
if ($width || $height) {
$image->resize($width, $height, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
$image->scale($width, $height);
}
$image->encode(null, $quality);
$this->disk->put($filePath, (string) $image);
$encoded = $image->toJpeg(quality: $quality);
$this->disk->put($filePath, (string) $encoded);
}
public function getFileUrl(string $path): string