KnowledgeGraphIntegration.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 = null;
  18. protected static ?int $navigationSort = 7;
  19. protected static bool $shouldRegisterNavigation = false;
  20. protected string $view = 'filament.pages.integrations.knowledge-graph-integration';
  21. public ?string $selectedKpCode = null;
  22. public string $activeTab = 'graph';
  23. public bool $showSidebar = true;
  24. public function mount(Request $request): void
  25. {
  26. $this->selectedKpCode = $request->query('kp_code');
  27. $this->activeTab = $request->query('tab', 'graph');
  28. }
  29. #[Computed]
  30. public function tabs()
  31. {
  32. return [
  33. 'graph' => [
  34. 'label' => '知识图谱',
  35. 'icon' => 'heroicon-o-share',
  36. 'component' => 'knowledge-graph',
  37. ],
  38. 'list' => [
  39. 'label' => '知识点列表',
  40. 'icon' => 'heroicon-o-list-bullet',
  41. 'component' => 'knowledge-points-list',
  42. ],
  43. 'stats' => [
  44. 'label' => '题库统计',
  45. 'icon' => 'heroicon-o-chart-bar',
  46. 'component' => 'knowledge-point-stats',
  47. ],
  48. 'network' => [
  49. 'label' => '关联网络',
  50. 'icon' => 'heroicon-o-squares-2x2',
  51. 'component' => 'knowledge-network',
  52. ],
  53. ];
  54. }
  55. public function setActiveTab(string $tab): void
  56. {
  57. $this->activeTab = $tab;
  58. $this->dispatch('tabChanged', tab: $tab);
  59. }
  60. public function toggleSidebar()
  61. {
  62. $this->showSidebar = !$this->showSidebar;
  63. }
  64. public function clearSelection()
  65. {
  66. $this->selectedKpCode = null;
  67. $this->dispatch('clearAllSelections');
  68. }
  69. public function updatedSelectedKpCode($value)
  70. {
  71. if ($value) {
  72. $this->dispatch('kpSelected', kpCode: $value);
  73. }
  74. }
  75. public function getBreadcrumbs(): array
  76. {
  77. return [
  78. 'knowledge-graph-integration' => '知识图谱整合视图',
  79. ];
  80. }
  81. }