From 9f370bf42952d7e1f4a1abae461a8b6230ae4fb0 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 25 Aug 2025 10:37:19 +0800 Subject: [PATCH] fix: remove @tauri-apps/api/os import and use local UA/platform detection for mac class --- src/main.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index 9d59af2..b197261 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -4,16 +4,18 @@ import App from './App' import './index.css' // 导入 Tauri API(自动绑定到 window.api) import './lib/tauri-api' -import { platform as osPlatform } from '@tauri-apps/api/os' // 根据平台添加 body class,便于平台特定样式 -osPlatform().then((p) => { - if (p === 'darwin') { +try { + const ua = navigator.userAgent || '' + const plat = (navigator.platform || '').toLowerCase() + const isMac = /mac/i.test(ua) || plat.includes('mac') + if (isMac) { document.body.classList.add('is-mac') } -}).catch(() => { +} catch { // 忽略平台检测失败 -}) +} ReactDOM.createRoot(document.getElementById('root')!).render(