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']; }