优化数据

This commit is contained in:
kuaifan
2023-03-16 21:50:21 +08:00
parent c6d874ad59
commit 0e0604570e
3 changed files with 26 additions and 8 deletions

View File

@@ -2044,6 +2044,27 @@ class Base
}
}
/**
* 获取平台类型
* @return string
*/
public static function platform()
{
$platform = strtolower(trim(Request::header('platform')));
if (in_array($platform, ['android', 'ios', 'win', 'mac', 'web'])) {
return $platform;
}
$agent = strtolower(Request::server('HTTP_USER_AGENT'));
if (str_contains($agent, 'android')) {
$platform = 'android';
} elseif (str_contains($agent, 'iphone') || str_contains($agent, 'ipad')) {
$platform = 'ios';
} else {
$platform = 'unknown';
}
return $platform;
}
/**
* 返回根据距离sql排序语句
* @param $lat