This commit is contained in:
@@ -10,6 +10,7 @@ import type { DingtalkSessionView } from './dingtalkSession'
|
||||
const finished = new Set(['success', 'expired', 'failed', 'closed'])
|
||||
|
||||
interface DingtalkSessionControlProps {
|
||||
triggerLabel?: string
|
||||
autoStart?: boolean
|
||||
hideTrigger?: boolean
|
||||
space?: string
|
||||
@@ -17,7 +18,7 @@ interface DingtalkSessionControlProps {
|
||||
onClose?: () => void
|
||||
}
|
||||
|
||||
export function DingtalkSessionControl({ autoStart = false, hideTrigger = false, space, onSuccess, onClose }: DingtalkSessionControlProps = {}) {
|
||||
export function DingtalkSessionControl({ autoStart = false, hideTrigger = false, space, onSuccess, onClose, triggerLabel = '扫码刷新会话' }: DingtalkSessionControlProps = {}) {
|
||||
const [session, setSession] = useState<DingtalkSessionView | null>(null)
|
||||
const [failure, setFailure] = useState<string | null>(null)
|
||||
const [starting, setStarting] = useState(false)
|
||||
@@ -89,7 +90,7 @@ export function DingtalkSessionControl({ autoStart = false, hideTrigger = false,
|
||||
|
||||
return <div className="dingtalk-session-control">
|
||||
{!hideTrigger ? <button className="secondary" disabled={starting || (session ? !finished.has(session.state) : false)} onClick={() => void start()}>
|
||||
{session && !finished.has(session.state) ? '扫码进行中…' : '扫码刷新会话'}
|
||||
{session && !finished.has(session.state) ? '扫码进行中…' : triggerLabel}
|
||||
</button> : null}
|
||||
{lastSuccess && !hideTrigger ? <p className="success-message" role="status">✅ 钉钉会话已刷新</p> : null}
|
||||
{failure && !open ? <p className="error-message" role="alert">{failure}</p> : null}
|
||||
|
||||
Reference in New Issue
Block a user