From 537a77dcfdc3a52e34796dd7d270d65fbbf704cd Mon Sep 17 00:00:00 2001 From: lq Date: Tue, 17 Jun 2025 16:45:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E7=9B=B8=E5=86=8C=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/ImageController.php | 1 + resources/views/compress.blade.php | 872 ----------------------- resources/views/upload.blade.php | 384 ++++++++++ routes/web.php | 17 +- 4 files changed, 391 insertions(+), 883 deletions(-) delete mode 100644 resources/views/compress.blade.php create mode 100644 resources/views/upload.blade.php diff --git a/app/Http/Controllers/ImageController.php b/app/Http/Controllers/ImageController.php index 6635738e..94041d16 100644 --- a/app/Http/Controllers/ImageController.php +++ b/app/Http/Controllers/ImageController.php @@ -14,6 +14,7 @@ class ImageController extends Controller $image = request()->file('image'); $pid = request()->post('pid'); +// return $image; return new ImageService()->processImage($image, $pid); } } diff --git a/resources/views/compress.blade.php b/resources/views/compress.blade.php deleted file mode 100644 index 70f94008..00000000 --- a/resources/views/compress.blade.php +++ /dev/null @@ -1,872 +0,0 @@ - - - - - - 图片压缩工具 - - - - -
-
- -
-

批量压缩并替换图片文件

-
-
- -
- - -
-
-
-

原始图片

-
-
-
-
- -

请从左侧选择一张图片

-
-
-
-
-
文件大小
-
0 KB
-
-
-
分辨率
-
0×0
-
-
-
-
- -
-
-

压缩后图片

-
-
-
-
- -

压缩后图片将显示在这里

-
-
-
-
-
文件大小
-
0 KB
-
-
-
分辨率
-
0×0
-
-
-
- 尺寸减少:0% -
-
-
- - -
-
-

批量压缩进度

-
-
-
- -

批量压缩状态将显示在这里

-
- - - -
- -

压缩完成!所有文件已更新

-
-
-
-
-
-
- - -
-
-

确认批量操作

-

- 您将压缩 0 个文件,覆盖其原始文件。
- 此操作不可逆,请确保您已备份重要文件。 -

-
- - -
-
-
- - - - diff --git a/resources/views/upload.blade.php b/resources/views/upload.blade.php new file mode 100644 index 00000000..2d4815c7 --- /dev/null +++ b/resources/views/upload.blade.php @@ -0,0 +1,384 @@ + + + + + + 图片上传 | Laravel相册 - 暗色主题 + + + + + + + + +
+ + + + +
+ +
+

上传新图片

+

选择相册并上传图片(支持拖拽排序)

+
+ + +
+ +
+
+
+

@{{ current }} / @{{ totalUpload }}上传中...

+

请稍候,正在上传图片

+
+
+ + +
+ + +
+ + +
+
+ + +
+ +

拖放图片到这里

+

+ +

支持 JPG, PNG 格式,最大 10MB

+
+
+ +
+
+
+ + +
+
+

已选图片 @{{ images.length }}

+
+ +
+
+ +
+
+ + +
+ +
+ + + + + + + + + +
+

@{{ image.file.name }}

+

@{{ formatFileSize(image.file.size) }}

+
+ + +
+ @{{ index + 1 }} +
+
+
+ +
+
+ 提示:拖拽图片左上角的 可以调整顺序 +
+ +
+
+
+
+ + + +
+ +
+
上传成功!
+
成功上传 @{{ uploadedCount }} 张图片
+
+ +
+
+ + +
+

Laravel 12.x 图片上传系统 © 2023 | 暗色主题

+
+
+ + + + diff --git a/routes/web.php b/routes/web.php index 65dabd9f..ca8b154c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -24,11 +24,7 @@ Route::get('/o', function () { foreach ($photoAlbum as $album) { $album->url = \Illuminate\Support\Facades\Storage::url($album->url); $album->created_at = date('Y-m-d', $album->created_at); - foreach ($album['photos'] as &$photo) { - $photo->original = \Illuminate\Support\Facades\Storage::url($photo->original); - $photo->compressed = \Illuminate\Support\Facades\Storage::url($photo->compressed); - $photo->watermarked = \Illuminate\Support\Facades\Storage::url($photo->watermarked); - } + $album->count = count($album['photos']); } // exit(json_encode($photoAlbum)); return view('o-index', [ @@ -43,10 +39,6 @@ Route::get('/detail', function () { $photoAlbum->url = \Illuminate\Support\Facades\Storage::url($photoAlbum->url); $photoAlbum->created_at = date('Y-m-d', $photoAlbum->created_at); foreach ($photoAlbum['photos'] as $index => &$photo) { -// if ($index > 5) { -// unset($photoAlbum['photos'][$index]); -// continue; -// } $photo->original = \Illuminate\Support\Facades\Storage::url($photo->original); $photo->compressed = \Illuminate\Support\Facades\Storage::url($photo->compressed); $photo->watermarked = \Illuminate\Support\Facades\Storage::url($photo->watermarked); @@ -57,7 +49,10 @@ Route::get('/detail', function () { 'photo_album' => $photoAlbum, ]); }); -Route::get('/images/compress', function() { - return view('compress'); +Route::get('/upload', function() { + $photoAlbum = \App\Models\PhotoAlbumModel::with('photos')->get(); + return view('upload',[ + 'photo_album' => $photoAlbum, + ]); }); Route::post('/upload', [\App\Http\Controllers\ImageController::class, 'upload']);