Compare commits

...

2 Commits

Author SHA1 Message Date
root 3f8971aa55 chore(desktop): brand dev-time app name as ShengxinPush
Desktop Client Build / Resolve Build Metadata (push) Successful in 1m26s
Desktop Client Build / Build Desktop Client (push) Successful in 33m18s
Desktop Client Build / Publish Client Artifacts to NAS (push) Successful in 44s
setName pins the runtime app name (menu bar, task switcher) and
setAboutPanelOptions overrides the macOS About panel which is sourced
separately from Info.plist when running unpackaged. Packaged builds are
unaffected: electron-builder productName "省心推" still drives the .app
bundle and NSIS installer metadata. The macOS Dock label in dev still
shows "Electron" because that comes from the unpacked Electron.app
bundle's CFBundleName, which is outside Electron's API surface.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 23:15:08 +08:00
root b7ba3ba58a feat(desktop): surface baijiahao challenge-required failures with actionable copy
Baijiahao throws baijiahao_challenge_required when its risk control flags
the network environment, but PublishManagementView previously showed the
raw "code: ..., message: ..." string. Route the error through the existing
normalizer pipeline so users see a clear "需要人机验证 + 去后台手动完成
一次发稿" prompt instead.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 23:03:00 +08:00
3 changed files with 50 additions and 1 deletions
+18
View File
@@ -63,6 +63,24 @@ import { initTray, showTrayBalloon } from './tray'
import { STANDARD_USER_AGENT } from './user-agent'
import { startHotViewReaper } from './view-pool'
// In dev (no packaged Info.plist / NSIS metadata) Electron falls back to the
// generic "Electron" name, so the macOS menu bar and Windows task switcher
// show "Electron". Pin the dev-time app name to the product brand. Packaged
// builds ignore this because Info.plist `CFBundleName` (driven by
// electron-builder `productName`) takes precedence.
app.setName('ShengxinPush')
// The macOS "About" panel pulls from a separate options bag — `setName` alone
// leaves it as "Electron 41.x". Set explicit copy here so the dev About dialog
// matches the brand. Packaged macOS again wins via Info.plist.
app.setAboutPanelOptions({
applicationName: 'ShengxinPush',
applicationVersion: app.getVersion(),
version: app.getVersion(),
copyright: 'Copyright © 2026 shengxintui.com',
website: 'https://shengxintui.com',
})
app.commandLine.appendSwitch(
'disable-features',
'PostQuantumKyber,EncryptedClientHello,UseDnsHttpsSvcb,UseDnsHttpsSvcbAlpn',
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest'
import {
BAIJIAHAO_CHALLENGE_REQUIRED_MESSAGE,
PUBLISH_ACCOUNT_NOT_LOGGED_IN_MESSAGE,
QIEHAO_REAL_NAME_AUTH_MESSAGE,
WANGYIHAO_DRAFT_SAVE_PARAMETER_MESSAGE,
@@ -8,6 +9,7 @@ import {
WANGYIHAO_TOKEN_MISSING_MESSAGE,
WEIXIN_GZH_PUBLIC_URL_MISSING_MESSAGE,
isQiehaoRealNameAuthError,
normalizeBaijiahaoPublishErrorMessage,
normalizePublisherErrorMessage,
normalizePublisherLoginErrorMessage,
normalizeQiehaoPublishErrorMessage,
@@ -76,6 +78,18 @@ describe('publisher error normalization', () => {
).toBe(WANGYIHAO_PUBLISH_CLICK_MESSAGE)
})
it('normalizes Baijiahao challenge-required failures', () => {
expect(normalizePublisherErrorMessage('baijiahao_challenge_required')).toBe(
BAIJIAHAO_CHALLENGE_REQUIRED_MESSAGE,
)
expect(
normalizePublisherErrorMessage('baijiahao_challenge_required:您所在网络环境异常,请完成验证'),
).toBe(BAIJIAHAO_CHALLENGE_REQUIRED_MESSAGE)
expect(normalizeBaijiahaoPublishErrorMessage('Error: baijiahao_challenge_required')).toBe(
BAIJIAHAO_CHALLENGE_REQUIRED_MESSAGE,
)
})
it('normalizes Weixin GZH missing public URL failures', () => {
expect(normalizePublisherErrorMessage('weixin_gzh_public_url_missing:100000093')).toBe(
WEIXIN_GZH_PUBLIC_URL_MISSING_MESSAGE,
@@ -10,6 +10,8 @@ export const WANGYIHAO_PUBLISH_CLICK_MESSAGE =
'网易号草稿已保存,但自动发布未完成。请打开网易号后台确认草稿状态后重试。'
export const WEIXIN_GZH_PUBLIC_URL_MISSING_MESSAGE =
'微信公众号可能已触发管理员/运营者授权发布,桌面端未能获取到文章外链。请打开公众号后台完成授权发布,并在发表记录中确认文章链接。'
export const BAIJIAHAO_CHALLENGE_REQUIRED_MESSAGE =
'百家号检测到网络环境异常,需要人机验证。请打开百家号后台手动完成一次发稿或验证后再重试发布。'
const PUBLISH_PLATFORM_LABELS: Record<string, string> = {
baijiahao: '百家号',
@@ -124,12 +126,27 @@ export function normalizeWeixinGzhPublishErrorMessage(
return normalized
}
export function normalizeBaijiahaoPublishErrorMessage(
message: string | null | undefined,
): string | null {
const normalized = normalizeErrorText(message)
if (!normalized) {
return null
}
if (/\bbaijiahao_challenge_required\b/i.test(normalized)) {
return BAIJIAHAO_CHALLENGE_REQUIRED_MESSAGE
}
return normalized
}
export function normalizePublisherErrorMessage(message: string | null | undefined): string | null {
if (message === 'compliance_blocked') {
return '内容合规检测已阻断本次发布,请修改文章后重新发布。'
}
const qiehaoMessage = normalizeQiehaoPublishErrorMessage(message)
const wangyihaoMessage = normalizeWangyihaoPublishErrorMessage(qiehaoMessage)
const loginMessage = normalizePublisherLoginErrorMessage(wangyihaoMessage)
const baijiahaoMessage = normalizeBaijiahaoPublishErrorMessage(wangyihaoMessage)
const loginMessage = normalizePublisherLoginErrorMessage(baijiahaoMessage)
return normalizeWeixinGzhPublishErrorMessage(loginMessage)
}