diff --git a/soul-admin/src/pages/find-partner/tabs/CKBConfigPanel.tsx b/soul-admin/src/pages/find-partner/tabs/CKBConfigPanel.tsx index bd73305a..80f8ec46 100644 --- a/soul-admin/src/pages/find-partner/tabs/CKBConfigPanel.tsx +++ b/soul-admin/src/pages/find-partner/tabs/CKBConfigPanel.tsx @@ -5,7 +5,7 @@ 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, + RefreshCw, Zap, CheckCircle2, XCircle, Smartphone, FileText, ExternalLink, Save, } from 'lucide-react' import { get, post } from '@/api/client' @@ -20,6 +20,10 @@ const typeMap = ['partner', 'investor', 'mentor', 'team'] export function CKBConfigPanel() { const [testPhone, setTestPhone] = useState('13800000000') const [testWechat, setTestWechat] = useState('') + const [apiUrl, setApiUrl] = useState('https://ckbapi.quwanzhi.com/v1/api/scenarios') + const [apiKey, setApiKey] = useState('fyngh-ecy9h-qkdae-epwd5-rz6kd') + const [docNotes, setDocNotes] = useState('') + const [isSaving, setIsSaving] = useState(false) const [tests, setTests] = useState([ { endpoint: '/api/ckb/join', label: '找伙伴', method: 'POST', status: 'idle' }, { endpoint: '/api/ckb/join', label: '资源对接', method: 'POST', status: 'idle' }, @@ -62,6 +66,36 @@ export function CKBConfigPanel() { for (let i = 0; i < tests.length; i++) await testOne(i) } + async function loadConfig() { + try { + const data = await get<{ data?: { apiUrl?: string; apiKey?: string; docNotes?: string } }>('/api/db/config/full?key=ckb_config') + const c = data?.data + if (c?.apiUrl) setApiUrl(c.apiUrl) + if (c?.apiKey) setApiKey(c.apiKey) + if (c?.docNotes) setDocNotes(c.docNotes) + } catch { + // ignore + } + } + + async function saveConfig() { + setIsSaving(true) + try { + const res = await post<{ success?: boolean; error?: string }>('/api/db/config', { + key: 'ckb_config', + value: { apiUrl, apiKey, docNotes }, + description: '存客宝接口配置', + }) + alert(res?.success !== false ? '存客宝配置已保存' : `保存失败: ${res?.error || '未知错误'}`) + } catch (e) { + alert(`保存失败: ${e instanceof Error ? e.message : '网络错误'}`) + } finally { + setIsSaving(false) + } + } + + useState(() => { void loadConfig(); return null }) + return ( @@ -79,6 +113,22 @@ export function CKBConfigPanel() { +
+
+ + setApiUrl(e.target.value)} /> +
+
+ + setApiKey(e.target.value)} /> +
+
+ +
+
+
@@ -121,7 +171,30 @@ export function CKBConfigPanel() { 场景获客API | - Key: fyngh-ec... + Key: {apiKey ? `${apiKey.slice(0, 8)}...` : '未配置'} +
+ +
+
+

场景获客接口摘要

+
+

接口:POST /v1/api/scenarios

+

必填鉴权:apiKeysigntimestamp

+

至少一项:phonewechatId

+

可选字段:namesourceremarktagssiteTagsportrait

+

签名:排除 sign/apiKey/portrait,按键升序拼接值后双重 MD5

+

成功返回:{"{ code: 200, message: '新增成功|已存在' }"}

+
+
+
+

说明备注(可编辑)

+