feat: 则跟你讲唉设备状态

This commit is contained in:
Max 2026-03-20 09:58:52 +08:00
parent fb84e6f4fe
commit 8ac3a222c1
1 changed files with 78 additions and 0 deletions

View File

@ -221,6 +221,13 @@
<div class="status-version" id="statusVersion"></div> <div class="status-version" id="statusVersion"></div>
</div> </div>
<!-- ══════════ 0. 设备与内核信息 ══════════ -->
<div class="section-title">0. 设备与内核信息</div>
<div class="card" id="deviceInfoCard">
<div class="card-label">WebView / 设备环境(自动检测)</div>
<div id="deviceInfoContent" style="font-size:12px; line-height:1.8; color:var(--text);"></div>
</div>
<!-- ══════════ 1. 环境检测 ══════════ --> <!-- ══════════ 1. 环境检测 ══════════ -->
<div class="section-title">1. 环境检测</div> <div class="section-title">1. 环境检测</div>
<div class="card"> <div class="card">
@ -751,6 +758,77 @@ function handleFileInput(input, previewId) {
// ═══════════════════════════════════════ // ═══════════════════════════════════════
log('info', 'System', '测试页已加载,等待 AppShell 桥接注入…'); log('info', 'System', '测试页已加载,等待 AppShell 桥接注入…');
// ═══════════════════════════════════════
// 0. 设备与内核信息(自动填充)
// ═══════════════════════════════════════
(function populateDeviceInfo() {
const ua = navigator.userAgent;
// 解析 Chrome/WebView 版本
const chromeMatch = ua.match(/Chrome\/([\d.]+)/);
const chromeVersion = chromeMatch ? chromeMatch[1] : null;
const chromeMajor = chromeVersion ? chromeVersion.split('.')[0] : null;
// 解析 Android 版本
const androidMatch = ua.match(/Android\s+([\d.]+)/);
const androidVersion = androidMatch ? androidMatch[1] : null;
// 解析设备型号 (粗略: Android 后括号内的末尾部分)
const buildMatch = ua.match(/;\s*([^;)]+)\s+Build\//);
const deviceModel = buildMatch ? buildMatch[1].trim() : null;
// WebView 标识
const isWebView = /; wv\)/.test(ua) || /WebView/.test(ua);
const screen = window.screen;
const dpr = window.devicePixelRatio || 1;
const rows = [
['🌐 WebView 内核', chromeVersion ? `Chrome/${chromeVersion}` : '未识别'],
['📦 Chrome 主版本', chromeMajor || '—'],
['🤖 Android 版本', androidVersion || '—'],
['📱 设备型号', deviceModel || '—'],
['🏷 WebView 标识', isWebView ? '✅ 内嵌 WebView (wv)' : '❌ 非 WebView'],
['📐 屏幕分辨率', `${screen.width} × ${screen.height} (实际像素 ${Math.round(screen.width * dpr)} × ${Math.round(screen.height * dpr)})`],
['🖥 Viewport', `${window.innerWidth} × ${window.innerHeight}`],
['🔍 像素密度 (DPR)', dpr.toFixed(2)],
['🌍 语言', navigator.language || '—'],
['📡 在线状态', navigator.onLine ? '✅ 在线' : '❌ 离线'],
];
// 可选: 内存信息 (仅 Chrome)
if (navigator.deviceMemory) {
rows.push(['💾 设备内存', navigator.deviceMemory + ' GB (近似值)']);
}
if (navigator.hardwareConcurrency) {
rows.push(['⚙️ CPU 核心', navigator.hardwareConcurrency + ' 核']);
}
let html = '<table style="width:100%; border-collapse:collapse;">';
rows.forEach(([label, value]) => {
html += `<tr style="border-bottom:1px solid var(--border);">`;
html += `<td style="padding:4px 8px; font-weight:600; white-space:nowrap; color:var(--muted);">${label}</td>`;
html += `<td style="padding:4px 8px;">${value}</td>`;
html += `</tr>`;
});
html += '</table>';
// 可折叠的完整 UserAgent
html += `<details style="margin-top:8px;"><summary style="cursor:pointer; font-size:11px; color:var(--info);">📋 完整 UserAgent</summary>`;
html += `<div style="margin-top:4px; padding:8px; background:#f3f4f6; border-radius:6px; font-size:11px; word-break:break-all; font-family:monospace;">${escapeHtml(ua)}</div>`;
html += `</details>`;
document.getElementById('deviceInfoContent').innerHTML = html;
log('ok', 'DeviceInfo', {
chrome: chromeVersion || 'unknown',
android: androidVersion || 'unknown',
model: deviceModel || 'unknown',
isWebView,
screen: `${screen.width}x${screen.height}@${dpr}x`,
});
})();
// 延迟检测 Bridge 状态 // 延迟检测 Bridge 状态
setTimeout(function() { setTimeout(function() {
if (window.AppShell) { if (window.AppShell) {