Toggle navigation
Toggle navigation
This project
Loading...
Sign in
卢阳
/
front_backend_zImage
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
ly0303521
2026-01-20 14:55:24 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f0186ff2061f3557eef5c19a0d9f8323476271f6
f0186ff2
1 parent
df29545a
给“动感视界”增加点赞功能,并且该点赞数也会触发增加视频生成的次数
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
14 deletions
backend/main.py
backend/usage.json
z-image-generator/components/ImageCard.tsx
backend/main.py
View file @
f0186ff
...
...
@@ -260,11 +260,13 @@ async def toggle_like(item_id: str, user_id: str = Query(..., alias="userId")):
return
updated_item
updated_item
=
video_store
.
toggle_like
(
item_id
,
user_id
)
if
updated_item
:
return
updated_item
raise
HTTPException
(
status_code
=
404
,
detail
=
"Item not found"
)
updated_item
=
video_store
.
toggle_like
(
item_id
,
user_id
)
if
updated_item
:
return
updated_item
if
updated_item
:
is_liked_after
=
user_id
in
updated_item
.
get
(
"likedBy"
,
[])
if
is_liked_after
and
not
is_liked_before
:
usage_store
.
update_bonus
(
user_id
,
1
)
elif
not
is_liked_after
and
is_liked_before
:
usage_store
.
update_bonus
(
user_id
,
-
1
)
return
updated_item
raise
HTTPException
(
status_code
=
404
,
detail
=
"Item not found"
)
@app.get
(
"/usage/{user_id}"
)
...
...
backend/usage.json
View file @
f0186ff
...
...
@@ -6,7 +6,7 @@
},
"11110000"
:
{
"daily_used"
:
2
,
"bonus_count"
:
0
,
"bonus_count"
:
2
,
"last_reset"
:
"2026-01-20"
}
}
\ No newline at end of file
...
...
z-image-generator/components/ImageCard.tsx
View file @
f0186ff
...
...
@@ -16,7 +16,6 @@ const ImageCard: React.FC<ImageCardProps> = ({ image, onClick, onLike, currentUs
const handleLike = (e: React.MouseEvent) => {
e.stopPropagation();
if (isVideo) return; // Liking is disabled for videos for now
onLike(image);
};
...
...
@@ -123,7 +122,7 @@ const ImageCard: React.FC<ImageCardProps> = ({ image, onClick, onLike, currentUs
<button
onClick={handleLike}
className={`flex items-center gap-1.5 px-3 py-1.5 rounded-full backdrop-blur-md transition-all duration-200 ${image.isLikedByCurrentUser ? 'bg-red-500/80 text-white' : 'bg-white/20 text-white hover:bg-white/30'}`}
title={currentUser ? "Like this
image
" : "Login to like"}
title={currentUser ? "Like this" : "Login to like"}
>
<Heart size={14} fill={image.isLikedByCurrentUser ? "currentColor" : "none"} />
<span className="text-xs font-bold">{image.likes}</span>
...
...
@@ -133,13 +132,19 @@ const ImageCard: React.FC<ImageCardProps> = ({ image, onClick, onLike, currentUs
<div className="flex justify-between items-end">
<div className="text-xs text-gray-300 font-mono flex flex-col gap-1">
<span className="opacity-75">ID: {image.authorId || 'UNKNOWN'}</span>
{image.generationTime && (
<span className="bg-white/10 px-1.5 py-0.5 rounded w-fit flex items-center gap-1"><Hourglass size={10} />{image.generationTime.toFixed(1)}s</span>
)}
</div>
{image.generationTime && (
<div className="flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-white/10 backdrop-blur-md text-white">
<Hourglass size={12} />
<span className="text-xs font-bold">{image.generationTime.toFixed(1)}s</span>
</div>
)}
<button
onClick={handleLike}
className={`flex items-center gap-1.5 px-3 py-1.5 rounded-full backdrop-blur-md transition-all duration-200 ${image.isLikedByCurrentUser ? 'bg-red-500/80 text-white' : 'bg-white/20 text-white hover:bg-white/30'}`}
title={currentUser ? "Like this video" : "Login to like"}
>
<Heart size={14} fill={image.isLikedByCurrentUser ? "currentColor" : "none"} />
<span className="text-xs font-bold">{image.likes}</span>
</button>
</div>
)}
</div>
...
...
Please
register
or
login
to post a comment