diff --git a/soul-admin/src/pages/find-partner/tabs/CKBConfigPanel.tsx b/soul-admin/src/pages/find-partner/tabs/CKBConfigPanel.tsx new file mode 100644 index 00000000..bd73305a --- /dev/null +++ b/soul-admin/src/pages/find-partner/tabs/CKBConfigPanel.tsx @@ -0,0 +1,129 @@ +import { useState } from 'react' +import { Card, CardContent } from '@/components/ui/card' +import { Input } from '@/components/ui/input' +import { Label } from '@/components/ui/label' +import { Button } from '@/components/ui/button' +import { Badge } from '@/components/ui/badge' +import { + RefreshCw, Zap, CheckCircle2, XCircle, Smartphone, FileText, ExternalLink, +} from 'lucide-react' +import { get, post } from '@/api/client' + +interface TestResult { + endpoint: string; label: string + method: 'GET' | 'POST'; status: 'idle' | 'testing' | 'success' | 'error' + message?: string; responseTime?: number +} + +const typeMap = ['partner', 'investor', 'mentor', 'team'] + +export function CKBConfigPanel() { + const [testPhone, setTestPhone] = useState('13800000000') + const [testWechat, setTestWechat] = useState('') + const [tests, setTests] = useState([ + { endpoint: '/api/ckb/join', label: '找伙伴', method: 'POST', status: 'idle' }, + { endpoint: '/api/ckb/join', label: '资源对接', method: 'POST', status: 'idle' }, + { endpoint: '/api/ckb/join', label: '导师顾问', method: 'POST', status: 'idle' }, + { endpoint: '/api/ckb/join', label: '团队招募', method: 'POST', status: 'idle' }, + { endpoint: '/api/ckb/match', label: '匹配上报', method: 'POST', status: 'idle' }, + { endpoint: '/api/miniprogram/ckb/lead', label: '链接卡若', method: 'POST', status: 'idle' }, + { endpoint: '/api/match/config', label: '匹配配置', method: 'GET', status: 'idle' }, + ]) + + const getBody = (idx: number) => { + const phone = testPhone.trim(); const wechat = testWechat.trim() + if (idx <= 3) return { type: typeMap[idx], phone: phone || undefined, wechat: wechat || undefined, userId: 'admin_test', name: '后台测试' } + if (idx === 4) return { matchType: 'partner', phone: phone || undefined, wechat: wechat || undefined, userId: 'admin_test', nickname: '后台测试', matchedUser: { id: 'test', nickname: '测试', matchScore: 88 } } + if (idx === 5) return { phone: phone || undefined, wechatId: wechat || undefined, userId: 'admin_test', name: '后台测试' } + return {} + } + + const testOne = async (idx: number) => { + const t = tests[idx] + if (t.method === 'POST' && !testPhone.trim() && !testWechat.trim()) { alert('请填写测试手机号'); return } + const next = [...tests]; next[idx] = { ...t, status: 'testing', message: undefined, responseTime: undefined }; setTests(next) + const start = performance.now() + try { + const res = t.method === 'GET' + ? await get<{ success?: boolean; message?: string }>(t.endpoint) + : await post<{ success?: boolean; message?: string }>(t.endpoint, getBody(idx)) + const elapsed = Math.round(performance.now() - start) + const msg = res?.message || '' + const ok = res?.success === true || msg.includes('已存在') || msg.includes('已加入') || msg.includes('已提交') + const n = [...tests]; n[idx] = { ...t, status: ok ? 'success' : 'error', message: msg || (ok ? '正常' : '异常'), responseTime: elapsed }; setTests(n) + } catch (e: unknown) { + const elapsed = Math.round(performance.now() - start) + const n = [...tests]; n[idx] = { ...t, status: 'error', message: e instanceof Error ? e.message : '失败', responseTime: elapsed }; setTests(n) + } + } + + const testAll = async () => { + if (!testPhone.trim() && !testWechat.trim()) { alert('请填写测试手机号'); return } + for (let i = 0; i < tests.length; i++) await testOne(i) + } + + return ( + + +
+
+

存客宝配置与接口测试

+ CKB + + API 文档 + +
+ +
+ +
+
+ +
+ + setTestPhone(e.target.value)} /> +
+
+
+ 💬 +
+ + setTestWechat(e.target.value)} /> +
+
+
+ +
+ {tests.map((t, idx) => ( +
+
+ {t.status === 'idle' &&
} + {t.status === 'testing' && } + {t.status === 'success' && } + {t.status === 'error' && } + {t.label} +
+
+ {t.responseTime !== undefined && {t.responseTime}ms} + +
+
+ ))} +
+ +
+ + 场景获客API + + | + Key: fyngh-ec... +
+ + + ) +}