'use client'; // Subscription.tsx — 订阅导入(链接 + 二维码占位 + 一键导入三方客户端)。承袭 UCSub。 import React, { useEffect, useState } from 'react'; import { Icon } from './icons'; import { card } from './shared'; import type { TFn } from '../lib/i18n'; import { getClient } from '../lib/api/client'; export default function Subscription({ t, mobile }: { t: TFn; mobile: boolean }) { const api = getClient(); const [url, setUrl] = useState(''); const [copied, setCopied] = useState(false); const [reset, setReset] = useState(false); const [busy, setBusy] = useState(false); useEffect(() => { api.getSubscription().then((s) => setUrl(s.url)).catch(() => {}); }, [api]); const clients = [ { name: `${t('brandName')} App`, sub: 'iOS / Android / 桌面', icon: 'shield-check', accent: true }, { name: 'Shadowrocket', sub: 'iOS', icon: 'external-link' }, { name: 'Clash Verge', sub: 'Windows / macOS', icon: 'external-link' }, { name: 'v2rayN', sub: 'Windows', icon: 'external-link' }, { name: 'sing-box', sub: '全平台', icon: 'external-link' }, ]; async function copy() { try { await navigator.clipboard?.writeText(url); } catch { /* ignore */ } setCopied(true); setTimeout(() => setCopied(false), 1800); } async function doReset() { if (busy) return; setBusy(true); try { const s = await api.resetSubscription(); setUrl(s.url); setReset(true); } finally { setBusy(false); } } return (