From 0f79ed14f01d62df8abb7107d40d83a5ac4d6abb Mon Sep 17 00:00:00 2001 From: javayhu Date: Sat, 12 Jul 2025 19:29:47 +0800 Subject: [PATCH] refactor: standardize string quotes and improve formatting in components --- src/ai/image/components/QualityModeToggle.tsx | 18 +++++++++--------- src/ai/image/components/Stopwatch.tsx | 6 ++++-- src/ai/image/lib/image-helpers.ts | 14 +++++++------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/ai/image/components/QualityModeToggle.tsx b/src/ai/image/components/QualityModeToggle.tsx index ce44cd0..d9abde0 100644 --- a/src/ai/image/components/QualityModeToggle.tsx +++ b/src/ai/image/components/QualityModeToggle.tsx @@ -1,10 +1,10 @@ -"use client"; +'use client'; -import { Zap, Sparkles } from "lucide-react"; -import { Button } from "@/components/ui/button"; -import { useToast } from "@/hooks/use-toast"; +import { Button } from '@/components/ui/button'; +import { useToast } from '@/hooks/use-toast'; +import { Sparkles, Zap } from 'lucide-react'; -export type QualityMode = "performance" | "quality"; +export type QualityMode = 'performance' | 'quality'; interface QualityModeToggleProps { value: QualityMode; @@ -25,9 +25,9 @@ export function QualityModeToggle({ variant="secondary" disabled={disabled} onClick={() => { - onValueChange("performance"); + onValueChange('performance'); toast({ - description: "Switching to faster models for quicker generation", + description: 'Switching to faster models for quicker generation', duration: 2000, }); }} @@ -39,10 +39,10 @@ export function QualityModeToggle({ variant="secondary" disabled={disabled} onClick={() => { - onValueChange("quality"); + onValueChange('quality'); toast({ description: - "Switching to higher quality models for better results", + 'Switching to higher quality models for better results', duration: 2000, }); }} diff --git a/src/ai/image/components/Stopwatch.tsx b/src/ai/image/components/Stopwatch.tsx index f4a1a82..e567796 100644 --- a/src/ai/image/components/Stopwatch.tsx +++ b/src/ai/image/components/Stopwatch.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react"; +import { useEffect, useState } from 'react'; export function Stopwatch({ startTime }: { startTime: number }) { const [elapsed, setElapsed] = useState(0); @@ -12,6 +12,8 @@ export function Stopwatch({ startTime }: { startTime: number }) { }, [startTime]); return ( -
{(elapsed / 1000).toFixed(1)}s
+
+ {(elapsed / 1000).toFixed(1)}s +
); } diff --git a/src/ai/image/lib/image-helpers.ts b/src/ai/image/lib/image-helpers.ts index 677ef69..dde39b5 100644 --- a/src/ai/image/lib/image-helpers.ts +++ b/src/ai/image/lib/image-helpers.ts @@ -1,5 +1,5 @@ export const imageHelpers = { - base64ToBlob: (base64Data: string, type = "image/png"): Blob => { + base64ToBlob: (base64Data: string, type = 'image/png'): Blob => { const byteString = atob(base64Data); const arrayBuffer = new ArrayBuffer(byteString.length); const uint8Array = new Uint8Array(arrayBuffer); @@ -13,7 +13,7 @@ export const imageHelpers = { generateImageFileName: (provider: string): string => { const uniqueId = Math.random().toString(36).substring(2, 8); - return `${provider}-${uniqueId}`.replace(/[^a-z0-9-]/gi, ""); + return `${provider}-${uniqueId}`.replace(/[^a-z0-9-]/gi, ''); }, shareOrDownload: async ( @@ -22,7 +22,7 @@ export const imageHelpers = { ): Promise => { const fileName = imageHelpers.generateImageFileName(provider); const blob = imageHelpers.base64ToBlob(imageData); - const file = new File([blob], `${fileName}.png`, { type: "image/png" }); + const file = new File([blob], `${fileName}.png`, { type: 'image/png' }); try { if (navigator.share) { @@ -31,13 +31,13 @@ export const imageHelpers = { title: `Image generated by ${provider}`, }); } else { - throw new Error("Share API not available"); + throw new Error('Share API not available'); } } catch (error) { // Fall back to download for any error (including share cancellation) - console.error("Error sharing/downloading:", error); + console.error('Error sharing/downloading:', error); const blobUrl = URL.createObjectURL(blob); - const link = document.createElement("a"); + const link = document.createElement('a'); link.href = blobUrl; link.download = `${fileName}.png`; document.body.appendChild(link); @@ -48,6 +48,6 @@ export const imageHelpers = { }, formatModelId: (modelId: string): string => { - return modelId.split("/").pop() || modelId; + return modelId.split('/').pop() || modelId; }, };