评论错误卡片:额度文案双保险(中文特征词兜底+连接异常优先判)、底部边距加大与footer分隔线隔开(桌面30px/移动24px)
Deploy to Production / pre-check (push) Successful in 1m19s
Deploy to Production / build (push) Successful in 4m3s
Deploy to Production / deploy-edgeone (push) Successful in 3m55s
Deploy to Production / finalize (push) Successful in 28s
Deploy to Production / notify-failure (push) Skipped

This commit is contained in:
zqlit committed 2026-10-03 21:01:58 +08:00
1 parent bff48517c0
commit 298f10e6bc
1 file changed
+11 -4
+11 -4
View File
@@ -63,7 +63,7 @@
var st = document.createElement('style'); var st = document.createElement('style');
st.id = 'atk-err-css'; st.id = 'atk-err-css';
st.textContent = st.textContent =
'.atk-error-layer{padding:0!important;background:transparent!important}' + '.atk-error-layer{padding:0!important;margin:14px 0 30px!important;background:transparent!important}' +
'.atk-err-card{display:block;text-align:center;padding:30px 22px;box-sizing:border-box;' + '.atk-err-card{display:block;text-align:center;padding:30px 22px;box-sizing:border-box;' +
'animation:atkErrIn .35s cubic-bezier(.22,1,.36,1)}' + 'animation:atkErrIn .35s cubic-bezier(.22,1,.36,1)}' +
'@keyframes atkErrIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}' + '@keyframes atkErrIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}' +
@@ -77,7 +77,7 @@
'font-size:13px;font-weight:600;cursor:pointer;transition:background .2s,color .2s,transform .2s;user-select:none}' + 'font-size:13px;font-weight:600;cursor:pointer;transition:background .2s,color .2s,transform .2s;user-select:none}' +
'.atk-err-retry:hover{background:var(--theme-main,#07c160);color:#fff}' + '.atk-err-retry:hover{background:var(--theme-main,#07c160);color:#fff}' +
'.atk-err-retry:active{transform:scale(.96)}' + '.atk-err-retry:active{transform:scale(.96)}' +
'@media (max-width:640px){.atk-err-card{padding:24px 16px}.atk-err-ic{font-size:26px}' + '@media (max-width:640px){.atk-error-layer{margin:10px 0 24px!important}.atk-err-card{padding:20px 14px}.atk-err-ic{font-size:26px}' +
'.atk-err-t{font-size:14px}.atk-err-d{font-size:12.5px}}'; '.atk-err-t{font-size:14px}.atk-err-d{font-size:12.5px}}';
document.head.appendChild(st); document.head.appendChild(st);
} }
@@ -92,9 +92,16 @@
var prev = layer.querySelector('.atk-err-card'); var prev = layer.querySelector('.atk-err-card');
if (prev && prev.getAttribute('data-raw') === raw) return; // 内容没变,不重复渲染 if (prev && prev.getAttribute('data-raw') === raw) return; // 内容没变,不重复渲染
// 优先用结构化错误码;没有就按「网络层失败」处理 // 优先用结构化错误码;没有就从 Artalk 原始错误文本里认特征词
// (D1 额度用尽 / 网络失败都有固定措辞)。结构化记录有时效且 Artalk
// 走某些路径时抓不到,只靠它会出现"有时显示通用文案"的不稳定 ——
// 双保险后,额度用尽这类固定故障任何时候都能显示出对应文案。
var fresh = last && (Date.now() - last.at < 30000) ? last : null; var fresh = last && (Date.now() - last.at < 30000) ? last : null;
var code = (fresh && fresh.code) || (/failed to fetch|network ?error|load failed/i.test(raw) ? 'network' : 'internal'); var code = (fresh && fresh.code)
|| (/数据库连接异常|d1_unavailable/i.test(raw) ? 'd1_unavailable'
: /D1_ERROR|exceeded D1|free tier|额度已用尽|暂时不可用|加载失败|无法获取|出了点小状况/i.test(raw) ? 'd1_quota'
: /failed to fetch|network ?error|load failed/i.test(raw) ? 'network'
: 'internal');
var info = INFO[code] || INFO.internal; var info = INFO[code] || INFO.internal;
// 服务端文案是给「直接调 API 的人」写的,自带一句"评论服务暂时不可用:", // 服务端文案是给「直接调 API 的人」写的,自带一句"评论服务暂时不可用:",
// 放到卡片里会和标题重复,这里去掉冗余前缀 // 放到卡片里会和标题重复,这里去掉冗余前缀