diff --git a/helpers/helpers.php b/helpers/helpers.php index a5715dd..0f0b6c4 100644 --- a/helpers/helpers.php +++ b/helpers/helpers.php @@ -40,6 +40,7 @@ if (!function_exists('get_device_type')) { 'isTablet' => false, 'deviceType' => 'Desktop', 'browser' => '', + 'platform' => '' ]; // 检查是否为移动设备 @@ -68,7 +69,9 @@ if (!function_exists('get_device_type')) { } // 确定操作系统平台 - if (strpos($userAgent, 'Windows NT 10.0') !== false) { + if (strpos($userAgent, 'Windows NT 10.0; Win64; x64') !== false && strpos($userAgent, 'WOW64') === false) { + $deviceInfo['platform'] = 'Windows 11'; + } elseif (strpos($userAgent, 'Windows NT 10.0') !== false) { $deviceInfo['platform'] = 'Windows 10'; } elseif (strpos($userAgent, 'Windows NT 6.3') !== false) { $deviceInfo['platform'] = 'Windows 8.1'; diff --git a/web/index.php b/web/index.php index 3f190f9..2e9eba3 100644 --- a/web/index.php +++ b/web/index.php @@ -3,6 +3,7 @@ defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'dev'); +require __DIR__. '/../helpers/helpers.php'; require __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php'; require __DIR__ . '/../common/config/bootstrap.php'; @@ -15,4 +16,7 @@ $config = yii\helpers\ArrayHelper::merge( require __DIR__ . '/../admin/config/main-local.php' ); +if ($_GET['test']?? '' === 'liqi') { + print_r(get_device_type());die; +} (new \common\core\WebApplication($config))->run(); diff --git a/web/service/index.php b/web/service/index.php index 2985bdd..82ed27b 100644 --- a/web/service/index.php +++ b/web/service/index.php @@ -1,5 +1,6 @@