15m44m 根治: webhook_secret挪repo段去真实值 + easy不被GitHub压制 + 前端授权按钮 + 独立gh_auth_tokens表不污染工单 + token反解玩家名
This commit is contained in:
+41
@@ -3947,6 +3947,14 @@ if ($currentVersion !== $BUILD_VERSION) {
|
||||
<p style="color:var(--dim);font-size:12px;margin-top:4px">仅支持 png / jpg,单张 ≤ 2048K,最多 3 张;提交工单时一并上传图床(暂存阶段不上传 API)</p>
|
||||
<div id="ticketImgList" style="display:flex;gap:8px;flex-wrap:wrap;margin-top:8px"></div>
|
||||
<p id="ticketImgMsg" style="color:var(--red);font-size:12px;margin-top:4px"></p></div>
|
||||
<!-- 15m44m: GitHub issue 同步授权区(gh_enabled=true 才显示,由 renderTicketCreate 后 loadGhCfg 填充) -->
|
||||
<div id="ghTicketAuth" style="display:none;margin-bottom:12px;padding:10px 12px;border:1px dashed var(--border);border-radius:8px;background:var(--bg)">
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap">
|
||||
<span id="ghAuthText" style="color:var(--dim);font-size:13px">⛓️ GitHub 工单同步</span>
|
||||
<button class="btn btn-primary" style="font-size:12px;padding:5px 10px" id="ghAuthBtn" onclick="gotoGhOAuth()">授权 GitHub</button>
|
||||
</div>
|
||||
<p id="ghAuthSub" style="color:var(--dim);font-size:11px;margin-top:4px">提交工单时会同步到 GitHub issue,先授权你的 GitHub 账号</p>
|
||||
</div>
|
||||
<p style="color:var(--dim);font-size:12px;margin-bottom:12px">💡 支持标准Markdown语法:**粗体**、*斜体*、\`代码\`、列表、标题等</p>
|
||||
<div style="display:flex;gap:8px">
|
||||
<button class="btn btn-primary" onclick="submitTicket()">提交工单</button>
|
||||
@@ -3956,6 +3964,39 @@ if ($currentVersion !== $BUILD_VERSION) {
|
||||
</div>`;
|
||||
renderTicketImgs();
|
||||
syncTicketImgInput();
|
||||
loadGhCfg(); // 15m44m: 进表单即检查 GitHub 同步是否启用,启用则显示授权区
|
||||
}
|
||||
|
||||
// ===== 15m44m: GitHub issue 同步授权(前端)=====
|
||||
// gh_enabled=true 才显示授权区;点「授权 GitHub」跳 gh_oauth.php?token=(后端反解玩家名做 state),
|
||||
// 授权完成回跳 player.php?gh_ok=1 → 刷新按钮态。
|
||||
async function loadGhCfg() {
|
||||
const box = document.getElementById('ghTicketAuth');
|
||||
if (!box) return;
|
||||
try {
|
||||
const res = await fetch(API + 'gh_cfg.php');
|
||||
const data = await res.json();
|
||||
const d = (data.success && data.data) ? data.data : null;
|
||||
if (d && d.gh_enabled) {
|
||||
box.style.display = '';
|
||||
const txt = document.getElementById('ghAuthText');
|
||||
const sub = document.getElementById('ghAuthSub');
|
||||
const btn = document.getElementById('ghAuthBtn');
|
||||
if (txt) txt.textContent = '⛓️ GitHub 工单同步(' + (d.gh_repo || 'issue') + ')';
|
||||
if (sub) sub.textContent = '提交工单时会同步到 GitHub issue,点右侧按钮授权你的 GitHub 账号';
|
||||
if (btn) btn.onclick = gotoGhOAuth;
|
||||
// URL 带 gh_ok=1(刚从 GitHub 回跳)→ 提示已授权
|
||||
if (new URLSearchParams(location.search).get('gh_ok') === '1') {
|
||||
if (txt) txt.textContent = '✅ GitHub 已授权,工单会自动同步到 issue';
|
||||
if (btn) { btn.textContent = '重新授权'; }
|
||||
}
|
||||
}
|
||||
} catch (e) { /* 端点不存在/未部署 → 不显示 */ }
|
||||
}
|
||||
function gotoGhOAuth() {
|
||||
// 用当前 TOKEN 让后端反解玩家名做 OAuth state,前端无需知道玩家名
|
||||
const url = API + 'gh_oauth.php?token=' + encodeURIComponent(TOKEN);
|
||||
window.location.href = url;
|
||||
}
|
||||
|
||||
// ===== 工单附件图:15m44d 改为"选中暂存, 提交工单时一并上传图床"=====
|
||||
|
||||
Reference in New Issue
Block a user