fix: 手动触发
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 4m15s

This commit is contained in:
sexygoat
2026-04-28 11:14:13 +08:00
parent b88f2d185e
commit fb10b72760
9 changed files with 462 additions and 205 deletions

View File

@@ -33,7 +33,7 @@
<!-- 操作按钮组 -->
<div v-if="hasCardInfo" class="operation-button-group">
<ElButton @click="handleRefresh" type="primary" :icon="Refresh"> 刷新 </ElButton>
<ElButton @click="handleRefresh" type="primary" :icon="Refresh" :disabled="refreshDisabled"> 刷新 </ElButton>
</div>
</div>
</ElCard>
@@ -54,10 +54,12 @@
// Props
interface Props {
hasCardInfo?: boolean
refreshDisabled?: boolean
}
withDefaults(defineProps<Props>(), {
hasCardInfo: false
hasCardInfo: false,
refreshDisabled: false
})
// Emits

View File

@@ -53,6 +53,9 @@
<ElDescriptionsItem label="本月已用流量">{{
formatDataSize(cardInfo?.current_month_usage_mb || 0)
}}</ElDescriptionsItem>
<ElDescriptionsItem label="运营商周期月内已用流量">{{
formatDataSize(cardInfo?.last_gateway_reading_mb || 0)
}}</ElDescriptionsItem>
<ElDescriptionsItem label="实名时间">{{
cardInfo?.real_name_at ? formatDateTime(cardInfo.real_name_at) : '-'
}}</ElDescriptionsItem>
@@ -480,6 +483,7 @@
real_name_status?: number
network_status?: number
current_month_usage_mb?: number
last_gateway_reading_mb?: number
device_type?: string
device_name?: string
device_model?: string

View File

@@ -4,7 +4,9 @@
<div class="card-header">
<span>套餐列表</span>
<div class="card-header-right">
<ElButton type="primary" @click="handleShowRecharge">套餐充值</ElButton>
<ElButton type="primary" :disabled="props.boundDeviceId" @click="handleShowRecharge"
>套餐充值</ElButton
>
</div>
</div>
</template>

View File

@@ -276,6 +276,9 @@ export function useAssetInfo() {
if (data.current_month_usage_mb !== undefined) {
cardInfo.value.current_month_usage_mb = data.current_month_usage_mb
}
if (data.last_gateway_reading_mb !== undefined) {
cardInfo.value.last_gateway_reading_mb = data.last_gateway_reading_mb
}
} else if (assetType === 'device') {
// 设备的实时状态
if (data.device_protect_status !== undefined) {
@@ -353,8 +356,9 @@ export function useAssetInfo() {
* 刷新资产数据(调用refresh接口后重新加载)
* @param identifier - 资产标识符
* @param assetType - 资产类型(card/device)
* @returns true if refresh was successful, false if rate limited (429)
*/
const refreshAsset = async (identifier: string, assetType: string) => {
const refreshAsset = async (identifier: string, assetType: string): Promise<boolean> => {
try {
await AssetService.refreshAsset(identifier)
ElMessage.success('刷新成功')
@@ -363,8 +367,15 @@ export function useAssetInfo() {
if (identifier) {
await loadRealtimeStatus(identifier, assetType)
}
return true
} catch (error: any) {
console.log(error)
// Check if it's a 429 rate limit error
if (error?.response?.status === 429) {
ElMessage.warning('操作过于频繁请30秒后再试')
return false
}
return false
}
}

View File

@@ -4,6 +4,7 @@
<AssetSearchCard
ref="assetSearchCardRef"
:has-card-info="!!cardInfo"
:refresh-disabled="refreshDisabled"
@search="handleSearch"
@refresh="handleRefresh"
/>
@@ -266,6 +267,9 @@
await updatePollingStatus(val)
})
// ========== 刷新按钮状态 ==========
const refreshDisabled = ref(false)
// ========== 事件处理 ==========
/**
@@ -301,7 +305,14 @@
*/
const handleRefresh = async () => {
if (!cardInfo.value) return
await refreshAsset(cardInfo.value.identifier, cardInfo.value.asset_type)
const success = await refreshAsset(cardInfo.value.identifier, cardInfo.value.asset_type)
if (!success) {
// 如果刷新失败429错误禁用刷新按钮30秒
refreshDisabled.value = true
setTimeout(() => {
refreshDisabled.value = false
}, 30000)
}
}
/**