request->param('platform', 'all'); $version = VersionModel::mk()->getLatestVersion($platform); if (!$version) { $this->error('暂无版本信息'); } // 处理下载地址 $version['download_url'] = $this->getFullUrl($version['download_url']); $this->success('获取成功', $version); } /** * 检查更新 * @return void */ public function check() { $currentVersion = $this->request->param('version'); $platform = $this->request->param('platform', 'all'); if (empty($currentVersion)) { $this->error('请提供当前版本号'); } $result = VersionModel::mk()->checkUpdate($currentVersion, $platform); if (isset($result['error'])) { $this->error($result['error']); } // 如果有更新,处理下载地址 if ($result['has_update'] && isset($result['version_info'])) { $result['version_info']['download_url'] = $this->getFullUrl($result['version_info']['download_url']); } $this->success('检查完成', $result); } /** * 获取完整的下载地址 * @param string $path 相对路径 * @return string */ protected function getFullUrl($path) { return sysconf('site_domain') . $path; } }