KnowledgeGraphIntegration.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace App\Filament\Pages\Integrations;
  3. use BackedEnum;
  4. use Filament\Pages\Page;
  5. use UnitEnum;
  6. use Livewire\Attributes\Computed;
  7. use Illuminate\Http\Request;
  8. use App\Livewire\Integrations\KnowledgeGraphComponent;
  9. use App\Livewire\Integrations\KnowledgePointsListComponent;
  10. use App\Livewire\Integrations\KnowledgePointStatsComponent;
  11. use App\Livewire\Integrations\KnowledgeNetworkComponent;
  12. class KnowledgeGraphIntegration extends Page
  13. {
  14. protected static ?string $title = '知识图谱整合视图';
  15. protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-globe-alt';
  16. protected static ?string $navigationLabel = '知识图谱整合';
  17. protected static string|UnitEnum|null $navigationGroup = '整合视图';
  18. protected static ?int $navigationSort = 10;
  19. protected string $view = 'filament.pages.integrations.knowledge-graph-integration';
  20. public ?string $selectedKpCode = null;
  21. public string $activeTab = 'graph';
  22. public bool $showSidebar = true;
  23. public function mount(Request $request): void
  24. {
  25. $this->selectedKpCode = $request->query('kp_code');
  26. $this->activeTab = $request->query('tab', 'graph');
  27. }
  28. #[Computed]
  29. public function tabs()
  30. {
  31. return [
  32. 'graph' => [
  33. 'label' => '知识图谱',
  34. 'icon' => 'heroicon-o-share',
  35. 'component' => 'knowledge-graph',
  36. ],
  37. 'list' => [
  38. 'label' => '知识点列表',
  39. 'icon' => 'heroicon-o-list-bullet',
  40. 'component' => 'knowledge-points-list',
  41. ],
  42. 'stats' => [
  43. 'label' => '题库统计',
  44. 'icon' => 'heroicon-o-chart-bar',
  45. 'component' => 'knowledge-point-stats',
  46. ],
  47. 'network' => [
  48. 'label' => '关联网络',
  49. 'icon' => 'heroicon-o-squares-2x2',
  50. 'component' => 'knowledge-network',
  51. ],
  52. ];
  53. }
  54. public function setActiveTab(string $tab): void
  55. {
  56. $this->activeTab = $tab;
  57. $this->dispatch('tabChanged', tab: $tab);
  58. }
  59. public function toggleSidebar()
  60. {
  61. $this->showSidebar = !$this->showSidebar;
  62. }
  63. public function clearSelection()
  64. {
  65. $this->selectedKpCode = null;
  66. $this->dispatch('clearAllSelections');
  67. }
  68. public function updatedSelectedKpCode($value)
  69. {
  70. if ($value) {
  71. $this->dispatch('kpSelected', kpCode: $value);
  72. }
  73. }
  74. public function getBreadcrumbs(): array
  75. {
  76. return [
  77. 'knowledge-graph-integration' => '知识图谱整合视图',
  78. ];
  79. }
  80. }