优化IP显示

This commit is contained in:
2023-06-28 11:23:31 +08:00
parent 95d80fe568
commit b106f99c91

View File

@@ -4,6 +4,7 @@ declare (strict_types=1);
namespace app\model;
use think\facade\Request;
use think\Model;
/**
@@ -29,7 +30,15 @@ class PostVisit extends Model
$value = $this->getAttr('nickname');
if (empty($value)) {
$value = 'IP用户:'.$this->getAttr('ip');
$current_ip = Request::ip();
$ip = $this->getAttr('ip');
if ($current_ip == $ip) {
$value = '您的IP:' . $ip;
} else {
$value = 'IP用户:' . $ip;
}
}
return $value;