feat(publish/dongchedi): publish via page context with cover and conservative HTML

懂车帝发布闸现走 Playwright/WebContents 内的 fetch,附带 CSRF token、自动
draft+commit 两步保存,并在前置流程中把正文 HTML 收敛到 p/strong/img、表格
降级为段落、过滤本地素材 URL。同步把懂车帝纳入封面强制平台,更新中英文
提示与错误码文案。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-28 18:35:36 +08:00
parent bf7594ccd8
commit 4c4795e029
10 changed files with 684 additions and 106 deletions
+11
View File
@@ -148,6 +148,17 @@
- `/Users/liangxu/Documents/test/geo-rankly/packages/shared-types/src/index.ts`
- `/Users/liangxu/Documents/test/geo-rankly/packages/http-client/src/index.ts`
## Dongchedi Desktop Publish Debug - 2026-04-28
- Local `desktop_tasks` evidence for article `95` showed the latest `dongchedi` failures changed from `request_failed_403` to platform response `server exception` after switching the adapter to page-context publish.
- Raw `article_versions.markdown_content` stores diff-match-patch patches by design; repository reconstruction for article `95` produced a normal 8219-byte article body, so raw DB diff text is not the publish payload.
- The reconstructed article contains editor image asset references from `/api/public/assets/...`; Dongchedi `/spice/image?sk=dcd` cannot fetch localhost/relative desktop assets. Leaving those image URLs in final HTML is a likely cause of Dongchedi `server exception`.
- After image URL replacement was fixed, Dongchedi still returned `server exception`; local reconstruction of article `95` showed the submitted HTML contained GFM `<table>` output. The Dongchedi publish API likely rejects or crashes on table markup, so the desktop adapter now downgrades tables to paragraph rows before submit.
- After table downgrading, Dongchedi still returned `server exception`; the adapter now further reduces content to conservative tags (`p`, `strong`, `img`), strips editor image wrapper attributes, converts headings/list items to paragraphs, and runs ImageX-uploaded local body images through `spice/image` before inserting the content URL.
- Latest retry after conservative HTML still returned `server exception` with `content_table_count = 0`, `content_has_local_asset_url = false`, and `content_image_count = 1`, so the remaining suspects are the body image URL shape, table-derived HTML entities, or cover metadata rather than raw local asset/table markup.
- Follow-up hardening removes `&nbsp;` from Dongchedi body HTML and tries Dongchedi `/spice/image?sk=dcd` in both session and page context.
- A retry showed `content_image_upload_strategies = ['imagex_direct_fallback']` and still returned `server exception`, confirming direct ImageX body URLs are not safe for Dongchedi正文. The adapter now removes local body images that cannot be converted to a Dongchedi `spice` URL and submits the article with the uploaded cover only.
- A no-body-image retry still returned `server exception`, leaving `extra.content_word_cnt` as the most suspicious remaining mismatch because it was still hardcoded to the reference extension's `267` while the final submitted content length is much larger. The adapter now computes `content_word_cnt` from the final HTML text and logs both submitted and recomputed counts.
## Visual/Browser Findings
- Reviewed the reference screenshots for `工作台.png` and `模板创作.png` and matched the new UI to the same left-nav plus airy card/table composition.
- Browser automation verification was attempted but blocked by the local Playwright MCP directory error; preview HTTP verification succeeded instead.