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
2f42720c
Commit
2f42720c
authored
Sep 06, 2023
by
zhangshize
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add sort and shuffle
parent
625200f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
3 deletions
+46
-3
src/ui/BuildDeck/index.tsx
src/ui/BuildDeck/index.tsx
+32
-2
src/ui/BuildDeck/store.ts
src/ui/BuildDeck/store.ts
+14
-1
No files found.
src/ui/BuildDeck/index.tsx
View file @
2f42720c
...
...
@@ -3,8 +3,10 @@ import {
DeleteOutlined
,
EditOutlined
,
FilterOutlined
,
RetweetOutlined
,
SearchOutlined
,
SortAscendingOutlined
,
SwapOutlined
,
UndoOutlined
,
}
from
"
@ant-design/icons
"
;
import
{
...
...
@@ -99,6 +101,14 @@ export const Component: React.FC = () => {
}
};
const
handleDeckEditorShuffle
=
()
=>
{
editDeckStore
.
shuffle
(
editDeckStore
);
};
const
handleDeckEditorSort
=
()
=>
{
editDeckStore
.
sort
(
editDeckStore
);
};
return
(
<
DndProvider
backend=
{
HTML5Backend
}
>
<
Background
/>
...
...
@@ -134,6 +144,8 @@ export const Component: React.FC = () => {
onClear=
{
editDeckStore
.
clear
}
onReset=
{
handleDeckEditorReset
}
onSave=
{
handleDeckEditorSave
}
onShuffle=
{
handleDeckEditorShuffle
}
onSort=
{
handleDeckEditorSort
}
/>
</
div
>
<
div
className=
{
styles
.
select
}
>
...
...
@@ -155,10 +167,12 @@ Component.displayName = "Build";
/** 正在编辑的卡组 */
export
const
DeckEditor
:
React
.
FC
<
{
deck
:
IDeck
;
onShuffle
:
()
=>
void
;
onSort
:
()
=>
void
;
onClear
:
()
=>
void
;
onReset
:
()
=>
void
;
onSave
:
()
=>
void
;
}
>
=
({
deck
,
onClear
,
onReset
,
onSave
})
=>
{
}
>
=
({
deck
,
onClear
,
onReset
,
onSave
,
onShuffle
,
onSort
})
=>
{
const
snapEditDeck
=
useSnapshot
(
editDeckStore
);
const
[
deckName
,
setDeckName
]
=
useState
(
editDeckStore
.
deckName
);
...
...
@@ -223,11 +237,27 @@ export const DeckEditor: React.FC<{
placeholder=
"请输入卡组名字"
bordered=
{
false
}
prefix=
{
<
EditOutlined
/>
}
style=
{
{
width
:
40
0
}
}
style=
{
{
width
:
24
0
}
}
onChange=
{
(
e
)
=>
setDeckName
(
e
.
target
.
value
)
}
value=
{
deckName
}
/>
<
Space
style=
{
{
marginRight
:
6
}
}
>
<
Button
type=
"text"
size=
"small"
icon=
{
<
SwapOutlined
/>
}
onClick=
{
onShuffle
}
>
打乱
</
Button
>
<
Button
type=
"text"
size=
"small"
icon=
{
<
RetweetOutlined
/>
}
onClick=
{
onSort
}
>
排序
</
Button
>
<
Button
type=
"text"
size=
"small"
...
...
src/ui/BuildDeck/store.ts
View file @
2f42720c
import
{
shuffle
}
from
"
lodash-es
"
;
import
{
proxy
}
from
"
valtio
"
;
import
{
type
CardMeta
}
from
"
@/api
"
;
...
...
@@ -30,7 +31,7 @@ export const editDeckStore = proxy({
},
set
(
deck
:
EditingDeck
)
{
editDeckStore
.
deckName
=
deck
.
deckName
;
editDeckStore
.
main
=
deck
.
main
.
sort
(
compareCards
)
;
editDeckStore
.
main
=
deck
.
main
;
editDeckStore
.
extra
=
deck
.
extra
.
sort
(
compareCards
);
editDeckStore
.
side
=
deck
.
side
.
sort
(
compareCards
);
editDeckStore
.
edited
=
false
;
...
...
@@ -41,6 +42,18 @@ export const editDeckStore = proxy({
editDeckStore
.
side
=
[];
editDeckStore
.
edited
=
true
;
},
/**
* 打乱
* @description 通常只有主卡组有打乱的需求,但这里也支持额外和副卡组
*/
shuffle
(
deck
:
EditingDeck
,
type
:
Type
=
"
main
"
)
{
editDeckStore
[
type
]
=
shuffle
(
deck
[
type
]);
editDeckStore
.
edited
=
true
;
},
sort
(
deck
:
EditingDeck
,
type
:
Type
=
"
main
"
)
{
editDeckStore
[
type
]
=
deck
[
type
].
sort
(
compareCards
);
editDeckStore
.
edited
=
true
;
},
getAll
()
{
return
[
...
editDeckStore
.
main
,
...
...
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