revert: some browsers may report wrong pixel density, closes #1305 (#1306)

This reverts commit 6e0cc38aa7ca726e251c16e453922fcd637cee49.
This commit is contained in:
Huang Xin
2025-06-02 12:19:13 +08:00
committed by GitHub
parent dbc4651141
commit 87d610bb62
@@ -1,17 +1,11 @@
import { getOSPlatform } from '@/utils/misc';
import { useMediaQuery } from 'react-responsive';
// use desktop size as base size
export const useResponsiveSize = (baseSize: number) => {
const isPhone = useMediaQuery({ maxWidth: 480 });
const isTablet = useMediaQuery({ minWidth: 481, maxWidth: 1024 });
if (typeof window === 'undefined') {
return baseSize;
}
const pixelRatio = window.devicePixelRatio || 2.4;
const isMobile = ['android', 'ios'].includes(getOSPlatform());
if (isPhone && isMobile) return baseSize * (pixelRatio / 3) * 1.25;
if (isTablet && isMobile) return baseSize * (pixelRatio / 3) * 1.25;
if (isPhone) return baseSize * 1.25;
if (isTablet) return baseSize * 1.25;
return baseSize;
};