15m44v 续: 修附件替换串 \u 残留+前端授权态误判
- gh_api.php ghSyncCreate 替换串终版:'\u📎 附件\1' 的 \u 在 PHP 单引号里是字面 反斜杠+u, 传给 PCRE 替换串 \u=下个字符转大写, 对 emoji 无效→吐出字面 u (issue body 出现 'u 📎 附件1')。 改 "\U0001F4CE 附件\1" (emoji 直接字面值, 只留 \1 反向引用, 无任何大小写/转义指令)。 - api/gh_cfg.php 加 gh_authorized 字段: 带 token 反解玩家名查 gh_auth_tokens, /user 验活(破CF缓存), 有效→true。根治前端'重新进表单 URL 无 gh_ok 就误判未授权'。 - player.php loadGhCfg 改 fetch gh_cfg.php?token= 按 gh_authorized 显示已授权态(不再只靠 URL 参数)。 commit 083f760/9b081a6
This commit is contained in:
+13
-7
@@ -3974,7 +3974,9 @@ if ($currentVersion !== $BUILD_VERSION) {
|
||||
const box = document.getElementById('ghTicketAuth');
|
||||
if (!box) return;
|
||||
try {
|
||||
const res = await fetch(API + 'gh_cfg.php');
|
||||
// ★ 15m44v: fetch 带 token,后端据此验活该玩家 GitHub token,返回 gh_authorized。
|
||||
// 根治"重新进表单 URL 无 gh_ok 就误判未授权"——现在只要 token 真有效就显示已授权。
|
||||
const res = await fetch(API + 'gh_cfg.php?token=' + encodeURIComponent(TOKEN));
|
||||
const data = await res.json();
|
||||
const d = (data.success && data.data) ? data.data : null;
|
||||
if (d && d.gh_enabled) {
|
||||
@@ -3985,13 +3987,17 @@ if ($currentVersion !== $BUILD_VERSION) {
|
||||
// ★ 15m44n 互斥二选一:GitHub 模式附件全走 issue,不走图床 → 切附件区文案
|
||||
const hint = document.getElementById('ticketImgHint');
|
||||
if (hint) hint.textContent = '📎 GitHub 模式:附件随工单同步到 GitHub issue(不走图床)。选中的文件名会记入 issue,原图请在 GitHub issue 页直接上传。';
|
||||
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') {
|
||||
// ★ 15m44v: 按 gh_authorized 显示授权态(不再只靠 URL gh_ok 参数)
|
||||
const isAuthed = d.gh_authorized === true
|
||||
|| new URLSearchParams(location.search).get('gh_ok') === '1';
|
||||
if (isAuthed) {
|
||||
if (txt) txt.textContent = '✅ GitHub 已授权,工单+附件会自动同步到 issue';
|
||||
if (btn) { btn.textContent = '重新授权'; }
|
||||
if (sub) sub.textContent = '当前账号 token 有效,工单提交将自动同步到 GitHub issue';
|
||||
if (btn) { btn.textContent = '重新授权'; btn.onclick = gotoGhOAuth; }
|
||||
} else {
|
||||
if (txt) txt.textContent = '⛓️ GitHub 工单同步(' + (d.gh_repo || 'issue') + ')';
|
||||
if (sub) sub.textContent = '工单与附件都同步到 GitHub issue,点右侧按钮授权你的 GitHub 账号';
|
||||
if (btn) { btn.textContent = '授权 GitHub'; btn.onclick = gotoGhOAuth; }
|
||||
}
|
||||
}
|
||||
} catch (e) { /* 端点不存在/未部署 → 不显示 */ }
|
||||
|
||||
Reference in New Issue
Block a user