From 3599d413d90bc7ad5496d27246f40fbb1c036d85 Mon Sep 17 00:00:00 2001 From: speakeloudest Date: Tue, 24 Feb 2026 09:30:06 +0200 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AEua=E5=A4=84=E7=90=86=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Home/components/DownloadButton.vue | 35 +++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/pages/Home/components/DownloadButton.vue b/src/pages/Home/components/DownloadButton.vue index e72500f..d03c52f 100644 --- a/src/pages/Home/components/DownloadButton.vue +++ b/src/pages/Home/components/DownloadButton.vue @@ -72,16 +72,33 @@ const currentPlatform = ref('win') onMounted(() => { const ua = navigator.userAgent; - if (/Macintosh|Mac OS X/i.test(ua)) { - currentPlatform.value = 'mac' - } else if (/iPhone|iPad|iPod/i.test(ua)) { - currentPlatform.value = 'ios' - } else if (/Android/i.test(ua)) { - currentPlatform.value = 'android' - } else { - currentPlatform.value = 'win' + const platform = navigator.platform || ''; // 辅助判断 + + // 1. 先判断 Android (通常比较稳定) + if (/Android/i.test(ua)) { + currentPlatform.value = 'android'; } -}) + // 2. 判断 iOS 设备 (iPhone, iPod) + else if (/iPhone|iPod/i.test(ua)) { + currentPlatform.value = 'ios'; + } + // 3. 核心改进:区分 Mac 和 iPad + else if (/Macintosh|Mac OS X/i.test(ua)) { + // iPadOS 桌面模式下,支持多点触控(通常 > 1) + // 而真正的 Mac 电脑通常 maxTouchPoints 为 0 或 undefined + if (navigator.maxTouchPoints > 1) { + currentPlatform.value = 'ios'; // 归类为 iOS 端(iPad) + } else { + currentPlatform.value = 'mac'; + } + } + // 4. 其他情况默认为 Windows + else { + currentPlatform.value = 'win'; + } + + console.log('Detected Platform:', currentPlatform.value); +}); request.get('/api/v1/common/client/download', { invite_code: getAllQueryString('ic'),