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
2805ab54
Commit
2805ab54
authored
Mar 07, 2024
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 默认卡图
parent
c964f920
Pipeline
#25698
canceled with stages
in 3 minutes and 42 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
22 deletions
+28
-22
src/ui/Shared/YgoCard/index.tsx
src/ui/Shared/YgoCard/index.tsx
+28
-22
No files found.
src/ui/Shared/YgoCard/index.tsx
View file @
2805ab54
import
classNames
from
"
classnames
"
;
import
classNames
from
"
classnames
"
;
import
{
CSSProperties
,
useMemo
}
from
"
react
"
;
import
{
CSSProperties
,
useMemo
,
useEffect
,
useState
}
from
"
react
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
isSuperReleaseCard
}
from
"
@/superPreRelease
"
;
import
{
isSuperReleaseCard
}
from
"
@/superPreRelease
"
;
...
@@ -21,33 +21,39 @@ export const YgoCard: React.FC<Props> = (props) => {
...
@@ -21,33 +21,39 @@ export const YgoCard: React.FC<Props> = (props) => {
const
{
const
{
className
,
className
,
code
=
0
,
code
=
0
,
// cardName,
isBack
=
false
,
isBack
=
false
,
width
,
width
,
style
,
style
,
onClick
,
onClick
,
onLoad
,
onLoad
,
}
=
props
;
}
=
props
;
return
useMemo
(
()
=>
(
const
defaultCardSrc
=
"
https://img2.imgtp.com/2024/03/06/G6wTJRz9.png
"
;
<
div
const
[
src
,
setSrc
]
=
useState
(
defaultCardSrc
);
className=
{
classNames
(
styles
[
"
ygo-card
"
],
className
)
}
style=
{
useEffect
(()
=>
{
{
setSrc
(
defaultCardSrc
);
// 以后应该是一个获取默认卡面的方法
width
,
const
img
=
new
Image
();
"
--src
"
:
`url(${getCardImgUrl(code, isBack)})`
,
img
.
onload
=
()
=>
{
...
style
,
setSrc
(
img
.
src
);
// 图片加载完成后更新src状态
}
as
any
};
}
// 直接设置图片路径,无需url()包裹
onClick=
{
onClick
}
img
.
src
=
getCardImgUrl
(
code
,
isBack
);
// 加载完成
},
[
code
,
isBack
]);
// useEffect的依赖数组中加入isBack
onLoad=
{
onLoad
}
>
return
(
{
/* 暂时不能这么写...但如果用onload的话来判断可能又很消耗性能,再看看吧 */
}
<
div
{
/* {cardName} */
}
className=
{
classNames
(
styles
[
"
ygo-card
"
],
className
)
}
</
div
>
style=
{
),
{
[
code
],
width
,
"
--src
"
:
`url(${src})`
,
...
style
,
}
as
any
}
onClick=
{
onClick
}
onLoad=
{
onLoad
}
></
div
>
);
);
};
};
...
...
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