From a8b2c11808b3a5fe15a26c9a895bd4e5a3846384 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 13 Jan 2026 17:24:14 +0800 Subject: [PATCH] =?UTF-8?q?pc=E7=AB=AF=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/AuthController.php | 2 +- app/common/logic/AuthLogic.php | 2 ++ app/common/service/AuthService.php | 4 ++-- app/common/utils/Feishu.php | 5 +++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/common/controller/AuthController.php b/app/common/controller/AuthController.php index a568b82..f85d520 100644 --- a/app/common/controller/AuthController.php +++ b/app/common/controller/AuthController.php @@ -32,7 +32,7 @@ class AuthController extends BaseController public function feishuScope(Request $request) { try { - $result = (new AuthService())->feishuAuthorize($request->get('app_id'), $request->system_code, $request->is_mob); + $result = (new AuthService())->feishuAuthorize($request->get('app_id'), $request->system_code, $request->get('is_pc','0')); return $this->success($result); } catch (\Throwable $e) { return $this->error($e->getMessage().$e->getLine().$e->getFile()); diff --git a/app/common/logic/AuthLogic.php b/app/common/logic/AuthLogic.php index da75795..4e9c0ac 100644 --- a/app/common/logic/AuthLogic.php +++ b/app/common/logic/AuthLogic.php @@ -314,10 +314,12 @@ class AuthLogic public function feishuAppInfo(string $app_id, string $systemCode='') { $fsAppInfo = CorpFeishuApp::where('app_id', $app_id)->first(); + return [ 'app_id' => $fsAppInfo->app_id, 'app_secret' => $fsAppInfo->app_secret, 'r_url' => $fsAppInfo->r_url, + 'm_url' => $fsAppInfo->m_url, 'scope' => $fsAppInfo->scopes, 'state' => $fsAppInfo->state, ]; diff --git a/app/common/service/AuthService.php b/app/common/service/AuthService.php index a6a352c..4d00200 100644 --- a/app/common/service/AuthService.php +++ b/app/common/service/AuthService.php @@ -13,12 +13,12 @@ class AuthService /** * 飞书授权 */ - public function feishuAuthorize(string $app_id, string $systemCcode, $mobile) + public function feishuAuthorize(string $app_id, string $systemCcode, $is_pc) { $logic = new AuthLogic(); $certificate = $logic->feishuAppInfo($app_id, $systemCcode); $feishu = new Feishu($certificate['app_id'], $certificate['app_secret'], 'xinyouhe'); - return ['auth_url' => $feishu->authorize($certificate, $mobile)]; + return ['auth_url' => $feishu->authorize($certificate, $is_pc)]; } /** diff --git a/app/common/utils/Feishu.php b/app/common/utils/Feishu.php index 39c9121..9673cea 100644 --- a/app/common/utils/Feishu.php +++ b/app/common/utils/Feishu.php @@ -92,11 +92,12 @@ class Feishu /** * 授权 */ - public function authorize($certificate,$mobile, $url = 'authen/v1/authorize') + public function authorize($certificate,$is_pc, $url = 'authen/v1/authorize') { + $redirect_uri = $is_pc==1?$certificate['r_url']:$certificate['m_url']; $arr = [ 'app_id' => $certificate['app_id'], - 'redirect_uri' => $certificate['r_url'], + 'redirect_uri' => $redirect_uri, 'scope' => $certificate['scope'], 'state' => $certificate['state'] ];