Browse Source

feat(docs): 添加实时通知模块文档

pull/1049/head
feijie 1 year ago
parent
commit
23bd362728
  1. 129
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications/README.EN.md
  2. 120
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications/README.md

129
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications/README.EN.md

@ -0,0 +1,129 @@
# LINGYUN.Abp.Notifications
[简体中文](./README.md) | 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
```csharp
[DependsOn(typeof(AbpNotificationModule))]
public class YouProjectModule : AbpModule
{
// other
}
```
## Basic Usage
### 1. Send Notification
```csharp
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
```csharp
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
```json
{
"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

120
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications/README.md

@ -1,9 +1,22 @@
# LINGYUN.Abp.Notifications
实时通知基础模块
[English](./README.EN.md) | 简体中文
实时通知基础模块。
## 配置使用
## 功能
* 支持多种通知类型(系统、用户、应用、服务回调)
* 支持多种通知生命周期(一次性、持久化)
* 支持多种通知内容类型(文本、JSON、HTML、Markdown)
* 支持多种通知严重级别(成功、信息、警告、错误、致命)
* 支持通知订阅管理
* 支持通知状态管理(已读/未读)
* 支持多租户
* 支持本地化
* 支持自定义通知提供程序
## 模块依赖
```csharp
[DependsOn(typeof(AbpNotificationModule))]
@ -11,3 +24,106 @@ public class YouProjectModule : AbpModule
{
// other
}
```
## 基本用法
### 1. 发送通知
```csharp
public class MyService
{
private readonly INotificationSender _notificationSender;
public MyService(INotificationSender notificationSender)
{
_notificationSender = notificationSender;
}
public async Task SendNotificationAsync()
{
var data = new NotificationData();
data.TrySetData("title", "测试通知");
data.TrySetData("message", "这是一条测试通知");
await _notificationSender.SendNofiterAsync(
"TestNotification",
data,
severity: NotificationSeverity.Info);
}
}
```
### 2. 管理通知订阅
```csharp
public class MyService
{
private readonly INotificationSubscriptionManager _subscriptionManager;
public MyService(INotificationSubscriptionManager subscriptionManager)
{
_subscriptionManager = subscriptionManager;
}
public async Task SubscribeAsync(Guid userId)
{
await _subscriptionManager.SubscribeAsync(
userId,
"TestNotification");
}
}
```
## 配置选项
```json
{
"Notifications": {
"PublishProviders": [
"SignalR" // 可选的通知提供程序
]
}
}
```
## 通知类型
* Application - 平台通知
* System - 系统通知
* User - 用户通知
* ServiceCallback - 服务回调通知
## 通知生命周期
* OnlyOne - 一次性通知
* Persistent - 持久化通知
## 通知内容类型
* Text - 文本
* Json - JSON
* Html - HTML
* Markdown - Markdown
## 通知严重级别
* Success - 成功
* Info - 信息
* Warn - 警告
* Fatal - 致命
* Error - 错误
## 最佳实践
1. 根据实际需求选择合适的通知类型和生命周期
2. 合理使用通知严重级别,避免滥用高级别通知
3. 为通知添加适当的本地化支持
4. 定期清理过期的通知数据
## 注意事项
1. 持久化通知需要实现 INotificationStore 接口
2. 自定义通知提供程序需要实现 INotificationPublishProvider 接口
3. 通知名称应该具有唯一性和描述性
4. 考虑多租户场景下的数据隔离

Loading…
Cancel
Save