Merge branch 'feature/mzl-dev'
This commit is contained in:
@@ -7,6 +7,47 @@
|
||||
<title>frontend</title>
|
||||
<!-- 飞书扫码登录 SDK -->
|
||||
<script src="https://lf-package-cn.feishucdn.com/obj/feishu-static/lark/passport/qrcode/LarkSSOSDKWebQRCode-1.0.3.js"></script>
|
||||
<!-- 飞书 H5 JSBridge SDK(多 CDN 备用) -->
|
||||
<script>
|
||||
// 尝试加载飞书 JSBridge,如果失败则尝试其他 CDN
|
||||
var scripts = [
|
||||
'https://lf1-cdn-tos.bytegoofy.com/goofy/lark/passport/h5-jsbridge-1.0.3.js',
|
||||
'https://lf9-cn.feishucdn.com/obj/lark/passport/h5-jsbridge-1.0.3.js'
|
||||
];
|
||||
|
||||
function loadScript(url) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var script = document.createElement('script');
|
||||
script.src = url;
|
||||
script.onload = function() { console.log('JSBridge loaded from:', url); resolve(); };
|
||||
script.onerror = function() { reject(url); };
|
||||
document.head.appendChild(script);
|
||||
});
|
||||
}
|
||||
|
||||
// 按顺序尝试加载 JSBridge
|
||||
function loadJSBridge() {
|
||||
var index = 0;
|
||||
function tryNext() {
|
||||
if (index < scripts.length) {
|
||||
loadScript(scripts[index])
|
||||
.catch(function() {
|
||||
console.warn('JSBridge load failed:', scripts[index]);
|
||||
index++;
|
||||
tryNext();
|
||||
});
|
||||
} else {
|
||||
console.error('All JSBridge CDNs failed');
|
||||
}
|
||||
}
|
||||
tryNext();
|
||||
}
|
||||
|
||||
// 页面加载后尝试加载 JSBridge
|
||||
if (navigator.userAgent.includes('Lark') || navigator.userAgent.includes('feishu')) {
|
||||
loadJSBridge();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -110,11 +110,20 @@ export default function Login() {
|
||||
setEnvironment('feishu')
|
||||
handleFeishuAutoLogin()
|
||||
} else if (isInFeishu) {
|
||||
// 飞书内但 tt 对象不可用:自动显示二维码登录
|
||||
console.log('⚠️ 在飞书内但 tt 对象不可用,使用二维码登录')
|
||||
setEnvironment('external')
|
||||
// 飞书内环境,等待 tt 对象加载后尝试免登
|
||||
console.log('⏳ 在飞书内环境,等待 tt 对象加载...')
|
||||
setEnvironment('feishu')
|
||||
setLoading(false)
|
||||
setShowQRCode(true)
|
||||
// 给 tt 对象一些时间来加载(最多 2 秒)
|
||||
setTimeout(() => {
|
||||
if (window.tt) {
|
||||
console.log('✅ tt 对象已加载,开始免登')
|
||||
handleFeishuAutoLogin()
|
||||
} else {
|
||||
console.log('⚠️ tt 对象仍未加载,显示二维码登录')
|
||||
setShowQRCode(true)
|
||||
}
|
||||
}, 2000)
|
||||
} else {
|
||||
// 飞书外:显示登录选项
|
||||
console.log('📱 飞书外环境,显示登录选项')
|
||||
|
||||
Reference in New Issue
Block a user