From 09200ad33909d48c31122b88825999e9b4245cbd Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sat, 25 Nov 2023 17:26:14 +0800 Subject: [PATCH] feat: add device helper for mobile in api --- client/web/src/plugin/common/index.ts | 1 + client/web/src/utils/device-helper.ts | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 client/web/src/utils/device-helper.ts diff --git a/client/web/src/plugin/common/index.ts b/client/web/src/plugin/common/index.ts index 00c5493c..8bfec09c 100644 --- a/client/web/src/plugin/common/index.ts +++ b/client/web/src/plugin/common/index.ts @@ -21,6 +21,7 @@ export { } from '@/components/Modal'; export { Loadable } from '@/components/Loadable'; export { useIsMobile } from '@/hooks/useIsMobile'; +export { isMobile } from '@/utils/device-helper'; export { getGlobalState, useGlobalSocketEvent, diff --git a/client/web/src/utils/device-helper.ts b/client/web/src/utils/device-helper.ts new file mode 100644 index 00000000..ab5bd6a9 --- /dev/null +++ b/client/web/src/utils/device-helper.ts @@ -0,0 +1,3 @@ +export function isMobile(): boolean { + return window.document.body.clientWidth < 768; +}