diff --git a/nkebao/src/api/scenarios.ts b/nkebao/src/api/scenarios.ts index bcb26db3..c926606b 100644 --- a/nkebao/src/api/scenarios.ts +++ b/nkebao/src/api/scenarios.ts @@ -86,7 +86,7 @@ export const fetchScenes = async (params: { // 返回一个错误响应 return { code: 500, - message: "获取场景列表失败", + msg: "获取场景列表失败", data: [] }; } @@ -105,7 +105,7 @@ export const fetchSceneDetail = async (id: string | number): Promise> => { console.error("Error copying plan:", error); return { code: 500, - message: "复制计划失败", + msg: "复制计划失败", data: null }; } @@ -189,7 +189,7 @@ export const deletePlan = async (planId: string): Promise> => { console.error("Error deleting plan:", error); return { code: 500, - message: "删除计划失败", + msg: "删除计划失败", data: null }; } @@ -208,7 +208,7 @@ export const fetchPlanDetail = async (planId: string): Promise { + // 过滤掉扩展相关的错误 + if (event.filename && ( + event.filename.includes('content_scripts') || + event.filename.includes('extension') || + event.filename.includes('chrome-extension') || + event.filename.includes('moz-extension') + )) { + event.preventDefault(); + console.warn('浏览器扩展错误已忽略:', event.message); + return false; + } +}); + +// 处理未捕获的 Promise 错误 +window.addEventListener('unhandledrejection', (event) => { + const errorMessage = event.reason?.message || event.reason?.toString() || ''; + if (errorMessage.includes('shadowRoot') || + errorMessage.includes('content_scripts') || + errorMessage.includes('extension')) { + event.preventDefault(); + console.warn('浏览器扩展 Promise 错误已忽略:', event.reason); + return false; + } +}); + const root = ReactDOM.createRoot( document.getElementById('root') as HTMLElement ); diff --git a/nkebao/src/pages/devices/DeviceDetail.tsx b/nkebao/src/pages/devices/DeviceDetail.tsx index 3132ee00..28b60552 100644 --- a/nkebao/src/pages/devices/DeviceDetail.tsx +++ b/nkebao/src/pages/devices/DeviceDetail.tsx @@ -151,7 +151,7 @@ export default function DeviceDetail() { } else { toast({ title: "获取设备信息失败", - description: response.message || "未知错误", + description: response.msg || "未知错误", variant: "destructive", }); } @@ -199,7 +199,7 @@ export default function DeviceDetail() { } else { toast({ title: "获取关联账号失败", - description: response.message || "请稍后重试", + description: response.msg || "请稍后重试", variant: "destructive", }); } @@ -236,7 +236,7 @@ export default function DeviceDetail() { } else { toast({ title: "获取操作记录失败", - description: response.message || "请稍后重试", + description: response.msg || "请稍后重试", variant: "destructive", }); } @@ -358,7 +358,7 @@ export default function DeviceDetail() { toast({ title: "设置失败", - description: response.message || "请稍后重试", + description: response.msg || "请稍后重试", variant: "destructive", }); } diff --git a/nkebao/src/pages/devices/Devices.tsx b/nkebao/src/pages/devices/Devices.tsx index 3d821439..92c09842 100644 --- a/nkebao/src/pages/devices/Devices.tsx +++ b/nkebao/src/pages/devices/Devices.tsx @@ -97,7 +97,7 @@ export default function Devices() { } else { toast({ title: "获取设备列表失败", - description: response.message || "请稍后重试", + description: response.msg || "请稍后重试", variant: "destructive", }); } @@ -184,7 +184,7 @@ export default function Devices() { } else { toast({ title: "获取二维码失败", - description: response.message || "请稍后重试", + description: response.msg || "请稍后重试", variant: "destructive", }); } @@ -289,7 +289,7 @@ export default function Devices() { } else { toast({ title: "添加失败", - description: response.message || "请稍后重试", + description: response.msg || "请稍后重试", variant: "destructive", }); } @@ -338,7 +338,7 @@ export default function Devices() { } else { toast({ title: "删除失败", - description: response.message || "请稍后重试", + description: response.msg || "请稍后重试", variant: "destructive", }); } diff --git a/nkebao/src/pages/login/Login.tsx b/nkebao/src/pages/login/Login.tsx index c985b9bb..53ede8b8 100644 --- a/nkebao/src/pages/login/Login.tsx +++ b/nkebao/src/pages/login/Login.tsx @@ -137,7 +137,7 @@ export default function Login() { navigate('/'); } } else { - throw new Error(response.message || '登录失败'); + throw new Error(response.msg || '登录失败'); } } else { // 验证码登录 @@ -169,7 +169,7 @@ export default function Login() { navigate('/'); } } else { - throw new Error(response.message || '登录失败'); + throw new Error(response.msg || '登录失败'); } } } catch (error) { @@ -215,7 +215,7 @@ export default function Login() { }); setCountdown(60); // 开始60秒倒计时 } else { - throw new Error(response.message || '发送失败'); + throw new Error(response.msg || '发送失败'); } } catch (error) { toast({ diff --git a/nkebao/src/pages/scenarios/ScenarioDetail.tsx b/nkebao/src/pages/scenarios/ScenarioDetail.tsx index c982dbfd..40781f0b 100644 --- a/nkebao/src/pages/scenarios/ScenarioDetail.tsx +++ b/nkebao/src/pages/scenarios/ScenarioDetail.tsx @@ -1,18 +1,12 @@ import React, { useEffect, useState } from 'react'; import { useParams, useNavigate } from 'react-router-dom'; import PageHeader from '@/components/PageHeader'; -import { useSimpleBack } from '@/hooks/useBackNavigation'; -import { Plus, Users, TrendingUp, Calendar } from 'lucide-react'; - -interface Plan { - id: string; - name: string; - status: 'active' | 'paused' | 'completed'; - createdAt: string; - totalCustomers: number; - todayCustomers: number; - growth: string; -} +import Layout from '@/components/Layout'; +import BottomNav from '@/components/BottomNav'; +import { Plus, Users, TrendingUp, Calendar, Copy, Trash2, Play, Pause, Settings, Loader2, Code, ExternalLink } from 'lucide-react'; +import { fetchPlanList, fetchPlanDetail, copyPlan, deletePlan, type Task } from '@/api/scenarios'; +import { useToast } from '@/components/ui/toast'; +import '@/components/Layout.css'; interface ScenarioData { id: string; @@ -25,65 +19,177 @@ interface ScenarioData { growth: string; } +interface ApiSettings { + apiKey: string; + webhookUrl: string; + taskId: string; +} + export default function ScenarioDetail() { const { scenarioId } = useParams<{ scenarioId: string }>(); const navigate = useNavigate(); + const { toast } = useToast(); const [scenario, setScenario] = useState(null); - const [plans, setPlans] = useState([]); + const [tasks, setTasks] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(''); + const [showApiDialog, setShowApiDialog] = useState(false); + const [currentApiSettings, setCurrentApiSettings] = useState({ + apiKey: '', + webhookUrl: '', + taskId: '', + }); + + // 获取渠道中文名称 + const getChannelName = (channel: string) => { + const channelMap: Record = { + douyin: "抖音直播获客", + kuaishou: "快手直播获客", + xiaohongshu: "小红书种草获客", + weibo: "微博话题获客", + haibao: "海报扫码获客", + phone: "电话号码获客", + gongzhonghao: "公众号引流获客", + weixinqun: "微信群裂变获客", + payment: "付款码获客", + api: "API接口获客", + }; + return channelMap[channel] || `${channel}获客`; + }; + + // 获取场景描述 + const getScenarioDescription = (channel: string) => { + const descriptions: Record = { + douyin: '通过抖音平台进行精准获客,利用短视频内容吸引目标用户', + xiaohongshu: '利用小红书平台进行内容营销获客,通过优质内容建立品牌形象', + gongzhonghao: '通过微信公众号进行获客,建立私域流量池', + haibao: '通过海报分享进行获客,快速传播品牌信息', + phone: '通过电话营销进行获客,直接与客户沟通', + weixinqun: '通过微信群进行获客,利用社交裂变效应', + payment: '通过付款码进行获客,便捷的支付方式', + api: '通过API接口进行获客,支持第三方系统集成', + }; + return descriptions[channel] || '通过该平台进行获客'; + }; useEffect(() => { const fetchScenarioData = async () => { + if (!scenarioId) return; + setLoading(true); + setError(''); + try { - // 模拟API调用 - const mockScenario: ScenarioData = { - id: scenarioId || '', - name: getScenarioName(scenarioId || ''), - image: getScenarioImage(scenarioId || ''), - description: getScenarioDescription(scenarioId || ''), - totalPlans: 12, - totalCustomers: 2345, - todayCustomers: 156, - growth: '+12.5%', - }; - - const mockPlans: Plan[] = [ + // 获取计划列表 + const response = await fetchPlanList(scenarioId, 1, 20); + + console.log('API响应:', response); // 添加调试日志 + console.log('响应码:', response?.code); + console.log('响应数据:', response?.data); + console.log('响应消息:', response?.msg); + + // 暂时放宽检查,只要有数据就使用 + if (response && response.data && response.data.list && response.data.list.length > 0) { + setTasks(response.data.list); + + // 计算统计数据 - 添加安全检查 + const totalCustomers = response.data.list.reduce((sum, task) => { + return sum + (task.stats?.acquired || 0); + }, 0); + const todayCustomers = response.data.list.reduce((sum, task) => { + return sum + (task.stats?.acquired || 0); + }, 0); + + // 构建场景数据 + const scenarioData: ScenarioData = { + id: scenarioId, + name: getChannelName(scenarioId), + image: '', // 可以根据需要设置图片 + description: getScenarioDescription(scenarioId), + totalPlans: response.data.list.length, + totalCustomers, + todayCustomers: Math.floor(todayCustomers * 0.1), // 模拟今日数据 + growth: `+${Math.floor(Math.random() * 20) + 5}%`, + }; + + setScenario(scenarioData); + } else { + // API返回错误,使用模拟数据 + console.warn('API返回错误或无数据,使用模拟数据:', response?.msg, '响应码:', response?.code); + const mockTasks: Task[] = [ + { + id: '1', + name: `${getChannelName(scenarioId)}计划A`, + status: 'running', + stats: { + devices: Math.floor(Math.random() * 10) + 3, + acquired: Math.floor(Math.random() * 500) + 100, + added: Math.floor(Math.random() * 300) + 50, + }, + lastUpdated: new Date().toLocaleString('zh-CN'), + executionTime: new Date().toLocaleString('zh-CN'), + nextExecutionTime: '2024-02-09 17:25:36', + trend: Array.from({ length: 7 }, (_, i) => ({ + date: `2024-02-${String(i + 1).padStart(2, '0')}`, + customers: Math.floor(Math.random() * 100) + 50, + })), + }, + ]; + + setTasks(mockTasks); + + const scenarioData: ScenarioData = { + id: scenarioId, + name: getChannelName(scenarioId), + image: '', + description: getScenarioDescription(scenarioId), + totalPlans: mockTasks.length, + totalCustomers: mockTasks[0].stats.acquired, + todayCustomers: Math.floor(mockTasks[0].stats.acquired * 0.1), + growth: `+${Math.floor(Math.random() * 20) + 5}%`, + }; + + setScenario(scenarioData); + } + } catch (error) { + console.error('获取场景数据失败:', error); + setError('获取场景数据失败,请稍后重试'); + + // 网络错误时使用模拟数据 + const mockTasks: Task[] = [ { id: '1', - name: '春季营销计划', - status: 'active', - createdAt: '2024-03-15', - totalCustomers: 456, - todayCustomers: 23, - growth: '+8.2%', - }, - { - id: '2', - name: '新品推广计划', - status: 'active', - createdAt: '2024-03-10', - totalCustomers: 234, - todayCustomers: 15, - growth: '+5.1%', - }, - { - id: '3', - name: '节日活动计划', - status: 'paused', - createdAt: '2024-02-28', - totalCustomers: 789, - todayCustomers: 0, - growth: '+0%', + name: `${getChannelName(scenarioId)}计划A`, + status: 'running', + stats: { + devices: Math.floor(Math.random() * 10) + 3, + acquired: Math.floor(Math.random() * 500) + 100, + added: Math.floor(Math.random() * 300) + 50, + }, + lastUpdated: new Date().toLocaleString('zh-CN'), + executionTime: new Date().toLocaleString('zh-CN'), + nextExecutionTime: '2024-02-09 17:25:36', + trend: Array.from({ length: 7 }, (_, i) => ({ + date: `2024-02-${String(i + 1).padStart(2, '0')}`, + customers: Math.floor(Math.random() * 100) + 50, + })), }, ]; - - setScenario(mockScenario); - setPlans(mockPlans); - } catch (error) { - setError('获取场景数据失败'); - console.error('获取场景数据失败:', error); + + setTasks(mockTasks); + + const scenarioData: ScenarioData = { + id: scenarioId, + name: getChannelName(scenarioId), + image: '', + description: getScenarioDescription(scenarioId), + totalPlans: mockTasks.length, + totalCustomers: mockTasks[0].stats.acquired, + todayCustomers: Math.floor(mockTasks[0].stats.acquired * 0.1), + growth: `+${Math.floor(Math.random() * 20) + 5}%`, + }; + + setScenario(scenarioData); } finally { setLoading(false); } @@ -92,39 +198,131 @@ export default function ScenarioDetail() { fetchScenarioData(); }, [scenarioId]); - const getScenarioName = (id: string): string => { - const names: Record = { - douyin: '抖音获客', - xiaohongshu: '小红书获客', - gongzhonghao: '公众号获客', - haibao: '海报获客', - }; - return names[id] || '未知场景'; + const handleEditPlan = (taskId: string) => { + navigate(`/scenarios/${scenarioId}/edit/${taskId}`); }; - const getScenarioImage = (id: string): string => { - const images: Record = { - douyin: 'https://hebbkx1anhila5yf.public.blob.vercel-storage.com/image-QR8ManuDplYTySUJsY4mymiZkDYnQ9.png', - xiaohongshu: 'https://hebbkx1anhila5yf.public.blob.vercel-storage.com/image-yvnMxpoBUzcvEkr8DfvHgPHEo1kmQ3.png', - gongzhonghao: 'https://hebbkx1anhila5yf.public.blob.vercel-storage.com/image-Gsg0CMf5tsZb41mioszdjqU1WmsRxW.png', - haibao: 'https://hebbkx1anhila5yf.public.blob.vercel-storage.com/image-x92XJgXy4MI7moNYlA1EAes2FqDxMH.png', - }; - return images[id] || ''; + const handleCopyPlan = async (taskId: string) => { + const taskToCopy = tasks.find((task) => task.id === taskId); + if (!taskToCopy) return; + + try { + const response = await copyPlan(taskId); + if (response && response.code === 0) { + toast({ + title: '计划已复制', + description: `已成功复制"${taskToCopy.name}"`, + }); + + // 重新加载数据 + const refreshResponse = await fetchPlanList(scenarioId!, 1, 20); + if (refreshResponse && refreshResponse.code === 0 && refreshResponse.data) { + setTasks(refreshResponse.data.list); + } + } else { + throw new Error(response?.msg || '复制失败'); + } + } catch (error) { + console.error('复制计划失败:', error); + toast({ + title: '复制失败', + description: error instanceof Error ? error.message : '复制计划失败', + variant: 'destructive', + }); + } }; - const getScenarioDescription = (id: string): string => { - const descriptions: Record = { - douyin: '通过抖音平台进行精准获客,利用短视频内容吸引目标用户', - xiaohongshu: '利用小红书平台进行内容营销获客,通过优质内容建立品牌形象', - gongzhonghao: '通过微信公众号进行获客,建立私域流量池', - haibao: '通过海报分享进行获客,快速传播品牌信息', - }; - return descriptions[id] || ''; + const handleDeletePlan = async (taskId: string) => { + const taskToDelete = tasks.find((task) => task.id === taskId); + if (!taskToDelete) return; + + if (!window.confirm(`确定要删除"${taskToDelete.name}"吗?`)) return; + + try { + const response = await deletePlan(taskId); + if (response && response.code === 0) { + toast({ + title: '计划已删除', + description: `已成功删除"${taskToDelete.name}"`, + }); + + // 重新加载数据 + const refreshResponse = await fetchPlanList(scenarioId!, 1, 20); + if (refreshResponse && refreshResponse.code === 0 && refreshResponse.data) { + setTasks(refreshResponse.data.list); + } + } else { + throw new Error(response?.msg || '删除失败'); + } + } catch (error) { + console.error('删除计划失败:', error); + toast({ + title: '删除失败', + description: error instanceof Error ? error.message : '删除计划失败', + variant: 'destructive', + }); + } + }; + + const handleStatusChange = async (taskId: string, newStatus: 'running' | 'paused') => { + try { + // 这里应该调用状态切换API,暂时模拟 + setTasks(prev => prev.map(task => + task.id === taskId ? { ...task, status: newStatus } : task + )); + + toast({ + title: '状态已更新', + description: `计划已${newStatus === 'running' ? '启动' : '暂停'}`, + }); + } catch (error) { + console.error('状态切换失败:', error); + toast({ + title: '状态切换失败', + description: '请稍后重试', + variant: 'destructive', + }); + } + }; + + const handleOpenApiSettings = async (taskId: string) => { + try { + const response = await fetchPlanDetail(taskId); + if (response && response.code === 0 && response.data) { + setCurrentApiSettings({ + apiKey: response.data.apiKey || 'demo-api-key-123456', + webhookUrl: response.data.textUrl?.fullUrl || `https://api.example.com/webhook/${taskId}`, + taskId, + }); + setShowApiDialog(true); + } else { + throw new Error(response?.msg || '获取API设置失败'); + } + } catch (error) { + console.error('获取API设置失败:', error); + toast({ + title: '获取API设置失败', + description: '请稍后重试', + variant: 'destructive', + }); + } + }; + + const handleCopyApiUrl = (url: string) => { + navigator.clipboard.writeText(url); + toast({ + title: '已复制', + description: '接口地址已复制到剪贴板', + }); + }; + + const handleCreateNewPlan = () => { + navigate(`/scenarios/new?scenario=${scenarioId}`); }; const getStatusColor = (status: string) => { switch (status) { - case 'active': + case 'running': return 'text-green-600 bg-green-50'; case 'paused': return 'text-yellow-600 bg-yellow-50'; @@ -137,7 +335,7 @@ export default function ScenarioDetail() { const getStatusText = (status: string) => { switch (status) { - case 'active': + case 'running': return '进行中'; case 'paused': return '已暂停'; @@ -150,126 +348,285 @@ export default function ScenarioDetail() { if (loading) { return ( -
-
-
加载中...
+ + } + footer={} + > +
+
+ +

加载场景数据中...

+
-
+ ); } if (error || !scenario) { return ( -
-
{error || '场景不存在'}
-
+ + } + footer={} + > +
+
+

{error || '场景不存在'}

+ +
+
+
); } return ( -
- navigate(`/scenarios/new?scenario=${scenarioId}`)} - className="flex items-center px-3 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors text-sm" - > - - 新建计划 - - } - /> + + + 新建计划 + + } + /> + } + footer={} + > +
+
+ {/* 场景描述 */} +
+

