From d930c4daf48268de81f5efd89ec36d673891d469 Mon Sep 17 00:00:00 2001 From: gengruilin Date: Wed, 14 Oct 2026 17:04:03 +0800 Subject: [PATCH] refactor(wecom): carry the failed result in the page presentation The presentation keeps the failed operation result itself instead of a flag, and the section labels non-step phases from the shared `status.*` copy. --- .../client/ui-wecom/src/client/WecomConnection.tsx | 5 ++--- packages/client/ui-wecom/src/client/connection.ts | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/client/ui-wecom/src/client/WecomConnection.tsx b/packages/client/ui-wecom/src/client/WecomConnection.tsx index 8ec82941c1..f3bd28dd55 100644 --- a/packages/client/ui-wecom/src/client/WecomConnection.tsx +++ b/packages/client/ui-wecom/src/client/WecomConnection.tsx @@ -13,9 +13,8 @@ export function WecomConnectionSection(props: FaceProps): ReactNode { const { useWecomConnection, check, connect, cancel, openAuthorization, retry, t } = props const snapshot = useWecomConnection(value => value) const shown = presentConnection(snapshot) - const failed = 'failed' in shown && shown.failed ? snapshot.view?.result : undefined const actions: CliAccountAction[] = [] - let status = t(`status.${shown.phase === 'connecting' ? 'checking' : shown.phase}`) + let status: string | undefined let detail: string | undefined switch (shown.phase) { case 'disconnected': actions.push({ label: t('action.connect'), onClick: connect, variant: 'primary' }); detail = t('detail.disconnected'); break @@ -34,7 +33,7 @@ export function WecomConnectionSection(props: FaceProps): ReactNode { } return ( + actions={actions} detail={detail} failure={'failed' in shown && shown.failed !== undefined ? { text: t('failed'), command: shown.failed.failure } : undefined} /> ) } diff --git a/packages/client/ui-wecom/src/client/connection.ts b/packages/client/ui-wecom/src/client/connection.ts index 0a49c7efd1..8dc225dc23 100644 --- a/packages/client/ui-wecom/src/client/connection.ts +++ b/packages/client/ui-wecom/src/client/connection.ts @@ -12,7 +12,7 @@ export type WecomNotice = 'connected' export type ConnectionSnapshot = CliAccountSnapshot export type ConnectionPresentation = - | { readonly phase: Exclude; readonly failed: boolean } + | { readonly phase: Exclude; readonly failed: WecomState['result'] } | { readonly phase: 'connecting'; readonly step: 'authorizing' | 'connecting'; readonly url: string | undefined; readonly cancellable: boolean } export interface ConnectionFace { @@ -26,9 +26,9 @@ export interface ConnectionFace { } export function presentConnection({ view, stopped }: Pick): ConnectionPresentation { - if (stopped) return { phase: 'stopped', failed: false } + if (stopped) return { phase: 'stopped', failed: undefined } const operation = view?.operation - if (view === undefined || operation?.kind === 'check') return { phase: 'checking', failed: false } + if (view === undefined || operation?.kind === 'check') return { phase: 'checking', failed: undefined } if (operation !== undefined) { return { phase: 'connecting', @@ -37,9 +37,9 @@ export function presentConnection({ view, stopped }: Pick