"use client"; import React, { useState, useEffect } from "react"; import figlet from "figlet"; // @ts-ignore import standardFont from "figlet/importable-fonts/Standard.js"; // @ts-ignore import ghostFont from "figlet/importable-fonts/Ghost.js"; // @ts-ignore import slantFont from "figlet/importable-fonts/Slant.js"; // @ts-ignore import bubbleFont from "figlet/importable-fonts/Bubble.js"; // @ts-ignore import bannerFont from "figlet/importable-fonts/Banner.js"; // @ts-ignore import bigFont from "figlet/importable-fonts/Big.js"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Terminal, Copy } from "lucide-react"; import { toast } from "sonner"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; // Register fonts figlet.parseFont("Standard", standardFont); figlet.parseFont("Ghost", ghostFont); figlet.parseFont("Slant", slantFont); figlet.parseFont("Bubble", bubbleFont); figlet.parseFont("Banner", bannerFont); figlet.parseFont("Big", bigFont); const FONTS = ["Standard", "Ghost", "Slant", "Bubble", "Banner", "Big"]; export default function AsciiArtPage() { const [text, setText] = useState("i-Tools"); const [font, setFont] = useState("Standard"); const [output, setOutput] = useState(""); useEffect(() => { figlet.text( text, { font: font as any, horizontalLayout: "default", verticalLayout: "default", width: 80, whitespaceBreak: true, }, function (err, data) { if (err) { console.log("Something went wrong..."); console.dir(err); return; } setOutput(data || ""); } ); }, [text, font]); const copyToClipboard = async () => { try { await navigator.clipboard.writeText(output); toast.success("已复制到剪贴板"); } catch { toast.error("复制失败"); } }; return (

ASCII 艺术生成

将文本转换为复古的字符画风格

设置
setText(e.target.value)} placeholder="Type something..." maxLength={20} />
预览结果
                        {output || "Generating..."}
                    
); }