Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions frontend/packages/core/src/pages/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ const Login: FC = () => {
const code = query.get('code')
if (code) {
feishuLogin(code)
setSpinning(false)
return
}
if (isInFeishuClient() && feishu) {
openFeishuLogin()
}
setSpinning(false)
}
Expand Down Expand Up @@ -161,6 +166,21 @@ const Login: FC = () => {
fetchLogin({ username: 'guest', password: '12345678' })
}

const isInFeishuClient = () => {
// 方法1:检查User-Agent
const ua = navigator.userAgent.toLowerCase();
const isLark = ua.includes('lark') || ua.includes('feishu');

// 方法2:检查全局对象
const hasSDK = typeof window.h5sdk !== 'undefined' || typeof window.tt !== 'undefined';

// 方法3:检查URL参数
const params = new URLSearchParams(window.location.search);
const hasFeishuParams = params.has('from') || params.has('required_launch_ability');

return isLark || hasSDK || hasFeishuParams;
}

// 打开飞书授权页面
const openFeishuLogin = () => {
const href = window.location.origin + window.location.pathname
Expand Down