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
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
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
love_飞影
Neos
Commits
c711f067
Commit
c711f067
authored
Aug 09, 2023
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize: waitroom
parent
5e1d4b6b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
25 deletions
+43
-25
src/ui/Shared/Scrollbar/index.tsx
src/ui/Shared/Scrollbar/index.tsx
+8
-4
src/ui/WaitRoom/Chat.tsx
src/ui/WaitRoom/Chat.tsx
+28
-8
src/ui/WaitRoom/index.module.scss
src/ui/WaitRoom/index.module.scss
+1
-1
src/ui/WaitRoom/index.tsx
src/ui/WaitRoom/index.tsx
+6
-12
No files found.
src/ui/Shared/Scrollbar/index.tsx
View file @
c711f067
import
{
import
{
OverlayScrollbarsComponent
,
OverlayScrollbarsComponent
,
OverlayScrollbarsComponentProps
,
OverlayScrollbarsComponentProps
,
type
OverlayScrollbarsComponentRef
,
}
from
"
overlayscrollbars-react
"
;
}
from
"
overlayscrollbars-react
"
;
import
{
forwardRef
}
from
"
react
"
;
/**
/**
* @desc 创建漂亮的滚动条,包裹一些可能溢出的元素。
* @desc 创建漂亮的滚动条,包裹一些可能溢出的元素。
* @why chrome在113之后,取消了overflow: overlay的支持,所以需要使用overlayScrollbars来实现。
* @why chrome在113之后,取消了overflow: overlay的支持,所以需要使用overlayScrollbars来实现。
*/
*/
export
const
ScrollableArea
:
React
.
FC
<
export
const
ScrollableArea
=
forwardRef
<
OverlayScrollbarsComponentRef
<
"
div
"
>
,
React
.
PropsWithChildren
<
{
React
.
PropsWithChildren
<
{
scrollProps
?:
OverlayScrollbarsComponentProps
;
scrollProps
?:
OverlayScrollbarsComponentProps
;
elementProps
?:
React
.
HTMLAttributes
<
HTMLElement
>
;
elementProps
?:
React
.
HTMLAttributes
<
HTMLElement
>
;
className
?:
string
;
className
?:
string
;
style
?:
React
.
CSSProperties
;
style
?:
React
.
CSSProperties
;
}
>
}
>
>
=
({
scrollProps
=
{},
elementProps
,
className
,
style
,
children
}
)
=>
{
>
(({
scrollProps
=
{},
elementProps
,
className
,
style
,
children
},
ref
)
=>
{
const
{
options
=
{},
...
rest
}
=
scrollProps
;
const
{
options
=
{},
...
rest
}
=
scrollProps
;
scrollProps
;
return
(
return
(
<
OverlayScrollbarsComponent
<
OverlayScrollbarsComponent
options=
{
{
options=
{
{
...
@@ -35,10 +38,11 @@ export const ScrollableArea: React.FC<
...
@@ -35,10 +38,11 @@ export const ScrollableArea: React.FC<
height
:
"
100%
"
,
height
:
"
100%
"
,
}
}
}
}
{
...
rest
}
{
...
rest
}
ref=
{
ref
}
>
>
<
div
className=
{
className
}
style=
{
style
}
{
...
elementProps
}
>
<
div
className=
{
className
}
style=
{
style
}
{
...
elementProps
}
>
{
children
}
{
children
}
</
div
>
</
div
>
</
OverlayScrollbarsComponent
>
</
OverlayScrollbarsComponent
>
);
);
};
}
)
;
src/ui/WaitRoom/Chat.tsx
View file @
c711f067
import
{
Button
,
Input
}
from
"
antd
"
;
import
{
Button
,
Input
}
from
"
antd
"
;
import
{
useEffect
,
useState
}
from
"
react
"
;
import
{
type
OverlayScrollbarsComponentRef
}
from
"
overlayscrollbars-react
"
;
import
{
useEffect
,
useRef
,
useState
}
from
"
react
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
sendChat
}
from
"
@/api
"
;
import
{
sendChat
}
from
"
@/api
"
;
...
@@ -36,12 +37,32 @@ export const Chat: React.FC = () => {
...
@@ -36,12 +37,32 @@ export const Chat: React.FC = () => {
content
:
chatStore
.
message
,
content
:
chatStore
.
message
,
},
},
]);
]);
scrollToBottom
();
}
}
},
[
chat
]);
},
[
chat
]);
/** dialogs 滚动到最底下 */
const
scrollToBottom
=
()
=>
{
const
viewport
=
ref
.
current
?.
osInstance
()?.
elements
().
viewport
;
if
(
viewport
)
{
viewport
.
scrollTop
=
viewport
.
scrollHeight
;
}
};
/** 发信息 */
const
send
=
()
=>
{
if
(
input
!==
undefined
)
{
sendChat
(
input
);
setInput
(
""
);
}
};
/** 滚动条的ref */
const
ref
=
useRef
<
OverlayScrollbarsComponentRef
<
"
div
"
>>
(
null
);
return
(
return
(
<
div
className=
{
styles
.
chat
}
>
<
div
className=
{
styles
.
chat
}
>
<
ScrollableArea
className=
{
styles
.
dialogs
}
>
<
ScrollableArea
className=
{
styles
.
dialogs
}
ref=
{
ref
}
>
{
chatlist
.
map
((
item
,
idx
)
=>
(
{
chatlist
.
map
((
item
,
idx
)
=>
(
<
DialogItem
key=
{
idx
}
{
...
item
}
/>
<
DialogItem
key=
{
idx
}
{
...
item
}
/>
))
}
))
}
...
@@ -53,16 +74,15 @@ export const Chat: React.FC = () => {
...
@@ -53,16 +74,15 @@ export const Chat: React.FC = () => {
onChange=
{
(
event
)
=>
setInput
(
event
.
target
.
value
)
}
onChange=
{
(
event
)
=>
setInput
(
event
.
target
.
value
)
}
autoSize
autoSize
placeholder=
"请输入聊天内容"
placeholder=
"请输入聊天内容"
onPressEnter=
{
(
e
)
=>
{
e
.
preventDefault
();
send
();
}
}
/>
/>
<
Button
<
Button
type=
"text"
type=
"text"
icon=
{
<
IconFont
type=
"icon-send"
size=
{
16
}
/>
}
icon=
{
<
IconFont
type=
"icon-send"
size=
{
16
}
/>
}
onClick=
{
()
=>
{
onClick=
{
send
}
if
(
input
!==
undefined
)
{
sendChat
(
input
);
setInput
(
undefined
);
}
}
}
/>
/>
</
div
>
</
div
>
</
div
>
</
div
>
...
...
src/ui/WaitRoom/index.module.scss
View file @
c711f067
...
@@ -108,7 +108,7 @@
...
@@ -108,7 +108,7 @@
.btns-side
{
.btns-side
{
position
:
absolute
;
position
:
absolute
;
left
:
10px
;
left
:
10px
;
bottom
:
10px
;
top
:
10px
;
display
:
flex
;
display
:
flex
;
flex-direction
:
column
;
flex-direction
:
column
;
gap
:
10px
;
gap
:
10px
;
...
...
src/ui/WaitRoom/index.tsx
View file @
c711f067
...
@@ -144,9 +144,7 @@ export const Component: React.FC = () => {
...
@@ -144,9 +144,7 @@ export const Component: React.FC = () => {
who=
{
Who
.
Op
}
who=
{
Who
.
Op
}
player=
{
player
}
player=
{
player
}
btn=
{
btn=
{
room
.
stage
===
RoomStage
.
WAITING
?
(
room
.
stage
===
RoomStage
.
WAITING
?
null
:
(
<></>
)
:
(
<
MoraAvatar
<
MoraAvatar
mora=
{
mora=
{
op
?.
moraResult
!==
undefined
&&
op
?.
moraResult
!==
undefined
&&
...
@@ -267,15 +265,11 @@ const Controller: React.FC<{ onDeckChange: (deckName: string) => void }> = ({
...
@@ -267,15 +265,11 @@ const Controller: React.FC<{ onDeckChange: (deckName: string) => void }> = ({
}
}
}
}
>
>
{
snapRoom
.
selfType
===
SelfType
.
OBSERVER
?
"
加入决斗者
"
:
"
加入观战
"
}
{
snapRoom
.
selfType
===
SelfType
.
OBSERVER
?
"
加入决斗者
"
:
"
加入观战
"
}
<
Avatar
.
Group
className=
{
styles
[
"
avatars-watch
"
]
}
>
{
!!
snapRoom
.
observerCount
&&
(
{
Array
.
from
({
length
:
snapRoom
.
observerCount
}).
map
((
_
,
idx
)
=>
(
<
Avatar
size=
"small"
style=
{
{
marginLeft
:
8
}
}
>
<
Avatar
{
snapRoom
.
observerCount
}
key=
{
idx
}
</
Avatar
>
src=
{
`${NeosConfig.assetsPath}/default-avatar.png`
}
)
}
size=
"small"
/>
))
}
</
Avatar
.
Group
>
</
Button
>
</
Button
>
</
Space
>
</
Space
>
);
);
...
...
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