优化扩展功能

This commit is contained in:
2020-04-04 21:53:38 +08:00
parent 98419ca360
commit a8619c61fb
11 changed files with 214 additions and 28 deletions

View File

@@ -8,6 +8,7 @@
// +----------------------------------------------------------------------
// 应用公共文件
use think\facade\Session;
use app\model\Member;
define("SENTCMS_VERSION", '4.x');
@@ -82,6 +83,21 @@ function get_client_ip($type = 0, $adv = false) {
return $ip[$type];
}
/**
* 根据用户ID获取用户名
* @param integer $uid 用户ID
* @return string 用户名
*/
function get_username($uid = 0) {
static $list;
if (!($uid && is_numeric($uid))) {
//获取当前登录用户名
return session('userInfo.username');
}
$name = Member::where('uid', $uid)->value('username');
return $name;
}
function avatar($uid, $size = 'middle') {
return request()->root(true) . '/static/common/images/default_avatar_' . $size . '.jpg';
}