我正在尝试使用导航器检测勇敢。我参考了这篇文章,https://stackoverflow.com/a/60954062/14443512
我试过这个条件,
(navigator.brave && await navigator.brave.isBrave() || false)
但我得到错误,Property 'brave' does not exist on type 'Navigator'.
我在这里缺少任何配置吗?
我的代码块,
export const errorMessage = (networkError: netError): string | undefined => {
const {statusCode, message} = networkError;
if (statusCode === undefined) {
return message;
}
if (statusCode < 400) {
return undefined;
}
switch (statusCode) {
case 401:
return 'authn error';
case 403:
if(navigator.brave && await navigator.brave.isBrave() || false)
return 'browser not supported';
else
return 'authz error';
case 500:
if (message.includes("invalid value")) {
return invalidString;
}
break;
}
if (statusCode < 500) {
return 'error';
}
return 'serverError';
};