77use ba \Exception ;
88use ba \Filesystem ;
99use think \facade \Db ;
10- use GuzzleHttp \Client ;
1110use FilesystemIterator ;
1211use think \facade \Config ;
1312use RecursiveIteratorIterator ;
2120 */
2221class Server
2322{
24- private static ?Client $ client = null ;
25-
2623 private static string $ apiBaseUrl = '/api/v6.store/ ' ;
2724
2825 /**
@@ -33,7 +30,7 @@ public static function download(string $uid, string $dir, array $extend = []): s
3330 {
3431 $ tmpFile = $ dir . $ uid . ".zip " ;
3532 try {
36- $ client = self :: getClient ();
33+ $ client = get_ba_client ();
3734 $ response = $ client ->get (self ::$ apiBaseUrl . 'download ' , ['query ' => array_merge (['uid ' => $ uid , 'server ' => 1 ], $ extend )]);
3835 $ body = $ response ->getBody ();
3936 $ content = $ body ->getContents ();
@@ -63,7 +60,7 @@ public static function download(string $uid, string $dir, array $extend = []): s
6360 public static function installPreCheck (array $ query = []): bool
6461 {
6562 try {
66- $ client = self :: getClient ();
63+ $ client = get_ba_client ();
6764 $ response = $ client ->get (self ::$ apiBaseUrl . 'preCheck ' , ['query ' => $ query ]);
6865 $ body = $ response ->getBody ();
6966 $ statusCode = $ response ->getStatusCode ();
@@ -560,28 +557,4 @@ public static function getRuntime(string $dir, string $key = ''): mixed
560557 return $ runtimeContentArr ;
561558 }
562559 }
563-
564- /**
565- * 获取请求对象
566- * @return Client
567- */
568- protected static function getClient (): Client
569- {
570- $ options = [
571- 'base_uri ' => Config::get ('buildadmin.api_url ' ),
572- 'timeout ' => 30 ,
573- 'connect_timeout ' => 30 ,
574- 'verify ' => false ,
575- 'http_errors ' => false ,
576- 'headers ' => [
577- 'X-REQUESTED-WITH ' => 'XMLHttpRequest ' ,
578- 'Referer ' => dirname (request ()->root (true )),
579- 'User-Agent ' => 'BuildAdminClient ' ,
580- ]
581- ];
582- if (is_null (self ::$ client )) {
583- self ::$ client = new Client ($ options );
584- }
585- return self ::$ client ;
586- }
587560}
0 commit comments