diff --git a/app/Filament/Resources/TerminalResource.php b/app/Filament/Resources/TerminalResource.php index 76c78b8..10164b8 100644 --- a/app/Filament/Resources/TerminalResource.php +++ b/app/Filament/Resources/TerminalResource.php @@ -113,6 +113,24 @@ class TerminalResource extends Resource ]) ->columns(2), + Forms\Components\Section::make('语音唤醒') + ->schema([ + Forms\Components\Toggle::make('voice_wakeup_enabled') + ->label('启用语音唤醒') + ->default(false) + ->live() + ->helperText('开启后终端将启用语音唤醒功能'), + + Forms\Components\TextInput::make('voice_wakeup_word') + ->label('唤醒词') + ->maxLength(100) + ->placeholder('例如: 你好小智') + ->helperText('终端语音唤醒使用的唤醒词') + ->visible(fn(Forms\Get $get): bool => (bool) $get('voice_wakeup_enabled')), + ]) + ->columns(2) + ->description('配置终端的语音唤醒能力'), + Forms\Components\Section::make('知识库关联') ->schema([ Forms\Components\Repeater::make('knowledgeBaseAssociations') diff --git a/app/Filament/Resources/TerminalResource/Pages/ViewTerminal.php b/app/Filament/Resources/TerminalResource/Pages/ViewTerminal.php index eeb8073..1a896fe 100644 --- a/app/Filament/Resources/TerminalResource/Pages/ViewTerminal.php +++ b/app/Filament/Resources/TerminalResource/Pages/ViewTerminal.php @@ -79,6 +79,21 @@ class ViewTerminal extends ViewRecord ]) ->collapsible(), + Infolists\Components\Section::make('语音唤醒') + ->schema([ + Infolists\Components\IconEntry::make('voice_wakeup_enabled') + ->label('语音唤醒') + ->boolean() + ->trueIcon('heroicon-o-check-circle') + ->falseIcon('heroicon-o-x-circle') + ->trueColor('success') + ->falseColor('danger'), + Infolists\Components\TextEntry::make('voice_wakeup_word') + ->label('唤醒词') + ->placeholder('未设置'), + ]) + ->columns(2), + Infolists\Components\Section::make('状态信息') ->schema([ Infolists\Components\IconEntry::make('is_online') diff --git a/app/Http/Controllers/Api/TerminalApiController.php b/app/Http/Controllers/Api/TerminalApiController.php index 3cff39f..f7e08a7 100644 --- a/app/Http/Controllers/Api/TerminalApiController.php +++ b/app/Http/Controllers/Api/TerminalApiController.php @@ -47,6 +47,8 @@ class TerminalApiController extends Controller 'diagram_url' => $terminal->diagram_url, 'scada_data_url' => $terminal->scada_data_url, 'scada_tags_url' => $terminal->scada_tags_url, + 'voice_wakeup_enabled' => $terminal->voice_wakeup_enabled, + 'voice_wakeup_word' => $terminal->voice_wakeup_word, ], 'system_prompt' => $systemPrompt, 'guide_count' => $guideCount, diff --git a/app/Models/Terminal.php b/app/Models/Terminal.php index f42b110..df0adf7 100644 --- a/app/Models/Terminal.php +++ b/app/Models/Terminal.php @@ -26,6 +26,8 @@ class Terminal extends Model 'diagram_url', 'scada_data_url', 'scada_tags_url', + 'voice_wakeup_enabled', + 'voice_wakeup_word', 'is_online', 'last_online_at', ]; @@ -38,6 +40,7 @@ class Terminal extends Model protected function casts(): array { return [ + 'voice_wakeup_enabled' => 'boolean', 'is_online' => 'boolean', 'last_online_at' => 'datetime', ]; diff --git a/database/factories/TerminalFactory.php b/database/factories/TerminalFactory.php index a1142f7..9a99f5c 100644 --- a/database/factories/TerminalFactory.php +++ b/database/factories/TerminalFactory.php @@ -30,6 +30,8 @@ class TerminalFactory extends Factory 'ip_address' => fake()->localIpv4(), 'station_id' => null, // 需要关联实际的线站ID 'diagram_url' => fake()->imageUrl(1920, 1080, 'diagram', true), + 'voice_wakeup_enabled' => false, + 'voice_wakeup_word' => null, 'is_online' => fake()->boolean(70), // 70%概率在线 'last_online_at' => fake()->dateTimeBetween('-7 days', 'now'), ]; diff --git a/database/migrations/2026_03_02_014623_create_terminals_table.php b/database/migrations/2026_03_02_014623_create_terminals_table.php index 65eb2f4..a4b37b1 100644 --- a/database/migrations/2026_03_02_014623_create_terminals_table.php +++ b/database/migrations/2026_03_02_014623_create_terminals_table.php @@ -21,6 +21,8 @@ return new class extends Migration $table->string('diagram_url', 500)->nullable()->comment('组态界面地址'); $table->string('scada_data_url', 500)->nullable()->comment('网关数据查询地址'); $table->string('scada_tags_url', 500)->nullable()->comment('网关点位定义查询地址'); + $table->boolean('voice_wakeup_enabled')->default(false)->comment('语音唤醒是否启用'); + $table->string('voice_wakeup_word', 100)->nullable()->comment('语音唤醒词'); $table->boolean('is_online')->default(false)->comment('在线状态'); $table->timestamp('last_online_at')->nullable()->comment('最后在线时间'); $table->timestamps();