refactor: 清除前端冗余代码
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import axios from 'axios';
|
||||
import type { GraphData, Node, Edge } from '../types/graph';
|
||||
import type { GraphData, Node } from '../types/graph';
|
||||
import { API_BASE_URL, API_TIMEOUT } from '../config/constants';
|
||||
|
||||
/**
|
||||
@@ -33,21 +33,6 @@ export const graphApi = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 搜索节点(后端搜索)
|
||||
* @param query 搜索关键词
|
||||
* @returns 匹配的节点列表
|
||||
*/
|
||||
async searchNodes(query: string): Promise<Node[]> {
|
||||
try {
|
||||
const response = await apiClient.get<Node[]>(`/search?q=${encodeURIComponent(query)}`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Failed to search nodes:', error);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据 ID 获取节点详情
|
||||
* @param id 节点 ID
|
||||
@@ -62,21 +47,6 @@ export const graphApi = {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取节点的邻居节点和连接边
|
||||
* @param nodeId 节点 ID
|
||||
* @returns 包含邻居节点和边的对象
|
||||
*/
|
||||
async getNeighbors(nodeId: string): Promise<{ nodes: Node[]; edges: Edge[] }> {
|
||||
try {
|
||||
const response = await apiClient.get(`/nodes/${nodeId}/neighbors`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch neighbors:', error);
|
||||
return { nodes: [], edges: [] };
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default apiClient;
|
||||
Reference in New Issue
Block a user