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
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
Show 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 {
...
@@ -3,8 +3,10 @@ import {
DeleteOutlined
,
DeleteOutlined
,
EditOutlined
,
EditOutlined
,
FilterOutlined
,
FilterOutlined
,
RetweetOutlined
,
SearchOutlined
,
SearchOutlined
,
SortAscendingOutlined
,
SortAscendingOutlined
,
SwapOutlined
,
UndoOutlined
,
UndoOutlined
,
}
from
"
@ant-design/icons
"
;
}
from
"
@ant-design/icons
"
;
import
{
import
{
...
@@ -99,6 +101,14 @@ export const Component: React.FC = () => {
...
@@ -99,6 +101,14 @@ export const Component: React.FC = () => {
}
}
};
};
const
handleDeckEditorShuffle
=
()
=>
{
editDeckStore
.
shuffle
(
editDeckStore
);
};
const
handleDeckEditorSort
=
()
=>
{
editDeckStore
.
sort
(
editDeckStore
);
};
return
(
return
(
<
DndProvider
backend=
{
HTML5Backend
}
>
<
DndProvider
backend=
{
HTML5Backend
}
>
<
Background
/>
<
Background
/>
...
@@ -134,6 +144,8 @@ export const Component: React.FC = () => {
...
@@ -134,6 +144,8 @@ export const Component: React.FC = () => {
onClear=
{
editDeckStore
.
clear
}
onClear=
{
editDeckStore
.
clear
}
onReset=
{
handleDeckEditorReset
}
onReset=
{
handleDeckEditorReset
}
onSave=
{
handleDeckEditorSave
}
onSave=
{
handleDeckEditorSave
}
onShuffle=
{
handleDeckEditorShuffle
}
onSort=
{
handleDeckEditorSort
}
/>
/>
</
div
>
</
div
>
<
div
className=
{
styles
.
select
}
>
<
div
className=
{
styles
.
select
}
>
...
@@ -155,10 +167,12 @@ Component.displayName = "Build";
...
@@ -155,10 +167,12 @@ Component.displayName = "Build";
/** 正在编辑的卡组 */
/** 正在编辑的卡组 */
export
const
DeckEditor
:
React
.
FC
<
{
export
const
DeckEditor
:
React
.
FC
<
{
deck
:
IDeck
;
deck
:
IDeck
;
onShuffle
:
()
=>
void
;
onSort
:
()
=>
void
;
onClear
:
()
=>
void
;
onClear
:
()
=>
void
;
onReset
:
()
=>
void
;
onReset
:
()
=>
void
;
onSave
:
()
=>
void
;
onSave
:
()
=>
void
;
}
>
=
({
deck
,
onClear
,
onReset
,
onSave
})
=>
{
}
>
=
({
deck
,
onClear
,
onReset
,
onSave
,
onShuffle
,
onSort
})
=>
{
const
snapEditDeck
=
useSnapshot
(
editDeckStore
);
const
snapEditDeck
=
useSnapshot
(
editDeckStore
);
const
[
deckName
,
setDeckName
]
=
useState
(
editDeckStore
.
deckName
);
const
[
deckName
,
setDeckName
]
=
useState
(
editDeckStore
.
deckName
);
...
@@ -223,11 +237,27 @@ export const DeckEditor: React.FC<{
...
@@ -223,11 +237,27 @@ export const DeckEditor: React.FC<{
placeholder=
"请输入卡组名字"
placeholder=
"请输入卡组名字"
bordered=
{
false
}
bordered=
{
false
}
prefix=
{
<
EditOutlined
/>
}
prefix=
{
<
EditOutlined
/>
}
style=
{
{
width
:
40
0
}
}
style=
{
{
width
:
24
0
}
}
onChange=
{
(
e
)
=>
setDeckName
(
e
.
target
.
value
)
}
onChange=
{
(
e
)
=>
setDeckName
(
e
.
target
.
value
)
}
value=
{
deckName
}
value=
{
deckName
}
/>
/>
<
Space
style=
{
{
marginRight
:
6
}
}
>
<
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
<
Button
type=
"text"
type=
"text"
size=
"small"
size=
"small"
...
...
src/ui/BuildDeck/store.ts
View file @
2f42720c
import
{
shuffle
}
from
"
lodash-es
"
;
import
{
proxy
}
from
"
valtio
"
;
import
{
proxy
}
from
"
valtio
"
;
import
{
type
CardMeta
}
from
"
@/api
"
;
import
{
type
CardMeta
}
from
"
@/api
"
;
...
@@ -30,7 +31,7 @@ export const editDeckStore = proxy({
...
@@ -30,7 +31,7 @@ export const editDeckStore = proxy({
},
},
set
(
deck
:
EditingDeck
)
{
set
(
deck
:
EditingDeck
)
{
editDeckStore
.
deckName
=
deck
.
deckName
;
editDeckStore
.
deckName
=
deck
.
deckName
;
editDeckStore
.
main
=
deck
.
main
.
sort
(
compareCards
)
;
editDeckStore
.
main
=
deck
.
main
;
editDeckStore
.
extra
=
deck
.
extra
.
sort
(
compareCards
);
editDeckStore
.
extra
=
deck
.
extra
.
sort
(
compareCards
);
editDeckStore
.
side
=
deck
.
side
.
sort
(
compareCards
);
editDeckStore
.
side
=
deck
.
side
.
sort
(
compareCards
);
editDeckStore
.
edited
=
false
;
editDeckStore
.
edited
=
false
;
...
@@ -41,6 +42,18 @@ export const editDeckStore = proxy({
...
@@ -41,6 +42,18 @@ export const editDeckStore = proxy({
editDeckStore
.
side
=
[];
editDeckStore
.
side
=
[];
editDeckStore
.
edited
=
true
;
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
()
{
getAll
()
{
return
[
return
[
...
editDeckStore
.
main
,
...
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