兑换复验增加时间展示
This commit is contained in:
@@ -240,6 +240,52 @@ func (a *App) VerifyExchange(accountName string) map[string]any {
|
||||
}
|
||||
}
|
||||
|
||||
// VerifyAllExchange 批量查询兑换记录,带间隔避免请求过快。
|
||||
func (a *App) VerifyAllExchange() map[string]any {
|
||||
accounts := a.scheduler.AccountSnapshot()
|
||||
results := make(map[string]any)
|
||||
|
||||
for i, account := range accounts {
|
||||
if i > 0 {
|
||||
// 每个请求间隔 200ms,避免太快
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
}
|
||||
|
||||
if account.Cookie == "" {
|
||||
results[account.Name] = map[string]any{
|
||||
"success": false,
|
||||
"error": "Cookie 为空",
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
records, err := a.client.ExchangeList(account.Cookie)
|
||||
if err != nil {
|
||||
results[account.Name] = map[string]any{
|
||||
"success": false,
|
||||
"error": "查询失败: " + err.Error(),
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// 过滤当前活动的记录
|
||||
var matched []client.ExchangeRecord
|
||||
for _, r := range records {
|
||||
if r.CommodityID != "" {
|
||||
matched = append(matched, r)
|
||||
}
|
||||
}
|
||||
|
||||
results[account.Name] = map[string]any{
|
||||
"success": true,
|
||||
"records": matched,
|
||||
"count": len(matched),
|
||||
}
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
// GetVersion 返回应用版本号。
|
||||
func (a *App) GetVersion() string {
|
||||
return constants.Version
|
||||
|
||||
@@ -67,6 +67,22 @@ const verifyStats = computed(() => {
|
||||
return { verified, noRecord, failed, total: entries.length }
|
||||
})
|
||||
|
||||
// 格式化时间戳
|
||||
const formatTime = (timestamp: string) => {
|
||||
if (!timestamp) return ''
|
||||
const ts = parseInt(timestamp)
|
||||
if (isNaN(ts)) return timestamp
|
||||
// 斗鱼返回的是秒级时间戳
|
||||
const date = new Date(ts * 1000)
|
||||
return date.toLocaleString('zh-CN', {
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit'
|
||||
})
|
||||
}
|
||||
|
||||
// 执行复验
|
||||
const handleVerify = async () => {
|
||||
showToast('复验开始', '正在查询斗鱼兑换记录...', 'info')
|
||||
@@ -203,6 +219,7 @@ const handleVerify = async () => {
|
||||
<template v-if="entry.success">
|
||||
<div v-if="entry.count > 0" class="verify-records">
|
||||
<div v-for="(record, idx) in entry.records" :key="idx" class="verify-record">
|
||||
<span class="record-time">{{ formatTime(record.time) }}</span>
|
||||
<span class="record-name">{{ record.commodityName }}</span>
|
||||
<span class="record-role">{{ record.showName }}</span>
|
||||
</div>
|
||||
@@ -412,6 +429,14 @@ const handleVerify = async () => {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
font-size: 12px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.record-time {
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
min-width: 100px;
|
||||
}
|
||||
|
||||
.record-name {
|
||||
@@ -421,6 +446,7 @@ const handleVerify = async () => {
|
||||
|
||||
.record-role {
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.verify-no-record {
|
||||
|
||||
@@ -172,20 +172,15 @@ export function useVerifyExchange() {
|
||||
|
||||
const verifyAll = async () => {
|
||||
verifying.value = true
|
||||
const results: Record<string, any> = {}
|
||||
|
||||
for (const account of accounts.value) {
|
||||
try {
|
||||
const result = await App.VerifyExchange(account.name)
|
||||
results[account.name] = result
|
||||
} catch (e: any) {
|
||||
results[account.name] = { success: false, error: e.message }
|
||||
}
|
||||
try {
|
||||
// 使用后端批量查询接口,自带间隔
|
||||
const results = await App.VerifyAllExchange()
|
||||
verifyResults.value = results || {}
|
||||
} catch (e: any) {
|
||||
console.error('批量复验失败:', e)
|
||||
} finally {
|
||||
verifying.value = false
|
||||
}
|
||||
|
||||
verifyResults.value = results
|
||||
verifying.value = false
|
||||
return results
|
||||
}
|
||||
|
||||
const clearResults = () => {
|
||||
|
||||
Vendored
+1
@@ -26,6 +26,7 @@ interface Window {
|
||||
GetSettings: () => Promise<any>
|
||||
SaveSettings: (cfg: any) => Promise<any>
|
||||
VerifyExchange: (accountName: string) => Promise<any>
|
||||
VerifyAllExchange: () => Promise<any>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user