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
93439c46
Commit
93439c46
authored
Jun 25, 2023
by
chechunchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate sortcard modal
parent
eba32a50
Pipeline
#22409
failed with stages
in 15 minutes and 33 seconds
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
31 deletions
+39
-31
src/service/duel/gameMsg.ts
src/service/duel/gameMsg.ts
+1
-1
src/service/duel/sortCard.ts
src/service/duel/sortCard.ts
+5
-5
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/SortCardModal.tsx
src/ui/Duel/Message/SortCardModal.tsx
+33
-11
No files found.
src/service/duel/gameMsg.ts
View file @
93439c46
...
...
@@ -220,7 +220,7 @@ async function _handleGameMsg(pb: ygopro.YgoStocMsg) {
break
;
}
case
"
sort_card
"
:
{
onMsgSortCard
(
msg
.
sort_card
);
await
onMsgSortCard
(
msg
.
sort_card
);
break
;
}
...
...
src/service/duel/sortCard.ts
View file @
93439c46
import
{
fetchCard
,
ygopro
}
from
"
@/api
"
;
import
{
messageStore
}
from
"
@/stores
"
;
import
{
displaySortCardModal
}
from
"
@/ui/Duel/Message
"
;
type
MsgSortCard
=
ygopro
.
StocGameMessage
.
MsgSortCard
;
export
default
async
(
sortCard
:
MsgSortCard
)
=>
{
await
Promise
.
all
(
const
options
=
await
Promise
.
all
(
sortCard
.
options
.
map
(
async
({
code
,
response
})
=>
{
const
meta
=
await
fetchCard
(
code
!
);
messageStore
.
sortCardModal
.
options
.
push
(
{
return
{
meta
,
response
:
response
!
,
}
)
;
};
})
);
messageStore
.
sortCardModal
.
isOpen
=
true
;
await
displaySortCardModal
(
options
)
;
};
src/stores/messageStore/store.ts
View file @
93439c46
...
...
@@ -7,10 +7,6 @@ export const messageStore = proxy<ModalState>({
isOpen
:
false
,
options
:
[],
},
sortCardModal
:
{
isOpen
:
false
,
options
:
[],
},
announceModal
:
{
isOpen
:
false
,
min
:
1
,
...
...
src/stores/messageStore/types.ts
View file @
93439c46
import
type
{
CardMeta
,
ygopro
}
from
"
@/api
"
;
export
interface
ModalState
{
// 指示器选择弹窗
checkCounterModal
:
{
...
...
@@ -11,14 +9,6 @@ export interface ModalState {
max
:
number
;
}[];
};
// 卡牌排序弹窗
sortCardModal
:
{
isOpen
:
boolean
;
options
:
{
meta
:
CardMeta
;
response
:
number
;
}[];
};
// 宣言弹窗
announceModal
:
{
isOpen
:
boolean
;
...
...
src/ui/Duel/Message/SortCardModal.tsx
View file @
93439c46
// 卡牌排序弹窗
import
{
closestCenter
,
DndContext
,
...
...
@@ -15,23 +16,35 @@ import {
verticalListSortingStrategy
,
}
from
"
@dnd-kit/sortable
"
;
import
{
CSS
}
from
"
@dnd-kit/utilities
"
;
import
{
Button
,
Card
,
Modal
}
from
"
antd
"
;
import
{
Button
,
Card
}
from
"
antd
"
;
import
React
,
{
useEffect
,
useState
}
from
"
react
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
proxy
,
useSnapshot
}
from
"
valtio
"
;
import
{
sendSortCardResponse
}
from
"
@/api
"
;
import
{
CardMeta
}
from
"
@/api/cards
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
messageStore
}
from
"
@/stores
"
;
import
{
NeosModal
}
from
"
./NeosModal
"
;
const
NeosConfig
=
useConfig
();
const
{
sortCardModal
}
=
messageStore
;
interface
SortOption
{
meta
:
CardMeta
;
response
:
number
;
}
interface
SortCardModalProps
{
isOpen
:
boolean
;
options
:
SortOption
[];
}
const
defaultProps
=
{
isOpen
:
false
,
options
:
[],
};
const
localStore
=
proxy
<
SortCardModalProps
>
(
defaultProps
);
export
const
SortCardModal
=
()
=>
{
const
snapSortCardModal
=
useSnapshot
(
sortCardModal
);
const
isOpen
=
snapSortCardModal
.
isOpen
;
const
options
=
snapSortCardModal
.
options
;
const
{
isOpen
,
options
}
=
useSnapshot
(
localStore
);
const
[
items
,
setItems
]
=
useState
(
options
);
const
sensors
=
useSensors
(
useSensor
(
PointerSensor
),
...
...
@@ -42,8 +55,7 @@ export const SortCardModal = () => {
const
onFinish
=
()
=>
{
sendSortCardResponse
(
items
.
map
((
item
)
=>
item
.
response
));
sortCardModal
.
isOpen
=
false
;
sortCardModal
.
options
=
[];
rs
();
};
const
onDragEnd
=
(
event
:
DragEndEvent
)
=>
{
const
{
active
,
over
}
=
event
;
...
...
@@ -63,7 +75,7 @@ export const SortCardModal = () => {
},
[
options
]);
return
(
<
Modal
<
Neos
Modal
title=
"请为下列卡牌排序"
open=
{
isOpen
}
closable=
{
false
}
...
...
@@ -87,7 +99,7 @@ export const SortCardModal = () => {
))
}
</
SortableContext
>
</
DndContext
>
</
Modal
>
</
Neos
Modal
>
);
};
...
...
@@ -114,3 +126,13 @@ const SortableItem = (props: { id: number; meta: CardMeta }) => {
</
div
>
);
};
let
rs
:
(
arg
?:
any
)
=>
void
=
()
=>
{};
export
const
displaySortCardModal
=
async
(
options
:
SortOption
[])
=>
{
localStore
.
options
=
options
;
localStore
.
isOpen
=
true
;
await
new
Promise
<
void
>
((
resolve
)
=>
(
rs
=
resolve
));
localStore
.
isOpen
=
false
;
localStore
.
options
=
[];
};
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