资料卡展示对话或用户 id

This commit is contained in:
CrescentLeaf
2025-11-23 00:42:12 +08:00
parent 02d6ee4102
commit 65602f09f2

View File

@@ -25,7 +25,7 @@ export default function ChatInfoDialog({ chat, chatInfoDialogRef, openChatFragme
setIsFavourited(sharedFavouriteChats.map((v) => v.id).indexOf(chat?.id || '') != -1) setIsFavourited(sharedFavouriteChats.map((v) => v.id).indexOf(chat?.id || '') != -1)
}) })
let userId: string | null = null const [userId, setUserId] = React.useState<string | null>(null)
useAsyncEffect(async () => { useAsyncEffect(async () => {
if (chat?.type == 'private') { if (chat?.type == 'private') {
const re = await Client.invoke("Chat.getAnotherUserIdFromPrivate", { const re = await Client.invoke("Chat.getAnotherUserIdFromPrivate", {
@@ -34,7 +34,7 @@ export default function ChatInfoDialog({ chat, chatInfoDialogRef, openChatFragme
}) })
if (re.code != 200) if (re.code != 200)
return checkApiSuccessOrSncakbar(re, '获取用户失败') return checkApiSuccessOrSncakbar(re, '获取用户失败')
userId = re.data!.user_id as string setUserId(re.data!.user_id as string)
} }
}, [chat, sharedFavouriteChats]) }, [chat, sharedFavouriteChats])
@@ -50,10 +50,22 @@ export default function ChatInfoDialog({ chat, chatInfoDialogRef, openChatFragme
width: '50px', width: '50px',
height: '50px', height: '50px',
}} onClick={() => avatarUrl && openImageViewer(avatarUrl)} /> }} onClick={() => avatarUrl && openImageViewer(avatarUrl)} />
<span style={{ <div style={{
marginLeft: "15px", display: 'flex',
marginLeft: '15px',
marginRight: '15px',
fontSize: '16.5px', fontSize: '16.5px',
}}>{chat?.title}</span> flexDirection: 'column',
}}>
<span style={{
fontSize: '16.5px'
}}>{chat?.title}</span>
<span style={{
fontSize: '10.5px',
marginTop: '3px',
color: 'rgb(var(--mdui-color-secondary))',
}}>ID: {chat?.type == 'private' ? userId : chat?.id}</span>
</div>
</div> </div>
<mdui-divider style={{ <mdui-divider style={{
marginTop: "10px", marginTop: "10px",
@@ -77,7 +89,7 @@ export default function ChatInfoDialog({ chat, chatInfoDialogRef, openChatFragme
const re = await Client.invoke(favourited ? "User.removeContacts" : "User.addContacts", { const re = await Client.invoke(favourited ? "User.removeContacts" : "User.addContacts", {
token: data.access_token, token: data.access_token,
targets: [ targets: [
chat.id chat!.id
], ],
}) })
if (re.code != 200) if (re.code != 200)
@@ -91,7 +103,7 @@ export default function ChatInfoDialog({ chat, chatInfoDialogRef, openChatFragme
})}>{favourited ? '取消收藏' : '收藏对话'}</mdui-list-item> })}>{favourited ? '取消收藏' : '收藏对话'}</mdui-list-item>
<mdui-list-item icon="chat" rounded onClick={() => { <mdui-list-item icon="chat" rounded onClick={() => {
chatInfoDialogRef.current!.open = false chatInfoDialogRef.current!.open = false
openChatFragment(chat.id) openChatFragment(chat!.id)
}}></mdui-list-item> }}></mdui-list-item>
</mdui-list> </mdui-list>
</mdui-dialog> </mdui-dialog>