这是基于vue-vben-admin 模板适用于abp Vnext的前端管理项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

3.0 KiB

LINGYUN.Abp.Notifications

简体中文 | English

Real-time notification base module.

Features

  • Support multiple notification types (System, User, Application, Service Callback)
  • Support multiple notification lifetimes (One-time, Persistent)
  • Support multiple notification content types (Text, JSON, HTML, Markdown)
  • Support multiple notification severity levels (Success, Info, Warning, Error, Fatal)
  • Support notification subscription management
  • Support notification status management (Read/Unread)
  • Multi-tenancy support
  • Localization support
  • Custom notification provider support

Module Dependencies

[DependsOn(typeof(AbpNotificationModule))]
public class YouProjectModule : AbpModule
{
  // other
}

Basic Usage

1. Send Notification

public class MyService
{
    private readonly INotificationSender _notificationSender;

    public MyService(INotificationSender notificationSender)
    {
        _notificationSender = notificationSender;
    }

    public async Task SendNotificationAsync()
    {
        var data = new NotificationData();
        data.TrySetData("title", "Test Notification");
        data.TrySetData("message", "This is a test notification");

        await _notificationSender.SendNofiterAsync(
            "TestNotification",
            data,
            severity: NotificationSeverity.Info);
    }
}

2. Manage Notification Subscriptions

public class MyService
{
    private readonly INotificationSubscriptionManager _subscriptionManager;

    public MyService(INotificationSubscriptionManager subscriptionManager)
    {
        _subscriptionManager = subscriptionManager;
    }

    public async Task SubscribeAsync(Guid userId)
    {
        await _subscriptionManager.SubscribeAsync(
            userId,
            "TestNotification");
    }
}

Configuration Options

{
  "Notifications": {
    "PublishProviders": [
      "SignalR"  // Optional notification provider
    ]
  }
}

Notification Types

  • Application - Platform notifications
  • System - System notifications
  • User - User notifications
  • ServiceCallback - Service callback notifications

Notification Lifetimes

  • OnlyOne - One-time notifications
  • Persistent - Persistent notifications

Notification Content Types

  • Text - Text
  • Json - JSON
  • Html - HTML
  • Markdown - Markdown

Notification Severity Levels

  • Success - Success
  • Info - Information
  • Warn - Warning
  • Fatal - Fatal
  • Error - Error

Best Practices

  1. Choose appropriate notification types and lifetimes based on actual requirements
  2. Use notification severity levels appropriately, avoid overusing high-level notifications
  3. Add proper localization support for notifications
  4. Regularly clean up expired notification data

Notes

  1. Persistent notifications require implementation of INotificationStore interface
  2. Custom notification providers require implementation of INotificationPublishProvider interface
  3. Notification names should be unique and descriptive
  4. Consider data isolation in multi-tenant scenarios