125 lines
3.6 KiB
TypeScript
125 lines
3.6 KiB
TypeScript
import { http } from '@/lib/http'
|
|
|
|
export type DesktopBugReportType = 'crash' | 'bug'
|
|
export type DesktopBugReportStatus = 'new' | 'triaged' | 'in_progress' | 'resolved' | 'ignored'
|
|
export type DesktopBugReportSeverity = 'low' | 'medium' | 'high' | 'critical'
|
|
|
|
export interface DesktopBugReport {
|
|
id: string
|
|
report_type: DesktopBugReportType
|
|
status: DesktopBugReportStatus
|
|
severity: DesktopBugReportSeverity
|
|
tenant_id?: number | null
|
|
tenant_name?: string | null
|
|
workspace_id?: number | null
|
|
workspace_name?: string | null
|
|
user_id?: number | null
|
|
user_name?: string | null
|
|
user_phone?: string | null
|
|
user_email?: string | null
|
|
desktop_client_id?: string | null
|
|
crash_guid?: string | null
|
|
crash_report_id?: string | null
|
|
process_type?: string | null
|
|
electron_version?: string | null
|
|
app_version?: string | null
|
|
product_name?: string | null
|
|
platform?: string | null
|
|
os_arch?: string | null
|
|
device_name?: string | null
|
|
title: string
|
|
description?: string | null
|
|
dump_object_key?: string | null
|
|
dump_file_name?: string | null
|
|
dump_size_bytes?: number | null
|
|
dump_sha256?: string | null
|
|
form_fields: Record<string, unknown>
|
|
runtime_snapshot: Record<string, unknown>
|
|
app_log_tail?: string | null
|
|
resolution_note?: string | null
|
|
uploader_ip?: string | null
|
|
user_agent?: string | null
|
|
occurred_at: string
|
|
resolved_at?: string | null
|
|
created_at: string
|
|
updated_at: string
|
|
}
|
|
|
|
export interface DesktopBugReportList {
|
|
items: DesktopBugReport[]
|
|
total: number
|
|
page: number
|
|
size: number
|
|
}
|
|
|
|
export interface DesktopBugReportUpdatePayload {
|
|
status: DesktopBugReportStatus
|
|
severity: DesktopBugReportSeverity
|
|
resolution_note?: string | null
|
|
}
|
|
|
|
export interface DesktopBugReportDumpURL {
|
|
download_url: string
|
|
}
|
|
|
|
export const desktopBugReportStatusOptions = [
|
|
{ label: '新建', value: 'new' },
|
|
{ label: '已分诊', value: 'triaged' },
|
|
{ label: '处理中', value: 'in_progress' },
|
|
{ label: '已解决', value: 'resolved' },
|
|
{ label: '忽略', value: 'ignored' },
|
|
]
|
|
|
|
export const desktopBugReportSeverityOptions = [
|
|
{ label: '低', value: 'low' },
|
|
{ label: '中', value: 'medium' },
|
|
{ label: '高', value: 'high' },
|
|
{ label: '致命', value: 'critical' },
|
|
]
|
|
|
|
export const desktopBugReportTypeOptions = [
|
|
{ label: '崩溃', value: 'crash' },
|
|
{ label: '反馈', value: 'bug' },
|
|
]
|
|
|
|
export const desktopBugReportApi = {
|
|
list(params: {
|
|
keyword?: string
|
|
status?: string
|
|
severity?: string
|
|
report_type?: string
|
|
platform?: string
|
|
process_type?: string
|
|
tenant_id?: number
|
|
client_id?: string
|
|
page?: number
|
|
size?: number
|
|
}) {
|
|
return http.get<DesktopBugReportList>('/desktop-client/bug-reports', params)
|
|
},
|
|
get(id: string) {
|
|
return http.get<DesktopBugReport>(`/desktop-client/bug-reports/${id}`)
|
|
},
|
|
update(id: string, payload: DesktopBugReportUpdatePayload) {
|
|
return http.patch<DesktopBugReport, DesktopBugReportUpdatePayload>(
|
|
`/desktop-client/bug-reports/${id}`,
|
|
payload,
|
|
)
|
|
},
|
|
resolveDumpURL(id: string) {
|
|
return http.get<DesktopBugReportDumpURL>(`/desktop-client/bug-reports/${id}/dump-url`)
|
|
},
|
|
}
|
|
|
|
export function desktopBugReportStatusLabel(value?: string | null): string {
|
|
return desktopBugReportStatusOptions.find((item) => item.value === value)?.label ?? value ?? '—'
|
|
}
|
|
|
|
export function desktopBugReportSeverityLabel(value?: string | null): string {
|
|
return desktopBugReportSeverityOptions.find((item) => item.value === value)?.label ?? value ?? '—'
|
|
}
|
|
|
|
export function desktopBugReportTypeLabel(value?: string | null): string {
|
|
return desktopBugReportTypeOptions.find((item) => item.value === value)?.label ?? value ?? '—'
|
|
}
|