mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-03 15:06:36 +08:00
feat: 添加访问日志分页功能,优化相关接口和前端组件
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
import { apiRequest } from '@/lib/api/client';
|
||||
|
||||
import type { AccessLogItem } from '@/features/access-logs/types';
|
||||
import type { AccessLogList } from '@/features/access-logs/types';
|
||||
|
||||
export function getAccessLogs(nodeId?: string) {
|
||||
export function getAccessLogs(page: number, nodeId?: string, pageSize = 50) {
|
||||
const normalizedNodeId = nodeId?.trim();
|
||||
const query = normalizedNodeId
|
||||
? `?node_id=${encodeURIComponent(normalizedNodeId)}`
|
||||
: '';
|
||||
return apiRequest<AccessLogItem[]>(`/access-logs/${query}`);
|
||||
const searchParams = new URLSearchParams({
|
||||
p: String(Math.max(page, 0)),
|
||||
page_size: String(pageSize),
|
||||
});
|
||||
if (normalizedNodeId) {
|
||||
searchParams.set('node_id', normalizedNodeId);
|
||||
}
|
||||
return apiRequest<AccessLogList>(`/access-logs/?${searchParams.toString()}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user