This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user