From c7b54efc0653f08ec6ac83a95e9ea130d117206c Mon Sep 17 00:00:00 2001 From: Blucas <15555602203@163.com> Date: Mon, 6 Jan 2025 11:25:44 +0800 Subject: [PATCH] fix: show Page menu in huawei browser --- src/store/platform-config.ts | 15 +++------------ src/utils/brand.ts | 11 +++++++---- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/store/platform-config.ts b/src/store/platform-config.ts index 3f569779..40387452 100644 --- a/src/store/platform-config.ts +++ b/src/store/platform-config.ts @@ -4,21 +4,12 @@ import { ReactComponent as DatabaseSvg } from '@/assets/image/database.svg'; import { SpyClient, SpyStorage } from '@huolala-tech/page-spy-types'; import { FunctionComponent } from 'react'; import { useSocketMessageStore } from './socket-message'; +import { AllBrowserTypes } from '@/utils/brand'; export type StorageType = SpyStorage.DataType | 'AppStorage'; export const isBrowser = (browser: SpyClient.Browser) => { - return [ - 'wechat', - 'qq', - 'uc', - 'baidu', - 'edge', - 'chrome', - 'firefox', - 'safari', - 'unknown', - ].includes(browser); + return AllBrowserTypes.includes(browser); }; export const isMiniProgram = (browser: SpyClient.Browser) => { @@ -30,7 +21,7 @@ export const isUniAppNative = (browser: SpyClient.Browser) => { }; export const isHarmonyApp = (browser: SpyClient.Browser) => { - return browser.startsWith('harmony'); + return browser === 'harmony'; }; export const isReactNative = (browser: SpyClient.Browser) => { diff --git a/src/utils/brand.ts b/src/utils/brand.ts index 9114c1ef..dd78f731 100644 --- a/src/utils/brand.ts +++ b/src/utils/brand.ts @@ -91,6 +91,7 @@ export const AllBrowserTypes: SpyClient.Browser[] = [ 'wechat', 'qq', 'uni-native', + 'huawei', 'unknown', ]; @@ -112,7 +113,7 @@ export const OS_CONFIG: Record< }; export const BROWSER_CONFIG: Record< - SpyClient.Browser | 'harmony', + SpyClient.Browser, { logo: string; label: string; @@ -145,8 +146,9 @@ export const BROWSER_CONFIG: Record< 'mp-xhs': { logo: mpXhsSvg, label: t('common.mpxhs') }, 'mp-uni': { logo: uniSvg, label: 'Uni APP' }, 'uni-native': { logo: uniSvg, label: 'Uni APP' }, - harmony: { logo: huaweiSvg, label: 'Huawei' }, + huawei: { logo: huaweiSvg, label: 'Huawei' }, 'react-native': { logo: reactSvg, label: 'React Native' }, + harmony: { logo: harmonySvg, label: 'Harmony APP' }, }; export const getOSName = (os: string) => { @@ -178,7 +180,7 @@ const BROWSER_REGEXPS = { wechat: /MicroMessenger\/([\d.]+)/, qq: /(?:QQBrowser|MQQBrowser|QQ)\/([\d.]+)/, uc: /(?:UCBrowser|UCBS)\/([\d.]+)/, - harmony: /(?:HuaweiBrowser)\/([\d.]+)/, + huawei: /(?:HuaweiBrowser)\/([\d.]+)/, baidu: /(?:BIDUBrowser|baiduboxapp)[/]?([\d.]*)/, edge: /Edg(?:e|A|iOS)?\/([\d.]+)/, chrome: /(?:Chrome|CriOS)\/([\d.]+)/, @@ -186,8 +188,9 @@ const BROWSER_REGEXPS = { safari: /Version\/([\d.]+).*Safari/, 'uni-native': /uni-native\/([\d.]+)/, 'react-native': /react-native\/([\d.]+)/, + harmony: /API\/([\d.]+)/, ...MP_REGEXPS, -} as Record; +} as Record; const OS_REGEXPS = { windows: /(Windows NT |windows\/)([\d_.]+)/,