From 3933733309beca10e1ad4b57d7a41b7672e9b51a Mon Sep 17 00:00:00 2001 From: ypsdf1 Date: Wed, 25 Nov 2026 13:44:49 +0800 Subject: [PATCH] =?UTF-8?q?15m44p=20=E5=B7=A5=E5=8D=95=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E8=A7=86=E5=9B=BE=E8=A7=A3=E7=A0=81=20images?= =?UTF-8?q?=20+=20GitHub=20=E5=85=B3=20issue=20=E5=B8=A6=20state=5Freason?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - api/ticket.php: ticketMyList/ticketListAll 返回前 decodeTicketImages 把 images JSON 串解码成数组(与 ticketDetail 对齐)。旧版列表给前端的是字符串, applyTicketImgs(desc, t.images) 收字符串导致 [图片N] 占位符替换不到、 @gh: 附件名渲染不出来(用户实测'附件还是不对'根因)。 - gh_api.php: ghSyncClose 关 issue 加 state_reason——完结→completed(GitHub 显示 done)、驳回→not_planned(显示 not planned)。旧版只传 state=closed 不带 reason, GitHub 不会改成 done/not-planned 语义。 --- api/ticket.php | 7 +++++++ gh_api.php | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/api/ticket.php b/api/ticket.php index 8a4adf8..5f1057b 100644 --- a/api/ticket.php +++ b/api/ticket.php @@ -593,6 +593,11 @@ function ticketMyList() { $list = []; while ($row = $result->fetchArray(SQLITE3_ASSOC)) { + // ★ 15m44p: 列表视图 images 必须解码成数组,与 ticketDetail 对齐。 + // 旧版列表直接返回原始 JSON 字符串,前端 applyTicketImgs(desc, images) + // 收到的是字符串而非数组 → [图片N] 占位符替换不到、@gh: 附件名渲染不出来 + // (用户实测「附件还是不对」的根因)。 + $row['images'] = decodeTicketImages(isset($row['images']) ? $row['images'] : null); $list[] = $row; } @@ -796,6 +801,8 @@ function ticketListAll() { $list = []; while ($row = $result->fetchArray(SQLITE3_ASSOC)) { + // ★ 15m44p: 列表视图 images 必须解码成数组(同 ticketMyList),与 ticketDetail 对齐 + $row['images'] = decodeTicketImages(isset($row['images']) ? $row['images'] : null); $list[] = $row; } diff --git a/gh_api.php b/gh_api.php index 160f273..2dfc4ca 100644 --- a/gh_api.php +++ b/gh_api.php @@ -199,9 +199,13 @@ function ghSyncClose($ticketId, $kind, $token, $sender = 'admin') { $closeComment = ($kind === 'completed') ? GH_TICKET_PREFIX . $ticketId . '][' . $sender . '] ✅ 工单已完结' : GH_TICKET_PREFIX . $ticketId . '][' . $sender . '] 🚫 工单已驳回'; - // 先评论(留痕)再关 issue + // 先评论(留痕) ghApiRequest('POST', '/repos/' . $repo . '/issues/' . $issueNo . '/comments', ['body' => $closeComment], $token); - $r = ghApiRequest('POST', '/repos/' . $repo . '/issues/' . $issueNo . '/close', ['state' => 'closed'], $token); + // ★ 15m44p: 关 issue 带 state_reason —— 完结→completed(GitHub显示done) / 驳回→not_planned(显示not planned) + // 旧版只传 state=closed 没带 reason,GitHub 不会改成 done/not-planned 语义。 + $stateReason = ($kind === 'rejected') ? 'not_planned' : 'completed'; + $r = ghApiRequest('POST', '/repos/' . $repo . '/issues/' . $issueNo . '/close', + ['state' => 'closed', 'state_reason' => $stateReason], $token); if (!$r['ok']) ghLog('close issue #' . $issueNo . ' failed: ' . $r['msg']); return $r['ok']; }