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
love_飞影
Neos
Commits
e4e6b9f5
Commit
e4e6b9f5
authored
Aug 08, 2023
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: search card
parent
479b78a7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
11 deletions
+39
-11
src/api/cards.ts
src/api/cards.ts
+2
-2
src/ui/BuildDeck/index.module.scss
src/ui/BuildDeck/index.module.scss
+4
-0
src/ui/BuildDeck/index.tsx
src/ui/BuildDeck/index.tsx
+27
-5
src/ui/Layout/index.tsx
src/ui/Layout/index.tsx
+6
-4
No files found.
src/api/cards.ts
View file @
e4e6b9f5
...
...
@@ -62,7 +62,7 @@ export async function fetchCard(id: number): Promise<CardMeta> {
* @returns 卡片数据
*
* */
export
async
function
searchCard
(
export
async
function
searchCard
s
(
query
:
string
,
type
?:
number
):
Promise
<
CardMeta
[]
>
{
...
...
@@ -77,7 +77,7 @@ export async function searchCard(
// @ts-ignore
window
.
fetchCard
=
fetchCard
;
// @ts-ignore
window
.
searchCard
=
searchCard
;
window
.
searchCard
=
searchCard
s
;
export
function
getCardStr
(
meta
:
CardMeta
,
idx
:
number
):
string
|
undefined
{
switch
(
idx
)
{
...
...
src/ui/BuildDeck/index.module.scss
View file @
e4e6b9f5
...
...
@@ -102,3 +102,7 @@
gap
:
10px
;
}
}
.search-count
{
font-size
:
11px
;
}
src/ui/BuildDeck/index.tsx
View file @
e4e6b9f5
...
...
@@ -26,6 +26,7 @@ import { CardDetail } from "./CardDetail";
import
{
DeckSelect
}
from
"
./DeckSelect
"
;
import
styles
from
"
./index.module.scss
"
;
import
{
LoaderFunction
}
from
"
react-router-dom
"
;
import
{
searchCards
,
type
CardMeta
}
from
"
@/api
"
;
const
theme
:
ThemeConfig
=
{
components
:
{
...
...
@@ -147,14 +148,28 @@ const DeckEditor: React.FC<{
/** 卡片库,选择卡片加入正在编辑的卡组 */
const
CardSelect
:
React
.
FC
=
()
=>
{
const
[
searchResult
,
setSearchResult
]
=
useState
<
number
[]
>
([]);
const
[
searchWord
,
setSearchWord
]
=
useState
(
""
);
const
[
searchResult
,
setSearchResult
]
=
useState
<
CardMeta
[]
>
([]);
const
handleSearch
=
async
()
=>
{
const
result
=
await
searchCards
(
searchWord
);
setSearchResult
(
result
);
};
return
(
<
div
className=
{
styles
.
container
}
>
<
div
className=
{
styles
.
title
}
>
<
Input
placeholder=
"搜索卡片"
bordered=
{
false
}
suffix=
{
<
Button
type=
"text"
icon=
{
<
SearchOutlined
/>
}
/>
}
suffix=
{
<
Button
type=
"text"
icon=
{
<
SearchOutlined
/>
}
onClick=
{
handleSearch
}
/>
}
value=
{
searchWord
}
onChange=
{
(
e
)
=>
setSearchWord
(
e
.
target
.
value
)
}
onKeyUp=
{
(
e
)
=>
e
.
key
===
"
Enter
"
&&
handleSearch
()
}
/>
</
div
>
<
div
className=
{
styles
[
"
select-btns
"
]
}
>
...
...
@@ -164,7 +179,12 @@ const CardSelect: React.FC = () => {
{
false
&&
<
Badge
dot
offset=
{
[
5
,
-
5
]
}
/>
}
</
Button
>
<
Button
block
type=
"text"
icon=
{
<
SortAscendingOutlined
/>
}
>
排列
<
span
>
排列
<
span
className=
{
styles
[
"
search-count
"
]
}
>
(
{
searchResult
.
length
}
)
</
span
>
</
span
>
{
false
&&
<
Badge
dot
offset=
{
[
5
,
-
5
]
}
/>
}
</
Button
>
<
Button
block
type=
"text"
icon=
{
<
DeleteOutlined
/>
}
>
...
...
@@ -173,8 +193,10 @@ const CardSelect: React.FC = () => {
</
div
>
<
ScrollableArea
className=
{
styles
[
"
search-cards-container
"
]
}
>
<
div
className=
{
styles
[
"
search-cards
"
]
}
>
{
Array
.
from
({
length
:
60
}).
map
((
_
,
i
)
=>
(
<
div
className=
{
styles
.
card
}
key=
{
i
}
/>
{
searchResult
.
map
(({
id
},
i
)
=>
(
<
div
className=
{
styles
.
card
}
key=
{
i
}
>
<
YgoCard
code=
{
id
}
/>
</
div
>
))
}
</
div
>
</
ScrollableArea
>
...
...
src/ui/Layout/index.tsx
View file @
e4e6b9f5
...
...
@@ -20,11 +20,13 @@ export const loader: LoaderFunction = async () => {
const
user
=
getCookie
<
User
>
(
CookieKeys
.
USER
);
if
(
user
)
accountStore
.
login
(
user
);
// 加载卡组
deckStore
.
initialize
().
then
(()
=>
(
initStore
.
decks
=
true
));
if
(
!
initStore
.
decks
)
deckStore
.
initialize
().
then
(()
=>
(
initStore
.
decks
=
true
));
// 加载ygodb
initSqlite
().
then
(()
=>
(
initStore
.
sqlite
.
progress
=
1
));
initStore
.
sqlite
.
progress
=
0.01
;
if
(
!
initStore
.
sqlite
.
progress
)
{
initSqlite
().
then
(()
=>
(
initStore
.
sqlite
.
progress
=
1
));
initStore
.
sqlite
.
progress
=
0.01
;
}
return
null
;
};
...
...
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