From 8543f8e5734dabe8cf7a8efc71eadaf876daa0a3 Mon Sep 17 00:00:00 2001 From: ypsdf1 Date: Wed, 25 Nov 2026 16:42:57 +0800 Subject: [PATCH] =?UTF-8?q?15m44v=20=E9=99=84=E4=BB=B6=E8=B5=B0=E5=9B=BE?= =?UTF-8?q?=E5=BA=8A=E5=B5=8C=E7=9C=9F=E5=AE=9E=E5=9B=BE=E7=89=87:=20GitHu?= =?UTF-8?q?b=20=E6=A8=A1=E5=BC=8F=E9=99=84=E4=BB=B6=E4=B9=9F=E4=BC=A0?= =?UTF-8?q?=E5=9B=BE=E5=BA=8A=E6=8B=BFURL,=20issue=20body=20=E7=94=A8=20![?= =?UTF-8?q?](url)=20=E6=98=BE=E7=A4=BA=E5=AE=9E=E9=99=85=E5=9B=BE=E7=89=87?= =?UTF-8?q?(=E5=9B=BE=E5=BA=8A=E6=B2=A1=E9=85=8D=E6=89=8D=E5=9B=9E?= =?UTF-8?q?=E9=80=80=20@gh:=20=E5=8D=A0=E4=BD=8D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/ticket.php | 22 ++++++++++++++-------- gh_api.php | 7 ++++++- lsky.php | 15 ++++++++++++--- player.php | 4 ++-- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/api/ticket.php b/api/ticket.php index b704c95..8b9a198 100644 --- a/api/ticket.php +++ b/api/ticket.php @@ -293,15 +293,21 @@ function uploadTicketFiles() { return $GLOBALS['__ticket_dbg_urls']; } - // ★ 15m44n 互斥二选一(用户定调):type=GitHub 时附件【全走 issue,不走图床】。 - // 不上传图床(easy=false),只记录附件文件名(带 @gh: 标记),由前端把"附件"以 - // 占位文本塞进工单描述,ghSyncCreate 同步到 issue body。玩家真要贴图,直接贴 - // 图床外链或 GitHub issue 的拖拽上传。 + // ★ 15m44n 互斥 → ★ 15m44v 变更(用户定调"附件要显示实际图片"): + // GitHub 模式下附件【也走图床】拿真实 URL(图床配了真值时),ghSyncCreate 把 URL 用 + // markdown 图片语法 ![](url) 嵌进 issue body,GitHub 会把外链图片转存到自家 CDN 正常显示。 + // 这样 PHP 后台 + GitHub 都显示实际图片,不再是"只显示文件名"。 + // 仅当图床没配(baseurl/key 空)时才回退 @gh: 文件名占位(玩家去 GitHub 手动传)。 if (!empty($cfg['gh_enabled'])) { - $out = ghTicketFileNames(); - $GLOBALS['__ticket_dbg_uploaded'] = count($out); - $GLOBALS['__ticket_dbg_urls'] = $out; - return $out; + // 图床可用 → 不拦截,落到下方 uploadTicketFiles 走 easyUploadFile 拿真实 URL + // 图床没配 → 回退 ghTicketFileNames(@gh: 占位,仅记文件名) + if ($cfg['baseurl'] === '' || $cfg['key'] === '' || !$cfg['attach_enabled']) { + $out = ghTicketFileNames(); + $GLOBALS['__ticket_dbg_uploaded'] = count($out); + $GLOBALS['__ticket_dbg_urls'] = $out; + return $out; + } + // 图床可用:继续往下走(不 return),附件传图床拿真实 URL } $maxImages = max(1, (int)($cfg['max_images'] ?? 3)); $maxBytes = max(1, (int)($cfg['max_size_mb'] ?? 2)) * 1024 * 1024; diff --git a/gh_api.php b/gh_api.php index 5f280eb..42a2e67 100644 --- a/gh_api.php +++ b/gh_api.php @@ -165,9 +165,14 @@ function ghSyncCreate($ticketId, $player, $title, $description, $images = [], $t $bodyParts[] = ''; foreach ($images as $i => $u) { if (is_string($u) && strpos($u, '@gh:') === 0) { - // @gh:附件图N:文件名.png → 取冒号后的文件名展示 + // @gh:附件图N:文件名(图床没配时的回退占位)→ 只显示文件名,让玩家去 GitHub 传原图 $label = str_replace('@gh:', '', $u); $bodyParts[] = '📎 附件' . ($i + 1) . ':`' . $label . '`(需在 GitHub issue 上传原图)'; + } elseif (is_string($u) && (strpos($u, 'http://') === 0 || strpos($u, 'https://') === 0)) { + // ★ 15m44v: 真实图床 URL → markdown 图片语法嵌进 issue body。 + // GitHub 会把 ![](外链) 的图片自动转存到 user-images.githubusercontent.com CDN, + // issue 页正常显示实际图片(不再只是文件名)。 + $bodyParts[] = '附件' . ($i + 1) . ':' . "\n" . '![' . $u . '](' . $u . ')'; } else { $bodyParts[] = '附件图' . ($i + 1) . ':' . $u; } diff --git a/lsky.php b/lsky.php index 4c6fd37..3929669 100644 --- a/lsky.php +++ b/lsky.php @@ -236,16 +236,25 @@ function easyUploadFile($tmpPath, $origName) { */ function ticketImageUpload($tmpPath, $origName) { $cfg = loadImgJson(); - // 本期只做 EasyImages2.0(用户明令 GitHub issue 先不做) + // 15m44v: 图床可用(baseurl+key 配了真值)就传图床拿真实 URL —— 无论是否 GitHub 模式。 + // 旧版(15m44n 互斥铁律)GitHub 模式附件全走 issue 不走图床(easy=false 直接报"图床未配置"), + // 导致 PHP 后台 + GitHub 都只显示文件名。用户 2026-11-25 定调"附件要显示实际图片", + // 故 GitHub 模式附件【也走图床】:传 EasyImages2.0 拿真实 URL,ghSyncCreate 把 URL 用 + // markdown 图片语法 ![](url) 嵌进 issue body(GitHub 会把外链图片转存到自家 CDN 正常显示)。 + // 只要 baseurl+key 配了(图床可用)就传图床;图床没配才走兜底/报错。 if ($cfg['easy']) { return easyUploadFile($tmpPath, $origName); } + // easy=false 但 baseurl/key 配了(GitHub 模式 + 图床可用):也传图床拿 URL + // (loadImgJson 的 easy 在 gh_type 时被置 false,但图床真值仍可传 —— 15m44v 放开) + if ($cfg['baseurl'] !== '' && $cfg['key'] !== '' && $cfg['attach_enabled']) { + return easyUploadFile($tmpPath, $origName); + } // easy 未配置且非 GitHub(含 gh/GH/GitHub/github 任意写法):兜底旧兰空图床(lsky_keys.php 还在时) if (!$cfg['gh_type'] && $cfg['type'] === '') { return lskyUploadFile($tmpPath, $origName); } - return ['ok' => false, 'msg' => '图床未配置:img.json 的 baseurl/key 缺失(GitHub 模式附件走 issue,不走图床)']; - return ['ok' => false, 'msg' => '图床未配置:GitHub 模式附件走 issue,不走图床(loadImgJson.easy=false)']; + return ['ok' => false, 'msg' => '图床未配置:img.json 的 baseurl/key 缺失(GitHub 模式附件走图床拿 URL 嵌 issue)']; } /** 加载 lsky_keys.php(只加载一次),并检查必填项 */ diff --git a/player.php b/player.php index 7e772ff..8a59368 100644 --- a/player.php +++ b/player.php @@ -3984,9 +3984,9 @@ if ($currentVersion !== $BUILD_VERSION) { const txt = document.getElementById('ghAuthText'); const sub = document.getElementById('ghAuthSub'); const btn = document.getElementById('ghAuthBtn'); - // ★ 15m44n 互斥二选一:GitHub 模式附件全走 issue,不走图床 → 切附件区文案 + // ★ 15m44v:GitHub 模式附件也走图床拿真实 URL,issue body 用 ![](url) 嵌图显示实际图片 const hint = document.getElementById('ticketImgHint'); - if (hint) hint.textContent = '📎 GitHub 模式:附件随工单同步到 GitHub issue(不走图床)。选中的文件名会记入 issue,原图请在 GitHub issue 页直接上传。'; + if (hint) hint.textContent = '📎 GitHub 模式:附件上传图床后随工单同步到 GitHub issue(issue 内显示实际图片,不再是文件名)。选中的图片会一并上传图床。'; // ★ 15m44v: 按 gh_authorized 显示授权态(不再只靠 URL gh_ok 参数) const isAuthed = d.gh_authorized === true || new URLSearchParams(location.search).get('gh_ok') === '1';