fix: signal_bad_reason
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 1m6s
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 1m6s
This commit is contained in:
@@ -223,6 +223,8 @@ export interface DeviceRealtime {
|
|||||||
rsrq?: number
|
rsrq?: number
|
||||||
rssi?: string
|
rssi?: string
|
||||||
sinr?: number
|
sinr?: number
|
||||||
|
signal_quality?: string
|
||||||
|
signal_bad_reason?: string
|
||||||
last_online_time?: string
|
last_online_time?: string
|
||||||
last_update_time?: string
|
last_update_time?: string
|
||||||
sync_interval?: number
|
sync_interval?: number
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, onMounted } from 'vue'
|
import { ref, computed, onMounted } from 'vue'
|
||||||
import { getAssetDetail, getAssetPackages, getCurrentPackage, getAssetHistory, stopAsset, startAsset } from '@/api/assets'
|
import { getAssetDetail, getAssetPackages, getCurrentPackage, getAssetHistory, stopAsset, startAsset, getAssetRealtimeStatus } from '@/api/assets'
|
||||||
import type { AssetType, CardInfo, DeviceInfo, AssetPackage, HistoryRecord } from '@/api/assets'
|
import type { AssetType, CardInfo, DeviceInfo, AssetPackage, HistoryRecord } from '@/api/assets'
|
||||||
import { formatDataSize, formatTime } from '@/utils/format'
|
import { formatDataSize, formatTime } from '@/utils/format'
|
||||||
|
|
||||||
@@ -139,6 +139,13 @@ async function loadAssetDetail() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('准备调用 loadRealtimeStatus, assetIdentifier:', assetIdentifier.value)
|
||||||
|
|
||||||
|
// 获取实时状态 (包含信号质量和信号差的原因)
|
||||||
|
await loadRealtimeStatus()
|
||||||
|
|
||||||
|
console.log('loadRealtimeStatus 调用完成')
|
||||||
|
|
||||||
// 加载套餐列表
|
// 加载套餐列表
|
||||||
await loadPackages()
|
await loadPackages()
|
||||||
|
|
||||||
@@ -160,6 +167,35 @@ async function loadAssetDetail() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 加载实时状态
|
||||||
|
async function loadRealtimeStatus() {
|
||||||
|
try {
|
||||||
|
const realtimeData = await getAssetRealtimeStatus(assetIdentifier.value)
|
||||||
|
|
||||||
|
console.log('=== 实时状态接口返回 ===', realtimeData)
|
||||||
|
console.log('device_realtime:', realtimeData.device_realtime)
|
||||||
|
console.log('signal_quality:', realtimeData.device_realtime?.signal_quality)
|
||||||
|
console.log('signal_bad_reason:', realtimeData.device_realtime?.signal_bad_reason)
|
||||||
|
|
||||||
|
// 更新实时状态数据,包含信号质量和信号差的原因
|
||||||
|
if (realtimeData.device_realtime) {
|
||||||
|
// 使用对象展开确保响应式更新
|
||||||
|
realtimeStatus.value = {
|
||||||
|
...realtimeStatus.value,
|
||||||
|
signal_quality: realtimeData.device_realtime.signal_quality,
|
||||||
|
signal_bad_reason: realtimeData.device_realtime.signal_bad_reason,
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('=== 更新后的 realtimeStatus ===', realtimeStatus.value)
|
||||||
|
} else {
|
||||||
|
console.log('device_realtime 为空')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error: any) {
|
||||||
|
console.error('加载实时状态失败:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 加载套餐列表
|
// 加载套餐列表
|
||||||
async function loadPackages() {
|
async function loadPackages() {
|
||||||
try {
|
try {
|
||||||
@@ -380,6 +416,26 @@ function viewWallet() {
|
|||||||
/ {{ realtimeStatus?.voice_total || '-' }}
|
/ {{ realtimeStatus?.voice_total || '-' }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 信号 (仅设备类型) -->
|
||||||
|
<view v-if="assetType === 'device'" class="bg-[#f5f5f5] rounded-12px p-3">
|
||||||
|
<text class="text-12px text-[#999] block mb-1">
|
||||||
|
信号
|
||||||
|
</text>
|
||||||
|
<text class="text-16px font-700 text-[#212121] block">
|
||||||
|
{{ realtimeStatus?.signal_quality || '-' }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 信号差的原因 (仅设备类型) -->
|
||||||
|
<view v-if="assetType === 'device'" class="bg-[#f5f5f5] rounded-12px p-3">
|
||||||
|
<text class="text-12px text-[#999] block mb-1">
|
||||||
|
信号差的原因
|
||||||
|
</text>
|
||||||
|
<text class="text-16px font-700 text-[#212121] block">
|
||||||
|
{{ realtimeStatus?.signal_bad_reason || '-' }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<text class="text-11px text-[#999] block mt-3">
|
<text class="text-11px text-[#999] block mt-3">
|
||||||
|
|||||||
@@ -149,6 +149,18 @@
|
|||||||
return `${(num / 1024 / 1024 / 1024).toFixed(2)}GB`
|
return `${(num / 1024 / 1024 / 1024).toFixed(2)}GB`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isEmptyDisplayValue(value ?: string | number | null) {
|
||||||
|
return value === null || value === undefined || (typeof value === 'string' && value.trim() === '')
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDisplayValue(value ?: string | number | null) {
|
||||||
|
return isEmptyDisplayValue(value) ? '-' : String(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatBytesDisplay(bytes ?: string | number | null) {
|
||||||
|
return isEmptyDisplayValue(bytes) ? '-' : formatBytes(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
// 格式化时长(秒)
|
// 格式化时长(秒)
|
||||||
function formatDuration(seconds ?: string | number) {
|
function formatDuration(seconds ?: string | number) {
|
||||||
if (!seconds) return '0秒'
|
if (!seconds) return '0秒'
|
||||||
@@ -1103,6 +1115,18 @@
|
|||||||
<text class="text-[#666]">运行时长</text>
|
<text class="text-[#666]">运行时长</text>
|
||||||
<text class="text-[#212121]">{{ formatDuration(realtimeStatus.device_realtime.run_time) }}</text>
|
<text class="text-[#212121]">{{ formatDuration(realtimeStatus.device_realtime.run_time) }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 信号 -->
|
||||||
|
<view class="flex items-center justify-between text-11px">
|
||||||
|
<text class="text-[#666]">信号</text>
|
||||||
|
<text class="text-[#212121]">{{ getDisplayValue(realtimeStatus.device_realtime.signal_quality) }}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 信号差原因 -->
|
||||||
|
<view class="flex items-center justify-between text-11px">
|
||||||
|
<text class="text-[#666]">信号差原因</text>
|
||||||
|
<text class="text-[#212121]">{{ getDisplayValue(realtimeStatus.device_realtime.signal_bad_reason) }}</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -1111,27 +1135,29 @@
|
|||||||
<text class="text-12px text-[#666] block mb-2">流量统计</text>
|
<text class="text-12px text-[#666] block mb-2">流量统计</text>
|
||||||
<view class="space-y-1">
|
<view class="space-y-1">
|
||||||
<!-- 今日用量 -->
|
<!-- 今日用量 -->
|
||||||
<view v-if="realtimeStatus.device_realtime.daily_usage" class="flex items-center justify-between text-11px">
|
<view class="flex items-center justify-between text-11px">
|
||||||
<text class="text-[#666]">今日用量</text>
|
<text class="text-[#666]">今日用量</text>
|
||||||
<text class="text-[var(--brand-primary)] font-600">{{ formatBytes(realtimeStatus.device_realtime.daily_usage) }}</text>
|
<text class="text-[var(--brand-primary)] font-600">{{ formatBytesDisplay(realtimeStatus.device_realtime.daily_usage) }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 下载流量 -->
|
<!-- 下载流量 -->
|
||||||
<view v-if="realtimeStatus.device_realtime.dl_stats" class="flex items-center justify-between text-11px">
|
<view class="flex items-center justify-between text-11px">
|
||||||
<text class="text-[#666]">下载流量</text>
|
<text class="text-[#666]">下载流量</text>
|
||||||
<text class="text-[#212121]">{{ formatBytes(realtimeStatus.device_realtime.dl_stats) }}</text>
|
<text class="text-[#212121]">{{ formatBytesDisplay(realtimeStatus.device_realtime.dl_stats) }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 上传流量 -->
|
<!-- 上传流量 -->
|
||||||
<view v-if="realtimeStatus.device_realtime.ul_stats" class="flex items-center justify-between text-11px">
|
<view class="flex items-center justify-between text-11px">
|
||||||
<text class="text-[#666]">上传流量</text>
|
<text class="text-[#666]">上传流量</text>
|
||||||
<text class="text-[#212121]">{{ formatBytes(realtimeStatus.device_realtime.ul_stats) }}</text>
|
<text class="text-[#212121]">{{ formatBytesDisplay(realtimeStatus.device_realtime.ul_stats) }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 限速 -->
|
<!-- 限速 -->
|
||||||
<view v-if="realtimeStatus.device_realtime.limit_speed" class="flex items-center justify-between text-11px">
|
<view class="flex items-center justify-between text-11px">
|
||||||
<text class="text-[#666]">限速</text>
|
<text class="text-[#666]">限速</text>
|
||||||
<text class="text-[#212121]">{{ realtimeStatus.device_realtime.limit_speed }} Mbps</text>
|
<text class="text-[#212121]">
|
||||||
|
{{ isEmptyDisplayValue(realtimeStatus.device_realtime.limit_speed) ? '-' : `${realtimeStatus.device_realtime.limit_speed} Mbps` }}
|
||||||
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
Reference in New Issue
Block a user