From 3ab5787c262bef9aded38d1c841bf9877f2dee0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BF=97=E5=BC=BA?= <357099073@qq.com> Date: Mon, 26 May 2025 16:01:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8B=E8=BD=BD=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=A4=B1=E6=95=88game?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/view/game/detail.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/index/view/game/detail.php b/app/index/view/game/detail.php index 01fa502..52f6dda 100644 --- a/app/index/view/game/detail.php +++ b/app/index/view/game/detail.php @@ -202,12 +202,19 @@ 'X-Requested-With': 'XMLHttpRequest' } }) - .then(response => response.json()) + .then(response => { + if (!response.ok) { + throw new Error('网络响应失败'); + } + return response.json(); + }) .then(data => { if (data.code === 1) { const downloadsElement = document.getElementById('gameDownloads'); - let downloads = parseInt(downloadsElement.textContent); - downloadsElement.textContent = downloads + 1; + if (downloadsElement) { + let downloads = parseInt(downloadsElement.textContent); + downloadsElement.textContent = downloads + 1; + } // 直接使用返回的URL if (data.data && data.data.url) {