From 014c3b79814448dd5967868b9abbf1bbba66743f Mon Sep 17 00:00:00 2001 From: John Date: Sat, 12 Sep 2026 12:51:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(wechat):=20=E9=95=BF=E6=96=87=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E5=85=88=E7=95=99=E9=A1=B5=E8=84=9A=EF=BC=8C=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E5=BC=B9=E7=AA=97=E5=B1=95=E7=A4=BA=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E5=8E=9F=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 超过 2 万字时不再把阅读原文和关注区裁掉;公开页错误态不再误报需要登录 MindSpace。 Co-authored-by: Cursor --- docs/wechat-draft-publication-standard.md | 2 ++ mindspace-public-share-widget.mjs | 10 ++++--- mindspace-public-share-widget.test.mjs | 7 +++++ mindspace-wechat-page-draft.mjs | 14 ++++++++-- mindspace-wechat-page-draft.test.mjs | 23 +++++++++++++--- server.mjs | 1 + wechat-draft-article-layout.mjs | 31 +++++++++++++++++++--- wechat-draft-publication-standard.test.mjs | 31 +++++++++++++++++++--- 8 files changed, 102 insertions(+), 17 deletions(-) diff --git a/docs/wechat-draft-publication-standard.md b/docs/wechat-draft-publication-standard.md index c9d2a82..5a8ff05 100644 --- a/docs/wechat-draft-publication-standard.md +++ b/docs/wechat-draft-publication-standard.md @@ -26,6 +26,8 @@ 3. **阅读原文**:12px 小胶囊链接,位于正文末尾、关注区之前;有 `publicUrl` 时必须出现 4. **欢迎关注 TKMind 智趣** + 公众号二维码(无 logo、无额外导语) +正文超过 `maxContentChars`(20000)时,**先给阅读原文和关注区留额度,再截正文**,禁止先拼再整体 `slice` 把页脚裁掉。公开页失败弹窗必须展示服务端真实原因,不能用「请先登录 MindSpace」兜底掩盖校验失败。 + ## 封面(thumb_media_id) 优先级: diff --git a/mindspace-public-share-widget.mjs b/mindspace-public-share-widget.mjs index a6a059b..eb57da9 100644 --- a/mindspace-public-share-widget.mjs +++ b/mindspace-public-share-widget.mjs @@ -121,6 +121,7 @@ var wechatBlockedClose=wechatDialog.querySelector('[data-action="wechat-blocked- var wechatForbiddenClose=wechatDialog.querySelector('[data-action="wechat-forbidden-close"]'); var wechatDraftId=wechatDialog.querySelector('[data-wechat-draft-id]'); var wechatHint=wechatDialog.querySelector('[data-wechat-view="confirm"] [data-wechat-hint]'); +var wechatErrorHint=wechatDialog.querySelector('[data-wechat-view="error"] [data-wechat-hint]'); var wechatViews={ confirm:wechatDialog.querySelector('[data-wechat-view="confirm"]'), loading:wechatDialog.querySelector('[data-wechat-view="loading"]'), @@ -141,6 +142,7 @@ void refreshWechatDialog(); } function closeWechatDialog(){wechatDialog.hidden=true;showWechatView('confirm');} function setWechatHint(text){if(wechatHint)wechatHint.textContent=text||'';} +function setWechatErrorHint(text){if(wechatErrorHint)wechatErrorHint.textContent=text||'推送失败,请稍后重试。';} async function refreshWechatDialog(){ if(wechatChecking)return; var relativePath=workspaceRelativePath(); @@ -157,12 +159,12 @@ throw new Error(errBody.message||'无法检查公众号草稿状态'); var data=payload.data||{}; if(!data.configured){showWechatView('blocked');setWechatHint('请先在 M 配置中绑定公众号 AppID 和 AppSecret。');return;} var blockers=(data.validation&&data.validation.blockers)||[]; -if(!data.canPush){showWechatView('error');setWechatHint(blockers[0]||'当前页面暂不符合推送要求');return;} +if(!data.canPush){showWechatView('error');setWechatErrorHint(blockers[0]||'当前页面暂不符合推送要求');return;} setWechatHint(data.pageTitle||'当前页面'); showWechatView('confirm'); }catch(e){ showWechatView('error'); -setWechatHint(e&&e.message?e.message:'无法检查公众号草稿状态'); +setWechatErrorHint(e&&e.message?e.message:'无法检查公众号草稿状态'); }finally{wechatChecking=false;} } wechatButton.addEventListener('click',openWechatDialog); @@ -194,7 +196,7 @@ if(wechatDraftId){wechatDraftId.textContent=data.draftMediaId?'草稿 media_id setStatus('已推送到公众号草稿箱',false,true); }catch(e){ showWechatView('error'); -setWechatHint(e&&e.message?e.message:'推送失败'); +setWechatErrorHint(e&&e.message?e.message:'推送失败'); }finally{pushing=false;wechatConfirm.disabled=false;} }); } @@ -307,7 +309,7 @@ export function injectPublicFileShareButton(html, { isOwner = true } = {}) {