diff --git a/app/common/model/ModelTrait.php b/app/common/model/ModelTrait.php index ebd8649..92fa52f 100644 --- a/app/common/model/ModelTrait.php +++ b/app/common/model/ModelTrait.php @@ -4,6 +4,7 @@ namespace app\common\model; +use think\db\BaseQuery; use think\db\exception\DataNotFoundException; use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; @@ -120,9 +121,9 @@ trait ModelTrait * @param null $eachFn 处理结果函数 * @param array $params 分页参数 * @param int $limit 分页数 - * @return ModelTrait + * @return array */ - public static function page($model = null, $eachFn = null, $params = [], $limit = 20): ModelTrait + public static function page($model = null, $eachFn = null, $params = [], $limit = 20): array { if (is_numeric($eachFn) && is_numeric($model)) { return parent::page($model, $eachFn); diff --git a/app/common/model/UrlLog.php b/app/common/model/UrlLog.php index 54ba03e..5588738 100644 --- a/app/common/model/UrlLog.php +++ b/app/common/model/UrlLog.php @@ -20,11 +20,12 @@ class UrlLog extends BaseModel if ($url_data) { $this->where($urlWhere)->inc('pv')->update(); } else { - $dataUrl['url'] = $url; - $dataUrl['pv'] = 1; - $dataUrl['title'] = $title; - $dataUrl['date'] = $date_data; - $this->insertGetId($dataUrl); + $model = new self(); + $model->url = $url; + $model->pv = 1; + $model->title = $title; + $model->date = $date_data; + $model->save(); } } diff --git a/app/index/controller/Base.php b/app/index/controller/Base.php index 112760a..b1911b7 100644 --- a/app/index/controller/Base.php +++ b/app/index/controller/Base.php @@ -30,12 +30,10 @@ class Base extends BaseController protected function initialize() { parent::initialize(); - $this->userInfo = Session::get(Data::SESSION_KEY_USER_INFO); $this->userId = Session::get(Data::SESSION_KEY_USER_ID); - - if ($this->userId){ + if (!empty($this->userId)){ //模板兼容性标签 - $this->assign('user_info', $this->userInfo); + $this->assign('user_info', Session::get(Data::SESSION_KEY_USER_INFO)); $this->assign('user_id', $this->userId); } //判断是否关闭站点。 diff --git a/public/template/default/pc/index/index.html b/public/template/default/pc/index/index.html index 5f75e15..714a097 100644 --- a/public/template/default/pc/index/index.html +++ b/public/template/default/pc/index/index.html @@ -124,7 +124,7 @@