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