复机实名校验提示适配
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 5m41s

This commit is contained in:
luo
2026-07-21 14:30:30 +08:00
parent 6febc66eca
commit 47a2d88c9d
8 changed files with 172 additions and 6 deletions

View File

@@ -11,6 +11,7 @@ import { formatRemainingTime, FrontendRateLimitError } from '@/utils/business/ap
export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Promise<void>) {
// Loading states
const enableCardLoading = ref(false)
const startFailureMessage = ref('')
const disableCardLoading = ref(false)
const manualDeactivateCardLoading = ref(false)
const rebootDeviceLoading = ref(false)
@@ -29,22 +30,33 @@ export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Pr
type: 'warning'
})
startFailureMessage.value = ''
enableCardLoading.value = true
const res = await AssetService.startAsset(cardInfo.value.iccid)
const res = await AssetService.startAsset(cardInfo.value.iccid, {
requestOptions: { errorMessageMode: 'none' }
})
if (res.code === 0) {
ElMessage.success('启用成功')
if (refreshAssetFn) {
await refreshAssetFn()
}
return true
}
startFailureMessage.value = res.msg || '复机失败,请稍后重试'
return false
} catch (error: any) {
if (error !== 'cancel') {
if (error instanceof FrontendRateLimitError) {
ElMessage.warning(`操作过于频繁,请${formatRemainingTime(error.remainingMs)}后再试`)
return
return false
}
console.error('启用失败:', error)
const backendMessage = error?.response?.data?.msg
startFailureMessage.value =
typeof backendMessage === 'string' && backendMessage.trim()
? backendMessage
: '复机失败,请稍后重试'
}
return false
} finally {
enableCardLoading.value = false
}
@@ -303,6 +315,7 @@ export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Pr
return {
// Loading states
enableCardLoading,
startFailureMessage,
disableCardLoading,
manualDeactivateCardLoading,
rebootDeviceLoading,