diff --git a/src/types.ts b/src/types.ts index 28e767de..c1bdecbc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -170,4 +170,5 @@ export const enum BrowserKind { Safari = 'safari', IE = 'internet_explorer', WeChat = 'wechat', + Edge = 'edge', } diff --git a/src/utils/browser.ts b/src/utils/browser.ts index aefb336d..375358b5 100644 --- a/src/utils/browser.ts +++ b/src/utils/browser.ts @@ -52,7 +52,13 @@ export function getBrowserEngineKind(): BrowserEngineKind { export function getBrowserKind(): BrowserKind { const userAgent = navigator.userAgent?.toLowerCase() - if (strIncludes(userAgent, 'wechat')) { + if (strIncludes(userAgent, 'edg/')) { + return BrowserKind.Edge + } else if (strIncludes(userAgent, 'safari')) { + return BrowserKind.Safari + } else if (strIncludes(userAgent, 'trident') || strIncludes(userAgent, 'msie')) { + return BrowserKind.IE + } else if (strIncludes(userAgent, 'wechat')) { return BrowserKind.WeChat } else if (strIncludes(userAgent, 'firefox')) { return BrowserKind.Firefox @@ -60,10 +66,6 @@ export function getBrowserKind(): BrowserKind { return BrowserKind.Opera } else if (strIncludes(userAgent, 'chrome')) { return BrowserKind.Chrome - } else if (strIncludes(userAgent, 'safari')) { - return BrowserKind.Safari - } else if (strIncludes(userAgent, 'trident') || strIncludes(userAgent, 'msie')) { - return BrowserKind.IE } else { return BrowserKind.Unknown }