INNER CODE UNIT · TypeScript
isBrowser
libnyanpasu/clash-nyanpasu · frontend/platform/src/index.ts:6
export const isBrowser = () => typeof window !== 'undefined' && !isTauri()
export type WebNotificationOptions = {
title: string
body?: string
}
export async function showWebNotification({
title,
body,
}: WebNotificationOptions): Promise<void> {
if (typeof window === 'undefined') return
const fallback = () => window.alert(body ? `${title}: ${body}` : title)
if (!('Notification' in window)) {
fallback()
return
}