优化后台图片管理器性能

This commit is contained in:
Edward Yang 2023-01-11 19:40:22 +08:00
parent 5919f0d971
commit 71ab7a5da8
1 changed files with 10 additions and 4 deletions

View File

@ -77,8 +77,14 @@ class FileManagerService
$page = $page > 0 ? $page : 1;
$imageCollection = collect($images);
$currentImages = $imageCollection->forPage($page, $perPage);
$currentImages = $currentImages->map(function ($item) {
$item['url'] = image_resize("{$item['path']}");
return $item;
});
return [
'images' => $imageCollection->forPage($page, $perPage)->values()->toArray(),
'images' => $currentImages->values(),
'image_total' => $imageCollection->count(),
'image_page' => $page,
];
@ -203,11 +209,11 @@ class FileManagerService
*/
private function handleImage($filePath, $baseName): array
{
$path = "catalog{$filePath}";
return [
'path' => 'catalog' . $filePath,
'path' => $path,
'name' => $baseName,
'url' => image_resize("catalog{$filePath}"),
'origin_url' => image_origin("catalog{$filePath}"),
'origin_url' => image_origin($path),
'selected' => false,
];
}