Files
esengine/packages/editor-app/src/services/NotificationService.ts
YHH a3f7cc38b1 Feature/render pipeline (#232)
* refactor(engine): 重构2D渲染管线坐标系统

* feat(engine): 完善2D渲染管线和编辑器视口功能

* feat(editor): 实现Viewport变换工具系统

* feat(editor): 优化Inspector渲染性能并修复Gizmo变换工具显示

* feat(editor): 实现Run on Device移动预览功能

* feat(editor): 添加组件属性控制和依赖关系系统

* feat(editor): 实现动画预览功能和优化SpriteAnimator编辑器

* feat(editor): 修复SpriteAnimator动画预览功能并迁移CI到pnpm

* feat(editor): 修复SpriteAnimator动画预览并迁移到pnpm

* feat(editor): 修复SpriteAnimator动画预览并迁移到pnpm

* feat(editor): 修复SpriteAnimator动画预览并迁移到pnpm

* feat(editor): 修复SpriteAnimator动画预览并迁移到pnpm

* feat(ci): 迁移项目到pnpm并修复CI构建问题

* chore: 迁移CI工作流到pnpm并添加WASM构建支持

* chore: 迁移CI工作流到pnpm并添加WASM构建支持

* chore: 迁移CI工作流到pnpm并添加WASM构建支持

* chore: 迁移CI工作流到pnpm并添加WASM构建支持

* chore: 迁移CI工作流到pnpm并添加WASM构建支持

* chore: 迁移CI工作流到pnpm并添加WASM构建支持

* chore: 移除 network 相关包

* chore: 移除 network 相关包
2025-11-23 14:49:37 +08:00

54 lines
1.8 KiB
TypeScript

import { singleton } from 'tsyringe';
import type { INotification, NotificationType } from '@esengine/editor-core';
@singleton()
export class NotificationService implements INotification {
private showCallback?: (message: string, type?: NotificationType, duration?: number) => void;
private hideCallback?: (id: string) => void;
setCallbacks(
showCallback: (message: string, type?: NotificationType, duration?: number) => void,
hideCallback: (id: string) => void
): void {
this.showCallback = showCallback;
this.hideCallback = hideCallback;
}
show(message: string, type: NotificationType = 'info', duration: number = 3000): void {
if (this.showCallback) {
this.showCallback(message, type, duration);
} else {
console.warn('[NotificationService] showCallback not set, message:', message);
}
}
warning(title: string, message: string, duration: number = 5000): void {
this.show(`${title}: ${message}`, 'warning', duration);
}
error(title: string, message: string, duration: number = 5000): void {
this.show(`${title}: ${message}`, 'error', duration);
}
info(title: string, message: string, duration: number = 3000): void {
this.show(`${title}: ${message}`, 'info', duration);
}
success(title: string, message: string, duration: number = 3000): void {
this.show(`${title}: ${message}`, 'success', duration);
}
hide(id: string): void {
if (this.hideCallback) {
this.hideCallback(id);
} else {
console.warn('[NotificationService] hideCallback not set');
}
}
dispose(): void {
this.showCallback = undefined;
this.hideCallback = undefined;
}
}