作者 邓超

v2

... ... @@ -40,9 +40,9 @@ class Base {
// 缓存
$cacheKey = md5($url.':'.json_encode($data));
if(Cache::has($cacheKey)){
return Cache::get($cacheKey);
}
// if(Cache::has($cacheKey)){
// return Cache::get($cacheKey);
// }
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
... ... @@ -59,7 +59,7 @@ class Base {
$a = json_decode($a,true);
// 缓存1小时
Cache::set($cacheKey,$a['data']??[],3600);
Cache::set($cacheKey,$a['data']??[],empty($a['data'])?120:3600);
return $a['data']??[];
}
... ...
... ... @@ -79,11 +79,12 @@ class Index extends Base
*/
public function page($key){
$page = $this->getData('page',['urlkey'=>$key]);
if(!$page){
return redirect('/');
}
return response($page,200,['Content-Type'=>'text/html charset=urt-8;']);
return response($page,200,['Content-Type'=>'text/html;charset=urt-8;']);
}
... ...
... ... @@ -66,5 +66,7 @@ Route::get('/blogs', [\App\Http\Controllers\V2\Index::class,'blog']);
Route::get('/blog/{id}', [\App\Http\Controllers\V2\Index::class,'blog_info'])->where('id','\d+');
// 单页
Route::get('/page/{key}', [\App\Http\Controllers\V2\Index::class,'page'])->where('key','[a-z_\-\d]{2,}');
// 单页的另一种方式
Route::get('/{key}', [\App\Http\Controllers\V2\Index::class,'page'])->where('key','[a-z_\-\d]{2,}');
... ...