app->singleton(\App\Services\MathRecSysService::class, function () { return new \App\Services\MathRecSysService(); }); // 注册知识图谱服务 $this->app->singleton(\App\Services\KnowledgeGraphService::class, function ($app) { return new \App\Services\KnowledgeGraphService( $app->make(\App\Services\MathRecSysService::class) ); }); } /** * Bootstrap any application services. */ public function boot(): void { if (config('app.env') === 'production') { URL::forceScheme('https'); } MarkdownImport::updated(function (MarkdownImport $import): void { try { Redis::publish('markdown-imports', json_encode([ 'type' => 'markdown-imports', 'id' => $import->id, 'status' => $import->status, 'progress_stage' => $import->progress_stage, 'progress_message' => $import->progress_message, 'parsed_count' => $import->parsed_count ?? null, 'accepted_count' => $import->accepted_count ?? null, 'import_id' => $import->id, ], JSON_UNESCAPED_UNICODE)); } catch (\Throwable $e) { // SSE publish failed, ignore to avoid affecting business flow. } }); PreQuestionCandidate::updated(function (PreQuestionCandidate $candidate): void { try { Redis::publish('pre-question-candidates', json_encode([ 'type' => 'pre-question-candidates', 'id' => $candidate->id, 'import_id' => $candidate->import_id, 'status' => $candidate->status, 'is_question_candidate' => $candidate->is_question_candidate, ], JSON_UNESCAPED_UNICODE)); } catch (\Throwable $e) { // SSE publish failed, ignore to avoid affecting business flow. } }); } }