v2.3更新
This commit is contained in:
@@ -64,7 +64,7 @@ $apiResponse = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
if ($httpCode !== 200 || empty($apiResponse)) {
|
||||
if (empty($apiResponse)) {
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
@@ -75,15 +75,28 @@ if ($httpCode !== 200 || empty($apiResponse)) {
|
||||
}
|
||||
|
||||
$result = json_decode($apiResponse, true);
|
||||
if (!$result || !isset($result['success']) || !$result['success']) {
|
||||
if (!$result) {
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'version' => $stepVersion,
|
||||
'error' => $result['message'] ?? '升级失败'
|
||||
'error' => '升级服务返回数据格式错误'
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
|
||||
// 后端返回非200或 success=false 时,提取实际错误信息
|
||||
if ($httpCode !== 200 || !isset($result['success']) || !$result['success']) {
|
||||
$errorMsg = $result['message'] ?? ($result['error'] ?? '升级失败');
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'version' => $stepVersion,
|
||||
'error' => $errorMsg
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
|
||||
// 转发后端返回的数据
|
||||
echo json_encode($result['data']);
|
||||
$data = $result['data'] ?? [];
|
||||
echo json_encode($data);
|
||||
|
||||
Reference in New Issue
Block a user