初始化项目:添加后端代码、ThinkPHP框架、前端资源
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\library;
|
||||
|
||||
use think\Config;
|
||||
class Platform
|
||||
{
|
||||
/**
|
||||
* 获取请求来源平台
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getPlatform(){
|
||||
|
||||
$platform = trim((string)\think\Request::instance()->header('platform'));
|
||||
$platformMap = [
|
||||
'h5' => 'H5',
|
||||
'pc' => 'Pc',
|
||||
'app' => 'App',
|
||||
'wxminiprogram' => 'wxMiniProgram',
|
||||
'wxofficialaccount' => 'wxOfficialAccount',
|
||||
'dyminiprogram' => 'dyMiniProgram',
|
||||
'channels' => 'channels',
|
||||
];
|
||||
$key = strtolower($platform);
|
||||
|
||||
return isset($platformMap[$key]) ? $platformMap[$key] : $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备终端
|
||||
* @return string
|
||||
*/
|
||||
public static function getDeviceEnd(){
|
||||
if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
|
||||
return 'ios';
|
||||
}else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android')){
|
||||
return 'android';
|
||||
}else{
|
||||
return 'other';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取系统类型 独立版 or 微擎版
|
||||
* @return void
|
||||
*/
|
||||
public static function getSystemType(){
|
||||
if(defined('TUZHI_SYSTEM_TYPE') && TUZHI_SYSTEM_TYPE == 'single'){
|
||||
return 'single';
|
||||
}
|
||||
|
||||
return 'w7';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user