PageContent.php 979 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Web\Components\Page;
  3. use App\Exceptions\ApiException;
  4. use App\Web\Facades\WebFacade;
  5. use App\Web\Services\WebService;
  6. use Illuminate\View\Component;
  7. class PageContent extends Component
  8. {
  9. protected $moduleKeyList; //这是参数
  10. protected $viewFile; //视图地址
  11. public function __construct($viewFile = "", $moduleKeyList=[])
  12. {
  13. if (empty($viewFile)) {
  14. throw new ApiException("common.page_none", '您访问的地址不存在~');
  15. }
  16. $this->moduleKeyList = $moduleKeyList ?? '';
  17. $this->viewFile= $viewFile;
  18. }
  19. /**
  20. * 获取页面数据
  21. */
  22. public function render()
  23. {
  24. $params = [
  25. "route_path"=>WebService::LAYOUTS_ROUTE,
  26. "module_key_list"=> $this->moduleKeyList
  27. ];
  28. $retData = WebFacade::getStaticPageInfo($params);
  29. $retData['menu_data']=WebFacade::getWebMenu();
  30. return view($this->viewFile, $retData);
  31. }
  32. }