From 83c27e542736b02c5e279c9e06215f5b64b51590 Mon Sep 17 00:00:00 2001
From: sexygoat <1538832180@qq.com>
Date: Thu, 30 Apr 2026 16:35:44 +0800
Subject: [PATCH] fix: singer
---
components/DeviceStatusCard.vue | 22 ++++++++++++++-----
pages/index/index.vue | 18 +++++----------
utils/networkSignal.js | 39 ---------------------------------
3 files changed, 22 insertions(+), 57 deletions(-)
delete mode 100644 utils/networkSignal.js
diff --git a/components/DeviceStatusCard.vue b/components/DeviceStatusCard.vue
index 07fd8ee..32408cb 100644
--- a/components/DeviceStatusCard.vue
+++ b/components/DeviceStatusCard.vue
@@ -25,7 +25,7 @@
信号强度
- {{ getSignalText(deviceInfo) }}
+ {{ deviceInfo.signal_quality || '暂无数据' }}
设备电量
@@ -36,12 +36,14 @@
{{ deviceInfo.connCnt }}/{{ deviceInfo.max_clients }}
+
+ 怀疑原因:
+ {{ deviceInfo.signal_bad_reason }}
+
diff --git a/pages/index/index.vue b/pages/index/index.vue
index f0dee05..85e7253 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -155,10 +155,8 @@
totalBytesCnt: 0,
ssidName: '-',
ssidPwd: '-',
- rssi: '-',
- rsrp: '-',
- rsrq: '-',
- sinr: '-',
+ signal_quality: '暂无数据',
+ signal_bad_reason: '',
onlineStatus: '0',
connCnt: 0,
run_time: 0,
@@ -268,10 +266,8 @@
deviceInfo.connCnt = rt.client_number ?? 0;
deviceInfo.max_clients = rt.max_clients ?? 1;
deviceInfo.run_time = rt.run_time || 0;
- deviceInfo.rssi = rt.rssi ?? '-';
- deviceInfo.rsrp = rt.rsrp ?? '-';
- deviceInfo.rsrq = rt.rsrq ?? '-';
- deviceInfo.sinr = rt.sinr ?? '-';
+ deviceInfo.signal_quality = rt.signal_quality || '暂无数据';
+ deviceInfo.signal_bad_reason = rt.signal_bad_reason || '';
} else {
// 没有实时信息时设置默认值
deviceInfo.onlineStatus = '0';
@@ -282,10 +278,8 @@
deviceInfo.connCnt = 0;
deviceInfo.max_clients = 1;
deviceInfo.run_time = 0;
- deviceInfo.rssi = '-';
- deviceInfo.rsrp = '-';
- deviceInfo.rsrq = '-';
- deviceInfo.sinr = '-';
+ deviceInfo.signal_quality = '暂无数据';
+ deviceInfo.signal_bad_reason = '';
}
// 到期时间由 TrafficCard 组件获取套餐信息时一并返回
diff --git a/utils/networkSignal.js b/utils/networkSignal.js
deleted file mode 100644
index 97fbf0e..0000000
--- a/utils/networkSignal.js
+++ /dev/null
@@ -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));