Allow browsing before mini login
This commit is contained in:
@@ -10,6 +10,7 @@ export default function Chat() {
|
||||
const systemBanner = useSystemBanner()
|
||||
const [conversations, setConversations] = useState<ChatConversation[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [isGuest, setIsGuest] = useState(false)
|
||||
|
||||
useDidShow(() => {
|
||||
void loadConversations()
|
||||
@@ -17,10 +18,13 @@ export default function Chat() {
|
||||
|
||||
const loadConversations = async () => {
|
||||
if (!getToken()) {
|
||||
Taro.reLaunch({ url: '/pages/login/index' })
|
||||
setConversations([])
|
||||
setIsGuest(true)
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
setIsGuest(false)
|
||||
setLoading(true)
|
||||
try {
|
||||
const data = await getConversations()
|
||||
@@ -55,13 +59,27 @@ export default function Chat() {
|
||||
})
|
||||
}
|
||||
|
||||
const handleGuestLogin = () => {
|
||||
Taro.setStorageSync('postLoginRedirect', '/pages/chat/index')
|
||||
Taro.navigateTo({ url: '/pages/login/index' })
|
||||
}
|
||||
|
||||
return (
|
||||
<View className='chat-page'>
|
||||
<View className='page-header'>
|
||||
<Text className='page-title'>玩伴</Text>
|
||||
</View>
|
||||
|
||||
{loading ? (
|
||||
{isGuest ? (
|
||||
<View className='guest-card'>
|
||||
<Text className='guest-card-icon'>💬</Text>
|
||||
<Text className='guest-card-title'>亲子互动会话</Text>
|
||||
<Text className='guest-card-desc'>绑定设备后,可以在这里查看孩子、家长和 AI 玩伴之间的消息记录。</Text>
|
||||
<View className='guest-card-btn' onClick={handleGuestLogin}>
|
||||
<Text className='guest-card-btn-text'>登录后查看</Text>
|
||||
</View>
|
||||
</View>
|
||||
) : loading ? (
|
||||
<View className='loading'>
|
||||
<Text>加载中...</Text>
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user