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
baichixing
Neos
Commits
d7e1f353
Commit
d7e1f353
authored
Jun 25, 2023
by
chechunchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate checkcounter modal
parent
93439c46
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
35 deletions
+50
-35
src/service/duel/gameMsg.ts
src/service/duel/gameMsg.ts
+1
-1
src/service/duel/selectCounter.ts
src/service/duel/selectCounter.ts
+9
-9
src/stores/messageStore/store.ts
src/stores/messageStore/store.ts
+0
-4
src/stores/messageStore/types.ts
src/stores/messageStore/types.ts
+0
-10
src/ui/Duel/Message/CheckCounterModal.tsx
src/ui/Duel/Message/CheckCounterModal.tsx
+40
-11
No files found.
src/service/duel/gameMsg.ts
View file @
d7e1f353
...
...
@@ -215,7 +215,7 @@ async function _handleGameMsg(pb: ygopro.YgoStocMsg) {
break
;
}
case
"
select_counter
"
:
{
onMsgSelectCounter
(
msg
.
select_counter
);
await
onMsgSelectCounter
(
msg
.
select_counter
);
break
;
}
...
...
src/service/duel/selectCounter.ts
View file @
d7e1f353
import
{
ygopro
}
from
"
@/api
"
;
import
{
cardStore
,
messageStore
}
from
"
@/stores
"
;
import
{
cardStore
}
from
"
@/stores
"
;
import
{
displayCheckCounterModal
}
from
"
@/ui/Duel/Message
"
;
type
MsgSelectCounter
=
ygopro
.
StocGameMessage
.
MsgSelectCounter
;
export
default
(
selectCounter
:
MsgSelectCounter
)
=>
{
messageStore
.
checkCounterModal
.
counterType
=
selectCounter
.
counter_type
;
messageStore
.
checkCounterModal
.
min
=
selectCounter
.
min
;
messageStore
.
checkCounterModal
.
options
=
selectCounter
.
options
!
.
map
(
({
location
,
code
,
counter_count
})
=>
{
export
default
async
(
selectCounter
:
MsgSelectCounter
)
=>
{
await
displayCheckCounterModal
({
counterType
:
selectCounter
.
counter_type
,
min
:
selectCounter
.
min
,
options
:
selectCounter
.
options
!
.
map
(
({
location
,
code
,
counter_count
})
=>
{
const
id
=
cardStore
.
find
(
location
)?.
code
;
const
newCode
=
code
?
code
:
id
||
0
;
...
...
@@ -14,7 +15,6 @@ export default (selectCounter: MsgSelectCounter) => {
code
:
newCode
,
max
:
counter_count
!
,
};
}
);
messageStore
.
checkCounterModal
.
isOpen
=
true
;
}),
});
};
src/stores/messageStore/store.ts
View file @
d7e1f353
...
...
@@ -3,10 +3,6 @@ import { proxy } from "valtio";
import
type
{
ModalState
}
from
"
./types
"
;
export
const
messageStore
=
proxy
<
ModalState
>
({
checkCounterModal
:
{
isOpen
:
false
,
options
:
[],
},
announceModal
:
{
isOpen
:
false
,
min
:
1
,
...
...
src/stores/messageStore/types.ts
View file @
d7e1f353
export
interface
ModalState
{
// 指示器选择弹窗
checkCounterModal
:
{
isOpen
:
boolean
;
counterType
?:
number
;
min
?:
number
;
options
:
{
code
:
number
;
max
:
number
;
}[];
};
// 宣言弹窗
announceModal
:
{
isOpen
:
boolean
;
...
...
src/ui/Duel/Message/CheckCounterModal.tsx
View file @
d7e1f353
// 指示器选择弹窗
import
{
Omit
}
from
"
@react-spring/web
"
;
import
{
Button
,
Card
,
Col
,
InputNumber
,
Row
}
from
"
antd
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
proxy
,
useSnapshot
}
from
"
valtio
"
;
import
{
fetchStrings
,
sendSelectCounterResponse
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
messageStore
}
from
"
@/stores
"
;
import
{
DragModal
}
from
"
./Drag
Modal
"
;
import
{
NeosModal
}
from
"
./Neos
Modal
"
;
const
{
checkCounterModal
}
=
messageStore
;
interface
CheckCounterModalProps
{
isOpen
:
boolean
;
counterType
?:
number
;
min
?:
number
;
options
:
{
code
:
number
;
max
:
number
;
}[];
}
const
defaultProps
=
{
isOpen
:
false
,
options
:
[],
};
const
localStore
=
proxy
<
CheckCounterModalProps
>
(
defaultProps
);
const
NeosConfig
=
useConfig
();
export
const
CheckCounterModal
=
()
=>
{
const
snapCheckCounterModal
=
useSnapshot
(
checkCounterModal
);
const
snapCheckCounterModal
=
useSnapshot
(
localStore
);
const
isOpen
=
snapCheckCounterModal
.
isOpen
;
const
min
=
snapCheckCounterModal
.
min
||
0
;
...
...
@@ -28,14 +43,11 @@ export const CheckCounterModal = () => {
const
onFinish
=
()
=>
{
sendSelectCounterResponse
(
selected
);
messageStore
.
checkCounterModal
.
isOpen
=
false
;
messageStore
.
checkCounterModal
.
min
=
undefined
;
messageStore
.
checkCounterModal
.
counterType
=
undefined
;
messageStore
.
checkCounterModal
.
options
=
[];
rs
();
};
return
(
<
Drag
Modal
<
Neos
Modal
title=
{
`请移除${min}个${counterName}`
}
open=
{
isOpen
}
closable=
{
false
}
...
...
@@ -75,6 +87,23 @@ export const CheckCounterModal = () => {
);
})
}
</
Row
>
</
Drag
Modal
>
</
Neos
Modal
>
);
};
let
rs
:
(
arg
?:
any
)
=>
void
=
()
=>
{};
export
const
displayCheckCounterModal
=
async
(
args
:
Omit
<
CheckCounterModalProps
,
"
isOpen
"
>
)
=>
{
Object
.
entries
(
args
).
forEach
(([
key
,
value
])
=>
{
// @ts-ignore
localStore
[
key
]
=
value
;
});
localStore
.
isOpen
=
true
;
await
new
Promise
<
void
>
((
resolve
)
=>
(
rs
=
resolve
));
// 等待在组件内resolve
localStore
.
isOpen
=
false
;
localStore
.
options
=
[];
localStore
.
min
=
undefined
;
localStore
.
counterType
=
undefined
;
};
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