* @version 0.0.6 */ namespace app\controller; use app\BaseController; use think\facade\View; use think\App; use think\facade\Cache; use think\facade\Env; use app\model\Category; use app\model\System; class Base extends BaseController { /** * seo */ protected $seo = []; /** * makeHtmlFile */ protected $html = false; /** * 构造方法 * @access public * @param App $app 应用对象 */ public function __construct(App $app) { parent::__construct($app); } // 初始化 protected function initialize() { $system = System::cache('system', 3600)->find(1); $this->seo = [ 'title' => $system['title'], 'key' => $system['key'], 'des' => $system['des'] ]; View::assign('seo', $this->seo); if (Env::get('app.app_env', false)=='dev') { View::assign('bdtongji', ""); } else { View::assign('bdtongji', $system['tongji']); } // 栏目 $categoryList = Cache::get('category_list'); if (!$categoryList) { $categoryList = Category::getList(); Cache::set("category_list",$categoryList, 3600); } View::assign('categoryList', $categoryList); } }