refactor: standardize string quotes and improve formatting in components

This commit is contained in:
javayhu 2025-07-12 19:29:47 +08:00
parent ee341522f5
commit 0f79ed14f0
3 changed files with 20 additions and 18 deletions

View File

@ -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,
});
}}

View File

@ -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 (
<div className="text-lg text-zinc-500 font-mono">{(elapsed / 1000).toFixed(1)}s</div>
<div className="text-lg text-zinc-500 font-mono">
{(elapsed / 1000).toFixed(1)}s
</div>
);
}

View File

@ -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<void> => {
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;
},
};