fix(component): toast too many times when switch page mode (#2296)

This commit is contained in:
Himself65
2023-05-10 13:50:51 +08:00
committed by GitHub
parent e4f13ddae4
commit 19e20a6a20
5 changed files with 68 additions and 5 deletions

View File

@@ -9,8 +9,20 @@ export const toast = (message: string, options?: ToastOptions) => {
'.main-container'
) as HTMLElement;
logger.debug(`toast with message: "${message}"`, options);
window.dispatchEvent(
new CustomEvent('affine-toast:emit', { detail: message })
);
return basicToast(message, {
portal: mainContainer || document.body,
...options,
});
};
declare global {
// global Events
interface WindowEventMap {
'affine-toast:emit': CustomEvent<{
message: string;
}>;
}
}