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
b47391f0
Commit
b47391f0
authored
Sep 29, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加一些错误日志帮助定位问题
parent
f80a8f42
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
14 deletions
+32
-14
src/api/strings.ts
src/api/strings.ts
+7
-2
src/ui/Duel/PlayMat/ChatBox/index.tsx
src/ui/Duel/PlayMat/ChatBox/index.tsx
+1
-1
src/ui/Match/index.tsx
src/ui/Match/index.tsx
+2
-2
src/ui/Shared/chatHook.ts
src/ui/Shared/chatHook.ts
+21
-8
src/ui/WaitRoom/index.tsx
src/ui/WaitRoom/index.tsx
+1
-1
No files found.
src/api/strings.ts
View file @
b47391f0
...
@@ -12,7 +12,12 @@ export async function initStrings() {
...
@@ -12,7 +12,12 @@ export async function initStrings() {
for
(
const
line
of
lineIter
)
{
for
(
const
line
of
lineIter
)
{
if
(
!
line
.
startsWith
(
"
#
"
)
&&
line
!==
""
)
{
if
(
!
line
.
startsWith
(
"
#
"
)
&&
line
!==
""
)
{
let
[
region
,
code
,
value
]
=
line
.
split
(
"
"
,
3
);
let
[
region
,
code
,
value
]
=
line
.
split
(
"
"
,
3
);
localStorage
.
setItem
(
`
${
region
}
_
${
code
}
`
,
value
);
try
{
localStorage
.
setItem
(
`
${
region
}
_
${
code
}
`
,
value
);
}
catch
(
error
)
{
alert
(
`set item in local storage error:
${
error
}
`
);
break
;
}
}
}
}
}
}
}
...
@@ -24,7 +29,7 @@ export enum Region {
...
@@ -24,7 +29,7 @@ export enum Region {
}
}
export
function
fetchStrings
(
region
:
Region
,
id
:
string
|
number
):
string
{
export
function
fetchStrings
(
region
:
Region
,
id
:
string
|
number
):
string
{
return
localStorage
.
getItem
(
`
${
region
}
_
${
id
}
`
)
||
""
;
return
localStorage
.
getItem
(
`
${
region
}
_
${
id
}
`
)
??
""
;
}
}
export
function
getStrings
(
description
:
number
):
string
{
export
function
getStrings
(
description
:
number
):
string
{
...
...
src/ui/Duel/PlayMat/ChatBox/index.tsx
View file @
b47391f0
...
@@ -16,7 +16,7 @@ interface ChatItem {
...
@@ -16,7 +16,7 @@ interface ChatItem {
export
const
ChatBox
:
React
.
FC
=
()
=>
{
export
const
ChatBox
:
React
.
FC
=
()
=>
{
const
{
open
}
=
useSnapshot
(
store
);
const
{
open
}
=
useSnapshot
(
store
);
const
{
dialogs
,
input
,
setInput
,
ref
,
onSend
}
=
useChat
();
const
{
dialogs
,
input
,
setInput
,
ref
,
onSend
}
=
useChat
(
true
);
const
onClose
=
()
=>
(
store
.
open
=
false
);
const
onClose
=
()
=>
(
store
.
open
=
false
);
...
...
src/ui/Match/index.tsx
View file @
b47391f0
...
@@ -52,7 +52,7 @@ export const Component: React.FC = () => {
...
@@ -52,7 +52,7 @@ export const Component: React.FC = () => {
if
(
matchInfo
)
{
if
(
matchInfo
)
{
await
connectSrvpro
({
await
connectSrvpro
({
ip
:
matchInfo
.
address
+
"
:
"
+
(
matchInfo
.
port
+
1
),
ip
:
matchInfo
.
address
+
"
:
"
+
(
matchInfo
.
port
+
1
),
// 分配给Neos的Websocket端口是TCP端口+1
player
:
user
.
username
,
player
:
user
.
username
,
passWd
:
matchInfo
.
password
,
passWd
:
matchInfo
.
password
,
});
});
...
@@ -69,7 +69,7 @@ export const Component: React.FC = () => {
...
@@ -69,7 +69,7 @@ export const Component: React.FC = () => {
// 初始化,然后等待后端通知成功加入房间后跳转页面
// 初始化,然后等待后端通知成功加入房间后跳转页面
await
connectSrvpro
({
await
connectSrvpro
({
ip
:
server
,
ip
:
server
,
player
:
user
?.
name
??
"
Guest
"
,
player
:
user
?.
user
name
??
"
Guest
"
,
passWd
:
"
AI
"
,
passWd
:
"
AI
"
,
});
});
};
};
...
...
src/ui/Shared/chatHook.ts
View file @
b47391f0
...
@@ -5,7 +5,7 @@ import { useEffect, useRef, useState } from "react";
...
@@ -5,7 +5,7 @@ import { useEffect, useRef, useState } from "react";
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
sendChat
}
from
"
@/api
"
;
import
{
sendChat
}
from
"
@/api
"
;
import
{
chatStore
,
roomStore
}
from
"
@/stores
"
;
import
{
chatStore
,
isMe
,
roomStore
}
from
"
@/stores
"
;
interface
ChatItem
{
interface
ChatItem
{
name
:
string
;
name
:
string
;
...
@@ -13,7 +13,7 @@ interface ChatItem {
...
@@ -13,7 +13,7 @@ interface ChatItem {
content
:
string
;
content
:
string
;
}
}
export
const
useChat
=
()
=>
{
export
const
useChat
=
(
isDuel
:
boolean
=
false
)
=>
{
const
[
chatList
,
setChatList
]
=
useState
<
ChatItem
[]
>
([]);
const
[
chatList
,
setChatList
]
=
useState
<
ChatItem
[]
>
([]);
const
[
input
,
setInput
]
=
useState
<
string
|
undefined
>
(
undefined
);
const
[
input
,
setInput
]
=
useState
<
string
|
undefined
>
(
undefined
);
const
chat
=
useSnapshot
(
chatStore
);
const
chat
=
useSnapshot
(
chatStore
);
...
@@ -36,15 +36,28 @@ export const useChat = () => {
...
@@ -36,15 +36,28 @@ export const useChat = () => {
}
}
};
};
// 获取消息发送者的名字
const
getSenderName
=
(
sender
:
number
)
=>
{
if
(
sender
<
roomStore
.
players
.
length
)
{
if
(
isDuel
)
{
// 决斗内和决斗外场景sender是不一样的
if
(
isMe
(
sender
))
{
return
roomStore
.
getMePlayer
()?.
name
;
}
else
{
return
roomStore
.
getOpPlayer
()?.
name
;
}
}
else
{
return
roomStore
.
players
[
sender
]?.
name
;
}
}
else
if
(
sender
<=
8
||
(
sender
>=
11
&&
sender
<=
19
))
{
return
"
System
"
;
}
};
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
chatStore
.
sender
>=
0
&&
chatStore
.
message
.
length
!==
0
)
{
if
(
chatStore
.
sender
>=
0
&&
chatStore
.
message
.
length
!==
0
)
{
const
{
sender
}
=
chatStore
;
const
{
sender
}
=
chatStore
;
const
name
=
const
name
=
getSenderName
(
sender
)
??
"
?
"
;
sender
<
roomStore
.
players
.
length
?
roomStore
.
players
[
sender
]?.
name
??
"
?
"
:
(
sender
>
8
&&
sender
<
11
)
||
sender
>
19
?
"
?
"
:
"
System
"
;
setChatList
((
prev
)
=>
[
setChatList
((
prev
)
=>
[
...
prev
,
...
prev
,
{
{
...
...
src/ui/WaitRoom/index.tsx
View file @
b47391f0
...
@@ -90,7 +90,7 @@ export const Component: React.FC = () => {
...
@@ -90,7 +90,7 @@ export const Component: React.FC = () => {
if
(
deck
)
{
if
(
deck
)
{
setDeck
(
deck
);
setDeck
(
deck
);
}
else
{
}
else
{
alert
(
`Deck ${deckName} not found`
);
message
.
error
(
`Deck ${deckName} not found`
);
}
}
}
}
}
}
/>
/>
...
...
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