增加访问记录功能

This commit is contained in:
2023-06-28 11:12:30 +08:00
parent a12cca37e4
commit 65e1800c6f
18 changed files with 447 additions and 98 deletions

44
app/model/PostVisit.php Normal file
View File

@@ -0,0 +1,44 @@
<?php
declare (strict_types=1);
namespace app\model;
use think\Model;
/**
* @mixin \think\Model
*/
class PostVisit extends Model
{
//
public function getAvatarSrcAttr()
{
$value = $this->getAttr('avatar');
if(empty($value)) {
$value = '/static/images/avatar.png';
}
return $value;
}
public function getNicknameTitleAttr()
{
$value = $this->getAttr('nickname');
if(empty($value)) {
$value = 'IP用户:'.$this->getAttr('ip');
}
return $value;
}
public function getCreateTimeTitleAttr()
{
$value = $this->getData('create_time');
return show_time_ago($value);
}
}