feat: add user notification center
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\enum\notice;
|
||||
|
||||
/**
|
||||
* 用户站内消息场景。
|
||||
*
|
||||
* 使用独立的场景编号,避免与验证码等已有通知场景混用。
|
||||
*/
|
||||
class UserNoticeEnum
|
||||
{
|
||||
public const POST_COMMENT = 1001;
|
||||
public const COMMENT_REPLY = 1002;
|
||||
public const FOLLOWED = 1003;
|
||||
public const ADMIN_POINTS = 1004;
|
||||
public const SYSTEM = 1005;
|
||||
|
||||
public static function getSceneIds(): array
|
||||
{
|
||||
return [
|
||||
self::POST_COMMENT,
|
||||
self::COMMENT_REPLY,
|
||||
self::FOLLOWED,
|
||||
self::ADMIN_POINTS,
|
||||
self::SYSTEM,
|
||||
];
|
||||
}
|
||||
|
||||
public static function getMeta(int $sceneId): array
|
||||
{
|
||||
$map = [
|
||||
self::POST_COMMENT => [
|
||||
'type' => 'post_comment',
|
||||
'type_desc' => '帖子评论',
|
||||
'icon' => 'chat',
|
||||
'color' => '#1468f5',
|
||||
],
|
||||
self::COMMENT_REPLY => [
|
||||
'type' => 'comment_reply',
|
||||
'type_desc' => '评论回复',
|
||||
'icon' => 'chat',
|
||||
'color' => '#7c4dff',
|
||||
],
|
||||
self::FOLLOWED => [
|
||||
'type' => 'followed',
|
||||
'type_desc' => '新增关注',
|
||||
'icon' => 'account',
|
||||
'color' => '#10b981',
|
||||
],
|
||||
self::ADMIN_POINTS => [
|
||||
'type' => 'admin_points',
|
||||
'type_desc' => '积分到账',
|
||||
'icon' => 'coupon',
|
||||
'color' => '#f59e0b',
|
||||
],
|
||||
self::SYSTEM => [
|
||||
'type' => 'system',
|
||||
'type_desc' => '系统消息',
|
||||
'icon' => 'bell',
|
||||
'color' => '#64748b',
|
||||
],
|
||||
];
|
||||
|
||||
return $map[$sceneId] ?? [
|
||||
'type' => 'system',
|
||||
'type_desc' => '系统消息',
|
||||
'icon' => 'bell',
|
||||
'color' => '#64748b',
|
||||
];
|
||||
}
|
||||
|
||||
public static function getOptions(): array
|
||||
{
|
||||
$options = [];
|
||||
foreach (self::getSceneIds() as $sceneId) {
|
||||
$meta = self::getMeta($sceneId);
|
||||
$options[] = [
|
||||
'value' => $sceneId,
|
||||
'label' => $meta['type_desc'],
|
||||
];
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user