"use client" import { useState } from "react" import { Plus, Filter, Search, RefreshCw, MoreVertical, Clock, Copy, Code } from "lucide-react" import { Card } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import Link from "next/link" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu" import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from "recharts" import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { toast } from "@/components/ui/use-toast" import { useRouter } from "next/navigation" import type { Device } from "@/components/device-grid" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import { Badge } from "@/components/ui/badge" // Import Badge component interface Task { id: string name: string status: "running" | "paused" | "completed" stats: { devices: number customersPerDevice: number totalCalls: number successCalls: number errorCalls: number successRate: number } lastUpdated: string executionTime: string nextExecutionTime: string trend: { date: string; calls: number; success: number }[] deviceList: Device[] apiInfo: { endpoint: string method: string token: string } } // 生成随机数据的辅助函数 function generateRandomStats() { const devices = Math.floor(Math.random() * 16) + 5 const customersPerDevice = Math.floor(Math.random() * 11) + 10 const totalCalls = Math.floor(Math.random() * 1000) + 500 const successCalls = Math.floor(totalCalls * (Math.random() * 0.3 + 0.6)) const errorCalls = totalCalls - successCalls return { devices, customersPerDevice, totalCalls, successCalls, errorCalls, successRate: Math.round((successCalls / totalCalls) * 100), } } export default function ApiPage() { const [tasks, setTasks] = useState([ { id: "1", name: "APP加友接口", status: "running", stats: generateRandomStats(), lastUpdated: "2024-02-09 15:30", executionTime: "2024-02-09 17:24:10", nextExecutionTime: "2024-02-09 17:25:36", trend: Array.from({ length: 7 }, (_, i) => ({ date: `2024-02-${String(i + 1).padStart(2, "0")}`, calls: Math.floor(Math.random() * 100) + 50, success: Math.floor(Math.random() * 80) + 40, })), deviceList: [], apiInfo: { endpoint: "https://api.ckb.quwanzhi.com/api/open/task/addFriend", method: "POST", token: "ckb_token_xxxxx", }, }, ]) const [selectedTaskId, setSelectedTaskId] = useState(null) const [isApiDocsOpen, setIsApiDocsOpen] = useState(false) const router = useRouter() const toggleTaskStatus = (taskId: string) => { setTasks( tasks.map((task) => { if (task.id === taskId) { return { ...task, status: task.status === "running" ? "paused" : "running", } } return task }), ) } const copyTask = (taskId: string) => { const taskToCopy = tasks.find((task) => task.id === taskId) if (taskToCopy) { const newTask = { ...taskToCopy, id: `${Date.now()}`, name: `${taskToCopy.name} (副本)`, stats: generateRandomStats(), status: "paused" as const, lastUpdated: new Date().toLocaleString(), } setTasks([...tasks, newTask]) toast({ title: "复制成功", description: "已创建计划副本", }) } } const handleTaskClick = (taskId: string) => { router.push(`/scenarios/api/${taskId}/edit`) } const selectedTask = tasks.find((task) => task.id === selectedTaskId) return (

API获客

{tasks.map((task) => ( handleTaskClick(task.id)} >

{task.name}

router.push(`/scenarios/api/${task.id}/edit`)}> 编辑计划 copyTask(task.id)}> 复制计划 查看详情 删除计划
总调用次数
{task.stats.totalCalls}
成功调用
{task.stats.successCalls}
失败调用
{task.stats.errorCalls}
成功率
{task.stats.successRate}%
上次执行: {task.executionTime}
下次执行: {task.nextExecutionTime}
))}
API 文档 概述 接口列表 示例代码

概述

本接口文档依照REST标准,请求头需要添加token作为鉴权。

基础域名

https://api.ckb.quwanzhi.com

手机微信号加友接口

POST {/* Badge component used here */} /api/open/task/addFriend

请求参数

名称 类型 是否必填 说明
phone string 手机或微信号
tags string 标签
taskId int 计划任务ID

请求示例

                    {JSON.stringify(
                      {
                        phone: "18956545898",
                        taskId: 593,
                        tags: "90后,女生,美女",
                      },
                      null,
                      2,
                    )}
                  

返回示例

                    {JSON.stringify(
                      {
                        code: 10000,
                        data: null,
                        message: "操作成功",
                      },
                      null,
                      2,
                    )}
                  
) }