@jeffusion/bungee-core 6.12.0 → 6.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config-storage-worker.js +142 -7
- package/dist/gateway/plugin.js +3 -1
- package/dist/main.js +3290 -2992
- package/dist/observability-worker.js +948 -175
- package/dist/plugins/anthropic-request-sanitizer/index.js.map +2 -2
- package/dist/plugins/anthropic-tool-name-transformer/index.js.map +2 -2
- package/dist/plugins/chatgpt-oauth/index.js.map +2 -2
- package/dist/plugins/codex-router/index.js.map +2 -2
- package/dist/plugins/deepseek-reasoning-fix/index.js.map +2 -2
- package/dist/plugins/key-access/index.js.map +2 -2
- package/dist/plugins/key-rate-limit/index.js.map +2 -2
- package/dist/plugins/llm-protocol-adapter/index.js +4 -2
- package/dist/plugins/llm-protocol-adapter/index.js.map +4 -4
- package/dist/plugins/llm-tps/index.js.map +2 -2
- package/dist/plugins/model-mapping/index.js.map +2 -2
- package/dist/plugins/models-dev/index.js.map +2 -2
- package/dist/plugins/request-logs/index.js +1392 -0
- package/dist/plugins/request-logs/index.js.map +33 -0
- package/dist/plugins/request-logs/ingress.js +28 -0
- package/dist/plugins/request-logs/ingress.js.map +10 -0
- package/dist/plugins/request-logs/manifest.json +68 -0
- package/dist/plugins/request-logs/ui/RequestLogsPage.svelte +1130 -0
- package/dist/plugins/request-logs/ui/RequestLogsSettings.svelte +111 -0
- package/dist/plugins/signature-repair/index.js.map +2 -2
- package/dist/plugins/token-budget/index.js.map +2 -2
- package/dist/plugins/token-metering/index.js.map +2 -2
- package/dist/plugins/token-stats/index.js.map +2 -2
- package/dist/plugins/user-auth/index.js.map +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,1130 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
let { pluginName = "request-logs" }: { pluginName?: string; apiBase?: string } = $props();
|
|
3
|
+
import { defaultLogFilters, countLogFilters } from '$components/domain/log/filter-state';
|
|
4
|
+
import { onMount, onDestroy, untrack } from 'svelte';
|
|
5
|
+
import { _ } from '$i18n';
|
|
6
|
+
import { queryChains, exportLogs, type ChainEntry, type LogQueryParams, type TransportOutcome, type TransportType } from '$api/logs';
|
|
7
|
+
import { TRANSPORT_OUTCOMES, chainTransportOutcome, transportTone, transportTypeLabel, httpStatusLabel, parseStatusFilter } from '$components/domain/log/outcomes';
|
|
8
|
+
import ChainDetailModal from '$components/domain/log/ChainDetailModal.svelte';
|
|
9
|
+
import { BSwitch, LoadingIndicator, PanelCard, BDropdownAction } from '$components/industrial';
|
|
10
|
+
import { BSelect as Select } from '$components/industrial';
|
|
11
|
+
import { toast } from '$stores/toast';
|
|
12
|
+
import * as Sheet from '$components/ui/sheet';
|
|
13
|
+
|
|
14
|
+
// ---- Select option arrays (i18n-safe, constructed in reactive blocks) ----
|
|
15
|
+
import { isLoading } from 'svelte-i18n';
|
|
16
|
+
|
|
17
|
+
function onTransportTypeChange(value: string | string[]) {
|
|
18
|
+
if (Array.isArray(value)) return;
|
|
19
|
+
transportTypeFilter = value === 'http' || value === 'websocket' ? value : undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const exportItems = [
|
|
23
|
+
{ value: 'json', label: 'JSON' },
|
|
24
|
+
{ value: 'csv', label: 'CSV' },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
function onTransportSelectChange(value: string | string[]) {
|
|
28
|
+
if (Array.isArray(value)) return;
|
|
29
|
+
transportFilter = TRANSPORT_OUTCOMES.includes(value as TransportOutcome) ? value as TransportOutcome : undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function onExportSelect(format: string) {
|
|
33
|
+
if (format === 'json' || format === 'csv') {
|
|
34
|
+
handleExport(format);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 查询参数
|
|
39
|
+
let page = $state(1);
|
|
40
|
+
let limit = 50;
|
|
41
|
+
let searchTerm = $state('');
|
|
42
|
+
let method = $state('');
|
|
43
|
+
let statusFilter = $state('');
|
|
44
|
+
let transportFilter: TransportOutcome | undefined = $state(undefined);
|
|
45
|
+
let transportTypeFilter: TransportType | undefined = $state(undefined);
|
|
46
|
+
let requestTypeFilter = $state('');
|
|
47
|
+
let sortBy: 'timestamp' | 'duration' | 'status' = $state('timestamp');
|
|
48
|
+
let sortOrder: 'asc' | 'desc' = $state('desc');
|
|
49
|
+
let hasRetryFilter: boolean | undefined = $state(undefined);
|
|
50
|
+
|
|
51
|
+
// 时间范围过滤
|
|
52
|
+
let timeRangeType: 'all' | 'recent' | 'custom' = $state('recent');
|
|
53
|
+
let recentHours = $state(1);
|
|
54
|
+
let customStartTime = $state('');
|
|
55
|
+
let customEndTime = $state('');
|
|
56
|
+
|
|
57
|
+
// 数据
|
|
58
|
+
let logs: ChainEntry[] = $state([]);
|
|
59
|
+
let total = $state(0);
|
|
60
|
+
let totalPages = $state(0);
|
|
61
|
+
let loading = $state(true);
|
|
62
|
+
let error: string | null = $state(null);
|
|
63
|
+
|
|
64
|
+
// 详情模态框
|
|
65
|
+
let selectedChain: ChainEntry | null = $state(null);
|
|
66
|
+
let showDetailModal = $state(false);
|
|
67
|
+
let mobileActionsOpen = $state(false);
|
|
68
|
+
|
|
69
|
+
// 自动刷新配置
|
|
70
|
+
let autoRefreshEnabled = $state(true);
|
|
71
|
+
let refreshInterval: '5s' | '10s' | '30s' | '60s' = $state('30s');
|
|
72
|
+
let refreshTimer: number | null = null;
|
|
73
|
+
let lastRefreshTime: number = $state(0);
|
|
74
|
+
let showRefreshHint = $state(false);
|
|
75
|
+
|
|
76
|
+
// 刷新间隔映射(毫秒)
|
|
77
|
+
const REFRESH_INTERVALS = {
|
|
78
|
+
'5s': 5000,
|
|
79
|
+
'10s': 10000,
|
|
80
|
+
'30s': 30000,
|
|
81
|
+
'60s': 60000
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// 用于追踪过滤条件是否改变(避免响应式依赖冲突)
|
|
85
|
+
let lastFilters = '';
|
|
86
|
+
let mounted = $state(false);
|
|
87
|
+
let loadSerial = 0;
|
|
88
|
+
|
|
89
|
+
// 加载日志
|
|
90
|
+
async function loadLogs() {
|
|
91
|
+
const serial = ++loadSerial;
|
|
92
|
+
try {
|
|
93
|
+
loading = true;
|
|
94
|
+
error = null;
|
|
95
|
+
|
|
96
|
+
const params: LogQueryParams = {
|
|
97
|
+
page,
|
|
98
|
+
limit,
|
|
99
|
+
sortBy,
|
|
100
|
+
sortOrder,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// 搜索词
|
|
104
|
+
if (searchTerm.trim()) {
|
|
105
|
+
params.searchTerm = searchTerm.trim();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// 方法过滤
|
|
109
|
+
if (method) {
|
|
110
|
+
params.method = method;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 状态过滤
|
|
114
|
+
if (statusFilter) {
|
|
115
|
+
params.status = parseStatusFilter(statusFilter);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 传输结果过滤
|
|
119
|
+
if (transportTypeFilter !== undefined) params.transportType = transportTypeFilter;
|
|
120
|
+
if (transportFilter !== undefined) {
|
|
121
|
+
params.transportOutcome = transportFilter;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 请求类型过滤
|
|
125
|
+
if (requestTypeFilter) {
|
|
126
|
+
params.requestType = requestTypeFilter as 'final' | 'retry' | 'recovery';
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Chain-only: 仅显示有重试
|
|
130
|
+
if (hasRetryFilter !== undefined) {
|
|
131
|
+
params.hasRetry = hasRetryFilter;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// 时间范围过滤
|
|
135
|
+
if (timeRangeType === 'recent') {
|
|
136
|
+
params.endTime = Date.now();
|
|
137
|
+
params.startTime = Date.now() - recentHours * 60 * 60 * 1000;
|
|
138
|
+
} else if (timeRangeType === 'custom') {
|
|
139
|
+
if (customStartTime) {
|
|
140
|
+
params.startTime = new Date(customStartTime).getTime();
|
|
141
|
+
}
|
|
142
|
+
if (customEndTime) {
|
|
143
|
+
params.endTime = new Date(customEndTime).getTime();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const result = await queryChains(params);
|
|
148
|
+
if (serial !== loadSerial) return;
|
|
149
|
+
logs = result.data;
|
|
150
|
+
total = result.total;
|
|
151
|
+
totalPages = result.totalPages;
|
|
152
|
+
} catch (e: any) {
|
|
153
|
+
if (serial !== loadSerial) return;
|
|
154
|
+
error = e.message === 'logs.invalidStatus' ? $_('logs.invalidStatus') : e.message;
|
|
155
|
+
} finally {
|
|
156
|
+
if (serial === loadSerial) loading = false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// 导出日志
|
|
161
|
+
async function handleExport(format: 'json' | 'csv') {
|
|
162
|
+
try {
|
|
163
|
+
const params: LogQueryParams = {};
|
|
164
|
+
|
|
165
|
+
if (searchTerm.trim()) {
|
|
166
|
+
params.searchTerm = searchTerm.trim();
|
|
167
|
+
}
|
|
168
|
+
if (method) {
|
|
169
|
+
params.method = method;
|
|
170
|
+
}
|
|
171
|
+
if (statusFilter) {
|
|
172
|
+
params.status = parseStatusFilter(statusFilter);
|
|
173
|
+
}
|
|
174
|
+
if (transportTypeFilter !== undefined) params.transportType = transportTypeFilter;
|
|
175
|
+
if (transportFilter !== undefined) {
|
|
176
|
+
params.transportOutcome = transportFilter;
|
|
177
|
+
}
|
|
178
|
+
if (requestTypeFilter) {
|
|
179
|
+
params.requestType = requestTypeFilter as 'final' | 'retry' | 'recovery';
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (hasRetryFilter !== undefined) params.hasRetry = hasRetryFilter;
|
|
183
|
+
|
|
184
|
+
// 时间范围
|
|
185
|
+
if (timeRangeType === 'recent') {
|
|
186
|
+
params.endTime = Date.now();
|
|
187
|
+
params.startTime = Date.now() - recentHours * 60 * 60 * 1000;
|
|
188
|
+
} else if (timeRangeType === 'custom') {
|
|
189
|
+
if (customStartTime) {
|
|
190
|
+
params.startTime = new Date(customStartTime).getTime();
|
|
191
|
+
}
|
|
192
|
+
if (customEndTime) {
|
|
193
|
+
params.endTime = new Date(customEndTime).getTime();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const blob = await exportLogs(params, format);
|
|
198
|
+
const url = URL.createObjectURL(blob);
|
|
199
|
+
const a = document.createElement('a');
|
|
200
|
+
a.href = url;
|
|
201
|
+
a.download = `access-logs-${Date.now()}.${format}`;
|
|
202
|
+
a.click();
|
|
203
|
+
URL.revokeObjectURL(url);
|
|
204
|
+
} catch (e: any) {
|
|
205
|
+
toast.show(`Export failed: ${e.message}`, 'error');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// 查看详情
|
|
210
|
+
function viewDetail(chain: ChainEntry) {
|
|
211
|
+
selectedChain = chain;
|
|
212
|
+
showDetailModal = true;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// 格式化时间
|
|
216
|
+
function formatTime(timestamp: number): string {
|
|
217
|
+
return new Date(timestamp).toLocaleString();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// 格式化持续时间
|
|
221
|
+
function formatDuration(ms: number): string {
|
|
222
|
+
if (ms < 1000) return `${ms}ms`;
|
|
223
|
+
return `${(ms / 1000).toFixed(2)}s`;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// 清除所有筛选
|
|
227
|
+
function clearAllFilters() {
|
|
228
|
+
({ searchTerm, method, statusFilter, transportFilter, transportTypeFilter, requestTypeFilter,
|
|
229
|
+
hasRetryFilter, timeRangeType, recentHours, customStartTime, customEndTime,
|
|
230
|
+
sortBy, sortOrder, page } = defaultLogFilters());
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// 检查是否有激活的过滤条件
|
|
234
|
+
function hasActiveFilters(): boolean {
|
|
235
|
+
return !!(
|
|
236
|
+
searchTerm ||
|
|
237
|
+
method ||
|
|
238
|
+
statusFilter ||
|
|
239
|
+
transportFilter !== undefined ||
|
|
240
|
+
transportTypeFilter !== undefined ||
|
|
241
|
+
requestTypeFilter ||
|
|
242
|
+
hasRetryFilter !== undefined
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// 启动自动刷新
|
|
247
|
+
function startAutoRefresh() {
|
|
248
|
+
if (refreshTimer) {
|
|
249
|
+
clearInterval(refreshTimer);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (autoRefreshEnabled) {
|
|
253
|
+
const interval = REFRESH_INTERVALS[refreshInterval];
|
|
254
|
+
refreshTimer = window.setInterval(() => {
|
|
255
|
+
if (document.visibilityState === 'visible') {
|
|
256
|
+
// 如果有过滤条件,不自动刷新,只显示提示
|
|
257
|
+
if (hasActiveFilters()) {
|
|
258
|
+
showRefreshHint = true;
|
|
259
|
+
} else {
|
|
260
|
+
loadLogs();
|
|
261
|
+
lastRefreshTime = Date.now();
|
|
262
|
+
showRefreshHint = false;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}, interval);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// 停止自动刷新
|
|
270
|
+
function stopAutoRefresh() {
|
|
271
|
+
if (refreshTimer) {
|
|
272
|
+
clearInterval(refreshTimer);
|
|
273
|
+
refreshTimer = null;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// 手动刷新
|
|
278
|
+
async function manualRefresh() {
|
|
279
|
+
await loadLogs();
|
|
280
|
+
lastRefreshTime = Date.now();
|
|
281
|
+
showRefreshHint = false;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// 页面可见性变化处理
|
|
285
|
+
function handleVisibilityChange() {
|
|
286
|
+
if (document.visibilityState === 'visible') {
|
|
287
|
+
// 页面恢复可见时,如果距离上次刷新超过间隔,立即刷新
|
|
288
|
+
const elapsed = Date.now() - lastRefreshTime;
|
|
289
|
+
const interval = REFRESH_INTERVALS[refreshInterval];
|
|
290
|
+
if (elapsed >= interval) {
|
|
291
|
+
loadLogs();
|
|
292
|
+
}
|
|
293
|
+
if (autoRefreshEnabled) {
|
|
294
|
+
startAutoRefresh();
|
|
295
|
+
}
|
|
296
|
+
} else {
|
|
297
|
+
// 页面不可见时暂停刷新
|
|
298
|
+
stopAutoRefresh();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
onMount(() => {
|
|
303
|
+
// 恢复刷新配置
|
|
304
|
+
const savedInterval = localStorage.getItem('logsRefreshInterval');
|
|
305
|
+
if (savedInterval && savedInterval in REFRESH_INTERVALS) {
|
|
306
|
+
refreshInterval = savedInterval as typeof refreshInterval;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const savedAutoRefresh = localStorage.getItem('logsAutoRefresh');
|
|
310
|
+
if (savedAutoRefresh !== null) {
|
|
311
|
+
autoRefreshEnabled = savedAutoRefresh === 'true';
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
mounted = true;
|
|
315
|
+
|
|
316
|
+
// 监听页面可见性变化
|
|
317
|
+
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
onDestroy(() => {
|
|
321
|
+
loadSerial++;
|
|
322
|
+
stopAutoRefresh();
|
|
323
|
+
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
let transportTypeOptions = $derived($isLoading ? [] : [
|
|
327
|
+
{ value: '__all', label: $_('logs.allTransportTypes') },
|
|
328
|
+
{ value: 'http', label: 'HTTP' },
|
|
329
|
+
{ value: 'websocket', label: 'WS' },
|
|
330
|
+
]);
|
|
331
|
+
let transportTypeSelectValue = $derived(transportTypeFilter ?? '__all');
|
|
332
|
+
let methodOptions = $derived($isLoading ? [] : [
|
|
333
|
+
{ value: '', label: $_('logs.allMethods') },
|
|
334
|
+
{ value: 'GET', label: 'GET' },
|
|
335
|
+
{ value: 'POST', label: 'POST' },
|
|
336
|
+
{ value: 'PUT', label: 'PUT' },
|
|
337
|
+
{ value: 'DELETE', label: 'DELETE' },
|
|
338
|
+
{ value: 'PATCH', label: 'PATCH' },
|
|
339
|
+
]);
|
|
340
|
+
let transportOptions = $derived($isLoading ? [] : [
|
|
341
|
+
{ value: '__all', label: $_('logs.allResults') },
|
|
342
|
+
...TRANSPORT_OUTCOMES.map(value => ({ value, label: $_(`logs.transport.${value}`) })),
|
|
343
|
+
]);
|
|
344
|
+
let methodQuickFilterItems = $derived($isLoading ? [] : [
|
|
345
|
+
{ value: '', label: $_('logs.allMethods') },
|
|
346
|
+
{ value: 'GET', label: 'GET' },
|
|
347
|
+
{ value: 'POST', label: 'POST' },
|
|
348
|
+
{ value: 'PUT', label: 'PUT' },
|
|
349
|
+
{ value: 'DELETE', label: 'DELETE' },
|
|
350
|
+
{ value: 'PATCH', label: 'PATCH' },
|
|
351
|
+
]);
|
|
352
|
+
let resultQuickFilterItems = $derived(transportOptions);
|
|
353
|
+
let transportSelectValue = $derived(transportFilter ?? '__all');
|
|
354
|
+
let requestTypeOptions = $derived($isLoading ? [] : [
|
|
355
|
+
{ value: '', label: $_('logs.requestType_all') },
|
|
356
|
+
{ value: 'final', label: $_('logs.requestType_final') },
|
|
357
|
+
{ value: 'retry', label: $_('logs.requestType_retry') },
|
|
358
|
+
{ value: 'recovery', label: $_('logs.requestType_recovery') },
|
|
359
|
+
]);
|
|
360
|
+
let timeRangeOptions = $derived($isLoading ? [] : [
|
|
361
|
+
{ value: 'all', label: $_('logs.allTime') },
|
|
362
|
+
{ value: 'recent', label: $_('logs.recentTime') },
|
|
363
|
+
{ value: 'custom', label: $_('logs.customTime') },
|
|
364
|
+
]);
|
|
365
|
+
let sortByOptions = $derived($isLoading ? [] : [
|
|
366
|
+
{ value: 'timestamp', label: $_('logs.sortByTimestamp') },
|
|
367
|
+
{ value: 'duration', label: $_('logs.sortByDuration') },
|
|
368
|
+
{ value: 'status', label: $_('logs.sortByStatus') },
|
|
369
|
+
]);
|
|
370
|
+
let sortOrderOptions = $derived($isLoading ? [] : [
|
|
371
|
+
{ value: 'desc', label: $_('logs.desc') },
|
|
372
|
+
{ value: 'asc', label: $_('logs.asc') },
|
|
373
|
+
]);
|
|
374
|
+
let refreshIntervalOptions = $derived($isLoading ? [] : [
|
|
375
|
+
{ value: '5s', label: $_('logs.refreshEvery5s') },
|
|
376
|
+
{ value: '10s', label: $_('logs.refreshEvery10s') },
|
|
377
|
+
{ value: '30s', label: $_('logs.refreshEvery30s') },
|
|
378
|
+
{ value: '60s', label: $_('logs.refreshEvery60s') },
|
|
379
|
+
]);
|
|
380
|
+
$effect(() => {
|
|
381
|
+
if (!mounted) return;
|
|
382
|
+
if (autoRefreshEnabled) startAutoRefresh();
|
|
383
|
+
else stopAutoRefresh();
|
|
384
|
+
return stopAutoRefresh;
|
|
385
|
+
});
|
|
386
|
+
$effect(() => {
|
|
387
|
+
if (!mounted) return;
|
|
388
|
+
localStorage.setItem('logsRefreshInterval', refreshInterval);
|
|
389
|
+
localStorage.setItem('logsAutoRefresh', String(autoRefreshEnabled));
|
|
390
|
+
});
|
|
391
|
+
// 计算激活的筛选条件数量
|
|
392
|
+
let activeFiltersCount = $derived(countLogFilters({ searchTerm, method, statusFilter, transportFilter, transportTypeFilter,
|
|
393
|
+
requestTypeFilter, hasRetryFilter, timeRangeType, recentHours, customStartTime, customEndTime,
|
|
394
|
+
sortBy, sortOrder, page }));
|
|
395
|
+
// Reset pagination before dispatch, so a changed filter never queries a stale page.
|
|
396
|
+
$effect(() => {
|
|
397
|
+
if (!mounted) return;
|
|
398
|
+
const filters = JSON.stringify({ limit, searchTerm, method, statusFilter, transportFilter, transportTypeFilter,
|
|
399
|
+
requestTypeFilter, hasRetryFilter, sortBy, sortOrder, timeRangeType, recentHours,
|
|
400
|
+
customStartTime: timeRangeType === 'custom' ? customStartTime : '',
|
|
401
|
+
customEndTime: timeRangeType === 'custom' ? customEndTime : '' });
|
|
402
|
+
const changed = lastFilters !== '' && lastFilters !== filters;
|
|
403
|
+
lastFilters = filters;
|
|
404
|
+
if (changed && page !== 1) { page = 1; return; }
|
|
405
|
+
// Track page even when the filters did not change.
|
|
406
|
+
page;
|
|
407
|
+
untrack(() => { void loadLogs(); });
|
|
408
|
+
});
|
|
409
|
+
</script>
|
|
410
|
+
|
|
411
|
+
<div class="nx-page py-5 space-y-5" data-testid="page-logs">
|
|
412
|
+
<!-- ===== Header ============================================ -->
|
|
413
|
+
<div class="flex items-center gap-3">
|
|
414
|
+
<span class="nx-stripe" aria-hidden="true"></span>
|
|
415
|
+
<div class="flex flex-col leading-tight">
|
|
416
|
+
<span class="nx-label">// REQUEST LOGS</span>
|
|
417
|
+
<h1 class="nx-display text-xl text-zinc-50 tracking-[0.02em]">{$_('logs.title')}</h1>
|
|
418
|
+
</div>
|
|
419
|
+
</div>
|
|
420
|
+
|
|
421
|
+
<!-- New data hint -->
|
|
422
|
+
{#if showRefreshHint}
|
|
423
|
+
<div class="border-l-2 border-l-nexus-500 bg-nexus-500/5 px-3 py-2 flex items-center justify-between gap-3">
|
|
424
|
+
<div class="flex items-center gap-2">
|
|
425
|
+
<span class="nx-dot-accent"></span>
|
|
426
|
+
<span class="font-mono text-[11px] uppercase tracking-command text-nexus-200">{$_('logs.newDataAvailable')}</span>
|
|
427
|
+
</div>
|
|
428
|
+
<button class="nx-btn-ghost nx-btn-md" onclick={manualRefresh}>
|
|
429
|
+
{$_('common.refresh')}
|
|
430
|
+
</button>
|
|
431
|
+
</div>
|
|
432
|
+
{/if}
|
|
433
|
+
|
|
434
|
+
<!-- 统一操作栏(响应式设计) -->
|
|
435
|
+
<div class="mb-6">
|
|
436
|
+
<!-- 操作控制行 -->
|
|
437
|
+
<div class="flex items-center gap-2 mb-3 md:flex-wrap">
|
|
438
|
+
<!-- 搜索框(弹性伸缩) -->
|
|
439
|
+
<div class="flex-1 min-w-0 md:flex-[1_1_16rem]">
|
|
440
|
+
<input
|
|
441
|
+
type="text"
|
|
442
|
+
bind:value={searchTerm}
|
|
443
|
+
placeholder={$_('logs.searchPlaceholder')}
|
|
444
|
+
class="nx-input w-full"
|
|
445
|
+
data-testid="logs-filter-path-input"
|
|
446
|
+
/>
|
|
447
|
+
</div>
|
|
448
|
+
|
|
449
|
+
<!-- 桌面布局(≥768px):控件按可用空间自然换行 -->
|
|
450
|
+
<div class="hidden md:flex min-w-0 items-center gap-2 flex-wrap flex-[2_1_36rem]">
|
|
451
|
+
<!-- 左侧:过滤按钮组 -->
|
|
452
|
+
<div class="flex items-center gap-2 flex-wrap">
|
|
453
|
+
<div data-testid="logs-filter-type-select">
|
|
454
|
+
<BDropdownAction items={transportTypeOptions} onselect={onTransportTypeChange}
|
|
455
|
+
triggerClass={`${transportTypeFilter ? 'nx-btn-primary' : 'nx-btn-ghost'} nx-btn-md`}>
|
|
456
|
+
{#snippet trigger()}
|
|
457
|
+
{$_('logs.transportType')}{#if transportTypeFilter}: {transportTypeLabel(transportTypeFilter)}{/if}
|
|
458
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
|
|
459
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
|
460
|
+
</svg>
|
|
461
|
+
{/snippet}
|
|
462
|
+
</BDropdownAction>
|
|
463
|
+
</div>
|
|
464
|
+
<!-- Method 下拉 -->
|
|
465
|
+
<div data-testid="logs-filter-method-select">
|
|
466
|
+
<BDropdownAction
|
|
467
|
+
items={methodQuickFilterItems}
|
|
468
|
+
onselect={(val) => method = val}
|
|
469
|
+
triggerClass={`${method ? 'nx-btn-primary' : 'nx-btn-ghost'} nx-btn-md`}
|
|
470
|
+
>
|
|
471
|
+
{#snippet trigger()}
|
|
472
|
+
{$_('logs.method')}
|
|
473
|
+
{#if method}
|
|
474
|
+
<span class="nx-feature-tag">1</span>
|
|
475
|
+
{/if}
|
|
476
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
477
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
|
478
|
+
</svg>
|
|
479
|
+
{/snippet}
|
|
480
|
+
</BDropdownAction>
|
|
481
|
+
</div>
|
|
482
|
+
|
|
483
|
+
<!-- Status 下拉 -->
|
|
484
|
+
<BDropdownAction
|
|
485
|
+
width="w-48"
|
|
486
|
+
align="end"
|
|
487
|
+
triggerClass={`${statusFilter ? 'nx-btn-primary' : 'nx-btn-ghost'} nx-btn-md`}
|
|
488
|
+
>
|
|
489
|
+
{#snippet trigger()}
|
|
490
|
+
{$_('logs.status')}
|
|
491
|
+
{#if statusFilter}
|
|
492
|
+
<span class="nx-feature-tag">1</span>
|
|
493
|
+
{/if}
|
|
494
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
495
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
|
496
|
+
</svg>
|
|
497
|
+
{/snippet}
|
|
498
|
+
<div class="p-3"> <div class="space-y-1">
|
|
499
|
+
<div class="label py-1">
|
|
500
|
+
<span class="nx-field-label">{$_('logs.statusPlaceholder')}</span>
|
|
501
|
+
</div>
|
|
502
|
+
<input
|
|
503
|
+
type="text"
|
|
504
|
+
bind:value={statusFilter}
|
|
505
|
+
placeholder="200, 404, 5xx"
|
|
506
|
+
class="nx-input"
|
|
507
|
+
/>
|
|
508
|
+
</div>
|
|
509
|
+
|
|
510
|
+
</div>
|
|
511
|
+
</BDropdownAction>
|
|
512
|
+
|
|
513
|
+
<!-- Result 下拉 -->
|
|
514
|
+
<BDropdownAction
|
|
515
|
+
items={resultQuickFilterItems}
|
|
516
|
+
onselect={onTransportSelectChange}
|
|
517
|
+
triggerClass={`${transportFilter !== undefined ? 'nx-btn-primary' : 'nx-btn-ghost'} nx-btn-md`}
|
|
518
|
+
>
|
|
519
|
+
{#snippet trigger()}
|
|
520
|
+
{$_('logs.transportResult')}
|
|
521
|
+
{#if transportFilter !== undefined}
|
|
522
|
+
<span class="nx-feature-tag">1</span>
|
|
523
|
+
{/if}
|
|
524
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
525
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
|
526
|
+
</svg>
|
|
527
|
+
{/snippet}
|
|
528
|
+
</BDropdownAction>
|
|
529
|
+
|
|
530
|
+
<!-- More Filters 下拉 -->
|
|
531
|
+
<BDropdownAction
|
|
532
|
+
width="w-96"
|
|
533
|
+
align="end"
|
|
534
|
+
triggerClass={`${requestTypeFilter || timeRangeType !== 'recent' || recentHours !== 1 || sortBy !== 'timestamp' || sortOrder !== 'desc' ? 'nx-btn-primary' : 'nx-btn-ghost'} nx-btn-md`}
|
|
535
|
+
>
|
|
536
|
+
{#snippet trigger()}
|
|
537
|
+
{$_('logs.moreFilters')}
|
|
538
|
+
{#if requestTypeFilter || timeRangeType !== 'recent' || recentHours !== 1 || sortBy !== 'timestamp' || sortOrder !== 'desc'}
|
|
539
|
+
<span class="nx-feature-tag">
|
|
540
|
+
{[requestTypeFilter, timeRangeType !== 'recent' || recentHours !== 1, sortBy !== 'timestamp' || sortOrder !== 'desc'].filter(Boolean).length}
|
|
541
|
+
</span>
|
|
542
|
+
{/if}
|
|
543
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
544
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
|
545
|
+
</svg>
|
|
546
|
+
{/snippet}
|
|
547
|
+
<div class="p-3"> <div class="grid grid-cols-2 gap-3">
|
|
548
|
+
<!-- 请求类型 -->
|
|
549
|
+
<div class="min-w-0 space-y-1">
|
|
550
|
+
<div class="label py-1">
|
|
551
|
+
<span class="nx-field-label">{$_('logs.requestTypeFilter')}</span>
|
|
552
|
+
</div>
|
|
553
|
+
<Select options={requestTypeOptions} bind:value={requestTypeFilter} placeholder={$_('logs.requestType_all')} ariaLabel={$_('logs.requestTypeFilter')} />
|
|
554
|
+
</div>
|
|
555
|
+
|
|
556
|
+
<!-- 时间范围 -->
|
|
557
|
+
<div class="min-w-0 space-y-1">
|
|
558
|
+
<div class="label py-1">
|
|
559
|
+
<span class="nx-field-label">{$_('logs.timeRange')}</span>
|
|
560
|
+
</div>
|
|
561
|
+
<Select options={timeRangeOptions} bind:value={timeRangeType} placeholder={$_('logs.allTime')} ariaLabel={$_('logs.timeRange')} />
|
|
562
|
+
</div>
|
|
563
|
+
|
|
564
|
+
<!-- 最近时间(小时) -->
|
|
565
|
+
{#if timeRangeType === 'recent'}
|
|
566
|
+
<div class="min-w-0 space-y-1">
|
|
567
|
+
<div class="label py-1">
|
|
568
|
+
<span class="nx-field-label">{$_('logs.recentHours')}</span>
|
|
569
|
+
</div>
|
|
570
|
+
<input
|
|
571
|
+
type="number"
|
|
572
|
+
bind:value={recentHours}
|
|
573
|
+
min="1"
|
|
574
|
+
class="nx-input"
|
|
575
|
+
/>
|
|
576
|
+
</div>
|
|
577
|
+
{/if}
|
|
578
|
+
|
|
579
|
+
<!-- 自定义时间范围 -->
|
|
580
|
+
{#if timeRangeType === 'custom'}
|
|
581
|
+
<div class="col-span-2 min-w-0 space-y-1">
|
|
582
|
+
<div class="label py-1">
|
|
583
|
+
<span class="nx-field-label">{$_('logs.startTime')}</span>
|
|
584
|
+
</div>
|
|
585
|
+
<input
|
|
586
|
+
type="datetime-local"
|
|
587
|
+
bind:value={customStartTime}
|
|
588
|
+
class="nx-input min-w-0"
|
|
589
|
+
/>
|
|
590
|
+
</div>
|
|
591
|
+
|
|
592
|
+
<div class="col-span-2 min-w-0 space-y-1">
|
|
593
|
+
<div class="label py-1">
|
|
594
|
+
<span class="nx-field-label">{$_('logs.endTime')}</span>
|
|
595
|
+
</div>
|
|
596
|
+
<input
|
|
597
|
+
type="datetime-local"
|
|
598
|
+
bind:value={customEndTime}
|
|
599
|
+
class="nx-input min-w-0"
|
|
600
|
+
/>
|
|
601
|
+
</div>
|
|
602
|
+
{/if}
|
|
603
|
+
|
|
604
|
+
<!-- 排序 -->
|
|
605
|
+
<div class="col-span-2 border-t border-carbon-600"></div>
|
|
606
|
+
<div class="col-span-2 min-w-0 space-y-1">
|
|
607
|
+
<div class="label py-1">
|
|
608
|
+
<span class="nx-field-label">{$_('logs.sortBy')}</span>
|
|
609
|
+
</div>
|
|
610
|
+
<div class="flex flex-wrap gap-2">
|
|
611
|
+
<Select options={sortByOptions} bind:value={sortBy} placeholder={$_('logs.sortByTimestamp')} ariaLabel={$_('logs.sortBy')} class="flex-1" />
|
|
612
|
+
<Select options={sortOrderOptions} bind:value={sortOrder} placeholder={$_('logs.desc')} ariaLabel={$_('logs.sortBy')} width="w-24 min-w-[6rem]" />
|
|
613
|
+
</div>
|
|
614
|
+
</div>
|
|
615
|
+
</div>
|
|
616
|
+
|
|
617
|
+
</div>
|
|
618
|
+
</BDropdownAction>
|
|
619
|
+
{#if activeFiltersCount > 0}
|
|
620
|
+
<button
|
|
621
|
+
type="button"
|
|
622
|
+
class="nx-btn-ghost nx-btn-md focus-visible:ring-2 focus-visible:ring-nexus-500"
|
|
623
|
+
onclick={clearAllFilters}
|
|
624
|
+
>
|
|
625
|
+
{$_('logs.resetFilters')}
|
|
626
|
+
</button>
|
|
627
|
+
{/if}
|
|
628
|
+
</div>
|
|
629
|
+
|
|
630
|
+
<!-- 右侧:刷新和操作按钮组 -->
|
|
631
|
+
<div class="ml-auto flex items-center gap-2 flex-wrap">
|
|
632
|
+
<!-- 刷新设置下拉菜单 -->
|
|
633
|
+
<BDropdownAction width="w-64" align="end" triggerClass="nx-btn-outline nx-btn-md">
|
|
634
|
+
{#snippet trigger()}
|
|
635
|
+
<svg
|
|
636
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
637
|
+
class="h-4 w-4"
|
|
638
|
+
fill="none"
|
|
639
|
+
viewBox="0 0 24 24"
|
|
640
|
+
stroke="currentColor"
|
|
641
|
+
>
|
|
642
|
+
<path
|
|
643
|
+
stroke-linecap="round"
|
|
644
|
+
stroke-linejoin="round"
|
|
645
|
+
stroke-width="2"
|
|
646
|
+
d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"
|
|
647
|
+
/>
|
|
648
|
+
<path
|
|
649
|
+
stroke-linecap="round"
|
|
650
|
+
stroke-linejoin="round"
|
|
651
|
+
stroke-width="2"
|
|
652
|
+
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
|
|
653
|
+
/>
|
|
654
|
+
</svg>
|
|
655
|
+
{#if autoRefreshEnabled}
|
|
656
|
+
<span class="nx-pill-accent">{refreshInterval}</span>
|
|
657
|
+
{/if}
|
|
658
|
+
{/snippet}
|
|
659
|
+
<div class="p-3"> <div class="space-y-3">
|
|
660
|
+
<!-- Auto Refresh Toggle -->
|
|
661
|
+
<div class="space-y-1">
|
|
662
|
+
<label class="flex w-full items-center justify-between gap-3 cursor-pointer">
|
|
663
|
+
<span class="nx-field-label">{$_('logs.autoRefresh')}</span>
|
|
664
|
+
<BSwitch bind:checked={autoRefreshEnabled} description={$_('logs.autoRefresh')} />
|
|
665
|
+
</label>
|
|
666
|
+
</div>
|
|
667
|
+
|
|
668
|
+
<!-- Refresh Interval -->
|
|
669
|
+
{#if autoRefreshEnabled}
|
|
670
|
+
<div class="space-y-1">
|
|
671
|
+
<div class="label py-1">
|
|
672
|
+
<span class="nx-field-label">{$_('logs.refreshInterval')}</span>
|
|
673
|
+
</div>
|
|
674
|
+
<Select options={refreshIntervalOptions} bind:value={refreshInterval} placeholder="30s" ariaLabel={$_('logs.refreshInterval')} />
|
|
675
|
+
</div>
|
|
676
|
+
{/if}
|
|
677
|
+
{#if lastRefreshTime > 0}
|
|
678
|
+
<div class="text-xs text-gray-500 text-center">
|
|
679
|
+
{$_('logs.lastRefreshed')}: {new Date(lastRefreshTime).toLocaleTimeString()}
|
|
680
|
+
</div>
|
|
681
|
+
{/if}
|
|
682
|
+
</div>
|
|
683
|
+
|
|
684
|
+
</div>
|
|
685
|
+
</BDropdownAction>
|
|
686
|
+
|
|
687
|
+
<!-- 手动刷新按钮 -->
|
|
688
|
+
<button
|
|
689
|
+
type="button"
|
|
690
|
+
class="nx-btn-outline nx-btn-md"
|
|
691
|
+
onclick={manualRefresh}
|
|
692
|
+
disabled={loading}
|
|
693
|
+
>
|
|
694
|
+
{#if loading}
|
|
695
|
+
<LoadingIndicator label="" size="xs" centered={false} />
|
|
696
|
+
{:else}
|
|
697
|
+
<svg
|
|
698
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
699
|
+
class="h-4 w-4"
|
|
700
|
+
fill="none"
|
|
701
|
+
viewBox="0 0 24 24"
|
|
702
|
+
stroke="currentColor"
|
|
703
|
+
>
|
|
704
|
+
<path
|
|
705
|
+
stroke-linecap="round"
|
|
706
|
+
stroke-linejoin="round"
|
|
707
|
+
stroke-width="2"
|
|
708
|
+
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
|
|
709
|
+
/>
|
|
710
|
+
</svg>
|
|
711
|
+
{/if}
|
|
712
|
+
<span>{$_('common.refresh')}</span>
|
|
713
|
+
</button>
|
|
714
|
+
|
|
715
|
+
<!-- 导出按钮 -->
|
|
716
|
+
<BDropdownAction items={exportItems} width="w-32" onselect={onExportSelect} triggerClass="nx-btn-ghost nx-btn-md">
|
|
717
|
+
{#snippet trigger()}
|
|
718
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
719
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
|
|
720
|
+
</svg>
|
|
721
|
+
<span>{$_('logs.export')}</span>
|
|
722
|
+
{/snippet}
|
|
723
|
+
</BDropdownAction>
|
|
724
|
+
|
|
725
|
+
</div>
|
|
726
|
+
</div>
|
|
727
|
+
|
|
728
|
+
<!-- 窄屏布局(<768px):底部操作抽屉 -->
|
|
729
|
+
<div class="flex md:hidden shrink-0 items-center gap-2">
|
|
730
|
+
<Sheet.Root bind:open={mobileActionsOpen} preventScroll>
|
|
731
|
+
<Sheet.Trigger class="nx-btn-ghost nx-btn-md whitespace-nowrap">
|
|
732
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
733
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
|
|
734
|
+
</svg>
|
|
735
|
+
{$_('logs.actions')}
|
|
736
|
+
{#if activeFiltersCount > 0}<span class="nx-feature-tag">{activeFiltersCount}</span>{/if}
|
|
737
|
+
</Sheet.Trigger>
|
|
738
|
+
<Sheet.Content side="bottom" class="!max-h-[90dvh] !gap-0 !p-0 flex flex-col overflow-hidden" aria-describedby={undefined}
|
|
739
|
+
closeLabel={$_('common.close')} closeClass="!right-2 !top-2 flex h-10 w-10 items-center justify-center"
|
|
740
|
+
data-testid="logs-mobile-actions">
|
|
741
|
+
<Sheet.Title class="shrink-0 border-b border-carbon-600 px-4 py-4 pr-14 font-mono text-sm font-semibold text-zinc-100">{$_('logs.actions')}</Sheet.Title>
|
|
742
|
+
<div class="min-h-0 overflow-y-auto overscroll-contain px-4 py-3" data-testid="logs-mobile-actions-scroll">
|
|
743
|
+
<div class="grid grid-cols-2 gap-x-3 gap-y-3">
|
|
744
|
+
<div class="min-w-0 space-y-1">
|
|
745
|
+
<span class="nx-field-label !text-xs !tracking-normal">{$_('logs.transportType')}</span>
|
|
746
|
+
<Select options={transportTypeOptions} value={transportTypeSelectValue} onchange={onTransportTypeChange}
|
|
747
|
+
placeholder={$_('logs.allTransportTypes')} ariaLabel={$_('logs.transportType')} />
|
|
748
|
+
</div>
|
|
749
|
+
<div class="min-w-0 space-y-1">
|
|
750
|
+
<span class="nx-field-label !text-xs !tracking-normal">{$_('logs.method')}</span>
|
|
751
|
+
<Select options={methodOptions} bind:value={method} placeholder={$_('logs.allMethods')} ariaLabel={$_('logs.method')} />
|
|
752
|
+
</div>
|
|
753
|
+
<div class="min-w-0 space-y-1">
|
|
754
|
+
<label for="logs-mobile-status" class="nx-field-label !text-xs !tracking-normal">{$_('logs.status')}</label>
|
|
755
|
+
<input id="logs-mobile-status" type="text" bind:value={statusFilter} placeholder="200, 404, 5xx" class="nx-input w-full" />
|
|
756
|
+
</div>
|
|
757
|
+
<div class="min-w-0 space-y-1">
|
|
758
|
+
<span class="nx-field-label !text-xs !tracking-normal">{$_('logs.transportResult')}</span>
|
|
759
|
+
<Select options={transportOptions} value={transportSelectValue} onchange={onTransportSelectChange} placeholder={$_('logs.allResults')} ariaLabel={$_('logs.transportResult')} />
|
|
760
|
+
</div>
|
|
761
|
+
<div class="min-w-0 space-y-1">
|
|
762
|
+
<span class="nx-field-label !text-xs !tracking-normal">{$_('logs.requestTypeFilter')}</span>
|
|
763
|
+
<Select options={requestTypeOptions} bind:value={requestTypeFilter} placeholder={$_('logs.requestType_all')} ariaLabel={$_('logs.requestTypeFilter')} />
|
|
764
|
+
</div>
|
|
765
|
+
<div class="min-w-0 space-y-1">
|
|
766
|
+
<span class="nx-field-label !text-xs !tracking-normal">{$_('logs.timeRange')}</span>
|
|
767
|
+
<Select options={timeRangeOptions} bind:value={timeRangeType} placeholder={$_('logs.allTime')} ariaLabel={$_('logs.timeRange')} />
|
|
768
|
+
</div>
|
|
769
|
+
{#if timeRangeType === 'recent'}
|
|
770
|
+
<div class="col-span-2 min-w-0 space-y-1">
|
|
771
|
+
<label for="logs-mobile-hours" class="nx-field-label !text-xs !tracking-normal">{$_('logs.recentHours')}</label>
|
|
772
|
+
<input id="logs-mobile-hours" type="number" bind:value={recentHours} min="1" class="nx-input w-full" />
|
|
773
|
+
</div>
|
|
774
|
+
{/if}
|
|
775
|
+
{#if timeRangeType === 'custom'}
|
|
776
|
+
<div class="col-span-2 min-w-0 space-y-1">
|
|
777
|
+
<label for="logs-mobile-start" class="nx-field-label !text-xs !tracking-normal">{$_('logs.startTime')}</label>
|
|
778
|
+
<input id="logs-mobile-start" type="datetime-local" bind:value={customStartTime} class="nx-input w-full min-w-0" />
|
|
779
|
+
</div>
|
|
780
|
+
<div class="col-span-2 min-w-0 space-y-1">
|
|
781
|
+
<label for="logs-mobile-end" class="nx-field-label !text-xs !tracking-normal">{$_('logs.endTime')}</label>
|
|
782
|
+
<input id="logs-mobile-end" type="datetime-local" bind:value={customEndTime} class="nx-input w-full min-w-0" />
|
|
783
|
+
</div>
|
|
784
|
+
{/if}
|
|
785
|
+
<div class="col-span-2 min-w-0 space-y-1">
|
|
786
|
+
<span class="nx-field-label !text-xs !tracking-normal">{$_('logs.sortBy')}</span>
|
|
787
|
+
<div class="flex gap-2">
|
|
788
|
+
<Select options={sortByOptions} bind:value={sortBy} placeholder={$_('logs.sortByTimestamp')} ariaLabel={$_('logs.sortBy')} class="min-w-0 flex-1" />
|
|
789
|
+
<Select options={sortOrderOptions} bind:value={sortOrder} placeholder={$_('logs.desc')} ariaLabel={$_('logs.sortBy')} width="w-24 min-w-[6rem]" />
|
|
790
|
+
</div>
|
|
791
|
+
</div>
|
|
792
|
+
</div>
|
|
793
|
+
<div class="mt-3 flex items-center justify-between gap-2 border-t border-carbon-600 pt-3">
|
|
794
|
+
<span class="nx-field-label !text-xs !tracking-normal">{$_('logs.autoRefresh')}</span>
|
|
795
|
+
<div class="flex min-w-0 items-center gap-2">
|
|
796
|
+
<BSwitch bind:checked={autoRefreshEnabled} description={$_('logs.autoRefresh')} />
|
|
797
|
+
{#if autoRefreshEnabled}
|
|
798
|
+
<Select options={refreshIntervalOptions} bind:value={refreshInterval} placeholder="30s" ariaLabel={$_('logs.refreshInterval')} width="w-24" />
|
|
799
|
+
{/if}
|
|
800
|
+
</div>
|
|
801
|
+
</div>
|
|
802
|
+
</div>
|
|
803
|
+
<div class="shrink-0 border-t border-carbon-600 px-4 pt-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]" data-testid="logs-mobile-actions-footer">
|
|
804
|
+
<div class="grid grid-cols-2 gap-2">
|
|
805
|
+
{#if activeFiltersCount > 0}
|
|
806
|
+
<button type="button" class="nx-btn-ghost nx-btn-md w-full focus-visible:ring-2 focus-visible:ring-nexus-500" onclick={clearAllFilters}>{$_('logs.resetFilters')}</button>
|
|
807
|
+
{/if}
|
|
808
|
+
<button type="button" class="nx-btn-primary nx-btn-md w-full" class:col-span-2={activeFiltersCount === 0} onclick={manualRefresh} disabled={loading}>
|
|
809
|
+
{#if loading}<LoadingIndicator label="" size="xs" centered={false} />{/if}
|
|
810
|
+
{$_('common.refresh')}
|
|
811
|
+
</button>
|
|
812
|
+
<button type="button" class="nx-btn-ghost nx-btn-md w-full" onclick={() => handleExport('json')}>JSON</button>
|
|
813
|
+
<button type="button" class="nx-btn-ghost nx-btn-md w-full" onclick={() => handleExport('csv')}>CSV</button>
|
|
814
|
+
</div>
|
|
815
|
+
</div>
|
|
816
|
+
</Sheet.Content>
|
|
817
|
+
</Sheet.Root>
|
|
818
|
+
</div>
|
|
819
|
+
</div>
|
|
820
|
+
|
|
821
|
+
<!-- Filter Chips 展示区 -->
|
|
822
|
+
{#if activeFiltersCount > 0}
|
|
823
|
+
<div class="flex items-center gap-2 flex-wrap px-1">
|
|
824
|
+
{#if searchTerm.trim()}
|
|
825
|
+
<div class="inline-flex items-center gap-1.5 border border-carbon-500 bg-carbon-900 px-2.5 py-0.5 font-mono text-[11px] uppercase tracking-command text-zinc-300">
|
|
826
|
+
<span class="text-xs opacity-70">{$_('logs.searchTerm')}:</span>
|
|
827
|
+
<span class="font-medium">{searchTerm}</span>
|
|
828
|
+
<button
|
|
829
|
+
type="button"
|
|
830
|
+
class="inline-flex items-center justify-center h-4 w-4 text-zinc-500 hover:text-red-300 transition-colors"
|
|
831
|
+
onclick={() => searchTerm = ''}
|
|
832
|
+
aria-label={$_('logs.clearFilters')}
|
|
833
|
+
>
|
|
834
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
835
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
|
836
|
+
</svg>
|
|
837
|
+
</button>
|
|
838
|
+
</div>
|
|
839
|
+
{/if}
|
|
840
|
+
|
|
841
|
+
{#if transportTypeFilter}
|
|
842
|
+
<div class="inline-flex items-center gap-1.5 border border-nexus-500/60 bg-nexus-500/10 px-2.5 py-0.5 font-mono text-[11px] uppercase tracking-command text-nexus-300">
|
|
843
|
+
<span class="text-xs opacity-70">{$_('logs.transportType')}:</span>
|
|
844
|
+
<span class="font-medium">{transportTypeLabel(transportTypeFilter)}</span>
|
|
845
|
+
<button type="button" class="inline-flex h-6 w-6 items-center justify-center text-zinc-400 hover:text-zinc-100 focus-visible:ring-2 focus-visible:ring-nexus-500"
|
|
846
|
+
onclick={() => transportTypeFilter = undefined} aria-label={$_('logs.clearTransportType')}>
|
|
847
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
|
|
848
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
|
849
|
+
</svg>
|
|
850
|
+
</button>
|
|
851
|
+
</div>
|
|
852
|
+
{/if}
|
|
853
|
+
{#if method}
|
|
854
|
+
<div class="inline-flex items-center gap-1.5 border border-nexus-500/60 bg-nexus-500/10 px-2.5 py-0.5 font-mono text-[11px] uppercase tracking-command text-nexus-300">
|
|
855
|
+
<span class="text-xs opacity-70">{$_('logs.method')}:</span>
|
|
856
|
+
<span class="font-medium">{method}</span>
|
|
857
|
+
<button
|
|
858
|
+
type="button"
|
|
859
|
+
class="inline-flex items-center justify-center h-4 w-4 text-zinc-500 hover:text-red-300 transition-colors"
|
|
860
|
+
onclick={() => method = ''}
|
|
861
|
+
aria-label={$_('logs.clearFilters')}
|
|
862
|
+
>
|
|
863
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
864
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
|
865
|
+
</svg>
|
|
866
|
+
</button>
|
|
867
|
+
</div>
|
|
868
|
+
{/if}
|
|
869
|
+
|
|
870
|
+
{#if statusFilter}
|
|
871
|
+
<div class="inline-flex items-center gap-1.5 border border-nexus-500/60 bg-nexus-500/10 px-2.5 py-0.5 font-mono text-[11px] uppercase tracking-command text-nexus-300">
|
|
872
|
+
<span class="text-xs opacity-70">{$_('logs.status')}:</span>
|
|
873
|
+
<span class="font-medium">{statusFilter}</span>
|
|
874
|
+
<button
|
|
875
|
+
type="button"
|
|
876
|
+
class="inline-flex items-center justify-center h-4 w-4 text-zinc-500 hover:text-red-300 transition-colors"
|
|
877
|
+
onclick={() => statusFilter = ''}
|
|
878
|
+
aria-label={$_('logs.clearFilters')}
|
|
879
|
+
>
|
|
880
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
881
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
|
882
|
+
</svg>
|
|
883
|
+
</button>
|
|
884
|
+
</div>
|
|
885
|
+
{/if}
|
|
886
|
+
|
|
887
|
+
{#if transportFilter !== undefined}
|
|
888
|
+
<div class="inline-flex items-center gap-1.5 border border-nexus-500/60 bg-nexus-500/10 px-2.5 py-0.5 font-mono text-[11px] uppercase tracking-command text-nexus-300">
|
|
889
|
+
<span class="text-xs opacity-70">{$_('logs.transportResult')}:</span>
|
|
890
|
+
<span class="font-medium">{$_(`logs.transport.${transportFilter}`)}</span>
|
|
891
|
+
<button
|
|
892
|
+
type="button"
|
|
893
|
+
class="inline-flex items-center justify-center h-4 w-4 text-zinc-500 hover:text-red-300 transition-colors"
|
|
894
|
+
onclick={() => transportFilter = undefined}
|
|
895
|
+
aria-label={$_('logs.clearFilters')}
|
|
896
|
+
>
|
|
897
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
898
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
|
899
|
+
</svg>
|
|
900
|
+
</button>
|
|
901
|
+
</div>
|
|
902
|
+
{/if}
|
|
903
|
+
|
|
904
|
+
{#if requestTypeFilter}
|
|
905
|
+
<div class="inline-flex items-center gap-1.5 border border-nexus-500/60 bg-nexus-500/10 px-2.5 py-0.5 font-mono text-[11px] uppercase tracking-command text-nexus-300">
|
|
906
|
+
<span class="text-xs opacity-70">{$_('logs.requestType')}:</span>
|
|
907
|
+
<span class="font-medium">{$_(`logs.requestType_${requestTypeFilter}`)}</span>
|
|
908
|
+
<button
|
|
909
|
+
type="button"
|
|
910
|
+
class="inline-flex items-center justify-center h-4 w-4 text-zinc-500 hover:text-red-300 transition-colors"
|
|
911
|
+
onclick={() => requestTypeFilter = ''}
|
|
912
|
+
aria-label={$_('logs.clearFilters')}
|
|
913
|
+
>
|
|
914
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
915
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
|
916
|
+
</svg>
|
|
917
|
+
</button>
|
|
918
|
+
</div>
|
|
919
|
+
{/if}
|
|
920
|
+
|
|
921
|
+
{#if hasRetryFilter !== undefined}
|
|
922
|
+
<div class="inline-flex items-center gap-1.5 border border-nexus-500/60 bg-nexus-500/10 px-2.5 py-0.5 font-mono text-[11px] uppercase tracking-command text-nexus-300">
|
|
923
|
+
<span class="text-xs opacity-70">{$_('logs.chain.onlyRetries')}:</span>
|
|
924
|
+
<span class="font-medium">{hasRetryFilter ? $_('common.yes') : $_('common.no')}</span>
|
|
925
|
+
<button
|
|
926
|
+
type="button"
|
|
927
|
+
class="inline-flex items-center justify-center h-4 w-4 text-zinc-500 hover:text-red-300 transition-colors"
|
|
928
|
+
onclick={() => hasRetryFilter = undefined}
|
|
929
|
+
aria-label={$_('logs.clearFilters')}
|
|
930
|
+
>
|
|
931
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
932
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
|
933
|
+
</svg>
|
|
934
|
+
</button>
|
|
935
|
+
</div>
|
|
936
|
+
{/if}
|
|
937
|
+
|
|
938
|
+
<button
|
|
939
|
+
type="button"
|
|
940
|
+
class="inline-flex items-center gap-1.5 border px-2.5 py-0.5 font-mono text-[11px] uppercase tracking-command transition-colors {hasRetryFilter === true ? 'border-amber-500/60 bg-amber-500/10 text-amber-300' : 'border-carbon-500 bg-carbon-800 text-zinc-400 hover:text-zinc-200'}"
|
|
941
|
+
onclick={() => hasRetryFilter = hasRetryFilter === true ? undefined : true}
|
|
942
|
+
>
|
|
943
|
+
{$_('logs.chain.onlyRetries')}
|
|
944
|
+
</button>
|
|
945
|
+
|
|
946
|
+
{#if timeRangeType === 'recent' && recentHours !== 1}
|
|
947
|
+
<div class="inline-flex items-center gap-1.5 border border-nexus-500/60 bg-nexus-500/10 px-2.5 py-0.5 font-mono text-[11px] uppercase tracking-command text-nexus-300">
|
|
948
|
+
<span class="text-xs opacity-70">{$_('logs.timeRange')}:</span>
|
|
949
|
+
<span class="font-medium">{$_('logs.recentTime')} {recentHours}h</span>
|
|
950
|
+
<button
|
|
951
|
+
type="button"
|
|
952
|
+
class="inline-flex items-center justify-center h-4 w-4 text-zinc-500 hover:text-red-300 transition-colors"
|
|
953
|
+
onclick={() => recentHours = 1}
|
|
954
|
+
aria-label={$_('logs.clearFilters')}
|
|
955
|
+
>
|
|
956
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
957
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
|
958
|
+
</svg>
|
|
959
|
+
</button>
|
|
960
|
+
</div>
|
|
961
|
+
{/if}
|
|
962
|
+
|
|
963
|
+
{#if timeRangeType === 'custom'}
|
|
964
|
+
<div class="inline-flex items-center gap-1.5 border border-nexus-500/60 bg-nexus-500/10 px-2.5 py-0.5 font-mono text-[11px] uppercase tracking-command text-nexus-300">
|
|
965
|
+
<span class="text-xs opacity-70">{$_('logs.timeRange')}:</span>
|
|
966
|
+
<span class="font-medium">{$_('logs.customTime')}</span>
|
|
967
|
+
<button
|
|
968
|
+
type="button"
|
|
969
|
+
class="inline-flex items-center justify-center h-4 w-4 text-zinc-500 hover:text-red-300 transition-colors"
|
|
970
|
+
onclick={() => { timeRangeType = 'recent'; customStartTime = ''; customEndTime = ''; }}
|
|
971
|
+
aria-label={$_('logs.clearFilters')}
|
|
972
|
+
>
|
|
973
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
974
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
|
975
|
+
</svg>
|
|
976
|
+
</button>
|
|
977
|
+
</div>
|
|
978
|
+
{/if}
|
|
979
|
+
|
|
980
|
+
{#if timeRangeType === 'all'}
|
|
981
|
+
<div class="inline-flex items-center gap-1.5 border border-nexus-500/60 bg-nexus-500/10 px-2.5 py-0.5 font-mono text-[11px] uppercase tracking-command text-nexus-300">
|
|
982
|
+
<span class="text-xs opacity-70">{$_('logs.timeRange')}:</span>
|
|
983
|
+
<span class="font-medium">{$_('logs.allTime')}</span>
|
|
984
|
+
<button
|
|
985
|
+
type="button"
|
|
986
|
+
class="inline-flex items-center justify-center h-4 w-4 text-zinc-500 hover:text-red-300 transition-colors"
|
|
987
|
+
onclick={() => timeRangeType = 'recent'}
|
|
988
|
+
aria-label={$_('logs.clearFilters')}
|
|
989
|
+
>
|
|
990
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
991
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
|
992
|
+
</svg>
|
|
993
|
+
</button>
|
|
994
|
+
</div>
|
|
995
|
+
{/if}
|
|
996
|
+
|
|
997
|
+
{#if sortBy !== 'timestamp' || sortOrder !== 'desc'}
|
|
998
|
+
<div class="inline-flex items-center gap-1.5 border border-nexus-500/60 bg-nexus-500/10 px-2.5 py-0.5 font-mono text-[11px] uppercase tracking-command text-nexus-300">
|
|
999
|
+
<span class="text-xs opacity-70">{$_('logs.sortBy')}:</span>
|
|
1000
|
+
<span class="font-medium">{$_(`logs.sortBy${sortBy.charAt(0).toUpperCase() + sortBy.slice(1)}`)} {sortOrder === 'asc' ? '↑' : '↓'}</span>
|
|
1001
|
+
<button
|
|
1002
|
+
type="button"
|
|
1003
|
+
class="inline-flex items-center justify-center h-4 w-4 text-zinc-500 hover:text-red-300 transition-colors"
|
|
1004
|
+
onclick={() => { sortBy = 'timestamp'; sortOrder = 'desc'; }}
|
|
1005
|
+
aria-label={$_('logs.clearFilters')}
|
|
1006
|
+
>
|
|
1007
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
1008
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
|
1009
|
+
</svg>
|
|
1010
|
+
</button>
|
|
1011
|
+
</div>
|
|
1012
|
+
{/if}
|
|
1013
|
+
</div>
|
|
1014
|
+
{/if}
|
|
1015
|
+
</div>
|
|
1016
|
+
|
|
1017
|
+
<!-- 日志列表 -->
|
|
1018
|
+
{#if loading && logs.length === 0}
|
|
1019
|
+
<PanelCard title={$_('logs.title')} tag="LOADING">
|
|
1020
|
+
<LoadingIndicator label="LOADING LOG STREAM" height="md" />
|
|
1021
|
+
</PanelCard>
|
|
1022
|
+
{:else if error}
|
|
1023
|
+
<PanelCard title={$_('common.error')} tag="ERR" stripe="red">
|
|
1024
|
+
<p class="font-mono text-[11px] uppercase tracking-command text-red-300">{error}</p>
|
|
1025
|
+
</PanelCard>
|
|
1026
|
+
{:else if logs.length === 0}
|
|
1027
|
+
<PanelCard title={$_('logs.noData')} tag="EMPTY" stripe="zinc">
|
|
1028
|
+
<div class="py-6 text-center" data-testid="logs-empty-state">
|
|
1029
|
+
<span class="font-mono text-[11px] uppercase tracking-command text-zinc-500">
|
|
1030
|
+
{$_('logs.noData')}
|
|
1031
|
+
</span>
|
|
1032
|
+
</div>
|
|
1033
|
+
</PanelCard>
|
|
1034
|
+
{:else}
|
|
1035
|
+
<PanelCard title="REQUEST LOG" tag={`N=${logs.length}/${total}`} flush>
|
|
1036
|
+
<div class="w-full min-w-0 overflow-x-auto" data-testid="logs-table-scroll">
|
|
1037
|
+
<table class="w-full min-w-[1200px] whitespace-nowrap">
|
|
1038
|
+
<colgroup>
|
|
1039
|
+
<col class="w-44" />
|
|
1040
|
+
<col class="w-20" />
|
|
1041
|
+
<col class="w-[88px]" />
|
|
1042
|
+
<col class="w-56" />
|
|
1043
|
+
<col class="w-[100px]" />
|
|
1044
|
+
<col class="w-[100px]" />
|
|
1045
|
+
<col class="w-24" />
|
|
1046
|
+
<col class="w-56" />
|
|
1047
|
+
<col class="w-28" />
|
|
1048
|
+
</colgroup>
|
|
1049
|
+
<thead class="border-b border-carbon-600 bg-carbon-900/60">
|
|
1050
|
+
<tr>
|
|
1051
|
+
<th class="text-left nx-label py-2.5 px-4">{$_('logs.time')}</th>
|
|
1052
|
+
<th class="text-left nx-label py-2.5 px-4">{$_('logs.transportType')}</th>
|
|
1053
|
+
<th class="text-left nx-label py-2.5 px-4">{$_('logs.method')}</th>
|
|
1054
|
+
<th class="text-left nx-label py-2.5 px-4">{$_('logs.path')}</th>
|
|
1055
|
+
<th class="text-left nx-label py-2.5 px-4">{$_('logs.status')}</th>
|
|
1056
|
+
<th class="text-left nx-label py-2.5 px-4">{$_('logs.transportResult')}</th>
|
|
1057
|
+
<th class="text-right nx-label py-2.5 px-4">{$_('logs.duration')}</th>
|
|
1058
|
+
<th class="text-left nx-label py-2.5 px-4">{$_('logs.upstream')}</th>
|
|
1059
|
+
<th class="text-right nx-label py-2.5 px-4">{$_('logs.actions')}</th>
|
|
1060
|
+
</tr>
|
|
1061
|
+
</thead>
|
|
1062
|
+
<tbody>
|
|
1063
|
+
{#each logs as log, index (log.chainId)}
|
|
1064
|
+
{@const transport = chainTransportOutcome(log)}
|
|
1065
|
+
<tr class="group border-b border-carbon-600/60 hover:bg-carbon-700/40 transition-colors" data-testid={index === 0 ? 'logs-row-first' : undefined}>
|
|
1066
|
+
<td class="py-2.5 px-4 font-mono text-[11px] text-zinc-400">{formatTime(log.chainStartTs)}</td>
|
|
1067
|
+
<td class="py-2.5 px-4"><span class="nx-feature-tag" title={log.transportType === null ? $_('logs.transportTypeUnrecorded') : undefined}>{transportTypeLabel(log.transportType)}</span></td>
|
|
1068
|
+
<td class="py-2.5 px-4"><span class="nx-feature-tag">{log.method || '—'}</span></td>
|
|
1069
|
+
<td class="py-2.5 px-4 font-mono text-[12px] text-zinc-200 truncate max-w-xs" title={log.path}>
|
|
1070
|
+
{log.path}
|
|
1071
|
+
</td>
|
|
1072
|
+
<td class="py-2.5 px-4"><span class="nx-feature-tag">{httpStatusLabel(log.chainStatus)}</span></td>
|
|
1073
|
+
<td class="py-2.5 px-4"><span class={`inline-flex border px-2 py-0.5 font-mono text-[11px] ${transportTone(transport)}`}>{$_(`logs.transport.${transport}`)}</span></td>
|
|
1074
|
+
<td class="py-2.5 px-4 text-right font-mono text-[11px] text-zinc-300 tabular-nums">{log.transportType === 'websocket' && log.recordKind === 'access' && transport === 'pending' ? '—' : formatDuration(log.chainDurationMs)}</td>
|
|
1075
|
+
<td class="py-2.5 px-4 font-mono text-[11px] text-zinc-400 truncate max-w-xs" title={log.upstream || '-'}>
|
|
1076
|
+
{log.upstream || '—'}
|
|
1077
|
+
{#if log.chainAttempts > 1}
|
|
1078
|
+
<span class="ml-1 text-amber-300 text-[10px]">{$_('logs.chain.attemptsSummary', { values: { count: log.chainAttempts } })}</span>
|
|
1079
|
+
{/if}
|
|
1080
|
+
</td>
|
|
1081
|
+
<td class="py-2.5 px-4 text-right">
|
|
1082
|
+
<button
|
|
1083
|
+
class="nx-btn-ghost nx-btn-sm"
|
|
1084
|
+
|
|
1085
|
+
onclick={() => viewDetail(log)}
|
|
1086
|
+
>
|
|
1087
|
+
{$_('logs.viewDetail')}
|
|
1088
|
+
</button>
|
|
1089
|
+
</td>
|
|
1090
|
+
</tr>
|
|
1091
|
+
{/each}
|
|
1092
|
+
</tbody>
|
|
1093
|
+
</table>
|
|
1094
|
+
</div>
|
|
1095
|
+
|
|
1096
|
+
<!-- Pagination -->
|
|
1097
|
+
<div class="flex flex-wrap justify-between items-center gap-2 px-4 py-3 border-t border-carbon-600 bg-carbon-900/60">
|
|
1098
|
+
<span class="whitespace-nowrap font-mono text-[10px] uppercase tracking-command text-zinc-500">
|
|
1099
|
+
{$_('logs.showing', { values: { start: (page - 1) * limit + 1, end: Math.min(page * limit, total), total } })}
|
|
1100
|
+
</span>
|
|
1101
|
+
<div class="inline-flex shrink-0 whitespace-nowrap border border-carbon-500 bg-carbon-900">
|
|
1102
|
+
<button
|
|
1103
|
+
class="nx-pager-btn"
|
|
1104
|
+
disabled={page <= 1}
|
|
1105
|
+
onclick={() => (page = page - 1)}
|
|
1106
|
+
>«</button>
|
|
1107
|
+
<span class="nx-pager-btn pointer-events-none">
|
|
1108
|
+
{$_('logs.page', { values: { page, totalPages } })}
|
|
1109
|
+
</span>
|
|
1110
|
+
<button
|
|
1111
|
+
class="nx-pager-btn"
|
|
1112
|
+
disabled={page >= totalPages}
|
|
1113
|
+
onclick={() => (page = page + 1)}
|
|
1114
|
+
>»</button>
|
|
1115
|
+
</div>
|
|
1116
|
+
</div>
|
|
1117
|
+
</PanelCard>
|
|
1118
|
+
{/if}
|
|
1119
|
+
</div>
|
|
1120
|
+
|
|
1121
|
+
<!-- 详情模态框 -->
|
|
1122
|
+
{#if showDetailModal && selectedChain}
|
|
1123
|
+
<ChainDetailModal
|
|
1124
|
+
chain={selectedChain}
|
|
1125
|
+
onClose={() => {
|
|
1126
|
+
showDetailModal = false;
|
|
1127
|
+
selectedChain = null;
|
|
1128
|
+
}}
|
|
1129
|
+
/>
|
|
1130
|
+
{/if}
|