Skip to content

Commit 1ce13b5

Browse files
authored
Merge branch 'nocobase:main' into main
2 parents b03d9b5 + f63ba2d commit 1ce13b5

File tree

11 files changed

+240
-84
lines changed

11 files changed

+240
-84
lines changed

docs/config/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export default [
114114
'/api/server/plugin-manager',
115115
'/api/server/plugin',
116116
'/api/server/migration',
117-
'/api/server/sync-manager',
117+
// '/api/server/sync-manager',
118118
],
119119
},
120120
{

docs/config/handbook.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,22 @@ export default [
15011501
title: 'Notification manager',
15021502
'title.zh-CN': '通知管理',
15031503
'title.ja-JP': '通知管理',
1504-
link: '/handbook/notification-manager',
1504+
children: [
1505+
{
1506+
title: 'Overview',
1507+
'title.zh-CN': '概述',
1508+
'title.ja-JP': '概要',
1509+
link: '/handbook/notification-manager',
1510+
},
1511+
{
1512+
title: 'Development',
1513+
'title.zh-CN': '开发指南',
1514+
children: [
1515+
'/handbook/notification-manager/development/extension',
1516+
'/handbook/notification-manager/development/api',
1517+
],
1518+
},
1519+
],
15051520
},
15061521
{
15071522
title: 'Notification: In-app message',
@@ -1515,12 +1530,6 @@ export default [
15151530
'title.ja-JP': '通知:メール',
15161531
link: '/handbook/notification-email',
15171532
},
1518-
{
1519-
title: 'Notification extension',
1520-
'title.zh-CN': '通知扩展',
1521-
'title.ja-JP': '通知拡張',
1522-
link: '/handbook/notification-manager/extension',
1523-
},
15241533
],
15251534
},
15261535
{

docs/en-US/api/server/application.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,11 @@ Resource management. Refer to [ResourceManager](../resourcer/resource-manager.md
143143

144144
Cache management. Refer to [CacheManager](../cache/cache-manager.md).
145145

146+
<!--
146147
### `syncManager`
147148
148149
Sync signal management. Refer to [SyncManager](./sync-manager.md).
150+
-->
149151

150152
### `authManager`
151153

docs/en-US/welcome/getting-started/env.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ NocoBase API address prefix, default is `/api/`
5757
API_BASE_PATH=/api/
5858
```
5959

60+
<!-- will be open in 1.5
6061
### CLUSTER_MODE
6162
6263
The multi-core (cluster) mode for starting app. If this variable is configured, will be passed to the pm2 start command as the `-i <instances>` parameter. The options are consistent with the pm2 `-i` parameter (refer to [PM2: Cluster Mode](https://pm2.keymetrics.io/docs/usage/cluster-mode/)), including:
@@ -70,6 +71,7 @@ The default value is empty, meaning it is not enabled.
7071
:::warning{title="Attention"}
7172
This mode requires the use of plugins related to cluster mode, such as `@nocobase/plugin-sync-adapter-redis`. Otherwise, the functionality of applicaiton may encounter unexpected issues.
7273
:::
74+
-->
7375

7476
### PLUGIN_PACKAGE_PREFIX
7577

docs/ja-JP/api/server/application.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,11 @@ export interface ApplicationOptions {
143143

144144
缓存管理。参考 [CacheManager](../cache/cache-manager.md).
145145

146+
<!--
146147
### `syncManager`
147148
148149
同步信号管理器。参考 [SyncManager](./sync-manager.md).
150+
-->
149151

150152
### `authManager`
151153

docs/ja-JP/welcome/getting-started/env.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ API_BASE_PATH=/api/
5555

5656
### API_BASE_URL
5757

58+
<!-- will be open in 1.5
5859
### CLUSTER_MODE
5960
6061
マルチコア(クラスター)起動モードです。この変数が設定されている場合、`pm2 start` コマンドに `-i <instances>` の引数として透過的に渡されます。選択肢は pm2 の `-i` パラメータと一致します(参考:[PM2: クラスター モード](https://pm2.keymetrics.io/docs/usage/cluster-mode/)):
@@ -68,6 +69,7 @@ API_BASE_PATH=/api/
6869
:::warning{title="注意"}
6970
このモードはクラスター モード関連のプラグインと併せて使用する必要があります。そうしないと、アプリケーションの機能に異常が生じる可能性があります。
7071
:::
72+
-->
7173

7274
### PLUGIN_PACKAGE_PREFIX
7375

docs/zh-CN/api/server/application.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,11 @@ export interface ApplicationOptions {
143143

144144
缓存管理。参考 [CacheManager](../cache/cache-manager.md).
145145

146+
<!--
146147
### `syncManager`
147148
148149
同步信号管理器。参考 [SyncManager](./sync-manager.md).
150+
-->
149151

150152
### `authManager`
151153

docs/zh-CN/handbook/notification-in-app-message/index.md

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,43 @@
44

55
## 介绍
66

7-
支持用户在应用内接收消息通知
7+
支持用户在 NocoBase 应用内实时接收消息通知
88

9-
## 使用手册
9+
## 安装
1010

11-
以发送站内活动通知为例
11+
该插件为内置插件,无需安装。
1212

13-
1. 首先在通知的渠道管理配置一个站内信渠道
14-
![20241017075823-2024-10-17-07-58-27](https://static-docs.nocobase.com/20241017075823-2024-10-17-07-58-27.png)
15-
![20241017080112-2024-10-17-08-01-16](https://static-docs.nocobase.com/20241017080112-2024-10-17-08-01-16.png)
13+
## 添加站内信渠道
1614

17-
2. 配置一条工作流,增加通知节点并选择上一步创建好的渠道并配置
18-
![20241017081301-2024-10-17-08-13-05](https://static-docs.nocobase.com/20241017081301-2024-10-17-08-13-05.png)
15+
打开通知管理,点击新增按钮,选择站内信。
16+
![2024-11-08-08-33-26-20241108083326](https://static-docs.nocobase.com/2024-11-08-08-33-26-20241108083326.png)
1917

20-
3. 触发工作流执行,会实时收到通知
21-
![20241017082030-2024-10-17-08-20-34](https://static-docs.nocobase.com/20241017082030-2024-10-17-08-20-34.png)
18+
输入渠道名称和描述后,点击提交。
19+
![2024-11-08-08-34-32-20241108083431](https://static-docs.nocobase.com/2024-11-08-08-34-32-20241108083431.png)
20+
21+
列表上会新增一个对应渠道。
22+
23+
![2024-11-08-08-34-52-20241108083452](https://static-docs.nocobase.com/2024-11-08-08-34-52-20241108083452.png)
24+
25+
## 使用场景示例
26+
27+
为了帮助你更好地理解站内信的使用方法,以下是一个关于“营销线索跟进”的示例。
28+
29+
假设你的团队正在进行一个重要的营销活动,目标是跟进潜在客户的反馈和需求。使用站内信,你可以:
30+
31+
**创建通知渠道**:首先在通知渠道管理中,配置一个名称为“Marketing Clue”的站内信渠道,确保团队成员能够清晰识别该渠道的用途。
32+
33+
![2024-11-08-08-34-32-20241108083431](https://static-docs.nocobase.com/2024-11-08-08-34-32-20241108083431.png)
34+
35+
**配置工作流**:建立一条工作流,当有新营销线索时,自动触发通知。你可以在工作流中增加通知节点,选择之前创建的“Marketing Clue”渠道,并根据实际需求配置消息内容。例如:
36+
37+
![image-1-2024-10-27-14-07-17](https://static-docs.nocobase.com/image-1-2024-10-27-14-07-17.png)
38+
39+
**实时接收通知**:一旦触发工作流,所有相关人员将实时收到通知,确保团队能够快速响应和行动。
40+
41+
![image-2-2024-10-27-14-07-22](https://static-docs.nocobase.com/image-2-2024-10-27-14-07-22.png)
42+
43+
**消息管理与跟踪**:站内信将按照发送渠道名称进行分组。你可以根据消息的已读和未读状态筛选,便于快速查看重要信息。点击“查看”按钮将跳转到配置的链接页面,以便进一步处理相关事宜。
44+
45+
![20241027140648-2024-10-27-14-06-51-2024-10-29-13-26-41](https://static-docs.nocobase.com/20241027140648-2024-10-27-14-06-51-2024-10-29-13-26-41.png)
2246

23-
4. 站内消息会按照发送渠道名称分组,根据消息的已读未读状态可以筛选全部、未读和已读的消息分组,点击“查看”按钮会跳转到配置的链接页面
24-
![20241017082305-2024-10-17-08-23-10](https://static-docs.nocobase.com/20241017082305-2024-10-17-08-23-10.png)
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# API参考
2+
3+
## 服务端
4+
5+
### `BaseNotificationChannel`
6+
7+
是用户渠道类型的抽象类,定义了通知渠道需要的接口,扩展新的通知渠道类型需要继承此类,并实现其中的方法
8+
9+
```ts
10+
export abstract class BaseNotificationChannel<Message = any> {
11+
constructor(protected app: Application) {}
12+
abstract send(params: {
13+
channel: ChannelOptions;
14+
message: Message;
15+
}): Promise<{ message: Message; status: 'success' | 'fail'; reason?: string }>;
16+
}
17+
```
18+
19+
### `PluginNotificationManagerServer`
20+
21+
通知管理服务端插件,提供通知渠道类型注册方法和通知下发方法。
22+
23+
#### `registerChannelType()`
24+
25+
注册渠道类型的服务端,参考样例
26+
27+
```ts
28+
import PluginNotificationManagerServer from '@nocobase/plugin-notification-manager';
29+
import { Plugin } from '@nocobase/server';
30+
import { ExampleSever } from './example-server';
31+
export class PluginNotificationExampleServer extends Plugin {
32+
async load() {
33+
const notificationServer = this.pm.get(PluginNotificationManagerServer) as PluginNotificationManagerServer;
34+
notificationServer.registerChannelType({ type: 'example-sms', Channel: ExampleSever });
35+
}
36+
}
37+
38+
export default PluginNotificationExampleServer;
39+
```
40+
41+
##### 签名
42+
43+
`registerChannelType({ type, Channel }: {type: string, Channel: BaseNotificationChannel })`
44+
45+
#### `send()`
46+
47+
通知下发方法,调用此方法可下发通知
48+
49+
```ts
50+
send('in-app-message',
51+
message:[
52+
receivers: [1,2,3],
53+
receiverType: 'userId',
54+
content: '站内信测试',
55+
title: '站内信测试标题'
56+
],
57+
triggerFrom: 'workflow')
58+
59+
send('email',
60+
message:[
61+
62+
receiverType: 'email',
63+
content: '邮箱测试',
64+
title: '邮箱测试标题'
65+
],
66+
triggerFrom: 'workflow')
67+
```
68+
69+
##### 签名
70+
71+
`send(sendConfig: {channelName:stirng, message: Object, receivers: ReceiversType, triggerFrom: string })`
72+
73+
接收人`receivers`目前只支持两种格式:nocobase站内用户ID`userId`和渠道特定配置`channel-self-defined`
74+
75+
```ts
76+
type ReceiversType =
77+
| { value: number[]; type: 'userId' }
78+
| { value: any; type: 'channel-self-defined'; channelType: string };
79+
```
80+
81+
##### 详细信息
82+
83+
sendConfig
84+
85+
| 属性 | 类型 | 描述 |
86+
| ------------ | ------------ | --------- |
87+
| `channelName` | `string` | 渠道标识 |
88+
| `message` | `object` | 消息对象 |
89+
| `receivers` | `ReceiversType` | 接收人 |
90+
| `triggerFrom` | `string` | 触发来源 |
91+
92+
## 客户端
93+
94+
### `PluginNotificationManagerClient`
95+
96+
#### `channelTypes`
97+
98+
已注册渠道类型库
99+
100+
##### 签名
101+
102+
`channelTypes: Registry<registerTypeOptions>`
103+
104+
#### `registerChannelType()`
105+
106+
注册客户端渠道类型
107+
108+
##### 签名
109+
110+
`registerChannelType(params: registerTypeOptions)`
111+
112+
##### 类型
113+
114+
```ts
115+
type registerTypeOptions = {
116+
title: string; // 渠道显示标题
117+
type: string; // 渠道标识
118+
components: {
119+
ChannelConfigForm?: ComponentType // 渠道配置表单组件;
120+
MessageConfigForm?: ComponentType<{ variableOptions: any }> // 消息配置表单组件;
121+
ContentConfigForm?: ComponentType<{ variableOptions: any }> // 内容配置表单组件(只是消息内容,不包括接收人的配置);
122+
};
123+
meta?: { // 渠道配置元信息
124+
createable?: boolean //是否支持新增渠道;
125+
eidtable?: boolean //渠道配置信息是否可编辑;
126+
deletable?: boolean //渠道配置信息是否可删除;
127+
};
128+
};
129+
130+
type RegisterChannelType = (params: ChannelType) => void
131+
```

0 commit comments

Comments
 (0)