mirror of https://gitee.com/karson/fastadmin.git
优化代码
parent
9f2c08414a
commit
0a5484b738
|
|
@ -121,7 +121,7 @@ if (!function_exists('build_toolbar')) {
|
|||
$html = [];
|
||||
foreach ($btns as $k => $v) {
|
||||
//如果未定义或没有权限
|
||||
if (!isset($btnAttr[$v]) || ($v !== 'refresh' && !$auth->check("{$controller}/{$v}"))) {
|
||||
if (!isset($btnAttr[$v]) || ($v !== 'refresh' && !$auth->check("{$controller}/{$v}", $auth->id))) {
|
||||
continue;
|
||||
}
|
||||
list($href, $class, $icon, $text, $title) = $btnAttr[$v];
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ trait Backend
|
|||
}
|
||||
|
||||
//导入文件首行类型,默认是注释,如果需要使用字段名称请使用name
|
||||
$importHeadType = $this->importHeadType ?? 'comment';
|
||||
$importHeadType = isset($this->importHeadType) ? $this->importHeadType : 'comment';
|
||||
|
||||
$table = $this->model->getQuery()->getTable();
|
||||
$database = \think\Config::get('database.database');
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class UserGroup extends Model
|
|||
{
|
||||
$value = $value ? $value : $data['status'];
|
||||
$list = $this->getStatusList();
|
||||
return isset($list[$value]) ? $list[$value] : '';
|
||||
return $list[$value] ?? '';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class UserRule extends Model
|
|||
{
|
||||
$value = $value ? $value : $data['status'];
|
||||
$list = $this->getStatusList();
|
||||
return isset($list[$value]) ? $list[$value] : '';
|
||||
return $list[$value] ?? '';
|
||||
}
|
||||
|
||||
public static function getTreeList($selected = [])
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class Ems
|
|||
*
|
||||
* @param int $email 邮箱
|
||||
* @param string $event 事件
|
||||
* @return Ems
|
||||
* @return Ems|null
|
||||
*/
|
||||
public static function get($email, $event = 'default')
|
||||
{
|
||||
|
|
@ -36,7 +36,7 @@ class Ems
|
|||
->order('id', 'DESC')
|
||||
->find();
|
||||
Hook::listen('ems_get', $ems, null, true);
|
||||
return $ems ? $ems : null;
|
||||
return $ems ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class Sms
|
|||
->order('id', 'DESC')
|
||||
->find();
|
||||
Hook::listen('sms_get', $sms, null, true);
|
||||
return $sms ? $sms : null;
|
||||
return $sms ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ class Token
|
|||
/**
|
||||
* 清除Token
|
||||
* @access public
|
||||
* @param int user_id 会员ID
|
||||
* @param int $user_id 会员ID
|
||||
* @return boolean
|
||||
*/
|
||||
public static function clear($user_id = null)
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ class Upload
|
|||
$size = $matches ? $matches[1] : $this->config['maxsize'];
|
||||
$type = $matches ? strtolower($matches[2]) : 'b';
|
||||
$typeDict = ['b' => 0, 'k' => 1, 'kb' => 1, 'm' => 2, 'mb' => 2, 'gb' => 3, 'g' => 3];
|
||||
$size = $size * pow(1024, $typeDict[$type] ?? 0);
|
||||
$size = (int)($size * pow(1024, $typeDict[$type] ?? 0));
|
||||
if ($this->fileInfo['size'] > $size) {
|
||||
throw new UploadException(__(
|
||||
'File is too big (%sMiB), Max filesize: %sMiB.',
|
||||
|
|
|
|||
Loading…
Reference in New Issue