Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show Page menu in huawei browser #301

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions src/store/platform-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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) => {
Expand Down
11 changes: 7 additions & 4 deletions src/utils/brand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const AllBrowserTypes: SpyClient.Browser[] = [
'wechat',
'qq',
'uni-native',
'huawei',
'unknown',
];

Expand All @@ -112,7 +113,7 @@ export const OS_CONFIG: Record<
};

export const BROWSER_CONFIG: Record<
SpyClient.Browser | 'harmony',
SpyClient.Browser,
{
logo: string;
label: string;
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -178,16 +180,17 @@ 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.]+)/,
firefox: /(?:Firefox|FxiOS)\/([\d.]+)/,
safari: /Version\/([\d.]+).*Safari/,
'uni-native': /uni-native\/([\d.]+)/,
'react-native': /react-native\/([\d.]+)/,
harmony: /API\/([\d.]+)/,
...MP_REGEXPS,
} as Record<SpyClient.Browser | 'harmony', RegExp>;
} as Record<SpyClient.Browser, RegExp>;

const OS_REGEXPS = {
windows: /(Windows NT |windows\/)([\d_.]+)/,
Expand Down