diff --git a/img.json b/img.json index dbab8c0..fa628b9 100644 --- a/img.json +++ b/img.json @@ -2,21 +2,21 @@ "模式": { "type": "", "说明": [ - "1. type留空→走图床(EasyImages2.0)", - "2. 填GitHub→走GitHub issue(工单同步 caoyuanwiki 仓库)" + "1. type留空→只走内置工单+图床", + "2. 填GitHub→额外同步GitHub issue(需配repo段+前端授权)+前端出现授权按钮" ] }, "repo": { - "url": "https://github.com/ypsdf1/caoyuanwiki", - "Client ID": "Ov23li8Zk7KtdcDKEyXh", - "Client secrets": "6381a52aada20839bee8e9d31c156b56417e6fa5", + "url": "https://github.com/username/reponame", + "Client ID": "12345", + "Client secrets": "12345", + "webhook_secret": "000000", "type": { "public": true, "private": false, "备注": "仓库类型2选1,同时双开默认public" } }, - "webhook_secret": "4V8gi9h^&^47", "图像/附件支持": { "附件支持": true, "最大图片数量": 3, @@ -33,8 +33,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 1228519..6dffa08 100644 --- a/lsky.php +++ b/lsky.php @@ -99,10 +99,15 @@ function loadImgJson() { $cfg['attach_enabled'] = $attach; } - // easy = 走 EasyImages2.0(type 非 GitHub 且有 baseurl+key 且附件支持开) - $cfg['easy'] = ($cfg['type'] !== 'GitHub' && $cfg['baseurl'] !== '' && $cfg['key'] !== '' && $cfg['attach_enabled']); + // easy = 走 EasyImages2.0(有 baseurl+key 且附件支持开) + // 15m44m 修正:不再被 模式.type=GitHub 压制。type=GitHub 时图床与 issue 同步并存—— + // 图片照走 EasyImages 图床,工单/回复【额外】同步 GitHub issue(用户 2026-11-25 实测反馈: + // type=GitHub 仍走内置工单不跳授权 → 根因是 easy 被压 + 前端根本没接授权按钮)。 + $cfg['easy'] = ($cfg['baseurl'] !== '' && $cfg['key'] !== '' && $cfg['attach_enabled']); - // GitHub issue 集成(15m44l):repo.url → owner/name + OAuth Client ID/Secret + Webhook 密钥 + // GitHub issue 集成(15m44m 修正): + // webhook_secret 挪进 repo 段(用户明令:仓库 img.json 模板里 webhook_secret 塞进 repo 值, + // 顶层不再放敏感值)。优先读 repo.webhook_secret,兜底读顶层 webhook_secret(兼容旧生产文件)。 if (isset($j['repo']) && is_array($j['repo'])) { $url = isset($j['repo']['url']) ? trim((string)$j['repo']['url']) : ''; // 从 https://github.com/ypsdf1/caoyuanwiki 提取 owner/name(去掉协议+域名+尾斜杠) @@ -113,11 +118,18 @@ function loadImgJson() { $cfg['gh_repo'] = ($repoPath !== '' && strpos($repoPath, '/') !== false) ? $repoPath : ''; $cfg['gh_client_id'] = isset($j['repo']['Client ID']) ? trim((string)$j['repo']['Client ID']) : ''; $cfg['gh_client_secret'] = isset($j['repo']['Client secrets']) ? trim((string)$j['repo']['Client secrets']) : ''; + if (isset($j['repo']['webhook_secret'])) { + $cfg['gh_webhook_secret'] = trim((string)$j['repo']['webhook_secret']); + } } - $cfg['gh_webhook_secret'] = isset($j['webhook_secret']) ? trim((string)$j['webhook_secret']) : ''; - // gh_enabled = 模式.type=GitHub 且 repo 段填全(owner/name + client_id + client_secret) - $cfg['gh_enabled'] = ($cfg['type'] === 'GitHub' && $cfg['gh_repo'] !== '' - && $cfg['gh_client_id'] !== '' && $cfg['gh_client_secret'] !== ''); + if (!isset($j['repo']['webhook_secret'])) { + // 兼容旧顶层 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'); return $cfg; }