import { API_BASE, fetchWithAuth } from "./client"; export const subscriptionsApi = { getPlans: async () => { const res = await fetch(`${API_BASE}/api/v1/subscriptions/plans`); if (!res.ok) throw new Error("获取套餐失败"); return res.json(); }, getCurrent: async (token: string) => fetchWithAuth("/api/v1/subscriptions/current", {}, token), subscribe: async (token: string, plan: string) => fetchWithAuth( "/api/v1/subscriptions/subscribe", { method: "POST", body: JSON.stringify({ plan }), }, token ), cancel: async (token: string) => fetchWithAuth( "/api/v1/subscriptions/cancel", { method: "POST" }, token ), getHistory: async (token: string) => fetchWithAuth("/api/v1/subscriptions/history", {}, token), };