Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(desktop): 支持取消当前订阅
liugaowei5bfaa4c62caa
diff --git a/apps/desktop/src/main/billing/__tests__/index.test.ts b/apps/desktop/src/main/billing/__tests__/index.test.tsindex c903ab5df3..f0b02bb069 100644--- a/apps/desktop/src/main/billing/__tests__/index.test.ts+++ b/apps/desktop/src/main/billing/__tests__/index.test.ts@@ -161,6 +161,7 @@ describe('billing IPC', () => {BILLING_INVOKE.GET_CREDIT_USAGE,BILLING_INVOKE.GET_CATALOG,BILLING_INVOKE.GET_CURRENT_SUBSCRIPTION,+ BILLING_INVOKE.CANCEL_CURRENT_SUBSCRIPTION,])('rejects any payload on the no-payload channel %s before network access', async (channel) => {const { call, fetch } = harness();@@ -236,6 +237,30 @@ describe('billing IPC', () => {});});+ it('cancels the current subscription through one fixed provider-neutral DELETE', async () => {+ const { call, fetch } = harness();+ const canceled = {+ subscriptionId: 'subscription_1',+ status: 'ACTIVE',+ currentPeriodStartAt: '2026-07-01T00:00:00.000Z',+ currentPeriodEndAt: '2026-08-01T00:00:00.000Z',+ entitlementValidUntil: '2026-08-02T00:00:00.000Z',+ cancelAtPeriodEnd: true,+ effectivePlan: null,+ purchaseAttemptId: null,+ paymentAction: null,+ };+ fetch.mockResolvedValueOnce(canceled);++ await expect(call(BILLING_INVOKE.CANCEL_CURRENT_SUBSCRIPTION)).resolves.toEqual(canceled);+ expect(fetch).toHaveBeenCalledWith('/api/billing/subscription', {+ baseUrl: 'https://model-access.example',+ timeoutMs: 20_000,+ redactErrorDetails: true,+ method: 'DELETE',+ });+ });+it('rejects non-main-window senders before network access', async () => {const { call, fetch } = harness();await expect(call(BILLING_INVOKE.GET_CATALOG, undefined, { id: 2 })).rejects.toMatchObject({diff --git a/apps/desktop/src/main/billing/__tests__/projection.test.ts b/apps/desktop/src/main/billing/__tests__/projection.test.tsindex 3a7ec91f0b..dc11321993 100644--- a/apps/desktop/src/main/billing/__tests__/projection.test.ts+++ b/apps/desktop/src/main/billing/__tests__/projection.test.ts@@ -630,7 +630,6 @@ describe('billing response projection', () => {subscriptionId: 'subscription_1',status: 'ACTIVE',provider: 'future_provider',- managementAction: 'FUTURE_ACTION',currentPeriodStartAt: now,currentPeriodEndAt: '2026-08-23T12:00:00.000Z',entitlementValidUntil: null,@@ -672,7 +671,6 @@ describe('billing response projection', () => {});expect(projected.subscription).not.toHaveProperty('provider');- expect(projected.subscription).not.toHaveProperty('managementAction');expect(projected.subscription?.paymentAction).toBeNull();expect(projected.subscription?.effectivePlan).toEqual({version: 1,diff --git a/apps/desktop/src/main/billing/index.ts b/apps/desktop/src/main/billing/index.tsindex 36634d4efe..aa7955f9a7 100644--- a/apps/desktop/src/main/billing/index.ts+++ b/apps/desktop/src/main/billing/index.ts@@ -321,6 +321,15 @@ export function createBillingHandlers(projectBillingCurrentSubscription,);}),+ [BILLING_INVOKE.CANCEL_CURRENT_SUBSCRIPTION]: protect(async (raw) => {+ if (raw !== undefined) {+ throwIpcError('INVALID_PARAMS', 'subscription cancellation does not accept a payload');+ }+ return projectResponse(+ await invoke<unknown>('/api/billing/subscription', { method: 'DELETE' }),+ projectBillingSubscription,+ );+ }),[BILLING_INVOKE.REFRESH_SUBSCRIPTION_PURCHASE]: protect(async (raw) => {const { purchaseAttemptId } = parseIdPayload(raw, 'purchaseAttemptId');return projectResponse(diff --git a/apps/desktop/src/main/billing/projection.ts b/apps/desktop/src/main/billing/projection.tsindex 93329fcb93..d31c3953c7 100644--- a/apps/desktop/src/main/billing/projection.ts+++ b/apps/desktop/src/main/billing/projection.ts@@ -833,10 +833,6 @@ export function projectBillingSubscription(value: unknown): BillingSubscriptiontypeof value.provider === 'string' && SUPPORTED_PROVIDERS.has(value.provider)? value.provider: undefined;- const managementAction =- value.managementAction === 'API_CANCEL' || value.managementAction === 'PORTAL'- ? value.managementAction- : undefined;const entitlementStatus =typeof value.entitlementStatus === 'string' &&FULFILLMENT_STATUSES.has(value.entitlementStatus as BillingFulfillmentStatus)@@ -848,7 +844,6 @@ export function projectBillingSubscription(value: unknown): BillingSubscriptionsubscriptionId,status,...(provider ? { provider } : {}),- ...(managementAction ? { managementAction } : {}),...(entitlementStatus ? { entitlementStatus } : {}),currentPeriodStartAt,currentPeriodEndAt,diff --git a/apps/desktop/src/preload/preload.ts b/apps/desktop/src/preload/preload.tsindex b2d832fb77..b85d290972 100644--- a/apps/desktop/src/preload/preload.ts+++ b/apps/desktop/src/preload/preload.ts@@ -1565,6 +1565,8 @@ contextBridge.exposeInMainWorld('electronAPI', {createSubscription: (payload) =>ipcRenderer.invoke(BILLING_INVOKE.CREATE_SUBSCRIPTION, payload),getCurrentSubscription: () => ipcRenderer.invoke(BILLING_INVOKE.GET_CURRENT_SUBSCRIPTION),+ cancelCurrentSubscription: () =>+ ipcRenderer.invoke(BILLING_INVOKE.CANCEL_CURRENT_SUBSCRIPTION),refreshSubscriptionPurchase: (payload) =>ipcRenderer.invoke(BILLING_INVOKE.REFRESH_SUBSCRIPTION_PURCHASE, payload),quotePlanChange: (payload) => ipcRenderer.invoke(BILLING_INVOKE.QUOTE_PLAN_CHANGE, payload),diff --git a/apps/desktop/src/renderer/features/billing/BillingPage.tsx b/apps/desktop/src/renderer/features/billing/BillingPage.tsxindex 4a1b6af92c..7438334ef3 100644--- a/apps/desktop/src/renderer/features/billing/BillingPage.tsx+++ b/apps/desktop/src/renderer/features/billing/BillingPage.tsx@@ -11,6 +11,8 @@ import {} from 'lucide-react';import { useTranslation } from 'react-i18next';+import { useConfirmDialog } from '@/components/ui/confirm-dialog-provider';+import { toast } from '@/lib/toast';import { Spinner } from '@/components/ui/spinner';import { useAuth } from '@/contexts/AuthContext';import { cn } from '@/lib/utils';@@ -220,6 +222,7 @@ export function BillingPage() {export function BillingSettingsSection({ accountId }: { accountId: string | null }) {const { t, i18n } = useTranslation();+ const { confirm } = useConfirmDialog();const billingLocale = i18n.resolvedLanguage ?? i18n.language;const [catalog, setCatalog] = useState<BillingCatalog | null>(null);const [catalogError, setCatalogError] = useState(false);@@ -227,6 +230,7 @@ export function BillingSettingsSection({ accountId }: { accountId: string | nullconst [currentSubscription, setCurrentSubscription] = useState<BillingSubscription | null>(null);const [loadingSubscription, setLoadingSubscription] = useState(true);const [subscriptionError, setSubscriptionError] = useState(false);+ const [cancelingSubscription, setCancelingSubscription] = useState(false);const [creditUsage, setCreditUsage] = useState<ModelAccessCreditUsage | null>(null);const [balance, setBalance] = useState<ModelAccessBalance | null>(null);const [usageDetailsUnavailable, setUsageDetailsUnavailable] = useState(false);@@ -456,6 +460,45 @@ export function BillingSettingsSection({ accountId }: { accountId: string | null};}, [billingLocale, currentSubscription, planNameOf, t]);+ const cancelCurrentSubscription = useCallback(async () => {+ if (!currentSubscription || currentSubscription.cancelAtPeriodEnd || cancelingSubscription) {+ return;+ }+ const periodEndAt = currentPlanFacts?.periodEndAt ?? null;+ const confirmed = await confirm({+ title: t('billing.settings.subscriptionCard.cancelConfirmTitle'),+ description: periodEndAt+ ? t('billing.settings.subscriptionCard.cancelConfirmDescription', {+ date: periodEndAt,+ })+ : t('billing.settings.subscriptionCard.cancelConfirmDescriptionWithoutDate'),+ confirmText: t('billing.settings.subscriptionCard.cancelConfirmAction'),+ cancelText: t('commonUi.confirmDialog.cancel'),+ });+ if (!confirmed) return;++ setCancelingSubscription(true);+ try {+ const canceled = await billingApi.cancelCurrentSubscription();+ setCurrentSubscription(canceled);+ setSubscriptionError(false);+ toast.success(+ periodEndAt+ ? t('billing.settings.subscriptionCard.cancelSuccess', { date: periodEndAt })+ : t('billing.settings.subscriptionCard.cancelSuccessWithoutDate'),+ );+ } catch (error) {+ const ipcError = extractIpcError(error);+ toast.error(+ ipcError?.code === 'PRECONDITION_FAILED'+ ? t('billing.settings.subscriptionCard.cancelNotSupported')+ : t('billing.settings.subscriptionCard.cancelFailed'),+ );+ } finally {+ setCancelingSubscription(false);+ }+ }, [cancelingSubscription, confirm, currentPlanFacts?.periodEndAt, currentSubscription, t]);+// UI candidates only. The quote is the authority on whether a target is// actually reachable; this filter just avoids offering obviously invalid// targets (other interval, same level, or another provider's offers).@@ -606,17 +649,18 @@ export function BillingSettingsSection({ accountId }: { accountId: string | nullloading={loadingSubscription}error={subscriptionError}planChangeable={planChangeable}- actionDisabled={loadingSubscription || subscriptionError}+ canceling={cancelingSubscription}+ actionDisabled={loadingSubscription || subscriptionError || cancelingSubscription}pendingPlanChange={pendingPlanChange}pendingTargetName={planNameOf(pendingPlanChange?.targetPlan?.product.code)}+ onCancelSubscription={() => void cancelCurrentSubscription()}onChangePlan={openPlanChange}onPurchase={() => openPurchaseDialog('SUBSCRIPTION')}onResumePending={() => {if (pendingPlanChange) planChange.resumePending(pendingPlanChange);}}onCancelPending={() => {- if (pendingPlanChange)- void planChange.cancelChange(pendingPlanChange.planChangeId);+ if (pendingPlanChange) void planChange.cancelChange(pendingPlanChange.planChangeId);}}/></BillingGroup>@@ -803,9 +847,11 @@ function SubscriptionOverviewCard({loading,error,planChangeable,+ canceling,actionDisabled,pendingPlanChange,pendingTargetName,+ onCancelSubscription,onChangePlan,onPurchase,onResumePending,@@ -815,9 +861,11 @@ function SubscriptionOverviewCard({loading: boolean;error: boolean;planChangeable: boolean;+ canceling: boolean;actionDisabled: boolean;pendingPlanChange: BillingPendingPlanChange | null;pendingTargetName: string | null;+ onCancelSubscription: () => void;onChangePlan: () => void;onPurchase: () => void;onResumePending: () => void;@@ -890,16 +938,32 @@ function SubscriptionOverviewCard({</>)}</div>- <button- type="button"- onClick={planChangeable ? onChangePlan : onPurchase}- disabled={actionDisabled}- className="h-8 shrink-0 select-none rounded-full border border-[var(--border-default)] px-3.5 text-12 font-medium text-[var(--text-primary)] transition-colors hover:bg-[var(--surface-hover-soft)] disabled:cursor-not-allowed disabled:opacity-40"- >- {planChangeable- ? t('billing.settings.subscriptionCard.changeAction')- : t('billing.settings.subscriptionCard.action')}- </button>+ <div className="flex shrink-0 items-center gap-2.5">+ {facts && !facts.cancelAtPeriodEnd && (+ <button+ type="button"+ onClick={onCancelSubscription}+ disabled={actionDisabled}+ className="inline-flex h-8 select-none items-center justify-center rounded-full border border-[var(--border-default)] px-3.5 text-12 font-medium text-[var(--error-fg)] transition-colors hover:bg-[var(--error-bg)] disabled:cursor-not-allowed disabled:opacity-40"+ >+ {canceling ? (+ <Spinner size={13} />+ ) : (+ t('billing.settings.subscriptionCard.cancelAction')+ )}+ </button>+ )}+ <button+ type="button"+ onClick={planChangeable ? onChangePlan : onPurchase}+ disabled={actionDisabled}+ className="h-8 select-none rounded-full border border-[var(--border-default)] px-3.5 text-12 font-medium text-[var(--text-primary)] transition-colors hover:bg-[var(--surface-hover-soft)] disabled:cursor-not-allowed disabled:opacity-40"+ >+ {planChangeable+ ? t('billing.settings.subscriptionCard.changeAction')+ : t('billing.settings.subscriptionCard.action')}+ </button>+ </div></div>{pendingPlanChange && (<PendingPlanChangeBanner@@ -1088,9 +1152,7 @@ function UsageBreakdownCard({['purchased', usage.purchased],['promotional', usage.promotional],] as const- ).map(([key, pool]) => (- <CreditPoolRow key={key} label={poolLabels[key]} pool={pool} />- ))+ ).map(([key, pool]) => <CreditPoolRow key={key} label={poolLabels[key]} pool={pool} />): balance? ([diff --git a/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx b/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsxindex b57fb58323..e0163d5cea 100644--- a/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx+++ b/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx@@ -9,6 +9,12 @@ const i18n = {resolvedLanguage: 'en' as string | undefined,};+const uiMocks = vi.hoisted(() => ({+ confirm: vi.fn(),+ toastError: vi.fn(),+ toastSuccess: vi.fn(),+}));+const checkout = {state: {open: false,@@ -55,6 +61,15 @@ vi.mock('@/features/feature-context', () => ({vi.mock('@/contexts/AuthContext', () => ({useAuth: () => ({ dataOwnerId: 'account-fixture' }),}));+vi.mock('@/components/ui/confirm-dialog-provider', () => ({+ useConfirmDialog: () => ({ confirm: uiMocks.confirm }),+}));+vi.mock('@/lib/toast', () => ({+ toast: {+ error: uiMocks.toastError,+ success: uiMocks.toastSuccess,+ },+}));vi.mock('../useBillingCheckout', () => ({useBillingCheckout: () => checkout,}));@@ -64,6 +79,12 @@ vi.mock('qrcode', () => ({import { BillingPage } from '../BillingPage';+beforeEach(() => {+ uiMocks.confirm.mockReset().mockResolvedValue(false);+ uiMocks.toastError.mockReset();+ uiMocks.toastSuccess.mockReset();+});+describe('BillingPage remote catalog rendering', () => {beforeEach(() => {i18n.language = 'en';@@ -1122,6 +1143,7 @@ describe('BillingPage plan change', () => {})),getCatalog: vi.fn(async () => subscriptionCatalog),getCurrentSubscription: vi.fn(async () => ({ subscription: activeSubscription() })),+ cancelCurrentSubscription: vi.fn(),quotePlanChange: vi.fn(),confirmPlanChange: vi.fn(),refreshPlanChange: vi.fn(),@@ -1155,6 +1177,52 @@ describe('BillingPage plan change', () => {});});+ it('confirms provider-neutral cancellation and keeps credits unchanged until period end', async () => {+ const billing = install(billingMocks());+ billing.cancelCurrentSubscription.mockResolvedValue({+ ...activeSubscription(),+ cancelAtPeriodEnd: true,+ });+ uiMocks.confirm.mockResolvedValueOnce(true);++ render(<BillingPage />);+ fireEvent.click(await screen.findByText('billing.settings.subscriptionCard.cancelAction'));++ await waitFor(() => expect(billing.cancelCurrentSubscription).toHaveBeenCalledWith());+ expect(uiMocks.confirm).toHaveBeenCalledWith(+ expect.objectContaining({+ title: 'billing.settings.subscriptionCard.cancelConfirmTitle',+ confirmText: 'billing.settings.subscriptionCard.cancelConfirmAction',+ }),+ );+ expect(billing.getBalance).toHaveBeenCalledTimes(1);+ expect(uiMocks.toastSuccess).toHaveBeenCalledTimes(1);+ expect(+ screen.getByText((text) => text.startsWith('billing.settings.subscriptionCard.endsAt')),+ ).toBeTruthy();+ expect(screen.queryByText('billing.settings.subscriptionCard.cancelAction')).toBeNull();+ });++ it('shows the server-state rejection without inferring a payment provider', async () => {+ const billing = install(billingMocks());+ billing.cancelCurrentSubscription.mockRejectedValue(+ new Error('[PRECONDITION_FAILED] billing request conflicts with the current state'),+ );+ uiMocks.confirm.mockResolvedValueOnce(true);++ render(<BillingPage />);+ fireEvent.click(await screen.findByText('billing.settings.subscriptionCard.cancelAction'));++ await waitFor(() =>+ expect(uiMocks.toastError).toHaveBeenCalledWith(+ 'billing.settings.subscriptionCard.cancelNotSupported',+ ),+ );+ expect(billing.cancelCurrentSubscription).toHaveBeenCalledWith();+ expect(billing.getBalance).toHaveBeenCalledTimes(1);+ expect(screen.getByText('billing.settings.subscriptionCard.cancelAction')).toBeTruthy();+ });+it('offers plan change for an active subscription with same-provider candidates only', async () => {const billing = install(billingMocks());billing.quotePlanChange.mockResolvedValue({diff --git a/apps/desktop/src/renderer/features/billing/__tests__/api.test.ts b/apps/desktop/src/renderer/features/billing/__tests__/api.test.tsindex 702abd0ad1..9550031ce5 100644--- a/apps/desktop/src/renderer/features/billing/__tests__/api.test.ts+++ b/apps/desktop/src/renderer/features/billing/__tests__/api.test.ts@@ -10,6 +10,7 @@ describe('billing renderer API', () => {getCreditUsage: vi.fn(),listOrders: vi.fn(),createTopup: vi.fn(),+ cancelCurrentSubscription: vi.fn(),openPaymentRedirect: vi.fn(),};@@ -18,6 +19,10 @@ describe('billing renderer API', () => {billing.getCreditUsage.mockReset().mockResolvedValue({ available: '12.34' });billing.listOrders.mockReset().mockResolvedValue({ orders: [], nextCursor: null });billing.createTopup.mockReset().mockResolvedValue({ orderId: 'order_fixture' });+ billing.cancelCurrentSubscription.mockReset().mockResolvedValue({+ subscriptionId: 'subscription_fixture',+ cancelAtPeriodEnd: true,+ });billing.openPaymentRedirect.mockReset().mockResolvedValue({ success: true });Object.defineProperty(window, 'electronAPI', {configurable: true,@@ -53,6 +58,11 @@ describe('billing renderer API', () => {});});+ it('cancels the current subscription without exposing provider or request parameters', async () => {+ await billingApi.cancelCurrentSubscription();+ expect(billing.cancelCurrentSubscription).toHaveBeenCalledWith();+ });+it('uses the dedicated billing redirect method', async () => {const url = 'https://checkout.stripe.com/c/pay/session_fixture';await billingApi.openPaymentRedirect(url);diff --git a/apps/desktop/src/renderer/features/billing/api.ts b/apps/desktop/src/renderer/features/billing/api.tsindex 8e1cf43be7..c4a8303de0 100644--- a/apps/desktop/src/renderer/features/billing/api.ts+++ b/apps/desktop/src/renderer/features/billing/api.ts@@ -50,6 +50,9 @@ export const billingApi = {getCurrentSubscription(): Promise<BillingCurrentSubscription> {return window.electronAPI.billing.getCurrentSubscription();},+ cancelCurrentSubscription(): Promise<BillingSubscription> {+ return window.electronAPI.billing.cancelCurrentSubscription();+ },refreshSubscriptionPurchase(purchaseAttemptId: string): Promise<BillingSubscription> {return window.electronAPI.billing.refreshSubscriptionPurchase({ purchaseAttemptId });},diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 28a4faaf61..dad77c3135 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -7147,7 +7147,16 @@"priceInterval": "{{price}} / {{interval}}","includedCredits": "Includes {{amount}} credits per {{interval}}","renewsAt": "Renews {{date}}",- "endsAt": "Plan ends {{date}}"+ "endsAt": "Plan ends {{date}}",+ "cancelAction": "Cancel subscription",+ "cancelConfirmTitle": "Cancel your current subscription?",+ "cancelConfirmDescription": "This action does not issue a refund or immediately change your credits. Your current plan stays available through {{date}}, then it will not renew.",+ "cancelConfirmDescriptionWithoutDate": "This action does not issue a refund or immediately change your credits. Your current plan stays available through the end of this billing period, then it will not renew.",+ "cancelConfirmAction": "Confirm cancellation",+ "cancelSuccess": "Auto-renewal is canceled. Your current plan remains available through {{date}}.",+ "cancelSuccessWithoutDate": "Auto-renewal is canceled. Your current plan will end after this billing period.",+ "cancelNotSupported": "This subscription cannot be canceled yet.",+ "cancelFailed": "Could not cancel the subscription. Try again later."},"topupCard": {"action": "Buy credits"diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex e237a85e83..28253c7a0c 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -7136,7 +7136,16 @@"priceInterval": "{{price}} / {{interval}}","includedCredits": "毎{{interval}} {{amount}} クレジットを付与","renewsAt": "次回更新日: {{date}}",- "endsAt": "{{date}} にプラン終了"+ "endsAt": "{{date}} にプラン終了",+ "cancelAction": "サブスクリプションを解約",+ "cancelConfirmTitle": "現在のサブスクリプションを解約しますか?",+ "cancelConfirmDescription": "この操作による返金やクレジットの即時変更はありません。現在のプランは {{date}} まで利用でき、その後は更新されません。",+ "cancelConfirmDescriptionWithoutDate": "この操作による返金やクレジットの即時変更はありません。現在のプランは請求期間の終了まで利用でき、その後は更新されません。",+ "cancelConfirmAction": "解約を確定",+ "cancelSuccess": "自動更新を停止しました。現在のプランは {{date}} まで利用できます。",+ "cancelSuccessWithoutDate": "自動更新を停止しました。現在のプランはこの請求期間の終了後に終了します。",+ "cancelNotSupported": "このサブスクリプションは現在解約できません。",+ "cancelFailed": "サブスクリプションを解約できませんでした。しばらくしてからもう一度お試しください。"},"topupCard": {"action": "クレジットを購入"diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex b2842a3e1b..ce8b2f6033 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -7136,7 +7136,16 @@"priceInterval": "{{price}} / {{interval}}","includedCredits": "매{{interval}} {{amount}} 크레딧 포함","renewsAt": "다음 갱신일 {{date}}",- "endsAt": "{{date}}에 요금제 종료"+ "endsAt": "{{date}}에 요금제 종료",+ "cancelAction": "구독 취소",+ "cancelConfirmTitle": "현재 구독을 취소할까요?",+ "cancelConfirmDescription": "이 작업으로 환불되거나 크레딧이 즉시 변경되지 않습니다. 현재 요금제는 {{date}}까지 사용할 수 있으며 이후에는 갱신되지 않습니다.",+ "cancelConfirmDescriptionWithoutDate": "이 작업으로 환불되거나 크레딧이 즉시 변경되지 않습니다. 현재 요금제는 이번 결제 기간이 끝날 때까지 사용할 수 있으며 이후에는 갱신되지 않습니다.",+ "cancelConfirmAction": "취소 확인",+ "cancelSuccess": "자동 갱신을 취소했습니다. 현재 요금제는 {{date}}까지 사용할 수 있습니다.",+ "cancelSuccessWithoutDate": "자동 갱신을 취소했습니다. 현재 요금제는 이번 결제 기간이 끝난 후 종료됩니다.",+ "cancelNotSupported": "현재 이 구독은 취소할 수 없습니다.",+ "cancelFailed": "구독을 취소하지 못했습니다. 잠시 후 다시 시도해 주세요."},"topupCard": {"action": "크레딧 구매"diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 19b8596d24..982f9b81ca 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -7136,7 +7136,16 @@"priceInterval": "{{price}} / {{interval}}","includedCredits": "每{{interval}}包含 {{amount}} 点数","renewsAt": "下次续费 {{date}}",- "endsAt": "套餐将于 {{date}} 结束"+ "endsAt": "套餐将于 {{date}} 结束",+ "cancelAction": "取消订阅",+ "cancelConfirmTitle": "取消当前订阅?",+ "cancelConfirmDescription": "本次操作不会退款,也不会立即调整额度。当前套餐权益可继续使用至 {{date}},之后不再续费。",+ "cancelConfirmDescriptionWithoutDate": "本次操作不会退款,也不会立即调整额度。当前套餐权益可继续使用至本计费周期结束,之后不再续费。",+ "cancelConfirmAction": "确认取消",+ "cancelSuccess": "已取消自动续费,当前套餐可使用至 {{date}}。",+ "cancelSuccessWithoutDate": "已取消自动续费,当前套餐将在本计费周期结束后到期。",+ "cancelNotSupported": "当前订阅暂不支持取消。",+ "cancelFailed": "取消订阅失败,请稍后重试。"},"topupCard": {"action": "购买点数"diff --git a/apps/desktop/src/shared/billing.ts b/apps/desktop/src/shared/billing.tsindex af58ce4f36..b95016f80d 100644--- a/apps/desktop/src/shared/billing.ts+++ b/apps/desktop/src/shared/billing.ts@@ -19,6 +19,7 @@ export const BILLING_INVOKE = {RETRY_TOPUP: 'billing:retry-topup',CREATE_SUBSCRIPTION: 'billing:create-subscription',GET_CURRENT_SUBSCRIPTION: 'billing:get-current-subscription',+ CANCEL_CURRENT_SUBSCRIPTION: 'billing:cancel-current-subscription',REFRESH_SUBSCRIPTION_PURCHASE: 'billing:refresh-subscription-purchase',QUOTE_PLAN_CHANGE: 'billing:quote-plan-change',CONFIRM_PLAN_CHANGE: 'billing:confirm-plan-change',@@ -149,7 +150,6 @@ export type BillingSubscription = {subscriptionId: string;status: BillingSubscriptionStatus;provider?: string;- managementAction?: 'API_CANCEL' | 'PORTAL';entitlementStatus?: BillingFulfillmentStatus;currentPeriodStartAt: string | null;currentPeriodEndAt: string | null;@@ -225,6 +225,7 @@ export interface BillingRendererApi {idempotencyKey: string;}) => Promise<BillingSubscription>;getCurrentSubscription: () => Promise<BillingCurrentSubscription>;+ cancelCurrentSubscription: () => Promise<BillingSubscription>;refreshSubscriptionPurchase: (payload: {purchaseAttemptId: string;}) => Promise<BillingSubscription>;