From 9b6c978217c02e8d0456f55238a689612cee5a1a Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 15 Apr 2024 15:34:23 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20pad=E8=87=AA=E5=8A=A8=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E4=B8=BApc=E7=AB=AF=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core-frontend/src/utils/utils.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/core-frontend/src/utils/utils.ts b/core/core-frontend/src/utils/utils.ts index d19c79b9ed..644b101501 100644 --- a/core/core-frontend/src/utils/utils.ts +++ b/core/core-frontend/src/utils/utils.ts @@ -88,10 +88,18 @@ export const isPlatformClient = () => { } export function isMobile() { - return navigator.userAgent.match( - /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i + return ( + navigator.userAgent.match( + /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i + ) && !isTablet() ) } + +export function isTablet() { + const userAgent = navigator.userAgent + const tabletRegex = /iPad|Silk|Galaxy Tab|PlayBook|BlackBerry|(tablet|ipad|playbook)/i + return tabletRegex.test(userAgent) +} export function cutTargetTree(tree: BusiTreeNode[], targetId: string | number) { tree.forEach((node, index) => { if (node.id === targetId) {