From 07a08b9e1550fc3c2ed8d7882a7516adbce7e875 Mon Sep 17 00:00:00 2001 From: lq Date: Tue, 3 Dec 2024 16:48:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95=E8=BE=85?= =?UTF-8?q?=E5=8A=A9=E5=87=BD=E6=95=B0=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helpers/helpers.php | 5 ++++- web/index.php | 4 ++++ web/service/index.php | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) 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 @@