mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-06 08:06:19 +00:00
fix(frontend): scope usage record refresh
Refresh only the request detail table with an independent current-time snapshot, while preserving latest-request-wins ordering and leaving analytics cards untouched. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -19,7 +19,7 @@ interface UseUsageRecordsTableOptions {
|
||||
searchQuery: Ref<string>
|
||||
timeRangeParams: Readonly<Ref<UsageTimeRangeParams>>
|
||||
totalRecords: Ref<number>
|
||||
refreshTimeRangeEnd: () => void
|
||||
latestTimeRangeParams: () => UsageTimeRangeParams
|
||||
}
|
||||
|
||||
type UsageLoadScope = 'all' | 'table'
|
||||
@@ -30,6 +30,9 @@ export function useUsageRecordsTable(options: UseUsageRecordsTableOptions) {
|
||||
const records = shallowRef<any[]>([])
|
||||
const summary = shallowRef(emptySummary())
|
||||
const insights = shallowRef(emptyInsights())
|
||||
const tableTimeRangeParams = shallowRef<UsageTimeRangeParams>({
|
||||
...options.timeRangeParams.value,
|
||||
})
|
||||
const refreshingList = shallowRef(false)
|
||||
const diagnosticDimension = shallowRef('model')
|
||||
const diagnosticLoading = shallowRef(false)
|
||||
@@ -51,8 +54,11 @@ export function useUsageRecordsTable(options: UseUsageRecordsTableOptions) {
|
||||
}
|
||||
|
||||
const globalParams = scopedParams()
|
||||
if (scope === 'all') {
|
||||
tableTimeRangeParams.value = { ...globalParams }
|
||||
}
|
||||
const tableParams = {
|
||||
...globalParams,
|
||||
...tableTimeRangeParams.value,
|
||||
...filterParams(),
|
||||
}
|
||||
const resultPromise = getUsageRecords({
|
||||
@@ -149,8 +155,8 @@ export function useUsageRecordsTable(options: UseUsageRecordsTableOptions) {
|
||||
if (refreshingList.value || loading.value) return
|
||||
refreshingList.value = true
|
||||
try {
|
||||
options.refreshTimeRangeEnd()
|
||||
await withMinimumDuration(() => loadUsageRecords('all'))
|
||||
tableTimeRangeParams.value = options.latestTimeRangeParams()
|
||||
await withMinimumDuration(() => loadUsageRecords('table'))
|
||||
} finally {
|
||||
refreshingList.value = false
|
||||
}
|
||||
|
||||
@@ -17,10 +17,15 @@ export function useUsageTimeRange(initialRange: UsageTimeRange = 'today') {
|
||||
rangeEnd.value = dayjs()
|
||||
}
|
||||
|
||||
function latestTimeRangeParams() {
|
||||
return buildTimeRange(timeRange.value, dayjs())
|
||||
}
|
||||
|
||||
return {
|
||||
timeRange,
|
||||
timeRangeParams,
|
||||
refreshTimeRangeEnd,
|
||||
latestTimeRangeParams,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ const recordViewOptions = [
|
||||
{ label: '成功记录', value: 'success' },
|
||||
{ label: '错误排查', value: 'errors' },
|
||||
]
|
||||
const { timeRange, timeRangeParams, refreshTimeRangeEnd } = useUsageTimeRange()
|
||||
const { timeRange, timeRangeParams, refreshTimeRangeEnd, latestTimeRangeParams } =
|
||||
useUsageTimeRange()
|
||||
|
||||
const {
|
||||
page,
|
||||
@@ -65,7 +66,7 @@ const {
|
||||
searchQuery,
|
||||
timeRangeParams,
|
||||
totalRecords,
|
||||
refreshTimeRangeEnd,
|
||||
latestTimeRangeParams,
|
||||
})
|
||||
|
||||
const { showDetailModal, selectedUsageRecord, handleViewDetail } = useUsageRecordDetail({
|
||||
|
||||
Reference in New Issue
Block a user