This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
<view class="device-metrics flex-row-sb mt-md">
|
<view class="device-metrics flex-row-sb mt-md">
|
||||||
<view class="metric-item flex-col-center">
|
<view class="metric-item flex-col-center">
|
||||||
<view class="caption mb-xs">信号强度</view>
|
<view class="caption mb-xs">信号强度</view>
|
||||||
<view class="metric-value">{{ getSignalText(deviceInfo) }}</view>
|
<view class="metric-value">{{ deviceInfo.signal_quality || '暂无数据' }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="metric-item flex-col-center">
|
<view class="metric-item flex-col-center">
|
||||||
<view class="caption mb-xs">设备电量</view>
|
<view class="caption mb-xs">设备电量</view>
|
||||||
@@ -36,12 +36,14 @@
|
|||||||
<view class="metric-value">{{ deviceInfo.connCnt }}/{{ deviceInfo.max_clients }}</view>
|
<view class="metric-value">{{ deviceInfo.connCnt }}/{{ deviceInfo.max_clients }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view v-if="deviceInfo.signal_bad_reason" class="signal-reason">
|
||||||
|
<text class="signal-reason-label">怀疑原因:</text>
|
||||||
|
<text class="signal-reason-text">{{ deviceInfo.signal_bad_reason }}</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { getNetworkLevelByMetrics } from '@/utils/networkSignal.js';
|
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
deviceInfo: { type: Object, default: () => ({}) },
|
deviceInfo: { type: Object, default: () => ({}) },
|
||||||
isRealName: { type: Boolean, default: false },
|
isRealName: { type: Boolean, default: false },
|
||||||
@@ -50,9 +52,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
defineEmits(['authentication']);
|
defineEmits(['authentication']);
|
||||||
|
|
||||||
const getSignalText = (deviceInfo) =>
|
|
||||||
getNetworkLevelByMetrics(deviceInfo?.rsrp, deviceInfo?.rsrq, deviceInfo?.sinr);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -84,5 +83,16 @@
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.signal-reason {
|
||||||
|
margin-top: 16rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.signal-reason-label {
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -155,10 +155,8 @@
|
|||||||
totalBytesCnt: 0,
|
totalBytesCnt: 0,
|
||||||
ssidName: '-',
|
ssidName: '-',
|
||||||
ssidPwd: '-',
|
ssidPwd: '-',
|
||||||
rssi: '-',
|
signal_quality: '暂无数据',
|
||||||
rsrp: '-',
|
signal_bad_reason: '',
|
||||||
rsrq: '-',
|
|
||||||
sinr: '-',
|
|
||||||
onlineStatus: '0',
|
onlineStatus: '0',
|
||||||
connCnt: 0,
|
connCnt: 0,
|
||||||
run_time: 0,
|
run_time: 0,
|
||||||
@@ -268,10 +266,8 @@
|
|||||||
deviceInfo.connCnt = rt.client_number ?? 0;
|
deviceInfo.connCnt = rt.client_number ?? 0;
|
||||||
deviceInfo.max_clients = rt.max_clients ?? 1;
|
deviceInfo.max_clients = rt.max_clients ?? 1;
|
||||||
deviceInfo.run_time = rt.run_time || 0;
|
deviceInfo.run_time = rt.run_time || 0;
|
||||||
deviceInfo.rssi = rt.rssi ?? '-';
|
deviceInfo.signal_quality = rt.signal_quality || '暂无数据';
|
||||||
deviceInfo.rsrp = rt.rsrp ?? '-';
|
deviceInfo.signal_bad_reason = rt.signal_bad_reason || '';
|
||||||
deviceInfo.rsrq = rt.rsrq ?? '-';
|
|
||||||
deviceInfo.sinr = rt.sinr ?? '-';
|
|
||||||
} else {
|
} else {
|
||||||
// 没有实时信息时设置默认值
|
// 没有实时信息时设置默认值
|
||||||
deviceInfo.onlineStatus = '0';
|
deviceInfo.onlineStatus = '0';
|
||||||
@@ -282,10 +278,8 @@
|
|||||||
deviceInfo.connCnt = 0;
|
deviceInfo.connCnt = 0;
|
||||||
deviceInfo.max_clients = 1;
|
deviceInfo.max_clients = 1;
|
||||||
deviceInfo.run_time = 0;
|
deviceInfo.run_time = 0;
|
||||||
deviceInfo.rssi = '-';
|
deviceInfo.signal_quality = '暂无数据';
|
||||||
deviceInfo.rsrp = '-';
|
deviceInfo.signal_bad_reason = '';
|
||||||
deviceInfo.rsrq = '-';
|
|
||||||
deviceInfo.sinr = '-';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 到期时间由 TrafficCard 组件获取套餐信息时一并返回
|
// 到期时间由 TrafficCard 组件获取套餐信息时一并返回
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
const isEmptyValue = (value) => value === null || value === undefined || value === '' || value === '-';
|
|
||||||
|
|
||||||
const toFiniteNumber = (value) => {
|
|
||||||
if (isEmptyValue(value)) return null;
|
|
||||||
|
|
||||||
const numericValue = Number(value);
|
|
||||||
return Number.isFinite(numericValue) ? numericValue : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
const clampScore = (value) => Math.min(Math.max(value, 0), 100);
|
|
||||||
|
|
||||||
export const getNetworkScore = (rsrp, rsrq, sinr) => {
|
|
||||||
const rsrpValue = toFiniteNumber(rsrp);
|
|
||||||
const rsrqValue = toFiniteNumber(rsrq);
|
|
||||||
const sinrValue = toFiniteNumber(sinr);
|
|
||||||
|
|
||||||
const metrics = [
|
|
||||||
{ score: rsrpValue === null ? null : clampScore((rsrpValue + 120) * 2), weight: 0.5 },
|
|
||||||
{ score: sinrValue === null ? null : clampScore(sinrValue * 5), weight: 0.3 },
|
|
||||||
{ score: rsrqValue === null ? null : clampScore((rsrqValue + 20) * 5), weight: 0.2 }
|
|
||||||
].filter(item => item.score !== null);
|
|
||||||
|
|
||||||
if (!metrics.length) return null;
|
|
||||||
|
|
||||||
const totalWeight = metrics.reduce((sum, item) => sum + item.weight, 0);
|
|
||||||
return metrics.reduce((sum, item) => sum + item.score * item.weight, 0) / totalWeight;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getNetworkLevel = (score) => {
|
|
||||||
if (score === null || score === undefined || !Number.isFinite(score)) return '-';
|
|
||||||
if (score >= 85) return '极好';
|
|
||||||
if (score >= 70) return '良好';
|
|
||||||
if (score >= 50) return '一般';
|
|
||||||
if (score >= 30) return '较差';
|
|
||||||
return '很差';
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getNetworkLevelByMetrics = (rsrp, rsrq, sinr) =>
|
|
||||||
getNetworkLevel(getNetworkScore(rsrp, rsrq, sinr));
|
|
||||||
Reference in New Issue
Block a user