Mobilens English

流程 · 账号

删除账号

这个流程的所有画面

查看

确认

完成

何时出现
怎么离开
下一步
行为规则

    用法

    import { DeleteAccount, type DeleteResult } from '@/components/mobilens/DeleteAccount';
    
    async function deleteAccount(): Promise<DeleteResult> {
      const res = await fetch('https://api.example.com/me', { method: 'DELETE' });
      if (res.ok) return { status: 'deleted' };
      if (res.status === 409) return { status: 'rejected', reason: 'You have an active subscription. Cancel it first.', fixLabel: 'Manage subscription' };
      return { status: 'failed' };
    }
    
    export function DeleteAccountScreen({ signOut, openSubscriptions }: { signOut: () => void; openSubscriptions: () => void }) {
      return (
        <DeleteAccount
          deleteAccount={deleteAccount}
          onDeleted={signOut}
          onFix={openSubscriptions}
          losing={['Your profile and username', 'Your photos and albums', 'Your messages']}
        />
      );
    }
    

    API

    参数类型默认值说明
    title? string 'Delete account' Heading shown on the account review step.
    primaryLabel? string 'Delete account' Label of the review button that opens the confirmation sheet.
    labels? Partial<DeleteAccountLabels> – The words the screen shows. Pass a partial set to change only some of them.
    deleteAccount () => Promise<DeleteResult> – Deletes the account. A call that throws counts as failed.
    onDeleted () => void – Called after the goodbye screen's button: sign out and go to the start.
    onFix? () => void – Called when the user taps the fix for a rejection, such as Manage subscription.
    losing string[] – What is deleted, one line each.
    confirmWord? string 'DELETE' The word to type to confirm.
    autoFocus? boolean true Focus the field and bring up the keyboard when the sheet opens.
    initialStep? DeleteStep 'review' Where to start. Defaults to the review; pass a step in tests.
    onStepChange? (step: DeleteStep) => void – Called with every step the screen enters, for analytics or logging.

    这个流程用到的控件