moshaorui 2 ماه پیش
والد
کامیت
ba5b333b40
2فایلهای تغییر یافته به همراه5 افزوده شده و 3 حذف شده
  1. 4 2
      app/Http/Controllers/HomeController.php
  2. 1 1
      public/static/js/script.js

+ 4 - 2
app/Http/Controllers/HomeController.php

@@ -212,6 +212,7 @@ class HomeController extends Controller
 
         // Validate the URL
         if (filter_var($imageUrl, FILTER_VALIDATE_URL) === false) {
+            Session::put('downloadAllStatus', '2');
             return response()->json(['error' => 'Invalid URL'], 400);
         }
 
@@ -229,6 +230,7 @@ class HomeController extends Controller
             $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
             if ($httpCode !== 200) {
+                Session::put('downloadAllStatus', '2');
                 return response()->json(['error' => 'Failed to download image'], 500);
             }
 
@@ -237,13 +239,13 @@ class HomeController extends Controller
             // Generate a random filename
             $fileName = Str::random(32) . '.jpg';
 
-            Session::put('downloadAllStatus', '0');
+            Session::put('downloadAllStatus', '2');
             // Return the image as a download
             return response($imageContent)
                 ->header('Content-Type', 'image/jpeg')
                 ->header('Content-Disposition', 'attachment; filename="' . $fileName . '"');
         } catch (\Exception $e) {
-            Session::put('downloadAllStatus', '0');
+            Session::put('downloadAllStatus', '2');
             return response()->json(['error' => 'Error downloading image: ' . $e->getMessage()], 500);
         }
     }

+ 1 - 1
public/static/js/script.js

@@ -262,7 +262,7 @@ $(document).ready(function() {
                 dataType: 'json',
                 success: function(response) {
                     console.log(response);
-                    if (response.status == 0) {
+                    if (response.status == 0 || response.status == 2) {
                         clearInterval(intervalId);
                         layer.close(loadIndex); // 关闭加载层
                     }