feat(publish): unify image fetch failure message across adapters
Deployment Config CI / Deployment Config (push) Successful in 30s
Desktop Client Build / Resolve Build Metadata (push) Successful in 17s
Frontend CI / Frontend (push) Successful in 3m35s
Backend CI / Backend (push) Successful in 16m50s
Desktop Client Build / Build Desktop Client (push) Successful in 24m2s
Desktop Client Build / Publish Client Artifacts to NAS (push) Successful in 30s

Consolidate per-platform cover/image fetch failure prompts into a single
PUBLISH_IMAGE_FETCH_FAILED_MESSAGE constant shared by baijiahao, bilibili,
dongchedi, qiehao, smzdm, and zol adapters, and generalize the normalizer
to match any *_image_fetch_failed / *_cover_fetch_failed code. Also split
desktop publish list loading into initial vs manual-refresh states so the
refresh button no longer blanks the table, and fix admin-web active-task
detection to cover all pending statuses.
This commit is contained in:
2026-05-26 18:53:36 +08:00
parent 78fb9c42e2
commit fa52d4ca60
10 changed files with 67 additions and 34 deletions
@@ -4,8 +4,8 @@ import {
BAIJIAHAO_CHALLENGE_REQUIRED_MESSAGE,
DONGCHEDI_PLATFORM_EXCEPTION_MESSAGE,
PUBLISH_ACCOUNT_NOT_LOGGED_IN_MESSAGE,
PUBLISH_IMAGE_FETCH_FAILED_MESSAGE,
QIEHAO_REAL_NAME_AUTH_MESSAGE,
SMZDM_IMAGE_FETCH_FAILED_MESSAGE,
WANGYIHAO_DRAFT_SAVE_PARAMETER_MESSAGE,
WANGYIHAO_PUBLISH_CLICK_MESSAGE,
WANGYIHAO_TOKEN_MISSING_MESSAGE,
@@ -14,9 +14,9 @@ import {
normalizeBaijiahaoPublishErrorMessage,
normalizeDongchediPublishErrorMessage,
normalizePublisherErrorMessage,
normalizePublisherImageFetchErrorMessage,
normalizePublisherLoginErrorMessage,
normalizeQiehaoPublishErrorMessage,
normalizeSmzdmPublishErrorMessage,
normalizeWangyihaoPublishErrorMessage,
normalizeWeixinGzhPublishErrorMessage,
} from './publisher-errors'
@@ -115,12 +115,18 @@ describe('publisher error normalization', () => {
)
})
it('normalizes SMZDM image fetch failures to the desktop Chinese prompt', () => {
it('normalizes platform image fetch failures to the desktop Chinese prompt', () => {
expect(normalizePublisherErrorMessage('smzdm_image_fetch_failed', 'smzdm')).toBe(
SMZDM_IMAGE_FETCH_FAILED_MESSAGE,
PUBLISH_IMAGE_FETCH_FAILED_MESSAGE,
)
expect(normalizeSmzdmPublishErrorMessage('Error: smzdm_image_fetch_failed')).toBe(
SMZDM_IMAGE_FETCH_FAILED_MESSAGE,
expect(normalizePublisherErrorMessage('dongchedi_cover_fetch_failed', 'dongchedi')).toBe(
PUBLISH_IMAGE_FETCH_FAILED_MESSAGE,
)
expect(normalizePublisherErrorMessage('qiehao_image_fetch_failed:timeout', 'qiehao')).toBe(
PUBLISH_IMAGE_FETCH_FAILED_MESSAGE,
)
expect(normalizePublisherImageFetchErrorMessage('Error: bilibili_image_fetch_failed')).toBe(
PUBLISH_IMAGE_FETCH_FAILED_MESSAGE,
)
})
@@ -14,8 +14,8 @@ export const BAIJIAHAO_CHALLENGE_REQUIRED_MESSAGE =
'百家号检测到网络环境异常,需要人机验证。请打开百家号后台手动完成一次发稿或验证后再重试发布。'
export const DONGCHEDI_PLATFORM_EXCEPTION_MESSAGE =
'懂车帝平台返回异常,请打开懂车帝后台查看并处理平台提示,确认账号状态后再重试。'
export const SMZDM_IMAGE_FETCH_FAILED_MESSAGE =
'图片获取错误,请检查你文章图片是否正确'
export const PUBLISH_IMAGE_FETCH_FAILED_MESSAGE =
'图片获取错误,请检查你文章和封面图片是否正确'
const PUBLISH_PLATFORM_LABELS: Record<string, string> = {
baijiahao: '百家号',
@@ -266,7 +266,7 @@ export function normalizeDongchediPublishErrorMessage(
return normalized
}
export function normalizeSmzdmPublishErrorMessage(
export function normalizePublisherImageFetchErrorMessage(
message: string | null | undefined,
): string | null {
const normalized = normalizeErrorText(message)
@@ -274,8 +274,8 @@ export function normalizeSmzdmPublishErrorMessage(
return null
}
if (/\bsmzdm_image_fetch_failed\b/i.test(normalized)) {
return SMZDM_IMAGE_FETCH_FAILED_MESSAGE
if (/\b[a-z0-9_]+_(?:image|cover)_fetch_failed\b/i.test(normalized)) {
return PUBLISH_IMAGE_FETCH_FAILED_MESSAGE
}
return normalized
}
@@ -295,7 +295,7 @@ export function normalizePublisherErrorMessage(
const wangyihaoMessage = normalizeWangyihaoPublishErrorMessage(qiehaoMessage)
const baijiahaoMessage = normalizeBaijiahaoPublishErrorMessage(wangyihaoMessage)
const dongchediMessage = normalizeDongchediPublishErrorMessage(baijiahaoMessage, platform)
const smzdmMessage = normalizeSmzdmPublishErrorMessage(dongchediMessage)
const loginMessage = normalizePublisherLoginErrorMessage(smzdmMessage)
const imageFetchMessage = normalizePublisherImageFetchErrorMessage(dongchediMessage)
const loginMessage = normalizePublisherLoginErrorMessage(imageFetchMessage)
return normalizeWeixinGzhPublishErrorMessage(loginMessage)
}