mirror of
https://github.com/2930134478/AI-CS.git
synced 2026-06-15 00:44:30 +08:00
36 lines
665 B
TypeScript
36 lines
665 B
TypeScript
/**
|
|
* 访客端 API 服务
|
|
* 提供访客相关的 API 调用
|
|
*/
|
|
|
|
import { apiUrl } from "@/lib/config";
|
|
|
|
/**
|
|
* 在线客服信息
|
|
*/
|
|
export interface OnlineAgent {
|
|
id: number;
|
|
nickname: string;
|
|
avatar_url: string;
|
|
}
|
|
|
|
/**
|
|
* 获取在线客服列表
|
|
*/
|
|
export async function fetchOnlineAgents(): Promise<OnlineAgent[]> {
|
|
const response = await fetch(apiUrl("/visitor/online-agents"), {
|
|
method: "GET",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`获取在线客服列表失败: ${response.statusText}`);
|
|
}
|
|
|
|
const data = await response.json();
|
|
return data.agents || [];
|
|
}
|
|
|