feat(mobile): 重构移动端首页与个人中心

This commit is contained in:
yml
2026-11-12 22:48:18 +08:00
parent a4441bba9a
commit adc5a905da
11 changed files with 1902 additions and 232 deletions
+33
View File
@@ -0,0 +1,33 @@
import { useLayoutEffect } from 'react'
import { useLocation } from 'react-router-dom'
import {
getMobilePath,
isMobileDevice,
prefersDesktopSite,
setDesktopPreference,
} from '@/shared/utils/mobileHost'
export function MobileRouteGate() {
const location = useLocation()
useLayoutEffect(() => {
const params = new URLSearchParams(location.search)
if (params.get('desktop') === '1') {
setDesktopPreference(true)
params.delete('desktop')
const search = params.toString()
window.location.replace(`${location.pathname}${search ? `?${search}` : ''}${location.hash}`)
return
}
if (prefersDesktopSite() || !isMobileDevice()) return
const mobilePath = getMobilePath(location.pathname)
if (mobilePath === location.pathname) return
window.location.replace(`${mobilePath}${location.search}${location.hash}`)
}, [location.hash, location.pathname, location.search])
return null
}