我是用飞书授权的,飞书内打开应用,能授权但是授权完就关闭窗口了,无法进入应用。
而普通手机浏览器无法使用SDK,也没有提示。
建议修改frontend/src/views/mobile/sign/login/index.tsx
import { useState } from 'react'
import { useSearchParams } from 'react-router'
import { Button, Image, Tag, Typography } from 'antd'
import { apiBase as api } from '@/api'
import { getCode, loadSDK } from '@/const/channel/sdk'
import appHelper from '@/utils/appHelper'
import useInfo from '@/views/desktop/sign/login/useInfo'
import './index.less'
const Component = () => {
const { t } = appHelper.lang.use()
const [search] = useSearchParams()
const qKey = search.get('key') || ''
const [error, setError] = useState({ title: '', content: '' })
const [loading, setLoading] = useState(false)
const [noSDK, setNoSDK] = useState(false)
const { info } = useInfo({
key: qKey,
onBefore: async () => {
const sdk = await loadSDK()
setNoSDK(sdk.type === 0)
},
onError: (title, content) => {
setError({ title, content })
},
})
const handleAuth = async () => {
if (!info || !qKey) return
setLoading(true)
try {
const { type, code } = await getCode(info, qKey)
if (code) {
const callbackUrl = await api.post('/server/login', { key: qKey, type, code })
if (callbackUrl) {
window.location.replace(callbackUrl)
return
}
}
} catch {
// error already shown by api interceptor
} finally {
setLoading(false)
}
}
return (
{error.title ? (
) : (
<>
{info && qKey ? (
{t('获取账户信息,请勿扫描他人二维码')}
<div className="app">
<div className="logo">
<Image className="i" src={info.app.picture} preview={false}></Image>
</div>
<div className="title">
<div className="t">{info.app.name}</div>
<Tag>{info.app.entry}</Tag>
</div>
<Typography.Paragraph ellipsis={{ rows: 3 }} className="content">
{info.app.desc}
</Typography.Paragraph>
</div>
<div className="confirm">
{noSDK ? (
<div className="hint" style={{ color: '#999', fontSize: 14, textAlign: 'center', padding: '12px 0' }}>
{t('请在飞书 / 钉钉客户端内打开此页面进行授权')}
</div>
) : (
<Button className="btn" loading={loading} onClick={handleAuth}>
{t('确认授权')}
</Button>
)}
</div>
</div>
) : (
<></>
)}
</>
)}
</div>
)
}
export default Component
我是用飞书授权的,飞书内打开应用,能授权但是授权完就关闭窗口了,无法进入应用。
而普通手机浏览器无法使用SDK,也没有提示。
建议修改frontend/src/views/mobile/sign/login/index.tsx
import { useState } from 'react'
import { useSearchParams } from 'react-router'
import { Button, Image, Tag, Typography } from 'antd'
import { apiBase as api } from '@/api'
import { getCode, loadSDK } from '@/const/channel/sdk'
import appHelper from '@/utils/appHelper'
import useInfo from '@/views/desktop/sign/login/useInfo'
import './index.less'
const Component = () => {
const { t } = appHelper.lang.use()
const [search] = useSearchParams()
const qKey = search.get('key') || ''
const [error, setError] = useState({ title: '', content: '' })
const [loading, setLoading] = useState(false)
const [noSDK, setNoSDK] = useState(false)
const { info } = useInfo({
key: qKey,
onBefore: async () => {
const sdk = await loadSDK()
setNoSDK(sdk.type === 0)
},
onError: (title, content) => {
setError({ title, content })
},
})
const handleAuth = async () => {
if (!info || !qKey) return
setLoading(true)
try {
const { type, code } = await getCode(info, qKey)
if (code) {
const callbackUrl = await api.post('/server/login', { key: qKey, type, code })
if (callbackUrl) {
window.location.replace(callbackUrl)
return
}
}
} catch {
// error already shown by api interceptor
} finally {
setLoading(false)
}
}
return (
{error.title ? (
) : (
<>
{info && qKey ? (
)
}
export default Component