Skip to content

Commit

Permalink
Merge pull request #8 from Comsenz/site-open-admin
Browse files Browse the repository at this point in the history
修改判断小程序客户端
  • Loading branch information
ahuchjm authored Nov 11, 2020
2 parents aff0780 + 27e6e67 commit d2f10c9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Common/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ class Utils
*/
public static function requestFrom()
{
$server = $_SERVER;
if (strstr(strtolower($server['HTTP_USER_AGENT']), 'miniprogram')) {
$request = app('request');
$headers = $request->getHeaders();
$server = $request->getServerParams();
$headersStr = strtolower(json_encode($headers, 256));
$serverStr = strtolower(json_encode($server, 256));
if (strstr($server['HTTP_USER_AGENT'], 'miniprogram') || strstr($headersStr['X-App-Platform'], 'miniprogram')) {
return PubEnum::MinProgram;
}
if (isset($server['X-App-Platform'])) {
if (strstr(strtolower($server['X-App-Platform']), 'miniprogram')) {
return PubEnum::MinProgram;
}
}
app('log')->info('get_request_from_for_test_' . json_encode(['headers' => $headers, 'server' => $server], 256));
$requestFrom = PubEnum::PC;
// 如果有HTTP_X_WAP_PROFILE则一定是移动设备
if (isset($server['HTTP_X_WAP_PROFILE'])) {
Expand Down

0 comments on commit d2f10c9

Please sign in to comment.