feat:一键刷新与自动刷新覆盖绑定错误/使用超时/绑定超时
This commit is contained in:
@@ -785,7 +785,7 @@ export interface RockTokenRestoreResult {
|
||||
skipped_items: RockTokenRestoreSkipItem[];
|
||||
}
|
||||
|
||||
export interface RockMismatchRefreshResult {
|
||||
export interface RockStaleRefreshResult {
|
||||
scanned: number;
|
||||
fixed: number;
|
||||
failed: number;
|
||||
@@ -867,10 +867,10 @@ export const rockApi = {
|
||||
page_size: number;
|
||||
},
|
||||
),
|
||||
refreshMismatchTokens: () =>
|
||||
refreshStaleTokens: () =>
|
||||
request
|
||||
.post("/platform/rock/token-batches/refresh-mismatch")
|
||||
.then((r) => r.data.data as RockMismatchRefreshResult),
|
||||
.post("/platform/rock/token-batches/refresh-stale")
|
||||
.then((r) => r.data.data as RockStaleRefreshResult),
|
||||
previewTokenDelete: (params?: { status?: string; search?: string }) =>
|
||||
request
|
||||
.get("/platform/rock/token-batches/preview", { params })
|
||||
|
||||
@@ -38,7 +38,7 @@ export default function PlatformRock() {
|
||||
const [togglingAutoPurchase, setTogglingAutoPurchase] = useState(false)
|
||||
const [autoRefreshMismatchEnabled, setAutoRefreshMismatchEnabled] = useState(false)
|
||||
const [togglingAutoRefresh, setTogglingAutoRefresh] = useState(false)
|
||||
const [refreshingMismatch, setRefreshingMismatch] = useState(false)
|
||||
const [refreshingStale, setRefreshingStale] = useState(false)
|
||||
const [purchasing, setPurchasing] = useState(false)
|
||||
const [purchaseModalOpen, setPurchaseModalOpen] = useState(false)
|
||||
const [purchaseCount, setPurchaseCount] = useState(50)
|
||||
@@ -177,13 +177,13 @@ export default function PlatformRock() {
|
||||
}
|
||||
}
|
||||
|
||||
// 一键刷新全部绑定错误的 Token:同步执行,单次最多 20 条
|
||||
const handleRefreshMismatch = async () => {
|
||||
setRefreshingMismatch(true)
|
||||
// 一键刷新异常 Token:绑定错误 + 使用超时 + 绑定超时,同步执行,单次最多 20 条
|
||||
const handleRefreshStale = async () => {
|
||||
setRefreshingStale(true)
|
||||
try {
|
||||
const res = await rockApi.refreshMismatchTokens()
|
||||
const res = await rockApi.refreshStaleTokens()
|
||||
if (res.scanned === 0) {
|
||||
message.info('暂无可刷新的绑定错误 Token(10 分钟内已刷新过的会自动跳过)')
|
||||
message.info('暂无可刷新的异常 Token(10 分钟内已刷新过的会自动跳过)')
|
||||
} else if (res.failed > 0 || res.remaining > 0) {
|
||||
message.warning(res.message)
|
||||
} else {
|
||||
@@ -192,13 +192,13 @@ export default function PlatformRock() {
|
||||
loadData()
|
||||
loadTokens()
|
||||
} catch (e) {
|
||||
message.error('刷新绑定错误失败: ' + (e instanceof Error ? e.message : '未知错误'))
|
||||
message.error('一键刷新失败: ' + (e instanceof Error ? e.message : '未知错误'))
|
||||
} finally {
|
||||
setRefreshingMismatch(false)
|
||||
setRefreshingStale(false)
|
||||
}
|
||||
}
|
||||
|
||||
// 自动刷新绑定错误开关:切换即保存,后端每 5 分钟巡检一次
|
||||
// 自动刷新开关:与「一键刷新」同规则(绑定错误 + 使用超时 + 绑定超时),切换即保存
|
||||
const handleToggleAutoRefreshMismatch = async (checked: boolean) => {
|
||||
const previous = autoRefreshMismatchEnabled
|
||||
setAutoRefreshMismatchEnabled(checked)
|
||||
@@ -208,7 +208,7 @@ export default function PlatformRock() {
|
||||
setConfig(updated)
|
||||
setAutoRefreshMismatchEnabled(updated.auto_refresh_mismatch_enabled)
|
||||
message.success(
|
||||
checked ? '自动刷新已开启:每 5 分钟最多刷新 20 条绑定错误 Token' : '自动刷新已关闭',
|
||||
checked ? '自动刷新已开启:每 5 分钟按同样规则刷新最多 20 条异常 Token' : '自动刷新已关闭',
|
||||
)
|
||||
} catch (e) {
|
||||
setAutoRefreshMismatchEnabled(previous)
|
||||
@@ -476,12 +476,12 @@ export default function PlatformRock() {
|
||||
totalTokens={totalTokens}
|
||||
loadingTokens={loadingTokens}
|
||||
autoRefreshMismatchEnabled={autoRefreshMismatchEnabled}
|
||||
refreshingMismatch={refreshingMismatch}
|
||||
refreshingStale={refreshingStale}
|
||||
togglingAutoRefresh={togglingAutoRefresh}
|
||||
onSearchKeywordChange={setSearchKeyword}
|
||||
onFilterStatusChange={handleFilterStatusChange}
|
||||
onRefresh={loadTokens}
|
||||
onRefreshMismatch={handleRefreshMismatch}
|
||||
onRefreshStale={handleRefreshStale}
|
||||
onToggleAutoRefreshMismatch={handleToggleAutoRefreshMismatch}
|
||||
/>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Badge, Button, Card, Input, Radio, Space, Switch, Tooltip, Typography } from 'antd'
|
||||
import { ReloadOutlined, SearchOutlined, SyncOutlined } from '@ant-design/icons'
|
||||
import { ReloadOutlined, QuestionCircleOutlined, SearchOutlined, SyncOutlined } from '@ant-design/icons'
|
||||
import type { RockStats } from '../../api'
|
||||
|
||||
const { Text } = Typography
|
||||
@@ -11,12 +11,12 @@ export interface RockTokenFilterBarProps {
|
||||
totalTokens: number
|
||||
loadingTokens: boolean
|
||||
autoRefreshMismatchEnabled: boolean
|
||||
refreshingMismatch: boolean
|
||||
refreshingStale: boolean
|
||||
togglingAutoRefresh: boolean
|
||||
onSearchKeywordChange: (value: string) => void
|
||||
onFilterStatusChange: (value: string) => void
|
||||
onRefresh: () => void
|
||||
onRefreshMismatch: () => void
|
||||
onRefreshStale: () => void
|
||||
onToggleAutoRefreshMismatch: (checked: boolean) => void
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ export function RockTokenFilterBar({
|
||||
totalTokens,
|
||||
loadingTokens,
|
||||
autoRefreshMismatchEnabled,
|
||||
refreshingMismatch,
|
||||
refreshingStale,
|
||||
togglingAutoRefresh,
|
||||
onSearchKeywordChange,
|
||||
onFilterStatusChange,
|
||||
onRefresh,
|
||||
onRefreshMismatch,
|
||||
onRefreshStale,
|
||||
onToggleAutoRefreshMismatch,
|
||||
}: RockTokenFilterBarProps) {
|
||||
return (
|
||||
@@ -109,15 +109,24 @@ export function RockTokenFilterBar({
|
||||
<Button icon={<ReloadOutlined />} onClick={onRefresh} loading={loadingTokens}>
|
||||
刷新
|
||||
</Button>
|
||||
<Tooltip title="立即刷新全部绑定错误 Token(单次最多 20 条,约 30 秒)">
|
||||
<Button
|
||||
icon={<SyncOutlined />}
|
||||
onClick={onRefreshMismatch}
|
||||
loading={refreshingMismatch}
|
||||
>
|
||||
一键刷新全部绑定错误
|
||||
<Space size={4} style={{ whiteSpace: 'nowrap' }}>
|
||||
<Button icon={<SyncOutlined />} onClick={onRefreshStale} loading={refreshingStale}>
|
||||
一键刷新
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Tooltip
|
||||
title={
|
||||
<div style={{ fontSize: 12, lineHeight: 1.7 }}>
|
||||
同时刷新三类异常 Token:绑定错误、使用超时、绑定超时。
|
||||
<br />
|
||||
单次最多 20 条,逐条间隔 1.5 秒,同一 Token 10 分钟内不重复刷新。
|
||||
<br />
|
||||
「启用自动刷新」每 5 分钟按同样规则自动执行。
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<QuestionCircleOutlined style={{ color: '#94a3b8', fontSize: 15, cursor: 'help' }} />
|
||||
</Tooltip>
|
||||
</Space>
|
||||
<Space size={6} style={{ whiteSpace: 'nowrap' }}>
|
||||
<Switch
|
||||
size="small"
|
||||
|
||||
Reference in New Issue
Block a user