45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import type { JobStatus } from '@/api/assistantService'
|
|
|
|
export function errorText(error: unknown): string {
|
|
if (error instanceof Error) return error.message
|
|
if (typeof error === 'string') return error
|
|
const value = error as {
|
|
msg?: string
|
|
message?: string
|
|
response?: { data?: { msg?: string } }
|
|
} | null
|
|
return value?.response?.data?.msg || value?.msg || value?.message || '请求失败,请刷新后重试'
|
|
}
|
|
export function isCancelled(error: unknown) {
|
|
return (error as { code?: string })?.code === 'ERR_CANCELED'
|
|
}
|
|
export function formatTime(value: number) {
|
|
return value ? new Date(value * 1000).toLocaleString('zh-CN', { hour12: false }) : '—'
|
|
}
|
|
export function shanghaiTime(value: number) {
|
|
return value
|
|
? new Date(value * 1000).toLocaleString('zh-CN', {
|
|
timeZone: 'Asia/Shanghai',
|
|
hour12: false
|
|
})
|
|
: '—'
|
|
}
|
|
export const jobLabels: Record<JobStatus, string> = {
|
|
queued: '等待处理',
|
|
running: '分析中',
|
|
ready: '已生成 · 待人工核对',
|
|
failed: '生成失败',
|
|
needs_reconciliation: '调用状态待核实',
|
|
stale: '结果已过期'
|
|
}
|
|
const channelLabels: Record<string, string> = {
|
|
manual: '人工服务记录',
|
|
im: '腾讯 IM',
|
|
tracking: '跟踪备注',
|
|
tracking_note: '跟踪备注',
|
|
wecom: '企业微信',
|
|
qywx: '企业微信',
|
|
audio: '录音 / 转写'
|
|
}
|
|
export const channelLabel = (channel: string) => channelLabels[channel] || channel
|