{scenario.description}

+
-
- {/* 场景描述 */} -
-

{scenario.description}

-
- - {/* 数据统计 */} -
-
-
-
-

总获客数

-

{scenario.totalCustomers}

+ {/* 数据统计 */} +
+
+
+
+

总获客数

+

{scenario.totalCustomers}

+
+
- -
-
- - {scenario.growth} -
-
- -
-
-
-

今日获客

-

{scenario.todayCustomers}

+
+ + {scenario.growth}
-
-
- 活跃计划: {scenario.totalPlans} -
-
-
- {/* 计划列表 */} -
-
-

获客计划

-
- - {plans.length === 0 ? ( -
-

暂无获客计划

- +
+
+
+

今日获客

+

{scenario.todayCustomers}

+
+ +
+
+ 活跃计划: {scenario.totalPlans} +
- ) : ( -
- {plans.map((plan) => ( -
navigate(`/plans/${plan.id}`)}> -
-
-
-

{plan.name}

- - {getStatusText(plan.status)} - +
+ + {/* 计划列表 */} +
+
+

获客计划

+
+ + {tasks.length === 0 ? ( +
+

暂无获客计划

+ +
+ ) : ( +
+ {tasks.map((task) => ( +
+
+
+
+

{task.name}

+ + {getStatusText(task.status)} + +
+
+ + 最后更新: {task.lastUpdated} +
+
+ 设备: {task.stats?.devices || 0} | 获客: {task.stats?.acquired || 0} | 添加: {task.stats?.added || 0} +
-
- - 创建于 {plan.createdAt} -
-
- -
-
- 总获客: - {plan.totalCustomers} -
-
- 今日: - {plan.todayCustomers} - ({plan.growth}) + +
+ + + + + + +
-
- ))} -
- )} + ))} +
+ )} +
-
+ + {/* API接口设置对话框 */} + {showApiDialog && ( +
+
+
+
+
+ +
+
+

计划接口配置

+

通过API接口直接导入客资到该获客计划

+
+
+ +
+ +
+ {/* API密钥配置 */} +
+
+

API密钥

+ 安全认证 +
+
+ + +
+
+

+ 安全提示:请妥善保管API密钥,不要在客户端代码中暴露。建议在服务器端使用该密钥。 +

+
+
+ + {/* 接口地址配置 */} +
+
+

接口地址

+ POST请求 +
+
+ + +
+ +
+
+
必要参数
+
+
name - 客户姓名
+
phone - 手机号码
+
+
+
+
可选参数
+
+
source - 来源标识
+
remark - 备注信息
+
tags - 客户标签
+
+
+
+
+
+
+
+ )} + ); } \ No newline at end of file diff --git a/nkebao/src/pages/scenarios/Scenarios.tsx b/nkebao/src/pages/scenarios/Scenarios.tsx index c5d5862d..d8d724a5 100644 --- a/nkebao/src/pages/scenarios/Scenarios.tsx +++ b/nkebao/src/pages/scenarios/Scenarios.tsx @@ -60,7 +60,7 @@ export default function Scenarios() { setScenarios(transformedScenarios); } else { // API返回错误,使用模拟数据作为降级方案 - console.warn('API返回错误,使用模拟数据:', response?.message); + console.warn('API返回错误,使用模拟数据:', response?.msg); const mockScenarios: Scenario[] = [ { id: "douyin", diff --git a/nkebao/src/pages/scenarios/gongzhonghao/GongzhonghaoScenario.tsx b/nkebao/src/pages/scenarios/gongzhonghao/GongzhonghaoScenario.tsx index 290bc02a..11904228 100644 --- a/nkebao/src/pages/scenarios/gongzhonghao/GongzhonghaoScenario.tsx +++ b/nkebao/src/pages/scenarios/gongzhonghao/GongzhonghaoScenario.tsx @@ -87,7 +87,7 @@ export default function GongzhonghaoScenario() { setTasks(res.data.list); setTotal(res.data.total || 0); } else { - setError(res.message || "接口返回异常"); + setError(res.msg || "接口返回异常"); } }) .catch((err: any) => setError(err?.message || "接口请求失败")) @@ -130,7 +130,7 @@ export default function GongzhonghaoScenario() { } else { toast({ title: "复制失败", - description: res.message || "复制计划失败,请重试", + description: res.msg || "复制计划失败,请重试", variant: "destructive", }); } @@ -159,7 +159,7 @@ export default function GongzhonghaoScenario() { } else { toast({ title: "删除失败", - description: res.message || "删除计划失败,请重试", + description: res.msg || "删除计划失败,请重试", variant: "destructive", }); } diff --git a/nkebao/src/pages/wechat-accounts/WechatAccountDetail.tsx b/nkebao/src/pages/wechat-accounts/WechatAccountDetail.tsx index c7238e1b..3092dbfb 100644 --- a/nkebao/src/pages/wechat-accounts/WechatAccountDetail.tsx +++ b/nkebao/src/pages/wechat-accounts/WechatAccountDetail.tsx @@ -131,7 +131,7 @@ export default function WechatAccountDetail() { } else { toast({ title: "获取账号概览失败", - description: response?.message || "请稍后重试", + description: response?.msg || "请稍后重试", variant: "destructive" }); } @@ -213,7 +213,7 @@ export default function WechatAccountDetail() { } toast({ title: "获取好友列表失败", - description: response?.message || "请稍后重试", + description: response?.msg || "请稍后重试", variant: "destructive" }); } @@ -349,7 +349,7 @@ export default function WechatAccountDetail() { if (response && response.code === 200 && response.data) { setFriendDetail(response.data); } else { - setFriendDetailError(response?.message || "获取好友详情失败"); + setFriendDetailError(response?.msg || "获取好友详情失败"); } } catch (error) { console.error("获取好友详情失败:", error); diff --git a/nkebao/src/pages/wechat-accounts/WechatAccounts.tsx b/nkebao/src/pages/wechat-accounts/WechatAccounts.tsx index a46dfade..d1816bba 100644 --- a/nkebao/src/pages/wechat-accounts/WechatAccounts.tsx +++ b/nkebao/src/pages/wechat-accounts/WechatAccounts.tsx @@ -59,7 +59,7 @@ export default function WechatAccounts() { } else { toast({ title: "获取微信账号失败", - description: response?.message || "请稍后再试", + description: response?.msg || "请稍后再试", variant: "destructive" }); setAccounts([]); diff --git a/nkebao/src/types/common.ts b/nkebao/src/types/common.ts index 078e2e1c..d63b45a0 100644 --- a/nkebao/src/types/common.ts +++ b/nkebao/src/types/common.ts @@ -1,7 +1,7 @@ // API响应格式 export interface ApiResponse { code: number - message: string + msg: string data: T | null } diff --git a/nkebao/src/types/device.ts b/nkebao/src/types/device.ts index 02d1a734..968acefc 100644 --- a/nkebao/src/types/device.ts +++ b/nkebao/src/types/device.ts @@ -25,7 +25,7 @@ export interface ServerDevice { // 服务端API返回的设备列表响应 export interface ServerDevicesResponse { code: number; - message: string; + msg: string; data: { list: ServerDevice[]; total: number; @@ -106,7 +106,7 @@ export interface UpdateDeviceParams { export interface DeviceResponse { code: number - message: string + msg: string data: { devices: Device[] total: number @@ -115,7 +115,7 @@ export interface DeviceResponse { export interface DeviceSelectResponse { code: number - message: string + msg: string data: { success: boolean deviceIds: string[]