Compare commits
2 Commits
56f651f084
...
8c74eaacb1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c74eaacb1 | ||
|
|
db3dca724a |
@@ -7,9 +7,8 @@ import CallbackError from "./CallbackError.ts"
|
||||
import ApiCallbackMessage from "./ApiCallbackMessage.ts"
|
||||
|
||||
import * as marked from 'marked'
|
||||
import { text } from "node:stream/consumers";
|
||||
|
||||
class ChatMention extends BaseClientObject {
|
||||
export class ChatMention extends BaseClientObject {
|
||||
declare chat_id?: string
|
||||
declare user_id?: string
|
||||
declare text?: string
|
||||
@@ -41,7 +40,7 @@ class ChatMention extends BaseClientObject {
|
||||
type FileType = 'Video' | 'Image' | 'File'
|
||||
type MentionType = 'ChatMention' | 'UserMention'
|
||||
|
||||
class ChatAttachment extends BaseClientObject {
|
||||
export class ChatAttachment extends BaseClientObject {
|
||||
declare file_hash: string
|
||||
declare file_name: string
|
||||
constructor(client: LingChairClient, {
|
||||
|
||||
@@ -7,6 +7,7 @@ import GroupSettingsBean from "./bean/GroupSettingsBean.ts"
|
||||
import JoinRequestBean from "./bean/JoinRequestBean.ts"
|
||||
import MessageBean from "./bean/MessageBean.ts"
|
||||
import RecentChatBean from "./bean/RecentChatBean.ts"
|
||||
import Message, { ChatAttachment, ChatMention } from "./Message.ts"
|
||||
|
||||
import LingChairClient from "./LingChairClient.ts"
|
||||
import CallbackError from "./CallbackError.ts"
|
||||
@@ -14,10 +15,13 @@ import CallbackError from "./CallbackError.ts"
|
||||
export {
|
||||
LingChairClient,
|
||||
CallbackError,
|
||||
|
||||
|
||||
Chat,
|
||||
User,
|
||||
UserMySelf,
|
||||
Message,
|
||||
ChatAttachment,
|
||||
ChatMention,
|
||||
|
||||
UserBean,
|
||||
ChatBean,
|
||||
|
||||
@@ -12,6 +12,7 @@ import PreferenceUpdater from "../preference/PreferenceUpdater"
|
||||
import SwitchPreference from "../preference/SwitchPreference"
|
||||
import TextFieldPreference from "../preference/TextFieldPreference"
|
||||
import * as React from 'react'
|
||||
import ChatMessageContainer from "./ChatMessageContainer"
|
||||
|
||||
interface MduiTabFitSizeArgs extends React.HTMLAttributes<HTMLElement & Tab> {
|
||||
value: string
|
||||
@@ -34,7 +35,7 @@ export default function ChatFragment({
|
||||
}) {
|
||||
const nav = useNavigate()
|
||||
|
||||
const [tabItemSelected, setTabItemSelected] = React.useState('None')
|
||||
const [tabItemSelected, setTabItemSelected] = React.useState('Chat')
|
||||
const tabRef = React.useRef<Tab>()
|
||||
useEventListener(tabRef, 'change', () => {
|
||||
tabRef.current != null && setTabItemSelected(tabRef.current!.value as string)
|
||||
@@ -43,8 +44,6 @@ export default function ChatFragment({
|
||||
const chatPanelRef = React.useRef<HTMLElement>()
|
||||
const inputRef = React.useRef<TextField>()
|
||||
|
||||
|
||||
|
||||
return <div style={{
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
@@ -73,40 +72,42 @@ export default function ChatFragment({
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
height: "100%",
|
||||
width: '100%',
|
||||
overflowX: 'auto',
|
||||
}}></mdui-tabs>{
|
||||
chatInfo.isMember() ? <>
|
||||
<MduiTabFitSize value="Chat">{chatInfo.getTitle()}</MduiTabFitSize>
|
||||
{chatInfo.getType() == 'group' && chatInfo.isAdmin() && <MduiTabFitSize value="NewMemberRequests">加入请求</MduiTabFitSize>}
|
||||
{chatInfo.getType() == 'group' && <MduiTabFitSize value="GroupMembers">群组成员</MduiTabFitSize>}
|
||||
</>
|
||||
: <MduiTabFitSize value="RequestJoin">{chatInfo.getTitle()}</MduiTabFitSize>
|
||||
}
|
||||
{chatInfo.getType() == 'group' && <MduiTabFitSize value="Settings">设置</MduiTabFitSize>}
|
||||
<MduiTabFitSize value="None" style={{ display: 'none' }}></MduiTabFitSize>
|
||||
<div style={{
|
||||
flexGrow: '1',
|
||||
}}></div>
|
||||
<mdui-button-icon icon="open_in_new" onClick={() => {
|
||||
window.open('/chat?id=' + chatInfo.getId(), '_blank')
|
||||
}}>
|
||||
{
|
||||
chatInfo.isMember() ? <>
|
||||
<MduiTabFitSize value="Chat">{chatInfo.getTitle()}</MduiTabFitSize>
|
||||
{chatInfo.getType() == 'group' && chatInfo.isAdmin() && <MduiTabFitSize value="NewMemberRequests">加入请求</MduiTabFitSize>}
|
||||
{chatInfo.getType() == 'group' && <MduiTabFitSize value="GroupMembers">群组成员</MduiTabFitSize>}
|
||||
</>
|
||||
: <MduiTabFitSize value="RequestJoin">{chatInfo.getTitle()}</MduiTabFitSize>
|
||||
}
|
||||
{chatInfo.getType() == 'group' && <MduiTabFitSize value="Settings">设置</MduiTabFitSize>}
|
||||
<div style={{
|
||||
flexGrow: '1',
|
||||
}}></div>
|
||||
<mdui-button-icon icon="open_in_new" onClick={() => {
|
||||
window.open('/chat?id=' + chatInfo.getId(), '_blank')
|
||||
|
||||
}} style={{
|
||||
alignSelf: 'center',
|
||||
marginLeft: '5px',
|
||||
marginRight: '5px',
|
||||
}}></mdui-button-icon>
|
||||
<mdui-button-icon icon="refresh" onClick={() => {
|
||||
}} style={{
|
||||
alignSelf: 'center',
|
||||
marginLeft: '5px',
|
||||
marginRight: '5px',
|
||||
}}></mdui-button-icon>
|
||||
<mdui-button-icon icon="refresh" onClick={() => {
|
||||
|
||||
}} style={{
|
||||
alignSelf: 'center',
|
||||
marginLeft: '5px',
|
||||
marginRight: '5px',
|
||||
}}></mdui-button-icon>
|
||||
<mdui-button-icon icon="info" onClick={() => gotoChatInfo(nav, chatInfo.getId())} style={{
|
||||
alignSelf: 'center',
|
||||
marginLeft: '5px',
|
||||
marginRight: '5px',
|
||||
}}></mdui-button-icon>
|
||||
}} style={{
|
||||
alignSelf: 'center',
|
||||
marginLeft: '5px',
|
||||
marginRight: '5px',
|
||||
}}></mdui-button-icon>
|
||||
<mdui-button-icon icon="info" onClick={() => gotoChatInfo(nav, chatInfo.getId())} style={{
|
||||
alignSelf: 'center',
|
||||
marginLeft: '5px',
|
||||
marginRight: '5px',
|
||||
}}></mdui-button-icon>
|
||||
</mdui-tabs>
|
||||
</mdui-tabs>
|
||||
<mdui-tab-panel slot="panel" value="RequestJoin" style={{
|
||||
display: tabItemSelected == "RequestJoin" ? "flex" : "none",
|
||||
@@ -136,17 +137,7 @@ export default function ChatFragment({
|
||||
}}>
|
||||
{/* 这里显示一些提示 */}
|
||||
</div>
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-end',
|
||||
alignItems: 'center',
|
||||
marginBottom: '20px',
|
||||
paddingTop: "15px",
|
||||
flexGrow: '1',
|
||||
}}>
|
||||
{/* 消息放在这里 */}
|
||||
</div>
|
||||
<ChatMessageContainer chatInfo={chatInfo} />
|
||||
{
|
||||
// 输入框
|
||||
}
|
||||
@@ -301,20 +292,5 @@ export default function ChatFragment({
|
||||
)
|
||||
}
|
||||
</mdui-tab-panel>
|
||||
<mdui-tab-panel slot="panel" value="None" style={{
|
||||
display: tabItemSelected == "None" ? "flex" : "none",
|
||||
flexDirection: "column",
|
||||
height: "100%",
|
||||
}}>
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}>
|
||||
<mdui-circular-progress></mdui-circular-progress>
|
||||
</div>
|
||||
</mdui-tab-panel>
|
||||
</div >
|
||||
}
|
||||
|
||||
24
client/ui/chat-fragment/ChatMessageContainer.tsx
Normal file
24
client/ui/chat-fragment/ChatMessageContainer.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Chat, Message } from 'lingchair-client-protocol'
|
||||
import * as React from 'react'
|
||||
|
||||
export default function ChatMessageContainer({
|
||||
chatInfo,
|
||||
}: {
|
||||
chatInfo: Chat
|
||||
}) {
|
||||
const [messages, setMessages] = React.useState<Message[]>()
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-end',
|
||||
alignItems: 'center',
|
||||
marginBottom: '20px',
|
||||
paddingTop: "15px",
|
||||
flexGrow: '1',
|
||||
}}>
|
||||
{messages?.map((v) => v.getText())}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -9,7 +9,8 @@ import EffectOnly from "../EffectOnly"
|
||||
export default function LazyChatFragment({ chatId, openedWithRouter }: { chatId: string, openedWithRouter: boolean }) {
|
||||
return <React.Suspense fallback={<EffectOnly effect={() => {
|
||||
const s = showSnackbar({
|
||||
message: '请稍后',
|
||||
message: '请稍后...',
|
||||
autoCloseDelay: 0,
|
||||
})
|
||||
return () => {
|
||||
s.open = false
|
||||
|
||||
Reference in New Issue
Block a user