@reactuses/core 5.0.8 → 5.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +57 -0
- package/dist/index.d.cts +55 -1
- package/dist/index.d.mts +55 -1
- package/dist/index.d.ts +55 -1
- package/dist/index.mjs +56 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3202,6 +3202,61 @@ const useClipboard = ()=>{
|
|
|
3202
3202
|
];
|
|
3203
3203
|
};
|
|
3204
3204
|
|
|
3205
|
+
const getPlatform = (userAgent)=>{
|
|
3206
|
+
if (/iPad|iPhone|iPod|ios/i.test(userAgent)) {
|
|
3207
|
+
return "ios";
|
|
3208
|
+
} else if (/android/i.test(userAgent)) {
|
|
3209
|
+
return "android";
|
|
3210
|
+
} else {
|
|
3211
|
+
return "unknown";
|
|
3212
|
+
}
|
|
3213
|
+
};
|
|
3214
|
+
const usePlatform = ({ userAgent } = {
|
|
3215
|
+
userAgent: ""
|
|
3216
|
+
})=>{
|
|
3217
|
+
const [ua, setUa] = React.useState(userAgent || "");
|
|
3218
|
+
const [platform, setPlatform] = React.useState(()=>{
|
|
3219
|
+
if (userAgent) {
|
|
3220
|
+
return getPlatform(userAgent);
|
|
3221
|
+
}
|
|
3222
|
+
return "unknown";
|
|
3223
|
+
});
|
|
3224
|
+
React.useEffect(()=>{
|
|
3225
|
+
setPlatform(getPlatform(navigator.userAgent));
|
|
3226
|
+
setUa(navigator.userAgent);
|
|
3227
|
+
}, []);
|
|
3228
|
+
const isInMiniProgram = React.useCallback(()=>{
|
|
3229
|
+
return /miniprogram/i.test(ua);
|
|
3230
|
+
}, [
|
|
3231
|
+
ua
|
|
3232
|
+
]);
|
|
3233
|
+
const isInWechat = React.useCallback(()=>{
|
|
3234
|
+
return /micromessenger/i.test(ua);
|
|
3235
|
+
}, []);
|
|
3236
|
+
const isiPhoneX = React.useCallback(()=>{
|
|
3237
|
+
return /iPhoneX/i.test(ua);
|
|
3238
|
+
}, []);
|
|
3239
|
+
return {
|
|
3240
|
+
platform,
|
|
3241
|
+
isInMiniProgram,
|
|
3242
|
+
isInWechat,
|
|
3243
|
+
isiPhoneX
|
|
3244
|
+
};
|
|
3245
|
+
};
|
|
3246
|
+
|
|
3247
|
+
const useMobileLandscape = ()=>{
|
|
3248
|
+
const [isMobileLandscape, setIsMobileLandscape] = React.useState(false);
|
|
3249
|
+
const [orientation] = useOrientation();
|
|
3250
|
+
React.useEffect(()=>{
|
|
3251
|
+
const userAgent = window.navigator.userAgent;
|
|
3252
|
+
const isMobile = /Mobi|Android|iphone/i.test(userAgent);
|
|
3253
|
+
setIsMobileLandscape(isMobile && orientation.type === "landscape-primary");
|
|
3254
|
+
}, [
|
|
3255
|
+
orientation.type
|
|
3256
|
+
]);
|
|
3257
|
+
return isMobileLandscape;
|
|
3258
|
+
};
|
|
3259
|
+
|
|
3205
3260
|
exports.defaultOptions = defaultOptions;
|
|
3206
3261
|
exports.useActiveElement = useActiveElement;
|
|
3207
3262
|
exports.useAsyncEffect = useAsyncEffect;
|
|
@@ -3249,6 +3304,7 @@ exports.useLongPress = useLongPress;
|
|
|
3249
3304
|
exports.useMeasure = useMeasure;
|
|
3250
3305
|
exports.useMediaDevices = useMediaDevices;
|
|
3251
3306
|
exports.useMediaQuery = useMediaQuery;
|
|
3307
|
+
exports.useMobileLandscape = useMobileLandscape;
|
|
3252
3308
|
exports.useMount = useMount;
|
|
3253
3309
|
exports.useMountedState = useMountedState;
|
|
3254
3310
|
exports.useMouse = useMouse;
|
|
@@ -3262,6 +3318,7 @@ exports.useOnline = useOnline;
|
|
|
3262
3318
|
exports.useOrientation = useOrientation;
|
|
3263
3319
|
exports.usePageLeave = usePageLeave;
|
|
3264
3320
|
exports.usePermission = usePermission;
|
|
3321
|
+
exports.usePlatform = usePlatform;
|
|
3265
3322
|
exports.usePreferredColorScheme = usePreferredColorScheme;
|
|
3266
3323
|
exports.usePreferredContrast = usePreferredContrast;
|
|
3267
3324
|
exports.usePreferredDark = usePreferredDark;
|
package/dist/index.d.cts
CHANGED
|
@@ -2567,6 +2567,53 @@ type UseClipboard = () => readonly [string, (txt: string) => Promise<void>];
|
|
|
2567
2567
|
|
|
2568
2568
|
declare const useClipboard: UseClipboard;
|
|
2569
2569
|
|
|
2570
|
+
type Platform = "ios" | "android" | "unknown";
|
|
2571
|
+
/**
|
|
2572
|
+
* @title UsePlatformProps
|
|
2573
|
+
*/
|
|
2574
|
+
interface UsePlatformProps {
|
|
2575
|
+
/**
|
|
2576
|
+
* @zh 服务端渲染时,需要传递 `userAgent`
|
|
2577
|
+
* @en When server rendering, you need to pass `userAgent`
|
|
2578
|
+
*/
|
|
2579
|
+
userAgent?: string;
|
|
2580
|
+
}
|
|
2581
|
+
/**
|
|
2582
|
+
* @title usePlatform
|
|
2583
|
+
* @returns 和平台相关的对象
|
|
2584
|
+
* @returns_en object that related to platform
|
|
2585
|
+
*/
|
|
2586
|
+
type UsePlatform = (props?: UsePlatformProps) => UsePlatformReturn;
|
|
2587
|
+
/**
|
|
2588
|
+
* @title UsePlatformReturn
|
|
2589
|
+
*/
|
|
2590
|
+
interface UsePlatformReturn {
|
|
2591
|
+
/**
|
|
2592
|
+
* @zh 平台
|
|
2593
|
+
* @en platform
|
|
2594
|
+
*/
|
|
2595
|
+
platform: Platform;
|
|
2596
|
+
/**
|
|
2597
|
+
* @zh 是否在小程序中
|
|
2598
|
+
* @en Whether in mini program
|
|
2599
|
+
*/
|
|
2600
|
+
isInMiniProgram: () => boolean;
|
|
2601
|
+
/**
|
|
2602
|
+
* @zh 是否在微信中
|
|
2603
|
+
* @en whether in wechat
|
|
2604
|
+
*/
|
|
2605
|
+
isInWechat: () => boolean;
|
|
2606
|
+
/**
|
|
2607
|
+
* @zh 是否是 iPhoneX
|
|
2608
|
+
* @en whether is iPhoneX
|
|
2609
|
+
*/
|
|
2610
|
+
isiPhoneX: () => boolean;
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
declare const usePlatform: UsePlatform;
|
|
2614
|
+
|
|
2615
|
+
declare const useMobileLandscape: () => boolean;
|
|
2616
|
+
|
|
2570
2617
|
/**
|
|
2571
2618
|
* @title useDocumentVisiblity
|
|
2572
2619
|
* @returns_en document visibility
|
|
@@ -2912,4 +2959,11 @@ type UseWindowsFocus = (
|
|
|
2912
2959
|
*/
|
|
2913
2960
|
defauleValue?: boolean) => boolean;
|
|
2914
2961
|
|
|
2915
|
-
|
|
2962
|
+
/**
|
|
2963
|
+
* @title useMobileLandscape
|
|
2964
|
+
* @returns 是否是移动端横屏
|
|
2965
|
+
* @returns_en whether is mobile landscape
|
|
2966
|
+
*/
|
|
2967
|
+
type UseMobileLandscape = () => boolean;
|
|
2968
|
+
|
|
2969
|
+
export { type ColorScheme, type Contrast, type DepsEqualFnType, type EventType, type INetworkInformation, type IUseNetworkState, type KeyModifier, type Platform, type UseActiveElement, type UseAsyncEffect, type UseClickOutside, type UseClipboard, type UseCookie, type UseCookieState, type UseCountDown, type UseCounter, type UseCssVar, type UseCssVarOptions, type UseCustomCompareEffect, type UseCycleList, type UseDarkMode, type UseDarkOptions, type UseDebounce, type UseDebounceFn, type UseDeepCompareEffect, type UseDocumentVisibility, type UseDoubleClick, type UseDoubleClickProps, type UseDraggable, type UseDraggableOptions, type UseDropZone, type UseElementBounding, type UseElementBoundingOptions, type UseElementBoundingReturn, type UseElementSize, type UseElementVisibility, type UseEvent, type UseEventEmitter, type UseEventEmitterDisposable, type UseEventEmitterEvent, type UseEventEmitterEventOnce, type UseEventEmitterListener, type UseEventEmitterReturn, type UseEventListener, type UseEyeDropper, type UseEyeDropperOpenOptions, type UseEyeDropperOpenReturnType, type UseFavicon, type UseFileDialog, type UseFileDialogOptions, type UseFirstMountState, type UseFocus, type UseFps, type UseFpsOptions, type UseFullScreenOptions, type UseFullscreen, type UseGeolocation, type UseHover, type UseIdle, type UseInfiniteScroll, type UseInfiniteScrollArrivedState, type UseInfiniteScrollDirection, type UseInfiniteScrollLoadMore, type UseInfiniteScrollOptions, type UseIntersectionObserver, type UseInterval, type UseIntervalOptions, type UseKeyModifier, type UseLatest, type UseLocalStorage, type UseLocalStorageOptions, type UseLocalStorageSerializer, type UseLocationSelector, type UseLongPress, type UseLongPressOptions, type UseMeasure, type UseMeasureRect, type UseMediaDeviceOptions, type UseMediaDevices, type UseMediaQuery, type UseMobileLandscape, type UseModifierOptions, type UseMount, type UseMountedState, type UseMouse, type UseMouseCursorState, type UseMousePressed, type UseMousePressedOptions, type UseMousePressedSourceType, type UseMutationObserver, type UseNetwork, type UseObjectUrl, type UseOnline, type UseOrientation, type UseOrientationLockType, type UseOrientationState, type UseOrientationType, type UsePageLeave, type UsePermission, type UsePermissionDescriptorNamePolyfill, type UsePermissionGeneralPermissionDescriptor, type UsePermissionState, type UsePlatform, type UsePlatformProps, type UsePlatformReturn, type UsePreferredColorScheme, type UsePreferredContrast, type UsePreferredDark, type UsePrevious, type UseRafFn, type UseRafState, type UseReducedMotion, type UseResizeObserver, type UseScreenSafeArea, type UseScriptTag, type UseScriptTagOptions, type UseScriptTagStatus, type UseScroll, type UseScrollArrivedState, type UseScrollDirection, type UseScrollIntoView, type UseScrollIntoViewAnimation, type UseScrollIntoViewParams, type UseScrollLock, type UseScrollOffset, type UseScrollOptions, type UseSessionStorage, type UseSessionStorageOptions, type UseSessionStorageSerializer, type UseSetState, type UseSticky, type UseStickyParams, type UseSupported, type UseTextDirection, type UseTextDirectionOptions, type UseTextDirectionValue, type UseTextSelection, type UseThrottle, type UseThrottleFn, type UseTimeout, type UseTimeoutFn, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseTitle, type UseToggle, type UseUnmount, type UseUpdate, type UseWebNotification, type UseWebNotificationReturn, type UseWebNotificationShow, type UseWindowScroll, type UseWindowScrollState, type UseWindowSize, type UseWindowsFocus, defaultOptions, useActiveElement, useAsyncEffect, useClickOutside, useClipboard, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
|
package/dist/index.d.mts
CHANGED
|
@@ -2567,6 +2567,53 @@ type UseClipboard = () => readonly [string, (txt: string) => Promise<void>];
|
|
|
2567
2567
|
|
|
2568
2568
|
declare const useClipboard: UseClipboard;
|
|
2569
2569
|
|
|
2570
|
+
type Platform = "ios" | "android" | "unknown";
|
|
2571
|
+
/**
|
|
2572
|
+
* @title UsePlatformProps
|
|
2573
|
+
*/
|
|
2574
|
+
interface UsePlatformProps {
|
|
2575
|
+
/**
|
|
2576
|
+
* @zh 服务端渲染时,需要传递 `userAgent`
|
|
2577
|
+
* @en When server rendering, you need to pass `userAgent`
|
|
2578
|
+
*/
|
|
2579
|
+
userAgent?: string;
|
|
2580
|
+
}
|
|
2581
|
+
/**
|
|
2582
|
+
* @title usePlatform
|
|
2583
|
+
* @returns 和平台相关的对象
|
|
2584
|
+
* @returns_en object that related to platform
|
|
2585
|
+
*/
|
|
2586
|
+
type UsePlatform = (props?: UsePlatformProps) => UsePlatformReturn;
|
|
2587
|
+
/**
|
|
2588
|
+
* @title UsePlatformReturn
|
|
2589
|
+
*/
|
|
2590
|
+
interface UsePlatformReturn {
|
|
2591
|
+
/**
|
|
2592
|
+
* @zh 平台
|
|
2593
|
+
* @en platform
|
|
2594
|
+
*/
|
|
2595
|
+
platform: Platform;
|
|
2596
|
+
/**
|
|
2597
|
+
* @zh 是否在小程序中
|
|
2598
|
+
* @en Whether in mini program
|
|
2599
|
+
*/
|
|
2600
|
+
isInMiniProgram: () => boolean;
|
|
2601
|
+
/**
|
|
2602
|
+
* @zh 是否在微信中
|
|
2603
|
+
* @en whether in wechat
|
|
2604
|
+
*/
|
|
2605
|
+
isInWechat: () => boolean;
|
|
2606
|
+
/**
|
|
2607
|
+
* @zh 是否是 iPhoneX
|
|
2608
|
+
* @en whether is iPhoneX
|
|
2609
|
+
*/
|
|
2610
|
+
isiPhoneX: () => boolean;
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
declare const usePlatform: UsePlatform;
|
|
2614
|
+
|
|
2615
|
+
declare const useMobileLandscape: () => boolean;
|
|
2616
|
+
|
|
2570
2617
|
/**
|
|
2571
2618
|
* @title useDocumentVisiblity
|
|
2572
2619
|
* @returns_en document visibility
|
|
@@ -2912,4 +2959,11 @@ type UseWindowsFocus = (
|
|
|
2912
2959
|
*/
|
|
2913
2960
|
defauleValue?: boolean) => boolean;
|
|
2914
2961
|
|
|
2915
|
-
|
|
2962
|
+
/**
|
|
2963
|
+
* @title useMobileLandscape
|
|
2964
|
+
* @returns 是否是移动端横屏
|
|
2965
|
+
* @returns_en whether is mobile landscape
|
|
2966
|
+
*/
|
|
2967
|
+
type UseMobileLandscape = () => boolean;
|
|
2968
|
+
|
|
2969
|
+
export { type ColorScheme, type Contrast, type DepsEqualFnType, type EventType, type INetworkInformation, type IUseNetworkState, type KeyModifier, type Platform, type UseActiveElement, type UseAsyncEffect, type UseClickOutside, type UseClipboard, type UseCookie, type UseCookieState, type UseCountDown, type UseCounter, type UseCssVar, type UseCssVarOptions, type UseCustomCompareEffect, type UseCycleList, type UseDarkMode, type UseDarkOptions, type UseDebounce, type UseDebounceFn, type UseDeepCompareEffect, type UseDocumentVisibility, type UseDoubleClick, type UseDoubleClickProps, type UseDraggable, type UseDraggableOptions, type UseDropZone, type UseElementBounding, type UseElementBoundingOptions, type UseElementBoundingReturn, type UseElementSize, type UseElementVisibility, type UseEvent, type UseEventEmitter, type UseEventEmitterDisposable, type UseEventEmitterEvent, type UseEventEmitterEventOnce, type UseEventEmitterListener, type UseEventEmitterReturn, type UseEventListener, type UseEyeDropper, type UseEyeDropperOpenOptions, type UseEyeDropperOpenReturnType, type UseFavicon, type UseFileDialog, type UseFileDialogOptions, type UseFirstMountState, type UseFocus, type UseFps, type UseFpsOptions, type UseFullScreenOptions, type UseFullscreen, type UseGeolocation, type UseHover, type UseIdle, type UseInfiniteScroll, type UseInfiniteScrollArrivedState, type UseInfiniteScrollDirection, type UseInfiniteScrollLoadMore, type UseInfiniteScrollOptions, type UseIntersectionObserver, type UseInterval, type UseIntervalOptions, type UseKeyModifier, type UseLatest, type UseLocalStorage, type UseLocalStorageOptions, type UseLocalStorageSerializer, type UseLocationSelector, type UseLongPress, type UseLongPressOptions, type UseMeasure, type UseMeasureRect, type UseMediaDeviceOptions, type UseMediaDevices, type UseMediaQuery, type UseMobileLandscape, type UseModifierOptions, type UseMount, type UseMountedState, type UseMouse, type UseMouseCursorState, type UseMousePressed, type UseMousePressedOptions, type UseMousePressedSourceType, type UseMutationObserver, type UseNetwork, type UseObjectUrl, type UseOnline, type UseOrientation, type UseOrientationLockType, type UseOrientationState, type UseOrientationType, type UsePageLeave, type UsePermission, type UsePermissionDescriptorNamePolyfill, type UsePermissionGeneralPermissionDescriptor, type UsePermissionState, type UsePlatform, type UsePlatformProps, type UsePlatformReturn, type UsePreferredColorScheme, type UsePreferredContrast, type UsePreferredDark, type UsePrevious, type UseRafFn, type UseRafState, type UseReducedMotion, type UseResizeObserver, type UseScreenSafeArea, type UseScriptTag, type UseScriptTagOptions, type UseScriptTagStatus, type UseScroll, type UseScrollArrivedState, type UseScrollDirection, type UseScrollIntoView, type UseScrollIntoViewAnimation, type UseScrollIntoViewParams, type UseScrollLock, type UseScrollOffset, type UseScrollOptions, type UseSessionStorage, type UseSessionStorageOptions, type UseSessionStorageSerializer, type UseSetState, type UseSticky, type UseStickyParams, type UseSupported, type UseTextDirection, type UseTextDirectionOptions, type UseTextDirectionValue, type UseTextSelection, type UseThrottle, type UseThrottleFn, type UseTimeout, type UseTimeoutFn, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseTitle, type UseToggle, type UseUnmount, type UseUpdate, type UseWebNotification, type UseWebNotificationReturn, type UseWebNotificationShow, type UseWindowScroll, type UseWindowScrollState, type UseWindowSize, type UseWindowsFocus, defaultOptions, useActiveElement, useAsyncEffect, useClickOutside, useClipboard, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
|
package/dist/index.d.ts
CHANGED
|
@@ -2567,6 +2567,53 @@ type UseClipboard = () => readonly [string, (txt: string) => Promise<void>];
|
|
|
2567
2567
|
|
|
2568
2568
|
declare const useClipboard: UseClipboard;
|
|
2569
2569
|
|
|
2570
|
+
type Platform = "ios" | "android" | "unknown";
|
|
2571
|
+
/**
|
|
2572
|
+
* @title UsePlatformProps
|
|
2573
|
+
*/
|
|
2574
|
+
interface UsePlatformProps {
|
|
2575
|
+
/**
|
|
2576
|
+
* @zh 服务端渲染时,需要传递 `userAgent`
|
|
2577
|
+
* @en When server rendering, you need to pass `userAgent`
|
|
2578
|
+
*/
|
|
2579
|
+
userAgent?: string;
|
|
2580
|
+
}
|
|
2581
|
+
/**
|
|
2582
|
+
* @title usePlatform
|
|
2583
|
+
* @returns 和平台相关的对象
|
|
2584
|
+
* @returns_en object that related to platform
|
|
2585
|
+
*/
|
|
2586
|
+
type UsePlatform = (props?: UsePlatformProps) => UsePlatformReturn;
|
|
2587
|
+
/**
|
|
2588
|
+
* @title UsePlatformReturn
|
|
2589
|
+
*/
|
|
2590
|
+
interface UsePlatformReturn {
|
|
2591
|
+
/**
|
|
2592
|
+
* @zh 平台
|
|
2593
|
+
* @en platform
|
|
2594
|
+
*/
|
|
2595
|
+
platform: Platform;
|
|
2596
|
+
/**
|
|
2597
|
+
* @zh 是否在小程序中
|
|
2598
|
+
* @en Whether in mini program
|
|
2599
|
+
*/
|
|
2600
|
+
isInMiniProgram: () => boolean;
|
|
2601
|
+
/**
|
|
2602
|
+
* @zh 是否在微信中
|
|
2603
|
+
* @en whether in wechat
|
|
2604
|
+
*/
|
|
2605
|
+
isInWechat: () => boolean;
|
|
2606
|
+
/**
|
|
2607
|
+
* @zh 是否是 iPhoneX
|
|
2608
|
+
* @en whether is iPhoneX
|
|
2609
|
+
*/
|
|
2610
|
+
isiPhoneX: () => boolean;
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
declare const usePlatform: UsePlatform;
|
|
2614
|
+
|
|
2615
|
+
declare const useMobileLandscape: () => boolean;
|
|
2616
|
+
|
|
2570
2617
|
/**
|
|
2571
2618
|
* @title useDocumentVisiblity
|
|
2572
2619
|
* @returns_en document visibility
|
|
@@ -2912,4 +2959,11 @@ type UseWindowsFocus = (
|
|
|
2912
2959
|
*/
|
|
2913
2960
|
defauleValue?: boolean) => boolean;
|
|
2914
2961
|
|
|
2915
|
-
|
|
2962
|
+
/**
|
|
2963
|
+
* @title useMobileLandscape
|
|
2964
|
+
* @returns 是否是移动端横屏
|
|
2965
|
+
* @returns_en whether is mobile landscape
|
|
2966
|
+
*/
|
|
2967
|
+
type UseMobileLandscape = () => boolean;
|
|
2968
|
+
|
|
2969
|
+
export { type ColorScheme, type Contrast, type DepsEqualFnType, type EventType, type INetworkInformation, type IUseNetworkState, type KeyModifier, type Platform, type UseActiveElement, type UseAsyncEffect, type UseClickOutside, type UseClipboard, type UseCookie, type UseCookieState, type UseCountDown, type UseCounter, type UseCssVar, type UseCssVarOptions, type UseCustomCompareEffect, type UseCycleList, type UseDarkMode, type UseDarkOptions, type UseDebounce, type UseDebounceFn, type UseDeepCompareEffect, type UseDocumentVisibility, type UseDoubleClick, type UseDoubleClickProps, type UseDraggable, type UseDraggableOptions, type UseDropZone, type UseElementBounding, type UseElementBoundingOptions, type UseElementBoundingReturn, type UseElementSize, type UseElementVisibility, type UseEvent, type UseEventEmitter, type UseEventEmitterDisposable, type UseEventEmitterEvent, type UseEventEmitterEventOnce, type UseEventEmitterListener, type UseEventEmitterReturn, type UseEventListener, type UseEyeDropper, type UseEyeDropperOpenOptions, type UseEyeDropperOpenReturnType, type UseFavicon, type UseFileDialog, type UseFileDialogOptions, type UseFirstMountState, type UseFocus, type UseFps, type UseFpsOptions, type UseFullScreenOptions, type UseFullscreen, type UseGeolocation, type UseHover, type UseIdle, type UseInfiniteScroll, type UseInfiniteScrollArrivedState, type UseInfiniteScrollDirection, type UseInfiniteScrollLoadMore, type UseInfiniteScrollOptions, type UseIntersectionObserver, type UseInterval, type UseIntervalOptions, type UseKeyModifier, type UseLatest, type UseLocalStorage, type UseLocalStorageOptions, type UseLocalStorageSerializer, type UseLocationSelector, type UseLongPress, type UseLongPressOptions, type UseMeasure, type UseMeasureRect, type UseMediaDeviceOptions, type UseMediaDevices, type UseMediaQuery, type UseMobileLandscape, type UseModifierOptions, type UseMount, type UseMountedState, type UseMouse, type UseMouseCursorState, type UseMousePressed, type UseMousePressedOptions, type UseMousePressedSourceType, type UseMutationObserver, type UseNetwork, type UseObjectUrl, type UseOnline, type UseOrientation, type UseOrientationLockType, type UseOrientationState, type UseOrientationType, type UsePageLeave, type UsePermission, type UsePermissionDescriptorNamePolyfill, type UsePermissionGeneralPermissionDescriptor, type UsePermissionState, type UsePlatform, type UsePlatformProps, type UsePlatformReturn, type UsePreferredColorScheme, type UsePreferredContrast, type UsePreferredDark, type UsePrevious, type UseRafFn, type UseRafState, type UseReducedMotion, type UseResizeObserver, type UseScreenSafeArea, type UseScriptTag, type UseScriptTagOptions, type UseScriptTagStatus, type UseScroll, type UseScrollArrivedState, type UseScrollDirection, type UseScrollIntoView, type UseScrollIntoViewAnimation, type UseScrollIntoViewParams, type UseScrollLock, type UseScrollOffset, type UseScrollOptions, type UseSessionStorage, type UseSessionStorageOptions, type UseSessionStorageSerializer, type UseSetState, type UseSticky, type UseStickyParams, type UseSupported, type UseTextDirection, type UseTextDirectionOptions, type UseTextDirectionValue, type UseTextSelection, type UseThrottle, type UseThrottleFn, type UseTimeout, type UseTimeoutFn, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseTitle, type UseToggle, type UseUnmount, type UseUpdate, type UseWebNotification, type UseWebNotificationReturn, type UseWebNotificationShow, type UseWindowScroll, type UseWindowScrollState, type UseWindowSize, type UseWindowsFocus, defaultOptions, useActiveElement, useAsyncEffect, useClickOutside, useClipboard, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
|
package/dist/index.mjs
CHANGED
|
@@ -3195,4 +3195,59 @@ const useClipboard = ()=>{
|
|
|
3195
3195
|
];
|
|
3196
3196
|
};
|
|
3197
3197
|
|
|
3198
|
-
|
|
3198
|
+
const getPlatform = (userAgent)=>{
|
|
3199
|
+
if (/iPad|iPhone|iPod|ios/i.test(userAgent)) {
|
|
3200
|
+
return "ios";
|
|
3201
|
+
} else if (/android/i.test(userAgent)) {
|
|
3202
|
+
return "android";
|
|
3203
|
+
} else {
|
|
3204
|
+
return "unknown";
|
|
3205
|
+
}
|
|
3206
|
+
};
|
|
3207
|
+
const usePlatform = ({ userAgent } = {
|
|
3208
|
+
userAgent: ""
|
|
3209
|
+
})=>{
|
|
3210
|
+
const [ua, setUa] = useState(userAgent || "");
|
|
3211
|
+
const [platform, setPlatform] = useState(()=>{
|
|
3212
|
+
if (userAgent) {
|
|
3213
|
+
return getPlatform(userAgent);
|
|
3214
|
+
}
|
|
3215
|
+
return "unknown";
|
|
3216
|
+
});
|
|
3217
|
+
useEffect(()=>{
|
|
3218
|
+
setPlatform(getPlatform(navigator.userAgent));
|
|
3219
|
+
setUa(navigator.userAgent);
|
|
3220
|
+
}, []);
|
|
3221
|
+
const isInMiniProgram = useCallback(()=>{
|
|
3222
|
+
return /miniprogram/i.test(ua);
|
|
3223
|
+
}, [
|
|
3224
|
+
ua
|
|
3225
|
+
]);
|
|
3226
|
+
const isInWechat = useCallback(()=>{
|
|
3227
|
+
return /micromessenger/i.test(ua);
|
|
3228
|
+
}, []);
|
|
3229
|
+
const isiPhoneX = useCallback(()=>{
|
|
3230
|
+
return /iPhoneX/i.test(ua);
|
|
3231
|
+
}, []);
|
|
3232
|
+
return {
|
|
3233
|
+
platform,
|
|
3234
|
+
isInMiniProgram,
|
|
3235
|
+
isInWechat,
|
|
3236
|
+
isiPhoneX
|
|
3237
|
+
};
|
|
3238
|
+
};
|
|
3239
|
+
|
|
3240
|
+
const useMobileLandscape = ()=>{
|
|
3241
|
+
const [isMobileLandscape, setIsMobileLandscape] = useState(false);
|
|
3242
|
+
const [orientation] = useOrientation();
|
|
3243
|
+
useEffect(()=>{
|
|
3244
|
+
const userAgent = window.navigator.userAgent;
|
|
3245
|
+
const isMobile = /Mobi|Android|iphone/i.test(userAgent);
|
|
3246
|
+
setIsMobileLandscape(isMobile && orientation.type === "landscape-primary");
|
|
3247
|
+
}, [
|
|
3248
|
+
orientation.type
|
|
3249
|
+
]);
|
|
3250
|
+
return isMobileLandscape;
|
|
3251
|
+
};
|
|
3252
|
+
|
|
3253
|
+
export { defaultOptions, useActiveElement, useAsyncEffect, useClickOutside, useClipboard, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
|