From ed6462d8307c1705756ba0b940bfedd9db68a341 Mon Sep 17 00:00:00 2001 From: ypsdf1 Date: Wed, 25 Nov 2026 15:24:53 +0800 Subject: [PATCH] =?UTF-8?q?15m44u=20=E6=A8=A1=E5=BC=8F.type=20=E5=BD=92?= =?UTF-8?q?=E4=B8=80=E5=8C=96(gh/GH/GitHub/github=20=E5=85=A8=E7=AE=97)=20?= =?UTF-8?q?+=20=E4=BB=93=E5=BA=93=E7=89=88=20img.json=20=E8=BF=98=E5=8E=9F?= =?UTF-8?q?=E5=85=A8=E5=8D=A0=E4=BD=8D=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - lsky.php loadImgJson: 模式.type 归一化判定——小写去空格/横杠/下划线后等于 gh / github / 以 github 开头 都算 GitHub。gh/GH/GitHub/GITHUB/github-issue/github_issue 全部命中;其它值不算。easy/gh_enabled 改按归一化判断,不硬比 'GitHub'。 - img.json(仓库版, 进 git): api 段还原为 example.com/example 占位符(15m44t 误写真值 进 git 已纠正), repo 段保留占位符+webhook_secret+tag。生产 img.json(FTP) 单独 维护图床真值, 本次不部署 img.json, 避免再覆盖生产图床配置致 405。 --- img.json | 4 ++-- lsky.php | 27 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/img.json b/img.json index 226eff1..7100bcd 100644 --- a/img.json +++ b/img.json @@ -39,8 +39,8 @@ ] }, "api": { - "baseurl": "https://img.ypshidifu.cn/", - "key": "95895d65c850dd85b02180e2daabcd43", + "baseurl": "https://example.com/", + "key": "example", "说明": [ "1. key和API地址都要填", "2. 如果附件支持为true但api没配置自动退回false", diff --git a/lsky.php b/lsky.php index 2745d3c..4c6fd37 100644 --- a/lsky.php +++ b/lsky.php @@ -81,7 +81,13 @@ function loadImgJson() { if (!is_array($j)) return $cfg; // 模式.type - $cfg['type'] = isset($j['模式']['type']) ? trim((string)$j['模式']['type']) : ''; + // ★ 15m44u 归一化:gh / GH / GitHub / github(含 github-issue 等变体)一律算 GitHub。 + // 判定:去掉首尾空格 + 小写后,等于 'github' 或以 'github' 开头,或本身就是 'gh'。 + $typeRaw = isset($j['模式']['type']) ? trim((string)$j['模式']['type']) : ''; + $typeNorm = strtolower($typeRaw); + $typeNorm = str_replace([' ', '-', '_'], '', $typeNorm); // github-issue / github_issue → githubissue + $cfg['type'] = $typeRaw; + $isGhType = ($typeNorm === 'gh' || $typeNorm === 'github' || strpos($typeNorm, 'github') === 0); // api.baseurl / api.key(新格式:嵌套在 api 对象下;兼容旧格式:顶层 baseurl/key) if (isset($j['api']) && is_array($j['api'])) { @@ -111,7 +117,8 @@ function loadImgJson() { // - type 留空 → 内置工单 + 附件走图床(easy=true) // - type=GitHub → 附件全走 GitHub issue,图床关闭(easy=false) // 两者不并存:选 GitHub 后图床彻底不碰,附件由 ghSyncCreate/ghSyncReply 塞进 issue body。 - $cfg['easy'] = ($cfg['type'] !== 'GitHub' && $cfg['baseurl'] !== '' && $cfg['key'] !== '' && $cfg['attach_enabled']); + // ★ 15m44u: 用归一化 $isGhType 判断(gh/GH/GitHub/github 全算),不硬比 'GitHub'。 + $cfg['easy'] = (!$isGhType && $cfg['baseurl'] !== '' && $cfg['key'] !== '' && $cfg['attach_enabled']); // GitHub issue 集成(15m44m 修正): // webhook_secret 挪进 repo 段(用户明令:仓库 img.json 模板里 webhook_secret 塞进 repo 值, @@ -141,10 +148,11 @@ function loadImgJson() { // 兼容旧顶层 webhook_secret(已部署的生产 img.json 可能是旧结构) $cfg['gh_webhook_secret'] = isset($j['webhook_secret']) ? trim((string)$j['webhook_secret']) : ''; } - // gh_enabled = 模式.type 显式填 GitHub(不再看 repo 段是否填全——模板值/占位值也算已填, - // 真正缺配置时 gh_* 为空会让 ghSyncCreate 自动跳过,不影响内置工单入库)。 - // 用户手动把 模式.type 改成 GitHub 即启用 issue 同步 + 前端授权按钮。 - $cfg['gh_enabled'] = ($cfg['type'] === 'GitHub'); + // gh_enabled = 模式.type 归一化后算 GitHub(gh/GH/GitHub/github 全算,15m44u)。 + // 不再看 repo 段是否填全——模板值/占位值也算已填,真正缺配置时 gh_* 为空会让 + // ghSyncCreate 自动跳过,不影响内置工单入库。用户把 模式.type 改成任意 GitHub 写法即启用。 + $cfg['gh_type'] = $isGhType; + $cfg['gh_enabled'] = $cfg['gh_type']; return $cfg; } @@ -232,11 +240,12 @@ function ticketImageUpload($tmpPath, $origName) { if ($cfg['easy']) { return easyUploadFile($tmpPath, $origName); } - // easy 未配置且 type 非 GitHub:兜底旧兰空图床(lsky_keys.php 还在时) - if ($cfg['type'] === '') { + // 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' => '图床未配置:img.json 的 baseurl/key 缺失(GitHub 模式附件走 issue,不走图床)']; + return ['ok' => false, 'msg' => '图床未配置:GitHub 模式附件走 issue,不走图床(loadImgJson.easy=false)']; } /** 加载 lsky_keys.php(只加载一次),并检查必填项 */