diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index 9ad145b5..4003940b 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -1543,49 +1543,25 @@ class Auth extends BaseController //获取app版本更新信息 public function appVersion() { - $brandArray = [ - 'huawei', - 'honor', - 'iphone', - 'samsung', - 'xiaomi', - 'redmi', - 'mi', - 'oppo', - 'vivo', - 'nokia', - 'meizu', - 'moto' - ]; - Log::info("请求版本参数:" . json_encode(request()->param())); $type = $this->request->param('type', '-1'); - $version = $this->request->param('version', ''); - $phoneBrand = $this->request->param('phone_brand', ''); - $queryBuilder = Db::name('AppUpdate')->where('type', $type); + // $version = $this->request->param('version', ''); + // $phoneBrand = $this->request->param('phone_brand', ''); + // $queryBuilder = Db::name('AppUpdate')->where('type', $type); if ($type == 3) { $android = (Db::name('AppUpdate')->where('type', 1)->where('phone_brand', '')->order('id', 'desc')->find()) ?? (object)[]; $ios = (Db::name('AppUpdate')->where('type', 2)->where('phone_brand', '')->order('id', 'desc')->find()) ?? (object)[]; return app('json')->success(compact('android', 'ios')); } else { - if ($version) { - $queryBuilder = $queryBuilder->where('version', '>', $version); - } - if ($phoneBrand) { - $spos = false; - foreach ($brandArray as $b) { - $pos = stripos($phoneBrand, $b); - if ($pos !== false) { - $spos = true; - $queryBuilder = $queryBuilder->where('phone_brand', $b); - } - } - if ($spos === false) { - $queryBuilder = $queryBuilder->where('phone_brand', ''); - } - } - $appInfo = $queryBuilder->order('version', 'desc')->fetchSql(false)->find(); - if (empty($appInfo)) { - $appInfo = (Db::name('AppUpdate')->where('type', $type)->where('version', '>', $version)->find()) ?? (object)[]; + $agent = strtolower($_SERVER['HTTP_USER_AGENT']); + // 检查是否为iOS设备,包括iPhone和iPad + if (strpos($agent, 'iphone') !== false || strpos($agent, 'ipad') !== false) { + $appInfo=[]; + } elseif (strpos($agent, 'android') !== false) { + // 检查是否为Android设备 + $appInfo = Db::name('AppUpdate')->where('type', $type)->order('id','desc')->find(); + } else { + $appInfo=[]; + // 如果都不是,则输出其他 } }