From 28e4059d66b095e93023fa6c610a514a6868d86b Mon Sep 17 00:00:00 2001 From: liangxu Date: Tue, 26 May 2026 18:43:07 +0800 Subject: [PATCH] feat(smzdm): require 1:1 cover and surface image fetch failure prompt Add SMZDM to the cover-required platform list on both client and server, register a 800x800 native cover spec in the admin cover catalog, and normalize the desktop-client `smzdm_image_fetch_failed` adapter error to a user-friendly Chinese prompt across the publisher error pipeline. Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/admin-web/src/lib/cover-requirements.ts | 9 +++++++++ .../desktop-client/src/main/adapters/smzdm.ts | 2 +- .../src/shared/publisher-errors.test.ts | 11 +++++++++++ .../src/shared/publisher-errors.ts | 19 ++++++++++++++++++- server/internal/tenant/app/media_service.go | 2 +- .../tenant/app/publish_platforms_test.go | 10 +++++----- 6 files changed, 45 insertions(+), 8 deletions(-) diff --git a/apps/admin-web/src/lib/cover-requirements.ts b/apps/admin-web/src/lib/cover-requirements.ts index ff779cd..de26fa4 100644 --- a/apps/admin-web/src/lib/cover-requirements.ts +++ b/apps/admin-web/src/lib/cover-requirements.ts @@ -51,6 +51,15 @@ const requirementCatalog: Record> = { outputHeight: 900, priority: 90, }, + smzdm: { + required: true, + supportMode: 'native', + aspectRatio: 1, + aspectLabel: '1:1', + outputWidth: 800, + outputHeight: 800, + priority: 90, + }, } export function getPlatformCoverRequirements( diff --git a/apps/desktop-client/src/main/adapters/smzdm.ts b/apps/desktop-client/src/main/adapters/smzdm.ts index ac54196..4d69b87 100644 --- a/apps/desktop-client/src/main/adapters/smzdm.ts +++ b/apps/desktop-client/src/main/adapters/smzdm.ts @@ -787,7 +787,7 @@ function failureResult( if (message.startsWith('smzdm_image_fetch_failed')) { return { status: 'failed', - summary: '什么值得买正文图片读取失败,请检查文章图片后重试。', + summary: '图片获取错误,请检查你文章和封面图片是否正确', error: { code: 'smzdm_image_fetch_failed', message, diff --git a/apps/desktop-client/src/shared/publisher-errors.test.ts b/apps/desktop-client/src/shared/publisher-errors.test.ts index 2be9074..7159939 100644 --- a/apps/desktop-client/src/shared/publisher-errors.test.ts +++ b/apps/desktop-client/src/shared/publisher-errors.test.ts @@ -5,6 +5,7 @@ import { DONGCHEDI_PLATFORM_EXCEPTION_MESSAGE, PUBLISH_ACCOUNT_NOT_LOGGED_IN_MESSAGE, QIEHAO_REAL_NAME_AUTH_MESSAGE, + SMZDM_IMAGE_FETCH_FAILED_MESSAGE, WANGYIHAO_DRAFT_SAVE_PARAMETER_MESSAGE, WANGYIHAO_PUBLISH_CLICK_MESSAGE, WANGYIHAO_TOKEN_MISSING_MESSAGE, @@ -15,6 +16,7 @@ import { normalizePublisherErrorMessage, normalizePublisherLoginErrorMessage, normalizeQiehaoPublishErrorMessage, + normalizeSmzdmPublishErrorMessage, normalizeWangyihaoPublishErrorMessage, normalizeWeixinGzhPublishErrorMessage, } from './publisher-errors' @@ -113,6 +115,15 @@ describe('publisher error normalization', () => { ) }) + it('normalizes SMZDM image fetch failures to the desktop Chinese prompt', () => { + expect(normalizePublisherErrorMessage('smzdm_image_fetch_failed', 'smzdm')).toBe( + SMZDM_IMAGE_FETCH_FAILED_MESSAGE, + ) + expect(normalizeSmzdmPublishErrorMessage('Error: smzdm_image_fetch_failed')).toBe( + SMZDM_IMAGE_FETCH_FAILED_MESSAGE, + ) + }) + it('leaves unknown publisher errors unchanged', () => { expect(normalizePublisherErrorMessage('qiehao_publish_failed')).toBe('qiehao_publish_failed') }) diff --git a/apps/desktop-client/src/shared/publisher-errors.ts b/apps/desktop-client/src/shared/publisher-errors.ts index e4f2f78..71a3682 100644 --- a/apps/desktop-client/src/shared/publisher-errors.ts +++ b/apps/desktop-client/src/shared/publisher-errors.ts @@ -14,6 +14,8 @@ export const BAIJIAHAO_CHALLENGE_REQUIRED_MESSAGE = '百家号检测到网络环境异常,需要人机验证。请打开百家号后台手动完成一次发稿或验证后再重试发布。' export const DONGCHEDI_PLATFORM_EXCEPTION_MESSAGE = '懂车帝平台返回异常,请打开懂车帝后台查看并处理平台提示,确认账号状态后再重试。' +export const SMZDM_IMAGE_FETCH_FAILED_MESSAGE = + '图片获取错误,请检查你文章中图片是否正确' const PUBLISH_PLATFORM_LABELS: Record = { baijiahao: '百家号', @@ -264,6 +266,20 @@ export function normalizeDongchediPublishErrorMessage( return normalized } +export function normalizeSmzdmPublishErrorMessage( + message: string | null | undefined, +): string | null { + const normalized = normalizeErrorText(message) + if (!normalized) { + return null + } + + if (/\bsmzdm_image_fetch_failed\b/i.test(normalized)) { + return SMZDM_IMAGE_FETCH_FAILED_MESSAGE + } + return normalized +} + export function normalizePublisherErrorMessage( message: string | null | undefined, platform?: string | null, @@ -279,6 +295,7 @@ export function normalizePublisherErrorMessage( const wangyihaoMessage = normalizeWangyihaoPublishErrorMessage(qiehaoMessage) const baijiahaoMessage = normalizeBaijiahaoPublishErrorMessage(wangyihaoMessage) const dongchediMessage = normalizeDongchediPublishErrorMessage(baijiahaoMessage, platform) - const loginMessage = normalizePublisherLoginErrorMessage(dongchediMessage) + const smzdmMessage = normalizeSmzdmPublishErrorMessage(dongchediMessage) + const loginMessage = normalizePublisherLoginErrorMessage(smzdmMessage) return normalizeWeixinGzhPublishErrorMessage(loginMessage) } diff --git a/server/internal/tenant/app/media_service.go b/server/internal/tenant/app/media_service.go index 1a56d6d..0a82252 100644 --- a/server/internal/tenant/app/media_service.go +++ b/server/internal/tenant/app/media_service.go @@ -151,7 +151,7 @@ func publishBatchRequiresCover(accounts []platformAccountSeed) bool { func publishPlatformRequiresCover(platformID string) bool { switch strings.TrimSpace(platformID) { - case "weixin_gzh", "baijiahao", "dongchedi": + case "weixin_gzh", "baijiahao", "dongchedi", "smzdm": return true default: return false diff --git a/server/internal/tenant/app/publish_platforms_test.go b/server/internal/tenant/app/publish_platforms_test.go index c6aa4f5..77036a6 100644 --- a/server/internal/tenant/app/publish_platforms_test.go +++ b/server/internal/tenant/app/publish_platforms_test.go @@ -5,7 +5,7 @@ import "testing" func TestPublishPlatformRequiresCover(t *testing.T) { t.Parallel() - for _, platformID := range []string{"weixin_gzh", "baijiahao", "dongchedi"} { + for _, platformID := range []string{"weixin_gzh", "baijiahao", "dongchedi", "smzdm"} { if !publishPlatformRequiresCover(platformID) { t.Fatalf("publishPlatformRequiresCover(%q) = false, want true", platformID) } @@ -19,12 +19,12 @@ func TestPublishPlatformRequiresCover(t *testing.T) { func TestPublishCoverRequirementCallersIncludeWeixinGzh(t *testing.T) { t.Parallel() - accounts := []platformAccountSeed{{PlatformID: "weixin_gzh"}} + accounts := []platformAccountSeed{{PlatformID: "weixin_gzh"}, {PlatformID: "smzdm"}} if !publishBatchRequiresCover(accounts) { - t.Fatal("publishBatchRequiresCover() = false for weixin_gzh, want true") + t.Fatal("publishBatchRequiresCover() = false for cover-required platforms, want true") } - if !schedulePublishPlatformsRequireCover([]string{"weixin_gzh"}) { - t.Fatal("schedulePublishPlatformsRequireCover() = false for weixin_gzh, want true") + if !schedulePublishPlatformsRequireCover([]string{"weixin_gzh", "smzdm"}) { + t.Fatal("schedulePublishPlatformsRequireCover() = false for cover-required platforms, want true") } }