mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-02-02 10:50:49 +08:00
feat: cap log fetch size and add limit query param
This commit is contained in:
2
app.js
2
app.js
@@ -20,6 +20,7 @@ import { debounce } from './src/utils/dom.js';
|
||||
import {
|
||||
CACHE_EXPIRY_MS,
|
||||
MAX_LOG_LINES,
|
||||
LOG_FETCH_LIMIT,
|
||||
DEFAULT_AUTH_FILES_PAGE_SIZE,
|
||||
MIN_AUTH_FILES_PAGE_SIZE,
|
||||
MAX_AUTH_FILES_PAGE_SIZE,
|
||||
@@ -78,6 +79,7 @@ class CLIProxyManager {
|
||||
// 当前展示的日志行
|
||||
this.displayedLogLines = [];
|
||||
this.maxDisplayLogLines = MAX_LOG_LINES;
|
||||
this.logFetchLimit = LOG_FETCH_LIMIT;
|
||||
|
||||
// 日志时间戳(用于增量加载)
|
||||
this.latestLogTimestamp = null;
|
||||
|
||||
@@ -20,8 +20,20 @@ export const logsModule = {
|
||||
}
|
||||
|
||||
let url = '/logs';
|
||||
const params = new URLSearchParams();
|
||||
|
||||
if (incremental && this.latestLogTimestamp) {
|
||||
url += `?after=${this.latestLogTimestamp}`;
|
||||
params.set('after', this.latestLogTimestamp);
|
||||
}
|
||||
|
||||
const logFetchLimit = Number.isFinite(this.logFetchLimit) ? this.logFetchLimit : 2500;
|
||||
if (logFetchLimit > 0) {
|
||||
params.set('limit', logFetchLimit);
|
||||
}
|
||||
|
||||
const queryString = params.toString();
|
||||
if (queryString) {
|
||||
url += `?${queryString}`;
|
||||
}
|
||||
|
||||
const response = await this.makeRequest(url, {
|
||||
|
||||
@@ -53,6 +53,12 @@ export const OAUTH_MAX_POLL_DURATION_MS = 5 * 60 * 1000;
|
||||
*/
|
||||
export const MAX_LOG_LINES = 2000;
|
||||
|
||||
/**
|
||||
* 日志接口获取数量上限
|
||||
* 限制后端返回的日志行数,避免一次拉取过多数据
|
||||
*/
|
||||
export const LOG_FETCH_LIMIT = 2500;
|
||||
|
||||
/**
|
||||
* 认证文件列表默认每页显示数量
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user