From 68d9858dce4952bae453325030a69ca613720bd7 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Thu, 29 May 2025 19:18:23 +0700 Subject: [PATCH] try plugin listAllFromRemote error --- app/Models/PluginStore.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/app/Models/PluginStore.php b/app/Models/PluginStore.php index ac7aa539..2873810d 100644 --- a/app/Models/PluginStore.php +++ b/app/Models/PluginStore.php @@ -104,20 +104,25 @@ class PluginStore extends Model private static function listAllFromRemote() { - $response = Http::get(self::PLUGIN_LIST_API); - if ($response->getStatusCode() != 200) { - do_log(sprintf("status code: %d, body: %s", $response->getStatusCode(), $response->getBody()), 'error'); - return []; - } - $list = $response->json(); - foreach ($list as &$row) { - foreach ($row as $key => $value) { - if (is_array($value)) { - $row[$key] = json_encode($value); + try { + $response = Http::get(self::PLUGIN_LIST_API); + if ($response->getStatusCode() != 200) { + do_log(sprintf("status code: %d, body: %s", $response->getStatusCode(), $response->getBody()), 'error'); + return []; + } + $list = $response->json(); + foreach ($list as &$row) { + foreach ($row as $key => $value) { + if (is_array($value)) { + $row[$key] = json_encode($value); + } } } + return $list; + } catch (\Exception $e) { + do_log(sprintf("listAllFromRemote from: %s error: %s", self::PLUGIN_LIST_API, $e->getMessage()), 'error'); + return []; } - return $list; } public static function getHasNewVersionCount(): int