正在显示
3 个修改的文件
包含
8 行增加
和
5 行删除
| @@ -40,9 +40,9 @@ class Base { | @@ -40,9 +40,9 @@ class Base { | ||
| 40 | 40 | ||
| 41 | // 缓存 | 41 | // 缓存 | 
| 42 | $cacheKey = md5($url.':'.json_encode($data)); | 42 | $cacheKey = md5($url.':'.json_encode($data)); | 
| 43 | - if(Cache::has($cacheKey)){ | ||
| 44 | - return Cache::get($cacheKey); | ||
| 45 | - } | 43 | +// if(Cache::has($cacheKey)){ | 
| 44 | +// return Cache::get($cacheKey); | ||
| 45 | +// } | ||
| 46 | 46 | ||
| 47 | $ch = curl_init(); | 47 | $ch = curl_init(); | 
| 48 | curl_setopt($ch, CURLOPT_TIMEOUT, 30); | 48 | curl_setopt($ch, CURLOPT_TIMEOUT, 30); | 
| @@ -59,7 +59,7 @@ class Base { | @@ -59,7 +59,7 @@ class Base { | ||
| 59 | $a = json_decode($a,true); | 59 | $a = json_decode($a,true); | 
| 60 | 60 | ||
| 61 | // 缓存1小时 | 61 | // 缓存1小时 | 
| 62 | - Cache::set($cacheKey,$a['data']??[],3600); | 62 | + Cache::set($cacheKey,$a['data']??[],empty($a['data'])?120:3600); | 
| 63 | 63 | ||
| 64 | return $a['data']??[]; | 64 | return $a['data']??[]; | 
| 65 | } | 65 | } | 
| @@ -79,11 +79,12 @@ class Index extends Base | @@ -79,11 +79,12 @@ class Index extends Base | ||
| 79 | */ | 79 | */ | 
| 80 | public function page($key){ | 80 | public function page($key){ | 
| 81 | $page = $this->getData('page',['urlkey'=>$key]); | 81 | $page = $this->getData('page',['urlkey'=>$key]); | 
| 82 | + | ||
| 82 | if(!$page){ | 83 | if(!$page){ | 
| 83 | return redirect('/'); | 84 | return redirect('/'); | 
| 84 | } | 85 | } | 
| 85 | 86 | ||
| 86 | - return response($page,200,['Content-Type'=>'text/html charset=urt-8;']); | 87 | + return response($page,200,['Content-Type'=>'text/html;charset=urt-8;']); | 
| 87 | } | 88 | } | 
| 88 | 89 | ||
| 89 | 90 | 
| @@ -66,5 +66,7 @@ Route::get('/blogs', [\App\Http\Controllers\V2\Index::class,'blog']); | @@ -66,5 +66,7 @@ Route::get('/blogs', [\App\Http\Controllers\V2\Index::class,'blog']); | ||
| 66 | Route::get('/blog/{id}', [\App\Http\Controllers\V2\Index::class,'blog_info'])->where('id','\d+'); | 66 | Route::get('/blog/{id}', [\App\Http\Controllers\V2\Index::class,'blog_info'])->where('id','\d+'); | 
| 67 | // 单页 | 67 | // 单页 | 
| 68 | Route::get('/page/{key}', [\App\Http\Controllers\V2\Index::class,'page'])->where('key','[a-z_\-\d]{2,}'); | 68 | Route::get('/page/{key}', [\App\Http\Controllers\V2\Index::class,'page'])->where('key','[a-z_\-\d]{2,}'); | 
| 69 | +// 单页的另一种方式 | ||
| 70 | +Route::get('/{key}', [\App\Http\Controllers\V2\Index::class,'page'])->where('key','[a-z_\-\d]{2,}'); | ||
| 69 | 71 | ||
| 70 | 72 | 
- 
请 注册 或 登录 后发表评论