Add VIP presence themes and custom greetings

This commit is contained in:
2026-04-11 15:44:30 +08:00
parent 9fb7710079
commit 4eba9dfc12
21 changed files with 1126 additions and 49 deletions
+14
View File
@@ -35,6 +35,8 @@ class User extends Authenticatable
'email',
'sex',
'sign',
'custom_join_message',
'custom_leave_message',
'user_level',
'inviter_id',
'room_id',
@@ -197,6 +199,18 @@ class User extends Authenticatable
return $this->vipLevel?->icon ?? '';
}
/**
* 判断用户当前是否允许自定义会员进退场语句。
*/
public function canCustomizeVipPresence(): bool
{
if (! $this->isVip()) {
return false;
}
return (bool) $this->vipLevel?->allow_custom_messages;
}
/**
* 关联:当前用户的 VIP 购买订单记录
*/
+72
View File
@@ -20,6 +20,32 @@ class VipLevel extends Model
{
use HasFactory;
/**
* 会员进退场支持的特效选项。
*
* @var array<int, string>
*/
public const EFFECT_OPTIONS = [
'none',
'fireworks',
'rain',
'lightning',
'snow',
];
/**
* 会员进退场支持的横幅风格选项。
*
* @var array<int, string>
*/
public const BANNER_STYLE_OPTIONS = [
'aurora',
'storm',
'royal',
'cosmic',
'farewell',
];
/** @var string 表名 */
protected $table = 'vip_levels';
@@ -32,6 +58,11 @@ class VipLevel extends Model
'jjb_multiplier',
'join_templates',
'leave_templates',
'join_effect',
'leave_effect',
'join_banner_style',
'leave_banner_style',
'allow_custom_messages',
'sort_order',
'price',
'duration_days',
@@ -44,6 +75,7 @@ class VipLevel extends Model
'sort_order' => 'integer',
'price' => 'integer',
'duration_days' => 'integer',
'allow_custom_messages' => 'boolean',
];
/**
@@ -98,4 +130,44 @@ class VipLevel extends Model
return str_replace('{username}', $username, $template);
}
/**
* 获取规范化后的入场特效键名。
*/
public function joinEffectKey(): string
{
return in_array($this->join_effect, self::EFFECT_OPTIONS, true)
? (string) $this->join_effect
: 'none';
}
/**
* 获取规范化后的离场特效键名。
*/
public function leaveEffectKey(): string
{
return in_array($this->leave_effect, self::EFFECT_OPTIONS, true)
? (string) $this->leave_effect
: 'none';
}
/**
* 获取规范化后的入场横幅风格键名。
*/
public function joinBannerStyleKey(): string
{
return in_array($this->join_banner_style, self::BANNER_STYLE_OPTIONS, true)
? (string) $this->join_banner_style
: 'aurora';
}
/**
* 获取规范化后的离场横幅风格键名。
*/
public function leaveBannerStyleKey(): string
{
return in_array($this->leave_banner_style, self::BANNER_STYLE_OPTIONS, true)
? (string) $this->leave_banner_style
: 'farewell';
}
}