From 8b30e72c7f7b24b55845f2db8346721c6444c42e Mon Sep 17 00:00:00 2001 From: walker <13750528578@163.com> Date: Sun, 7 Jun 2026 02:59:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(xhs):=20=E6=94=AF=E6=8C=81=E6=96=B0?= =?UTF-8?q?=E9=97=BB=E5=9B=BE=E6=96=87=E5=8D=A1=E5=90=88=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 14 +- README.zh-CN.md | 10 +- cmd/mark2note/main.go | 221 +++++--- cmd/mark2note/main_publish_test.go | 277 +++++++--- cmd/mark2note/main_test.go | 32 +- configs/config.example.yaml | 13 +- internal/ai/deck_builder.go | 11 +- internal/ai/deck_builder_test.go | 27 +- internal/app/publish_service.go | 68 ++- internal/app/publish_service_test.go | 36 +- internal/app/service.go | 65 +++ internal/app/service_test.go | 34 ++ internal/config/config.go | 59 +- internal/config/config_test.go | 85 ++- internal/deck/deck.go | 50 +- internal/deck/deck_test.go | 38 +- internal/render/animated.go | 7 + internal/render/animated_test.go | 2 +- internal/render/assets/base.css | 87 ++- internal/render/assets/page.tmpl | 21 +- internal/render/template.go | 5 + internal/render/template_test.go | 262 +++++---- .../fixtures/default-all-variants.json | 52 +- .../fixtures/default-semantic-highlight.json | 8 +- .../fixtures/editorial-cool-all-variants.json | 52 +- .../editorial-cool-semantic-highlight.json | 8 +- .../fixtures/fresh-green-all-variants.json | 52 +- .../fixtures/plum-ink-all-variants.json | 52 +- .../fixtures/sage-mist-all-variants.json | 52 +- .../fixtures/tech-noir-all-variants.json | 52 +- .../tech-noir-semantic-highlight.json | 8 +- .../fixtures/warm-paper-all-variants.json | 52 +- .../warm-paper-semantic-highlight.json | 8 +- .../golden-html/default-all-variants.sha256 | 2 +- .../golden-html/default-author-global.sha256 | 2 +- .../golden-html/default-author-long.sha256 | 2 +- .../golden-html/default-author-none.sha256 | 2 +- .../default-author-override.sha256 | 2 +- .../default-semantic-highlight.sha256 | 2 +- .../editorial-cool-all-variants.sha256 | 2 +- .../editorial-cool-semantic-highlight.sha256 | 2 +- .../fresh-green-all-variants.sha256 | 2 +- .../golden-html/plum-ink-all-variants.sha256 | 2 +- .../golden-html/sage-mist-all-variants.sha256 | 2 +- .../golden-html/tech-noir-all-variants.sha256 | 2 +- .../tech-noir-semantic-highlight.sha256 | 2 +- .../warm-paper-all-variants.sha256 | 2 +- .../warm-paper-semantic-highlight.sha256 | 2 +- internal/xhs/publisher.go | 514 +++++++++++++++++- internal/xhs/publisher_test.go | 482 ++++++++++++++-- internal/xhs/request.go | 83 ++- internal/xhs/request_test.go | 66 ++- 52 files changed, 2423 insertions(+), 572 deletions(-) diff --git a/README.en.md b/README.en.md index c50e9fd..55ce665 100644 --- a/README.en.md +++ b/README.en.md @@ -196,7 +196,8 @@ Key fields: - `xhs.publish.headless`: default browser headless mode for `publish-xhs`, `--publish-xhs`, and `--prepare-xhs` - `xhs.publish.browser_path`: default browser executable path for `publish-xhs`, `--publish-xhs`, and `--prepare-xhs`; CLI `--chrome` can override it for one run - `xhs.publish.profile_dir`: default browser profile directory for `publish-xhs`, `--publish-xhs`, and `--prepare-xhs` -- `xhs.publish.mode`: default publish mode for `publish-xhs`, `--publish-xhs`, and `--prepare-xhs`, supporting `only-self` and `schedule`; main render commands can override it for one run with `--xhs-mode` +- `xhs.publish.mode`: publish timing/flow, not page visibility; supports `immediate` (normal immediate publish flow) and `schedule` (scheduled publish flow); main render commands can override it for one run with `--xhs-mode` +- `xhs.publish.visibility`: Xiaohongshu page visibility, not publish timing; supports `public` and `only-self` - `xhs.publish.schedule_at`: default scheduled publish time for `mode: schedule`, using `YYYY-MM-DD HH:MM:SS` and parsed in Asia/Shanghai; main render commands can override it for one run with `--xhs-schedule-at` - `xhs.publish.topic_generation.enabled`: whether `--publish-xhs` / `--prepare-xhs` calls AI to generate 3-6 Xiaohongshu topics when `--xhs-tags` is omitted, on by default - `xhs.publish.title_generation.enabled`: whether `--publish-xhs` / `--prepare-xhs` calls AI to rewrite titles that exceed `max_runes`, on by default @@ -357,8 +358,8 @@ Rules: Current behavior: -- standard publish mode currently submits as only-self-visible -- schedule mode still submits as scheduled publish +- `immediate` mode uses the normal publish flow; page visibility is controlled separately by `visibility` +- `schedule` mode submits a scheduled publish - media source is exclusive: use `--images` for standard image posts or `--live-report` for the Live pipeline ### Usage @@ -379,7 +380,7 @@ mark2note publish-xhs --help - `--content `: inline content text; exactly one of `--content` / `--content-file` is required - `--content-file `: content file path - `--tags `: comma-separated tags -- `--mode `: publish mode, supporting `only-self` and `schedule`; when omitted it falls back to `xhs.publish.mode`, otherwise defaults to `only-self` +- `--mode `: publish timing/flow, supporting `immediate` and `schedule`; when omitted it falls back to `xhs.publish.mode`, otherwise defaults to `immediate` - `--schedule-at