Repository navigation
feat(redenvelope): add risk control for red envelope claim and add QR Code Sharing #258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
small-lovely-cat
wants to merge
5
commits into
linux-do:master
Choose a base branch
from
small-lovely-cat:feat-red-envelope
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
de395be
feat(redenvelope): add risk control for red envelope claim and add QR…
small-lovely-cat 7a3eccf
fix(redenvelope): address claim review feedback
Aether-254 b0e3820
Merge pull request #1 from Aether-254/fix/redenvelope-review-findings
small-lovely-cat b0cd71b
fix(redenvelope): use redis atomic increase to avoid concurrency error
small-lovely-cat d4c61ec
fix(redenvelope): delay risk update check to avoid unintended risk co…
small-lovely-cat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
frontend/components/common/redenvelope/red-envelope-share.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| "use client" | ||
|
|
||
| import { useState } from "react" | ||
| import Image from "next/image" | ||
| import { motion, useReducedMotion } from "motion/react" | ||
| import { QRCodeSVG } from "qrcode.react" | ||
|
|
||
| export function RedEnvelopeShare({ link }: { link: string }) { | ||
| const [playing, setPlaying] = useState(false) | ||
| const [replay, setReplay] = useState(0) | ||
| const reduceMotion = useReducedMotion() | ||
|
|
||
| return ( | ||
| <> | ||
| <div className="-mt-2 flex justify-center py-1 md:hidden"> | ||
| <div className="w-1/2 rounded-xl bg-white p-1 shadow-sm ring-1 ring-black/5 sm:p-2"> | ||
| <QRCodeSVG value={link} size={224} marginSize={4} level="M" title="红包领取二维码" className="h-auto w-full" /> | ||
| </div> | ||
| </div> | ||
| <div | ||
| className="relative mx-auto -mt-2 hidden w-fit grid-cols-[176px_90px] items-center gap-3 py-1 md:grid" | ||
| onPointerEnter={(event) => { | ||
| if (event.pointerType === "mouse") setPlaying(true) | ||
| }} | ||
| onPointerLeave={(event) => { | ||
| if (event.pointerType === "mouse") setPlaying(false) | ||
| }} | ||
| onFocus={() => setPlaying(true)} | ||
| onBlur={(event) => { | ||
| if (!event.currentTarget.contains(event.relatedTarget)) setPlaying(false) | ||
| }} | ||
| > | ||
| <motion.button | ||
| type="button" | ||
| aria-expanded={playing} | ||
| initial={false} | ||
| animate={{ x: playing ? 0 : 51 }} | ||
| transition={reduceMotion ? { duration: 0 } : { type: "spring", stiffness: 180, damping: 24 }} | ||
| className="relative z-10 aspect-square w-full rounded-xl bg-white p-1 shadow-sm ring-1 ring-black/5 outline-none focus-visible:ring-2 focus-visible:ring-red-500 sm:p-2" | ||
| onClick={() => { | ||
| setPlaying(true) | ||
| setReplay(value => value + 1) | ||
| }} | ||
| > | ||
| <QRCodeSVG value={link} size={224} marginSize={4} level="M" className="h-auto w-full" /> | ||
| </motion.button> | ||
|
|
||
| <motion.div | ||
| initial={false} | ||
| animate={{ opacity: playing ? 1 : 0 }} | ||
| transition={{ duration: reduceMotion ? 0 : 0.3, delay: playing && !reduceMotion ? 0.15 : 0 }} | ||
| aria-hidden={!playing} | ||
| className="pointer-events-none relative h-44 min-w-0" | ||
| > | ||
| {playing && ( | ||
| <Image | ||
| key={replay} | ||
| src="/red-envelope-scan.svg" | ||
| alt="" | ||
| width={128} | ||
| height={252} | ||
| unoptimized | ||
| className="absolute inset-0 h-full w-full" | ||
| /> | ||
| )} | ||
| </motion.div> | ||
| </div> | ||
| </> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.