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