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
a5f0bc78
Commit
a5f0bc78
authored
Jun 16, 2024
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
show only my decks
parent
03a1ce6b
Pipeline
#27789
passed with stages
in 9 minutes and 18 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
114 additions
and
39 deletions
+114
-39
src/api/mdproDeck/schema.ts
src/api/mdproDeck/schema.ts
+2
-2
src/ui/BuildDeck/DeckDatabase/DeckResults/index.tsx
src/ui/BuildDeck/DeckDatabase/DeckResults/index.tsx
+82
-23
src/ui/BuildDeck/DeckDatabase/index.tsx
src/ui/BuildDeck/DeckDatabase/index.tsx
+30
-14
No files found.
src/api/mdproDeck/schema.ts
View file @
a5f0bc78
...
@@ -32,7 +32,7 @@ export interface MdproDeckLike {
...
@@ -32,7 +32,7 @@ export interface MdproDeckLike {
deckId
:
string
;
deckId
:
string
;
deckContributor
:
string
;
deckContributor
:
string
;
deckName
:
string
;
deckName
:
string
;
deckLike
:
string
;
deckLike
?:
number
;
deckCase
:
number
;
deckCase
:
number
;
lastDate
:
string
;
lastDate
?
:
string
;
}
}
src/ui/BuildDeck/DeckDatabase/DeckResults/index.tsx
View file @
a5f0bc78
import
{
message
,
Pagination
}
from
"
antd
"
;
import
{
App
,
message
,
Pagination
}
from
"
antd
"
;
import
React
,
{
memo
,
useEffect
}
from
"
react
"
;
import
React
,
{
memo
,
useEffect
}
from
"
react
"
;
import
{
type
INTERNAL_Snapshot
as
Snapshot
,
proxy
,
useSnapshot
}
from
"
valtio
"
;
import
{
type
INTERNAL_Snapshot
as
Snapshot
,
proxy
,
useSnapshot
}
from
"
valtio
"
;
import
YGOProDeck
from
"
ygopro-deck-encode
"
;
import
YGOProDeck
from
"
ygopro-deck-encode
"
;
import
{
mgetDeck
,
pullDecks
}
from
"
@/api
"
;
import
{
getPersonalList
,
mgetDeck
,
pullDecks
}
from
"
@/api
"
;
import
{
MdproDeckLike
}
from
"
@/api/mdproDeck/schema
"
;
import
{
MdproDeckLike
}
from
"
@/api/mdproDeck/schema
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
accountStore
}
from
"
@/stores
"
;
import
{
IconFont
}
from
"
@/ui/Shared
"
;
import
{
IconFont
}
from
"
@/ui/Shared
"
;
import
{
setSelectedDeck
}
from
"
../..
"
;
import
{
setSelectedDeck
}
from
"
../..
"
;
...
@@ -20,37 +21,91 @@ interface Props {
...
@@ -20,37 +21,91 @@ interface Props {
page
:
number
;
page
:
number
;
decks
:
MdproDeckLike
[];
decks
:
MdproDeckLike
[];
total
:
number
;
total
:
number
;
onlyMine
:
boolean
;
}
}
// TODO: useConfig
// TODO: useConfig
const
PAGE_SIZE
=
30
;
const
PAGE_SIZE
=
30
;
const
SORT_LIKE
=
true
;
const
SORT_LIKE
=
true
;
const
store
=
proxy
<
Props
>
({
query
:
""
,
page
:
1
,
decks
:
[],
total
:
0
});
const
store
=
proxy
<
Props
>
({
query
:
""
,
page
:
1
,
decks
:
[],
total
:
0
,
onlyMine
:
false
,
});
export
const
DeckResults
:
React
.
FC
=
memo
(()
=>
{
export
const
DeckResults
:
React
.
FC
=
memo
(()
=>
{
const
snap
=
useSnapshot
(
store
);
const
snap
=
useSnapshot
(
store
);
const
{
message
}
=
App
.
useApp
();
useEffect
(()
=>
{
useEffect
(()
=>
{
const
update
=
async
()
=>
{
if
(
snap
.
onlyMine
)
{
const
resp
=
await
pullDecks
({
// show only decks uploaded by myself
page
:
snap
.
page
,
size
:
PAGE_SIZE
,
const
update
=
async
()
=>
{
keyWord
:
snap
.
query
!==
""
?
snap
.
query
:
undefined
,
const
user
=
accountStore
.
user
;
sortLike
:
SORT_LIKE
,
if
(
user
)
{
});
const
resp
=
await
getPersonalList
({
userID
:
user
.
id
,
if
(
resp
?.
data
)
{
token
:
user
.
token
,
const
{
total
,
records
:
newDecks
}
=
resp
.
data
;
});
store
.
total
=
total
;
store
.
decks
=
newDecks
;
if
(
resp
)
{
}
else
{
if
(
resp
.
code
!==
0
||
resp
.
data
===
undefined
)
{
store
.
decks
=
[];
message
.
error
(
resp
.
message
);
}
}
else
{
};
const
decks
=
resp
.
data
;
update
();
const
total
=
decks
.
length
;
},
[
snap
.
query
,
snap
.
page
]);
store
.
total
=
total
;
if
(
total
===
0
)
{
store
.
page
=
1
;
store
.
decks
=
[];
}
else
{
if
(
total
<=
(
store
.
page
-
1
)
*
PAGE_SIZE
)
store
.
page
=
Math
.
floor
((
total
-
1
)
/
PAGE_SIZE
)
+
1
;
store
.
decks
=
decks
.
slice
(
(
store
.
page
-
1
)
*
PAGE_SIZE
,
store
.
page
*
PAGE_SIZE
,
);
}
}
}
else
{
message
.
error
(
"
获取个人卡组列表失败,请检查自己的网络状况。
"
);
}
}
else
{
message
.
error
(
"
需要先登录萌卡账号才能查看自己的在线卡组
"
);
// set to default
store
.
page
=
1
;
store
.
decks
=
[];
store
.
total
=
0
;
}
};
update
();
}
else
{
const
update
=
async
()
=>
{
const
resp
=
await
pullDecks
({
page
:
snap
.
page
,
size
:
PAGE_SIZE
,
keyWord
:
snap
.
query
!==
""
?
snap
.
query
:
undefined
,
sortLike
:
SORT_LIKE
,
});
if
(
resp
?.
data
)
{
const
{
total
,
records
:
newDecks
}
=
resp
.
data
;
store
.
total
=
total
;
store
.
decks
=
newDecks
;
}
else
{
store
.
decks
=
[];
}
};
update
();
}
},
[
snap
.
query
,
snap
.
page
,
snap
.
onlyMine
]);
const
onChangePage
=
async
(
page
:
number
)
=>
{
const
onChangePage
=
async
(
page
:
number
)
=>
{
const
resp
=
await
pullDecks
({
const
resp
=
await
pullDecks
({
...
@@ -160,4 +215,8 @@ function truncateString(str: string, maxLen: number): string {
...
@@ -160,4 +215,8 @@ function truncateString(str: string, maxLen: number): string {
return
`
${
start
}
...
${
end
}
`
;
return
`
${
start
}
...
${
end
}
`
;
}
}
export
const
freshMdrpoDecks
=
(
query
:
string
)
=>
(
store
.
query
=
query
);
export
const
freshMdrpoDecks
=
(
query
:
string
,
onlyMine
?:
boolean
)
=>
{
store
.
query
=
query
;
if
(
onlyMine
!==
undefined
)
store
.
onlyMine
=
onlyMine
;
};
src/ui/BuildDeck/DeckDatabase/index.tsx
View file @
a5f0bc78
...
@@ -15,7 +15,7 @@ import { useDrop } from "react-dnd";
...
@@ -15,7 +15,7 @@ import { useDrop } from "react-dnd";
import
{
CardMeta
,
searchCards
}
from
"
@/api
"
;
import
{
CardMeta
,
searchCards
}
from
"
@/api
"
;
import
{
isToken
}
from
"
@/common
"
;
import
{
isToken
}
from
"
@/common
"
;
import
{
emptySearchConditions
,
FtsConditions
}
from
"
@/middleware/sqlite/fts
"
;
import
{
emptySearchConditions
,
FtsConditions
}
from
"
@/middleware/sqlite/fts
"
;
import
{
ScrollableArea
,
Type
}
from
"
@/ui/Shared
"
;
import
{
ScrollableArea
,
Select
,
Type
}
from
"
@/ui/Shared
"
;
import
{
Filter
}
from
"
../Filter
"
;
import
{
Filter
}
from
"
../Filter
"
;
import
styles
from
"
../index.module.scss
"
;
import
styles
from
"
../index.module.scss
"
;
...
@@ -149,19 +149,35 @@ export const DeckDatabase: React.FC = () => {
...
@@ -149,19 +149,35 @@ export const DeckDatabase: React.FC = () => {
</
Button
>
</
Button
>
</
Space
>
</
Space
>
<
div
className=
{
styles
[
"
select-btns
"
]
}
>
<
div
className=
{
styles
[
"
select-btns
"
]
}
>
<
Button
{
showMdproDecks
?
(
block
<
Select
type=
{
title=
""
isEqual
(
emptySearchConditions
,
searchConditions
)
style=
{
{
width
:
"
18.90rem
"
}
}
?
"
text
"
defaultValue=
{
false
}
:
"
primary
"
options=
{
[
}
{
value
:
true
,
label
:
"
只显示我上传的卡组
"
},
disabled=
{
showMdproDecks
}
{
value
:
false
,
label
:
"
显示全部在线卡组
"
},
icon=
{
<
FilterOutlined
/>
}
]
}
onClick=
{
showFilterModal
}
onChange=
{
>
// @ts-ignore
筛选
(
value
)
=>
freshMdrpoDecks
(
searchWord
,
value
)
</
Button
>
}
/>
)
:
(
<
Button
block
type=
{
isEqual
(
emptySearchConditions
,
searchConditions
)
?
"
text
"
:
"
primary
"
}
disabled=
{
showMdproDecks
}
icon=
{
<
FilterOutlined
/>
}
onClick=
{
showFilterModal
}
>
筛选
</
Button
>
)
}
<
Dropdown
<
Dropdown
menu=
{
{
items
:
dropdownOptions
}
}
menu=
{
{
items
:
dropdownOptions
}
}
disabled=
{
showMdproDecks
}
disabled=
{
showMdproDecks
}
...
...
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