css
Some checks failed
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled

This commit is contained in:
zhongjy001
2026-02-14 02:28:10 +08:00
parent a16d73af0a
commit 4c9790d140
5 changed files with 1212 additions and 1213 deletions

View File

@@ -156,6 +156,6 @@ class AuthController extends Controller
private function loginRateLimiterKey(Request $request, string $username): string
{
return Str::lower($username).'|'.$request->ip();
return Str::lower($username) . '|' . $request->ip();
}
}

View File

@@ -42,7 +42,7 @@ class UploadController extends Controller
public function markdownImage(Request $request): JsonResponse
{
$validated = $request->validate([
'image' => ['required', 'file', 'image', 'mimes:jpg,jpeg,png,webp,gif', 'max:'.self::MAX_FILE_KB],
'image' => ['required', 'file', 'image', 'mimes:jpg,jpeg,png,webp,gif', 'max:' . self::MAX_FILE_KB],
], [
'image.required' => '请选择要上传的图片。',
'image.image' => '仅支持图片文件上传。',
@@ -77,22 +77,22 @@ class UploadController extends Controller
$thumbBinary = $this->encodeWebp($thumbImage, self::THUMB_WEBP_QUALITY);
$subDir = now()->format('Y/m/d');
$baseName = now()->format('YmdHis').'-'.Str::lower(Str::random(8));
$baseName = now()->format('YmdHis') . '-' . Str::lower(Str::random(8));
$mainPath = "markdown-images/{$subDir}/{$baseName}.webp";
$thumbPath = "markdown-images/{$subDir}/{$baseName}_thumb.webp";
Storage::disk('public')->put($mainPath, $mainBinary);
Storage::disk('public')->put($thumbPath, $thumbBinary);
$mainUrl = '/storage/'.ltrim($mainPath, '/');
$thumbUrl = '/storage/'.ltrim($thumbPath, '/');
$mainUrl = '/storage/' . ltrim($mainPath, '/');
$thumbUrl = '/storage/' . ltrim($thumbPath, '/');
return response()->json([
'success' => true,
'url' => $mainUrl,
'thumb_url' => $thumbUrl,
'filename' => basename($mainPath),
'markdown' => '![]('.$mainUrl.')',
'markdown' => '![](' . $mainUrl . ')',
]);
} catch (Throwable $exception) {
report($exception);