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
+2
View File
@@ -29,6 +29,8 @@ class UserFactory extends Factory
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
'sex' => 1,
'custom_join_message' => null,
'custom_leave_message' => null,
'user_level' => 1,
];
}
+5
View File
@@ -29,6 +29,11 @@ class VipLevelFactory extends Factory
'jjb_multiplier' => 1.2,
'join_templates' => null,
'leave_templates' => null,
'join_effect' => 'none',
'leave_effect' => 'none',
'join_banner_style' => 'aurora',
'leave_banner_style' => 'farewell',
'allow_custom_messages' => true,
'sort_order' => fake()->numberBetween(1, 20),
'price' => fake()->numberBetween(10, 99),
'duration_days' => 30,
@@ -0,0 +1,138 @@
<?php
/**
* 文件功能:为 VIP 等级与用户增加进退场主题字段
* 支持会员等级专属特效、横幅风格以及用户自定义欢迎语和离开语。
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 执行迁移:为 vip_levels users 表增加会员进退场主题相关字段。
*/
public function up(): void
{
Schema::table('vip_levels', function (Blueprint $table) {
$table->string('join_effect', 30)->nullable()->after('leave_templates')->comment('会员入场特效类型');
$table->string('leave_effect', 30)->nullable()->after('join_effect')->comment('会员离场特效类型');
$table->string('join_banner_style', 30)->default('aurora')->after('leave_effect')->comment('会员入场横幅风格');
$table->string('leave_banner_style', 30)->default('farewell')->after('join_banner_style')->comment('会员离场横幅风格');
$table->boolean('allow_custom_messages')->default(true)->after('leave_banner_style')->comment('是否允许会员自定义欢迎语和离开语');
});
Schema::table('users', function (Blueprint $table) {
$table->string('custom_join_message', 255)->nullable()->after('sign')->comment('用户自定义欢迎语');
$table->string('custom_leave_message', 255)->nullable()->after('custom_join_message')->comment('用户自定义离开语');
});
// 为现有 4 档会员预设不同的入场/离场语句、特效与横幅风格,确保开箱即用。
$this->seedVipPresenceThemes();
}
/**
* 回滚迁移:删除会员进退场主题相关字段。
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn([
'custom_join_message',
'custom_leave_message',
]);
});
Schema::table('vip_levels', function (Blueprint $table) {
$table->dropColumn([
'join_effect',
'leave_effect',
'join_banner_style',
'leave_banner_style',
'allow_custom_messages',
]);
});
}
/**
* 为现有会员等级回填默认进退场主题配置。
*/
private function seedVipPresenceThemes(): void
{
$themes = [
1 => [
'join_effect' => 'snow',
'leave_effect' => 'rain',
'join_banner_style' => 'aurora',
'leave_banner_style' => 'farewell',
'join_templates' => json_encode([
'白银贵宾 {username} 披着月色缓缓入场,银辉点亮了今晚的聊天室。',
'{username} 佩着白银徽章轻轻登场,清风与掌声一并来到。',
'欢迎白银会员 {username} 闪亮现身,今晚的好心情从此刻开始。',
], JSON_UNESCAPED_UNICODE),
'leave_templates' => json_encode([
'白银贵宾 {username} 挥挥手离场,留下一地温柔星光。',
'{username} 踩着银色余晖优雅退场,期待下次再会。',
'白银会员 {username} 已悄然离席,聊天室仍留着 TA 的温度。',
], JSON_UNESCAPED_UNICODE),
],
2 => [
'join_effect' => 'rain',
'leave_effect' => 'snow',
'join_banner_style' => 'storm',
'leave_banner_style' => 'aurora',
'join_templates' => json_encode([
'黄金贵宾 {username} 踏着流金光幕入场,整个房间都亮了起来。',
'{username} 驾着黄金座驾高调现身,全场目光瞬间聚焦。',
'欢迎黄金会员 {username} 荣耀登场,今夜的热度正式拉满。',
], JSON_UNESCAPED_UNICODE),
'leave_templates' => json_encode([
'黄金贵宾 {username} 在掌声与光束中谢幕离场。',
'{username} 留下一抹鎏金背影,从容地走出了今晚的高光。',
'黄金会员 {username} 已优雅退场,华丽气场仍在场中回荡。',
], JSON_UNESCAPED_UNICODE),
],
3 => [
'join_effect' => 'lightning',
'leave_effect' => 'rain',
'join_banner_style' => 'cosmic',
'leave_banner_style' => 'storm',
'join_templates' => json_encode([
'钻石贵宾 {username} 伴着星海电光降临,璀璨得令人移不开眼。',
'{username} 驾驭钻石流光闪耀入场,聊天室气氛瞬间拉到满格。',
'欢迎钻石会员 {username} 华彩登场,这一刻全场都被点亮。',
], JSON_UNESCAPED_UNICODE),
'leave_templates' => json_encode([
'钻石贵宾 {username} 化作一束流星光影,耀眼地离开了舞台。',
'{username} 留下满屏星辉后优雅退场,仿佛银河刚刚经过。',
'钻石会员 {username} 已离场,璀璨余韵仍在聊天室回响。',
], JSON_UNESCAPED_UNICODE),
],
4 => [
'join_effect' => 'fireworks',
'leave_effect' => 'lightning',
'join_banner_style' => 'royal',
'leave_banner_style' => 'cosmic',
'join_templates' => json_encode([
'至尊会员 {username} 御光而来,王者气场瞬间笼罩全场。',
'请注意,至尊贵宾 {username} 已荣耀驾临,今晚高光正式开启。',
'{username} 身披王者金辉震撼登场,整个聊天室都在为 TA 让路。',
], JSON_UNESCAPED_UNICODE),
'leave_templates' => json_encode([
'至尊会员 {username} 在雷光与礼赞中谢幕离场,气场依旧未散。',
'{username} 留下一道王者余辉后从容退场,全场仍沉浸在震撼之中。',
'至尊贵宾 {username} 已离席,聊天室却还回响着 TA 的登场气势。',
], JSON_UNESCAPED_UNICODE),
],
];
foreach ($themes as $sortOrder => $theme) {
DB::table('vip_levels')
->where('sort_order', $sortOrder)
->update($theme);
}
}
};