Base.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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\App;
  13. use think\facade\Cache;
  14. use think\facade\Env;
  15. use app\model\Category;
  16. use app\model\System;
  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. // 初始化
  37. protected function initialize()
  38. {
  39. $system = System::cache('system', 3600)->find(1);
  40. $this->seo = [
  41. 'title' => $system['title'],
  42. 'key' => $system['key'],
  43. 'des' => $system['des']
  44. ];
  45. View::assign('seo', $this->seo);
  46. if (Env::get('app.app_env', false)=='dev') {
  47. View::assign('bdtongji', "");
  48. } else {
  49. View::assign('bdtongji', $system['tongji']);
  50. }
  51. // 栏目
  52. $categoryList = Cache::get('category_list');
  53. if (!$categoryList) {
  54. $categoryList = Category::getList();
  55. Cache::set("category_list",$categoryList, 3600);
  56. }
  57. View::assign('categoryList', $categoryList);
  58. }
  59. }