Merge pull request #3 from handsomezhuzhu/v0/kdaugh14-4907-a84156e8

feat: add GitHub link button
This commit is contained in:
Simon
2026-02-05 00:50:16 +08:00
committed by GitHub
2 changed files with 76 additions and 39 deletions

View File

@@ -27,6 +27,7 @@ import {
Monitor, Monitor,
Languages, Languages,
Check, Check,
Github,
} from "lucide-react" } from "lucide-react"
import { Button } from "@/components/ui/button" import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input" import { Input } from "@/components/ui/input"
@@ -657,6 +658,22 @@ export default function TwoFactorAuth() {
</div> </div>
</div> </div>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<Button
variant="ghost"
size="icon"
asChild
>
<a
href="https://github.com/handsomezhuzhu/2fa-tool"
target="_blank"
rel="noopener noreferrer"
title="GitHub"
>
<Github className="h-5 w-5" />
<span className="sr-only">GitHub</span>
</a>
</Button>
<Button <Button
variant="ghost" variant="ghost"
size="icon" size="icon"
@@ -847,40 +864,42 @@ export default function TwoFactorAuth() {
{showAdvanced && ( {showAdvanced && (
<div className="mt-4 space-y-4"> <div className="mt-4 space-y-4">
<div className="space-y-2"> <div className="grid grid-cols-2 gap-4">
<Label>{t.algorithm}</Label> <div className="space-y-2">
<Select <Label>{t.algorithm}</Label>
value={newToken.algorithm} <Select
onValueChange={(value: "SHA1" | "SHA256" | "SHA512") => value={newToken.algorithm}
setNewToken({ ...newToken, algorithm: value }) onValueChange={(value: "SHA1" | "SHA256" | "SHA512") =>
} setNewToken({ ...newToken, algorithm: value })
> }
<SelectTrigger> >
<SelectValue /> <SelectTrigger>
</SelectTrigger> <SelectValue />
<SelectContent> </SelectTrigger>
<SelectItem value="SHA1">{t.algorithmDefault}</SelectItem> <SelectContent>
<SelectItem value="SHA256">SHA-256</SelectItem> <SelectItem value="SHA1">{t.algorithmDefault}</SelectItem>
<SelectItem value="SHA512">SHA-512</SelectItem> <SelectItem value="SHA256">SHA-256</SelectItem>
</SelectContent> <SelectItem value="SHA512">SHA-512</SelectItem>
</Select> </SelectContent>
</div> </Select>
<div className="space-y-2"> </div>
<Label>{t.digits}</Label> <div className="space-y-2">
<Select <Label>{t.digits}</Label>
value={newToken.digits.toString()} <Select
onValueChange={(value) => value={newToken.digits.toString()}
setNewToken({ ...newToken, digits: Number.parseInt(value) as 6 | 8 }) onValueChange={(value) =>
} setNewToken({ ...newToken, digits: Number.parseInt(value) as 6 | 8 })
> }
<SelectTrigger> >
<SelectValue /> <SelectTrigger>
</SelectTrigger> <SelectValue />
<SelectContent> </SelectTrigger>
<SelectItem value="6">{t.digitsDefault}</SelectItem> <SelectContent>
<SelectItem value="8">{t.digits8}</SelectItem> <SelectItem value="6">{t.digitsDefault}</SelectItem>
</SelectContent> <SelectItem value="8">{t.digits8}</SelectItem>
</Select> </SelectContent>
</Select>
</div>
</div> </div>
<div className="space-y-2"> <div className="space-y-2">
<Label>{t.period}</Label> <Label>{t.period}</Label>
@@ -1237,7 +1256,7 @@ function TokenCard({ token, code, timeLeft, showCode, onCopy, onEdit, onDelete,
<Edit2 className="h-4 w-4 mr-2" /> <Edit2 className="h-4 w-4 mr-2" />
{t.edit} {t.edit}
</DropdownMenuItem> </DropdownMenuItem>
<DropdownMenuItem onClick={onDelete} className="text-destructive"> <DropdownMenuItem onClick={onDelete} className="text-red-500 focus:text-red-500 focus:bg-red-500/10">
<Trash2 className="h-4 w-4 mr-2" /> <Trash2 className="h-4 w-4 mr-2" />
{t.delete} {t.delete}
</DropdownMenuItem> </DropdownMenuItem>

View File

@@ -31,7 +31,7 @@ const toastVariants = cva(
variant: { variant: {
default: 'border bg-background text-foreground', default: 'border bg-background text-foreground',
destructive: destructive:
'destructive group border-destructive bg-destructive text-destructive-foreground', 'destructive group border-red-500 bg-red-500 text-white dark:border-red-600 dark:bg-red-600',
}, },
}, },
defaultVariants: { defaultVariants: {
@@ -44,11 +44,19 @@ const Toast = React.forwardRef<
React.ElementRef<typeof ToastPrimitives.Root>, React.ElementRef<typeof ToastPrimitives.Root>,
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> & React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &
VariantProps<typeof toastVariants> VariantProps<typeof toastVariants>
>(({ className, variant, ...props }, ref) => { >(({ className, variant, onPointerDown, onMouseDown, ...props }, ref) => {
return ( return (
<ToastPrimitives.Root <ToastPrimitives.Root
ref={ref} ref={ref}
className={cn(toastVariants({ variant }), className)} className={cn(toastVariants({ variant }), className)}
onPointerDown={(e) => {
e.stopPropagation()
onPointerDown?.(e)
}}
onMouseDown={(e) => {
e.stopPropagation()
onMouseDown?.(e)
}}
{...props} {...props}
/> />
) )
@@ -73,14 +81,24 @@ ToastAction.displayName = ToastPrimitives.Action.displayName
const ToastClose = React.forwardRef< const ToastClose = React.forwardRef<
React.ElementRef<typeof ToastPrimitives.Close>, React.ElementRef<typeof ToastPrimitives.Close>,
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close> React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>
>(({ className, ...props }, ref) => ( >(({ className, onClick, ...props }, ref) => (
<ToastPrimitives.Close <ToastPrimitives.Close
ref={ref} ref={ref}
className={cn( className={cn(
'absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600', 'absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-100 transition-opacity hover:text-foreground focus:outline-none focus:ring-2 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600',
className, className,
)} )}
toast-close="" toast-close=""
onClick={(e) => {
e.stopPropagation()
onClick?.(e)
}}
onPointerDown={(e) => {
e.stopPropagation()
}}
onMouseDown={(e) => {
e.stopPropagation()
}}
{...props} {...props}
> >
<X className="h-4 w-4" /> <X className="h-4 w-4" />