feat: 飞书登录支持多租户和用户工号管理

后端改动:
- FeishuService: 从飞书用户信息获取 tenant_key 和手机号
- FeishuService: 新增 user_sn 表工号分配机制
- FeishuService: 优先使用 enterprise_email,支持手机号
- AuthController: 飞书免登支持 company 参数

前端改动:
- FeishuAutoLogin: 支持多租户 company 参数
- login/index: 支持 redirect 参数和已登录检测
- QRCodeLogin: 支持多租户参数传递
- router: 新增路由守卫和参数处理
- api.ts: 优化飞书登录 API 调用

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-02-27 17:57:49 +08:00
parent b1895be50d
commit b1ca2c58b7
8 changed files with 241 additions and 41 deletions
+27 -3
View File
@@ -92,13 +92,37 @@ export default function QRCodeLogin({ visible, onClose }: QRCodeLoginProps) {
console.log('🔍 window.QRLogin:', !!window.QRLogin)
// 从 URL 获取 company 参数(支持两种方式:直接参数或从 redirect 中提取)
const urlParams = new URLSearchParams(window.location.search)
let companyParam = urlParams.get('company')
// 如果当前 URL 没有 company,尝试从 redirect 参数中获取
if (!companyParam) {
const redirect = urlParams.get('redirect')
if (redirect) {
try {
const redirectUrl = new URL(redirect, window.location.origin)
companyParam = redirectUrl.searchParams.get('company')
console.log('🔍 从 redirect URL 中提取的 company 参数:', companyParam)
} catch (e) {
console.log('⚠️ 无法解析 redirect URL:', redirect)
}
}
}
console.log('🔍 最终使用的 company 参数:', companyParam)
// 生成登录会话
const requestBody: any = {}
if (companyParam) {
// 如果有 company 参数,传递给后端
requestBody.company = companyParam
}
const response = await fetch('/api/v1/auth/qrcode-login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
tenant_key: '14e7bc0fe5985740',
}),
body: JSON.stringify(requestBody),
})
const result = await response.json()