fix: 修复飞书免登功能,添加 H5 JSSDK 和 appId 自动获取

后端改动:
- 新增 /api/v1/auth/feishu-config 接口,根据 company 参数返回对应 appId

前端改动:
- 添加飞书 H5 JSSDK (h5-js-sdk-1.5.19.js)
- 修改登录页免登逻辑:先从后端获取 appId,再调用 tt.requestAuthCode
- 新增飞书环境检测测试页面 (/feishu-env-test)
- 移除测试页面的自动轮询逻辑

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-02-28 08:58:51 +08:00
parent 4c3b750884
commit 4667590feb
7 changed files with 1035 additions and 35 deletions
+43
View File
@@ -560,4 +560,47 @@ HTML;
return $this->error($e->getMessage());
}
}
/**
* 获取飞书配置(用于前端免登)
* 根据 company 参数返回对应的 appId
*/
public function feishuConfig(Request $request): Response
{
$companyParam = $request->get('company');
if (!$companyParam) {
return $this->error('缺少 company 参数');
}
try {
// company 参数是 company_id
$company = \app\model\Company::find($companyParam);
if (!$company) {
return $this->error('公司不存在');
}
$companyId = $company->id;
// 获取该公司的默认飞书应用
$feishuApp = \app\model\CompanyFeishuApp::where('company_id', $companyId)
->where('system_id', 1)
->where('status', 1)
->first();
if (!$feishuApp) {
return $this->error('该公司未配置飞书应用');
}
error_log("✅ feishuConfig - company_id={$companyId}, app_id={$feishuApp->app_id}");
return $this->success([
'app_id' => $feishuApp->app_id,
'company_id' => $companyId,
]);
} catch (\Exception $e) {
error_log("❌ feishuConfig 失败: " . $e->getMessage());
return $this->error($e->getMessage());
}
}
}