Base.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @file Index.php
  5. * @date 2019-02-27 14:49:36
  6. * @author huwhis<huuwhois>
  7. * @version 0.0.6
  8. */
  9. namespace app\controller;
  10. use app\BaseController;
  11. use think\facade\View;
  12. use think\facade\Config;
  13. use think\App;
  14. use app\model\Article;
  15. use app\model\Category;
  16. use think\facade\Env;
  17. class Base extends BaseController
  18. {
  19. /**
  20. * seo
  21. */
  22. protected $seo = [];
  23. /**
  24. * makeHtmlFile
  25. */
  26. protected $html = false;
  27. /**
  28. * 构造方法
  29. * @access public
  30. * @param App $app 应用对象
  31. */
  32. public function __construct(App $app)
  33. {
  34. parent::__construct($app);
  35. // 控制器初始化
  36. $this->initialize();
  37. }
  38. // 初始化
  39. protected function initialize()
  40. {
  41. // SEO标题
  42. $system = \app\model\System::find(1);
  43. $this->seo = [
  44. 'title' => $system->title,
  45. 'key' => $system->key,
  46. 'des' => $system->des,
  47. ];
  48. View::assign('seo', $this->seo);
  49. if (Env::get('app.app_env', false)=='dev') {
  50. View::assign('bdtongji', "");
  51. } else {
  52. View::assign('bdtongji', $system->tongji);
  53. }
  54. // 栏目菜单(nav)
  55. $categories = Category::getList(['is_nav'=>1]);
  56. View::assign('categories', $categories);
  57. // 一般栏目
  58. $cate_lists = Category::getList(['type'=>1]);
  59. View::assign('cate_lists', $cate_lists);
  60. }
  61. }