'use client'; import type React from 'react'; import { useId } from 'react'; import { createPortal } from 'react-dom'; import { useMounted } from '@wener/reaction'; export const UpdateNotificationToast: React.FC = (props) => { const id = useId(); const mounted = useMounted(); if (!mounted) { return null; } // https://github.com/GreatAuk/plugin-web-update-notification/blob/master/packages/core/src/shim.d.ts const { title, description, open, refreshButtonText, dismissButtonText, onRefresh = () => { location.reload(); }, onOpenChange, } = Object.assign({}, Locals.zh_CN, props); if (!open) { return null; } return createPortal(

{title}

{description}

{onOpenChange && ( )}
, document.body, id, ); }; export interface UpdateNotificationToastProps { title?: string; description?: string; refreshButtonText?: string; dismissButtonText?: string; onRefresh?: () => void; open?: boolean; onOpenChange?: (open: boolean) => void; } const Locals = { zh_CN: { title: '发现新版本', description: '网页更新啦!请刷新页面后使用。', refreshButtonText: '刷新', dismissButtonText: '忽略', }, };