优化抢购流程日志和复验性能
This commit is contained in:
@@ -6,6 +6,7 @@ export interface LogEntry {
|
||||
time: string
|
||||
level: string
|
||||
category: string
|
||||
account?: string
|
||||
message: string
|
||||
}
|
||||
|
||||
@@ -14,6 +15,7 @@ export interface LogMessage {
|
||||
type: 's' | 'e' | 'i' | 'w' | 'd'
|
||||
message: string
|
||||
category?: string
|
||||
account?: string
|
||||
source: 'local' | 'server'
|
||||
}
|
||||
|
||||
@@ -32,6 +34,19 @@ const resultSucceeded = (message: string): boolean => {
|
||||
return /成功|兑换上限|已抢到/.test(String(message || ''))
|
||||
}
|
||||
|
||||
const formatServerLogTime = (time: string): string => {
|
||||
const value = String(time || '')
|
||||
const match = value.match(/\d{2}:\d{2}:\d{2}\.\d{3}/)
|
||||
return match ? match[0] : value
|
||||
}
|
||||
|
||||
const cleanServerLogMessage = (message: string): string => {
|
||||
return String(message || '')
|
||||
.replace(/^\d{4}\/\d{2}\/\d{2}\s+\d{2}:\d{2}:\d{2}(?:\.\d{3})?\s*/i, '')
|
||||
.replace(/\[[^\]]+\]\[(debug|info|success|warn|error)\]\s*/i, '')
|
||||
.replace(/^\[账号:[^\]]+\]\s*/i, '')
|
||||
}
|
||||
|
||||
// 后端结果按“账号_第N包”返回,账号表按账号名展示,这里做一次归并。
|
||||
const normalizeResultStatuses = (data: Record<string, string>): Record<string, AccountStatus> => {
|
||||
const next: Record<string, AccountStatus> = {}
|
||||
@@ -80,14 +95,15 @@ export function useLogs() {
|
||||
else if (item.level === 'warn') type = 'w'
|
||||
else if (item.level === 'debug') type = 'd'
|
||||
|
||||
// 清理日志前缀
|
||||
const cleanMsg = String(item.message || '').replace(/\[[^\]]+\]\[(info|success|warn|error)\]\s*/i, '')
|
||||
// 清理后端结构化前缀,时间/分类/账号由独立字段展示。
|
||||
const cleanMsg = cleanServerLogMessage(item.message)
|
||||
|
||||
logs.value.push({
|
||||
time: item.time || '',
|
||||
time: formatServerLogTime(item.time || ''),
|
||||
type,
|
||||
message: cleanMsg,
|
||||
category: item.category,
|
||||
account: item.account,
|
||||
source: 'server'
|
||||
})
|
||||
})
|
||||
|
||||
@@ -20,9 +20,10 @@ export interface Settings {
|
||||
const App = window.go.main.App
|
||||
|
||||
const defaultRetryStages: RetryStage[] = [
|
||||
{ maxElapsed: 8, interval: 130 },
|
||||
{ maxElapsed: 25, interval: 260 },
|
||||
{ maxElapsed: 75, interval: 900 }
|
||||
{ maxElapsed: 4, interval: 180 },
|
||||
{ maxElapsed: 12, interval: 450 },
|
||||
{ maxElapsed: 30, interval: 1200 },
|
||||
{ maxElapsed: 75, interval: 2500 }
|
||||
]
|
||||
|
||||
const settings = ref<Settings>({
|
||||
|
||||
Reference in New Issue
Block a user