1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- declare(strict_types=1);
- /**
- * @file Index.php
- * @date 2019-02-27 14:49:36
- * @author huwhis<huuwhois>
- * @version 0.0.6
- */
- namespace app\index\controller;
- use think\facade\View;
- use think\facade\Config;
- use think\App;
- use app\common\model\Article;
- use app\common\model\Category;
- use think\facade\Env;
- abstract class Base
- {
- /**
- * Request实例
- * @var \think\Request
- */
- protected $request;
- /**
- * 应用实例
- * @var \think\App
- */
- protected $app;
- /**
- * seo
- */
- protected $seo = [];
- /**
- * makeHtmlFile
- */
- protected $html = false;
- /**
- * 构造方法
- * @access public
- * @param App $app 应用对象
- */
- public function __construct(App $app)
- {
- $this->app = $app;
- $this->request = $this->app->request;
- $this->html = Config::get('app.html', false);
- // 控制器初始化
- $this->initialize();
- }
- // 初始化
- protected function initialize()
- {
- // SEO标题
- $system = \app\common\model\System::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)) {
- View::assign('bdtongji', $system->tongji);
- } else {
- View::assign('bdtongji', "");
- }
- // 栏目菜单(nav)
- $categories = Category::getList(['is_nav'=>1]);
- View::assign('categories', $categories);
-
- // 一般栏目
- $cate_lists = Category::getList(['type'=>1]);
- View::assign('cate_lists', $cate_lists);
- }
- }
|