正在显示
1 个修改的文件
包含
9 行增加
和
8 行删除
| @@ -307,27 +307,28 @@ class RankDataLogic extends BaseLogic | @@ -307,27 +307,28 @@ class RankDataLogic extends BaseLogic | ||
| 307 | 307 | ||
| 308 | /** | 308 | /** |
| 309 | * 获取AI站点项目 | 309 | * 获取AI站点项目 |
| 310 | + * | ||
| 310 | * @author zbj | 311 | * @author zbj |
| 311 | * @date 2023/5/12 | 312 | * @date 2023/5/12 |
| 312 | */ | 313 | */ |
| 313 | public function getAiProjects($domain = null) | 314 | public function getAiProjects($domain = null) |
| 314 | { | 315 | { |
| 315 | - $key = 'ai_projects_list'; | ||
| 316 | - $data = Cache::get($key); | ||
| 317 | - if (!$data) { | 316 | + $file_path = public_path('ai_domains.txt'); |
| 317 | + $update_time = filemtime($file_path); | ||
| 318 | + $data = file_get_contents($file_path); | ||
| 319 | + if (time() - $update_time > 4 * 3600) { | ||
| 318 | $api_url = 'https://demosite5.globalso.com/api/domain'; | 320 | $api_url = 'https://demosite5.globalso.com/api/domain'; |
| 319 | try { | 321 | try { |
| 320 | -// $data = HttpUtils::get($api_url, []); | ||
| 321 | - $data = file_get_contents(public_path('ai_domain.text')); | 322 | + $data = HttpUtils::get($api_url, []); |
| 322 | if ($data) { | 323 | if ($data) { |
| 323 | - $data = Arr::s2a($data); | ||
| 324 | - Cache::put($key, $data, 4 * 3600); | 324 | + file_put_contents($file_path, $data); |
| 325 | } | 325 | } |
| 326 | } catch (\Exception | GuzzleException $e) { | 326 | } catch (\Exception | GuzzleException $e) { |
| 327 | errorLog('AI站点项目获取失败', [], $e); | 327 | errorLog('AI站点项目获取失败', [], $e); |
| 328 | - return false; | 328 | + file_put_contents($file_path, $data); |
| 329 | } | 329 | } |
| 330 | } | 330 | } |
| 331 | + $data = json_decode($data, true); | ||
| 331 | if ($domain !== null) { | 332 | if ($domain !== null) { |
| 332 | $domain = parse_url($domain); | 333 | $domain = parse_url($domain); |
| 333 | $data = collect($data['data'])->where('bind_domain', $domain['host'] ?? $domain['path'])->first(); | 334 | $data = collect($data['data'])->where('bind_domain', $domain['host'] ?? $domain['path'])->first(); |
-
请 注册 或 登录 后发表评论