Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Neos
Commits
93ca14a9
Commit
93ca14a9
authored
Aug 07, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support chat room
parent
42e2a5c7
Pipeline
#22942
failed with stages
in 12 minutes and 49 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
17 deletions
+58
-17
src/service/room/chat.ts
src/service/room/chat.ts
+1
-0
src/stores/chatStore.ts
src/stores/chatStore.ts
+2
-0
src/ui/NewWaitRoom/Chat.module.scss
src/ui/NewWaitRoom/Chat.module.scss
+3
-0
src/ui/NewWaitRoom/Chat.tsx
src/ui/NewWaitRoom/Chat.tsx
+52
-17
No files found.
src/service/room/chat.ts
View file @
93ca14a9
...
@@ -4,4 +4,5 @@ import { chatStore } from "@/stores";
...
@@ -4,4 +4,5 @@ import { chatStore } from "@/stores";
export
default
function
handleChat
(
pb
:
ygopro
.
YgoStocMsg
)
{
export
default
function
handleChat
(
pb
:
ygopro
.
YgoStocMsg
)
{
const
chat
=
pb
.
stoc_chat
;
const
chat
=
pb
.
stoc_chat
;
chatStore
.
message
=
chat
.
msg
;
chatStore
.
message
=
chat
.
msg
;
chatStore
.
sender
=
chat
.
player
;
}
}
src/stores/chatStore.ts
View file @
93ca14a9
...
@@ -3,10 +3,12 @@ import { proxy } from "valtio";
...
@@ -3,10 +3,12 @@ import { proxy } from "valtio";
import
{
type
NeosStore
}
from
"
./shared
"
;
import
{
type
NeosStore
}
from
"
./shared
"
;
export
interface
ChatState
extends
NeosStore
{
export
interface
ChatState
extends
NeosStore
{
sender
:
number
;
message
:
string
;
message
:
string
;
}
}
export
const
chatStore
=
proxy
<
ChatState
>
({
export
const
chatStore
=
proxy
<
ChatState
>
({
sender
:
-
1
,
message
:
""
,
message
:
""
,
reset
()
{
reset
()
{
chatStore
.
message
=
""
;
chatStore
.
message
=
""
;
...
...
src/ui/NewWaitRoom/Chat.module.scss
View file @
93ca14a9
...
@@ -17,6 +17,9 @@
...
@@ -17,6 +17,9 @@
.dialogs
{
.dialogs
{
padding
:
8px
0
;
padding
:
8px
0
;
overflow-y
:
scroll
;
scroll-behavior
:
smooth
;
max-height
:
85vh
;
@include
utils
.
scrollbar
;
@include
utils
.
scrollbar
;
.item
{
.item
{
vertical-align
:
baseline
;
vertical-align
:
baseline
;
...
...
src/ui/NewWaitRoom/Chat.tsx
View file @
93ca14a9
import
{
Button
,
Input
}
from
"
antd
"
;
import
{
Button
,
Input
}
from
"
antd
"
;
import
{
useEffect
,
useState
}
from
"
react
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
sendChat
}
from
"
@/api
"
;
import
{
chatStore
,
roomStore
}
from
"
@/stores
"
;
import
{
IconFont
}
from
"
../Shared
"
;
import
{
IconFont
}
from
"
../Shared
"
;
import
styles
from
"
./Chat.module.scss
"
;
import
styles
from
"
./Chat.module.scss
"
;
interface
ChatItem
{
name
:
string
;
time
:
string
;
content
:
string
;
}
export
const
Chat
:
React
.
FC
=
()
=>
{
export
const
Chat
:
React
.
FC
=
()
=>
{
const
[
chatlist
,
setChatlist
]
=
useState
<
ChatItem
[]
>
([]);
const
[
input
,
setInput
]
=
useState
<
string
|
undefined
>
(
undefined
);
const
chat
=
useSnapshot
(
chatStore
);
useEffect
(()
=>
{
if
(
chatStore
.
sender
>=
0
&&
chatStore
.
message
.
length
!=
0
)
{
const
now
=
new
Date
();
const
sender
=
chatStore
.
sender
;
const
name
=
sender
<
roomStore
.
players
.
length
?
roomStore
.
players
[
sender
].
name
:
(
sender
>
8
&&
sender
<
11
)
||
sender
>
19
?
"
?
"
:
"
System
"
;
setChatlist
((
prev
)
=>
[
...
prev
,
{
name
:
name
,
time
:
`
${
now
.
getHours
()}
:
${
now
.
getMinutes
()}
:
${
now
.
getSeconds
()}
`
,
content
:
chatStore
.
message
,
},
]);
}
},
[
chat
]);
return
(
return
(
<
div
className=
{
styles
.
chat
}
>
<
div
className=
{
styles
.
chat
}
>
<
div
className=
{
styles
.
dialogs
}
>
<
div
className=
{
styles
.
dialogs
}
>
<
DialogItem
{
chatlist
.
map
((
item
,
idx
)
=>
(
name=
"愧心Kanzo"
<
DialogItem
key=
{
idx
}
{
...
item
}
/>
time=
"00:34:28"
))
}
content=
"白银城连抽了三张钟"
/>
<
DialogItem
name=
"超级摆烂人"
time=
"00:34:38"
content=
"哦"
/>
<
DialogItem
name=
"超级摆烂人"
time=
"00:35:42"
content=
"是烙印融合,寄"
/>
</
div
>
</
div
>
<
div
className=
{
styles
.
input
}
>
<
div
className=
{
styles
.
input
}
>
<
Input
.
TextArea
<
Input
.
TextArea
bordered=
{
false
}
bordered=
{
false
}
value=
{
input
}
onChange=
{
(
event
)
=>
setInput
(
event
.
target
.
value
)
}
autoSize
autoSize
placeholder=
"请输入聊天内容"
placeholder=
"请输入聊天内容"
/>
/>
<
Button
type=
"text"
icon=
{
<
IconFont
type=
"icon-send"
size=
{
16
}
/>
}
/>
<
Button
type=
"text"
icon=
{
<
IconFont
type=
"icon-send"
size=
{
16
}
/>
}
onClick=
{
()
=>
{
if
(
input
!==
undefined
)
{
sendChat
(
input
);
setInput
(
undefined
);
}
}
}
/>
</
div
>
</
div
>
</
div
>
</
div
>
);
);
};
};
const
DialogItem
:
React
.
FC
<
{
const
DialogItem
:
React
.
FC
<
ChatItem
>
=
({
name
,
time
,
content
})
=>
{
name
:
string
;
time
:
string
;
content
:
string
;
}
>
=
({
name
,
time
,
content
})
=>
{
return
(
return
(
<
div
className=
{
styles
.
item
}
>
<
div
className=
{
styles
.
item
}
>
<
div
className=
{
styles
.
name
}
>
<
div
className=
{
styles
.
name
}
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment