mirror of
https://github.com/acepanel/panel.git
synced 2026-02-06 16:08:44 +08:00
特性(主页):新增检查更新
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Models\Plugin;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class InfosController extends Controller
|
||||
{
|
||||
@@ -293,4 +294,33 @@ class InfosController extends Controller
|
||||
);
|
||||
return response()->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查更新
|
||||
*/
|
||||
public function checkUpdate(): JsonResponse
|
||||
{
|
||||
$version = config('panel.version');
|
||||
$remoteVersion = Http::get('https://api.panel.haozi.xyz/api/version/info')->json();
|
||||
|
||||
if ($remoteVersion['code'] != 0) {
|
||||
$res['code'] = 1;
|
||||
$res['msg'] = '获取远程版本信息失败';
|
||||
$res['data'] = [];
|
||||
return response()->json($res);
|
||||
}
|
||||
|
||||
$res['code'] = 0;
|
||||
$res['msg'] = 'success';
|
||||
if (version_compare($version, $remoteVersion['data']['version'], '<')) {
|
||||
$res['data'] = [
|
||||
'version' => $remoteVersion['data']['version'],
|
||||
'describe' => $remoteVersion['data']['describe'],
|
||||
];
|
||||
} else {
|
||||
$res['data'] = [];
|
||||
}
|
||||
|
||||
return response()->json($res);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user