From 8f7fc19477e699a28db372dfc213207d5d40d69c Mon Sep 17 00:00:00 2001 From: sky Date: Sat, 7 Dec 2024 21:41:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20simpleadmin/www/index.html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simpleadmin/www/index.html | 41 ++++++++++++-------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/simpleadmin/www/index.html b/simpleadmin/www/index.html index 8294cdf..aec514f 100644 --- a/simpleadmin/www/index.html +++ b/simpleadmin/www/index.html @@ -654,7 +654,7 @@ this.atcmd = 'AT+QTEMP;+QUIMSLOT?;+QSPN;+CGCONTRDP=1;+QMAP="WWANIP";+QENG="servingcell";+QCAINFO;+QSIMSTAT?;+CSQ;+QGDNRCNT?;+QGDCNT?'; - // 定义运营商映射表 | Define operator mapping table + // ---------- 运营商名称处理 | Operator Information Processing ---------- const operatorMap = { // 中国大陆 (460) | Mainland China (460) "46000": "中国移动 (CMCC)", @@ -832,45 +832,30 @@ this.activeSim = "无SIM卡"; } - // --- Network Provider --- - // 获取 PLMN 码 | Get PLMN code - const plmn = lines + // ---------- 运营商信息处理 | Operator Information Processing ---------- + const parts = lines .find((line) => line.includes("+QSPN:")) - .split(",")[4] - .replace(/"/g, "") - .trim(); + .split(","); - console.log("PLMN:", plmn); - console.log("Mapped operator:", operatorMap[plmn]); - - const network_provider = lines - .find((line) => line.includes("+QSPN:")) - .split(",")[0] - .replace("+QSPN: ", "") - .replace(/"/g, "") - .trim(); + // 获取 PLMN 码和运营商名称 | Get PLMN code and operator name + const plmn = parts[4]?.replace(/"/g, "").trim(); + const network_provider = parts[0]?.replace("+QSPN: ", "").replace(/"/g, "").trim(); + // 按优先级处理运营商名称 | Process operator name by priority if (operatorMap[plmn]) { + // 1. 优先使用预定义的运营商映射 | First priority: use predefined operator mapping this.networkProvider = operatorMap[plmn]; } else if (network_provider.match(/^[0-9A-Fa-f]+$/) != null) { - // 处理16进制编码的运营商名称 - // Process operator names encoded in hexadecimal + // 2. 处理16进制编码的运营商名称 | Second priority: decode hex-encoded operator name try { const hexString = network_provider.replace(/^0x/, ''); const bytes = new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16))); - const decoder = new TextDecoder('utf-8'); - this.networkProvider = decoder.decode(bytes); - } catch (e) { - console.log("Error decoding hex operator name:", e); + this.networkProvider = new TextDecoder('utf-8').decode(bytes); + } catch { this.networkProvider = network_provider; } - } else if (network_provider.match(/^[0-9]+$/) != null) { - this.networkProvider = lines - .find((line) => line.includes("+QSPN:")) - .split(",")[2] - .replace(/"/g, "") - .trim(); } else { + // 3. 使用运营商提供的原始名称 | Third priority: use original operator name this.networkProvider = network_provider; }