fix: retain async holds for unknown provider outcomes
This commit is contained in:
1 parent
76265845dc
commit
5be06a97c1
18 files changed
+574
-108
No files matched your search
@@ -23,7 +23,7 @@ const number = (n: unknown) => n == null ? '—' : Number(n).toLocaleString('zh-
|
||||
const money = (n: unknown) => n == null ? '—' : `¥ ${Number(n).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 8 })}`
|
||||
const duration = (n: unknown) => n == null ? '—' : `${(Number(n) / 1000).toFixed(2)}s`
|
||||
const time = (value: string) => new Date(value).toLocaleString('zh-CN', { hour12: false })
|
||||
const statusName = (v: string) => ({ succeeded: '成功', failed: '失败', queued: '排队中', running: '执行中', cancelled: '已取消' })[v] || v
|
||||
const statusName = (v: string) => ({ succeeded: '成功', failed: '失败', queued: '排队中', running: '执行中', reconciling: '待核账(额度仍冻结)', cancelled: '已取消' })[v] || v
|
||||
const modeName = (v?: string) => ({ sync: '同步', stream: '流式', async: '异步' })[v || ''] || '—'
|
||||
const sourceName = (v?: string) => ({ playground: '在线调试', api: 'API', unknown: '历史调用' })[v || 'unknown'] || '历史调用'
|
||||
const pretty = (v: unknown) => v == null ? '未保存内容' : JSON.stringify(v, null, 2)
|
||||
@@ -108,7 +108,7 @@ onUnmounted(() => { requestSequence++; selectedId.value = ''; if (timer) window.
|
||||
<label>分组<select v-model="filters.groupId" class="text-input"><option value="">全部分组</option><option v-for="group in groups" :key="group.id" :value="group.id">{{ group.name }} · {{ group.channel }}</option></select></label>
|
||||
<label>调用类型<select v-model="filters.callMode" class="text-input"><option value="">全部类型</option><option value="sync">同步</option><option value="stream">流式</option><option value="async">异步</option></select></label>
|
||||
<label>请求类别<select v-model="filters.eventKind" class="text-input"><option value="">全部请求</option><option value="call">模型调用</option><option value="task">异步任务</option></select></label>
|
||||
<label>状态<select v-model="filters.status" class="text-input"><option value="">全部状态</option><option v-for="state in ['succeeded','failed','queued','running','cancelled']" :key="state" :value="state">{{ statusName(state) }}</option></select></label>
|
||||
<label>状态<select v-model="filters.status" class="text-input"><option value="">全部状态</option><option v-for="state in ['succeeded','failed','queued','running','reconciling','cancelled']" :key="state" :value="state">{{ statusName(state) }}</option></select></label>
|
||||
<label>费用记录<select v-model="filters.costState" class="text-input"><option value="">全部</option><option value="recorded">已记录</option><option value="pending">未记录</option></select></label>
|
||||
<label>来源<select v-model="filters.source" class="text-input"><option value="">全部来源</option><option value="playground">在线调试</option><option value="api">API</option><option value="unknown">历史调用(未标记来源)</option></select></label>
|
||||
<label>User-Agent<input v-model="filters.userAgent" class="text-input" maxlength="200" placeholder="模糊搜索客户端" /></label>
|
||||
|
||||
@@ -122,7 +122,7 @@ export interface PlatformOverview {
|
||||
availabilityPercent?: number
|
||||
asyncTasks: number
|
||||
asyncSuccessRate?: number
|
||||
tasks: { queued: number; running: number; succeeded: number; failed: number }
|
||||
tasks: { queued: number; running: number; reconciling?: number; succeeded: number; failed: number }
|
||||
series: Array<{ date: string; count: number }>
|
||||
ledger: Array<{ id: string; title: string; amount: number; createdAt: string }>
|
||||
}
|
||||
@@ -172,8 +172,9 @@ export interface AdminUsageSummary {
|
||||
costToday: number
|
||||
costThisMonth: number
|
||||
series: Array<{ date: string; count: number }>
|
||||
capacityGroups: Array<{ id: string; name: string; sourceLabel?: string; providerName?: string; mode?: string; routeEnabled?: boolean; running: number | null; limit: number; queued: number | null }>
|
||||
capacityGroups: Array<{ id: string; name: string; sourceLabel?: string; providerName?: string; mode?: string; routeEnabled?: boolean; running: number | null; limit: number; queued: number | null; reconciling?: number }>
|
||||
running?: number | null
|
||||
reconciling?: number | null
|
||||
capacityConfig?: {
|
||||
queueWaitMs: number
|
||||
defaultModelConcurrency: number
|
||||
@@ -231,7 +232,8 @@ export interface AsyncTaskResult {
|
||||
id: string
|
||||
model: string
|
||||
provider?: string
|
||||
status: 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled'
|
||||
status: 'queued' | 'running' | 'reconciling' | 'succeeded' | 'failed' | 'cancelled'
|
||||
requiresReconciliation?: boolean
|
||||
progress?: number
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
@@ -240,7 +242,7 @@ export interface AsyncTaskResult {
|
||||
result?: { format?: string; url?: string; modelUrl?: string; previewUrl?: string; videoUrl?: string; imageUrl?: string; audioUrl?: string; mimeType?: string; creditsConsumed?: number; [key: string]: unknown }
|
||||
output?: { modelUrl?: string; previewUrl?: string; videoUrl?: string; imageUrl?: string; audioUrl?: string; url?: string; format?: string; mimeType?: string }
|
||||
creditsConsumed?: number
|
||||
error?: { code?: number; message?: string }
|
||||
error?: { code?: string | number; message?: string; retryable?: boolean; requiresReconciliation?: boolean }
|
||||
}
|
||||
|
||||
/** OpenAI-compatible multimodal content. Keep text-only calls byte-for-byte compatible. */
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { AuthRole } from './services/auth'
|
||||
export type Portal = 'user' | 'admin'
|
||||
export type ModelType = '文本' | '多模态' | '图像' | '3D' | '视频' | '音频'
|
||||
export type CallMode = '同步' | '流式' | '异步'
|
||||
export type TaskStatus = '排队中' | '执行中' | '已完成' | '失败'
|
||||
export type TaskStatus = '排队中' | '执行中' | '待核账' | '已完成' | '失败'
|
||||
|
||||
export interface NavItem {
|
||||
id: string
|
||||
|
||||
@@ -202,8 +202,8 @@ function formatUsagePayload(value: unknown) {
|
||||
const queueGroups = computed(() => (adminSummary.value?.capacityGroups || []).map((group) => ({
|
||||
...group,
|
||||
type: `${group.providerName || '未知渠道'} · ${group.sourceLabel || '模型分组'}`,
|
||||
status: group.running === null ? '未读取' : group.routeEnabled === false ? '已停用,仍有任务' : group.queued ? '排队中' : group.running ? '执行中' : '空闲',
|
||||
warning: group.running === null || group.routeEnabled === false || !!group.queued,
|
||||
status: group.reconciling ? `待核账 ${group.reconciling} 笔(额度仍冻结)` : group.running === null ? '未读取' : group.routeEnabled === false ? '已停用,仍有任务' : group.queued ? '排队中' : group.running ? '执行中' : '空闲',
|
||||
warning: group.running === null || group.routeEnabled === false || !!group.queued || !!group.reconciling,
|
||||
})))
|
||||
const { page: capacityPage, pageSize: capacityPageSize, pagedItems: capacityPageGroups } = usePagination(queueGroups)
|
||||
const configuredCapacityGroups = computed(() => adminSummary.value?.capacityGroups.filter(group => group.routeEnabled !== false) || [])
|
||||
|
||||
@@ -235,6 +235,7 @@ function normalizeOverview(value: unknown): PlatformOverview {
|
||||
tasks: {
|
||||
queued: asNumber(rawTasks.queued),
|
||||
running: asNumber(rawTasks.running),
|
||||
reconciling: asNumber(rawTasks.reconciling),
|
||||
succeeded: asNumber(rawTasks.succeeded),
|
||||
failed: asNumber(rawTasks.failed),
|
||||
},
|
||||
@@ -504,6 +505,7 @@ function mapAsyncTask(task: AsyncTaskResult, model: ModelItem, taskPrompt?: stri
|
||||
const statusMap: Record<AsyncTaskResult['status'], TaskStatus> = {
|
||||
queued: '排队中',
|
||||
running: '执行中',
|
||||
reconciling: '待核账',
|
||||
succeeded: '已完成',
|
||||
failed: '失败',
|
||||
cancelled: '失败',
|
||||
@@ -516,7 +518,7 @@ function mapAsyncTask(task: AsyncTaskResult, model: ModelItem, taskPrompt?: stri
|
||||
status: statusMap[task.status],
|
||||
progress: task.status === 'succeeded' ? 100 : Math.round(task.progress || 0),
|
||||
createdAt: createdAt ? formatTaskTime(createdAt) : '刚刚',
|
||||
duration: task.completedAt ? '已完成' : '计算中',
|
||||
duration: task.completedAt ? '已完成' : task.status === 'reconciling' ? '等待核账' : '计算中',
|
||||
result: task.error?.message || (videoUrl ? '视频已生成' : imageUrl ? '图片已生成' : audioUrl ? '音频已生成' : modelUrl ? 'GLB 模型已生成' : resultUrl ? '文件已生成' : task.status === 'succeeded' ? '异步任务已完成' : task.status === 'running' ? `正在生成 · ${Math.round(task.progress || 0)}%` : '等待平台调度'),
|
||||
provider: task.provider,
|
||||
prompt: taskPrompt,
|
||||
@@ -557,13 +559,11 @@ async function pollTask(taskId: string, apiKey: string) {
|
||||
scheduleTaskPoll(taskId, apiKey, 2500)
|
||||
} else {
|
||||
taskPollers.delete(taskId)
|
||||
// The async endpoint settles or releases the wallet only when the
|
||||
// provider task reaches a terminal state. Refresh the overview here so
|
||||
// the balance card and usage counters reflect that settlement immediately
|
||||
// instead of waiting for a full page reload.
|
||||
// Reconciliation stops automatic polling, but it is NOT a failure or a refund.
|
||||
// Refresh financial state without encouraging another generation request.
|
||||
await refreshOverview()
|
||||
historyRevision.value++
|
||||
emit('notify', latest.status === 'succeeded' ? `${previous.name}完成,可以查看和保存结果` : `${previous.name}未能完成,请查看错误说明`)
|
||||
emit('notify', latest.status === 'reconciling' ? `${previous.name}结果尚未确认,额度仍冻结,请联系管理员核账,勿重复提交` : latest.status === 'succeeded' ? `${previous.name}完成,可以查看和保存结果` : `${previous.name}未能完成,请查看错误说明`)
|
||||
}
|
||||
} catch (error) {
|
||||
taskPollers.delete(taskId)
|
||||
@@ -1010,6 +1010,7 @@ $env:OPENAI_API_KEY="你的 MOYI 用户 API Key"
|
||||
.token-limit { display: grid; gap: 8px; }
|
||||
.response-result > p, .response-content { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; }
|
||||
.response-result .status-chip.failed { color: #b42318; background: #fee4e2; }
|
||||
.status-chip.待核账 { color: #b54708; background: #fffaeb; }
|
||||
.response-result p[role="alert"] { color: #b42318; }
|
||||
.playground-selectors { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
|
||||
.playground-selectors label { display: grid; gap: 8px; font-size: 13px; min-width: 0; }
|
||||
|
||||
Reference in new issue
Block a user