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:
@@ -11,22 +11,29 @@ const handleUnauthorized = () => {
|
||||
if (isLoggingOut) return
|
||||
isLoggingOut = true
|
||||
|
||||
// 保存当前页面信息,用于登录后跳转回来
|
||||
const currentUrl = window.location.pathname + window.location.search
|
||||
console.log('🚨 handleUnauthorized 被调用, currentUrl:', currentUrl)
|
||||
sessionStorage.setItem('redirect_after_login', currentUrl)
|
||||
|
||||
// 清除本地存储
|
||||
localStorage.removeItem('token')
|
||||
localStorage.removeItem('user-storage')
|
||||
|
||||
// 显示提示
|
||||
Toast.show({
|
||||
content: '登录已过期,请重新登录',
|
||||
duration: 2000,
|
||||
content: '请先登录',
|
||||
duration: 1500,
|
||||
})
|
||||
|
||||
// 延迟跳转,确保提示显示
|
||||
setTimeout(() => {
|
||||
isLoggingOut = false
|
||||
// 跳转到登录页,并清除历史记录
|
||||
window.location.href = '/login'
|
||||
}, 2000)
|
||||
const redirectUrl = '/login?redirect=' + encodeURIComponent(currentUrl)
|
||||
console.log('🚨 准备跳转到登录页, redirectUrl:', redirectUrl)
|
||||
// 跳转到登录页,带上 redirect 参数
|
||||
window.location.href = redirectUrl
|
||||
}, 500)
|
||||
}
|
||||
|
||||
// 创建 axios 实例
|
||||
@@ -82,19 +89,17 @@ export const authApi = {
|
||||
login: (username: string, password: string) =>
|
||||
api.post('/auth/login', { username, password }),
|
||||
|
||||
// 飞书免登(支持 app_id 或 tenant_key)
|
||||
feishuLogin: (authCode: string, options?: { appId?: string; tenantKey?: string }) =>
|
||||
// 飞书免登(支持 app_id、tenant_key 或 company)
|
||||
feishuLogin: (authCode: string, company?: string) =>
|
||||
api.post('/auth/feishu-login', {
|
||||
auth_code: authCode,
|
||||
app_id: options?.appId,
|
||||
tenant_key: options?.tenantKey,
|
||||
company: company,
|
||||
}),
|
||||
|
||||
// 生成二维码登录会话
|
||||
qrcodeLogin: (appId?: string, tenantKey?: string) =>
|
||||
qrcodeLogin: (company?: string) =>
|
||||
api.post('/auth/qrcode-login', {
|
||||
app_id: appId,
|
||||
tenant_key: tenantKey,
|
||||
company: company,
|
||||
}),
|
||||
|
||||
// 轮询二维码登录状态
|
||||
|
||||
Reference in New Issue
Block a user