"use client";
import React, { useState, useMemo } from "react";
import Link from "next/link";
import {
Code,
Zap,
Clock,
Lock,
Link as LinkIcon,
Hash,
Scissors,
QrCode,
FileText,
Car,
CloudDownload,
Search,
LayoutGrid,
Diff,
FileJson,
FileCode,
Database,
Braces,
Type,
Binary,
Languages,
ImageIcon,
Calculator,
FileSpreadsheet,
ImagePlus,
Network,
Barcode,
Terminal,
FerrisWheel,
CircleDollarSign,
Palette,
Timer,
Monitor,
Keyboard,
Volume2,
Users,
Tally5,
Hourglass,
Watch,
KeySquare,
ShieldAlert,
CaseSensitive,
Trophy,
TestTube,
} from "lucide-react";
// --- Data Definitions ---
interface Tool {
id: string;
title: string;
description: string;
icon: React.ReactNode;
href: string;
color: string;
isPlanned?: boolean;
}
interface Category {
id: string;
name: string;
icon: React.ReactNode;
tools: Tool[];
}
const categories: Category[] = [
{
id: "oi-tools",
name: "信奥工具",
icon: ,
tools: [
{
id: "testcase-generator",
title: "测试点生成",
description: "生成算法竞赛测试用例数据",
icon: ,
href: "/testcase-generator",
color: "text-purple-500",
},
],
},
{
id: "dev-tools",
name: "开发工具",
icon: ,
tools: [
{
id: "json-formatter",
title: "JSON 格式化",
description: "JSON 数据格式化、压缩和验证",
icon: ,
href: "/json-formatter",
color: "text-blue-500",
},
{
id: "diff",
title: "文本 Diff 对比",
description: "使用 Monaco 显示文本差异",
icon: ,
href: "/diff",
color: "text-slate-500",
},
{
id: "yaml-formatter",
title: "YAML 格式化",
description: "YAML 数据格式化和验证",
icon: ,
href: "/yaml-formatter",
color: "text-amber-600",
},
{
id: "html-formatter",
title: "HTML 格式化",
description: "HTML 代码格式化和美化",
icon: ,
href: "/html-formatter",
color: "text-orange-600",
},
{
id: "markdown",
title: "Markdown 编辑",
description: "Markdown 实时预览和导出",
icon: ,
href: "/markdown",
color: "text-blue-600",
},
{
id: "sql-formatter",
title: "SQL 格式化",
description: "SQL 语句格式化和美化",
icon: ,
href: "/sql-formatter",
color: "text-indigo-600",
},
{
id: "html-escape",
title: "HTML 转义",
description: "HTML 实体编码/解码",
icon: ,
href: "/html-escape",
color: "text-emerald-600",
},
],
},
{
id: "text-tools",
name: "文本工具",
icon: ,
tools: [
{
id: "text-formatter",
title: "文字格式化",
description: "清理文本中的多余空格和格式",
icon: ,
href: "/text-formatter",
color: "text-pink-500",
},
{
id: "case-converter",
title: "大小写转换",
description: "大写、小写、驼峰等格式转换",
icon: ,
href: "/case-converter",
color: "text-violet-500",
},
{
id: "lorem-ipsum",
title: "Lorem Ipsum",
description: "占位文本生成工具",
icon: ,
href: "/lorem-ipsum",
color: "text-zinc-500",
},
],
},
{
id: "encoding-tools",
name: "编码工具",
icon: ,
tools: [
{
id: "base64",
title: "Base64 编解码",
description: "Base64 编码与解码转换工具",
icon: ,
href: "/base64",
color: "text-emerald-500",
},
{
id: "base58",
title: "Base58 编解码",
description: "常用于比特币地址等场景",
icon: ,
href: "/base58",
color: "text-amber-500",
},
{
id: "base32",
title: "Base32 编解码",
description: "常用于 TOTP 等场景",
icon: ,
href: "/base32",
color: "text-orange-500",
},
{
id: "unicode",
title: "Unicode 转换",
description: "Unicode 字符与编码相互转换",
icon: ,
href: "/unicode",
color: "text-blue-500",
},
{
id: "url-encode",
title: "URL 编解码",
description: "URL 参数编码与解码处理",
icon: ,
href: "/url-encode",
color: "text-cyan-500",
},
],
},
{
id: "conversion-tools",
name: "转换工具",
icon: ,
tools: [
{
id: "timestamp",
title: "时间戳转换",
description: "时间戳与日期时间互相转换",
icon: ,
href: "/timestamp",
color: "text-orange-500",
},
{
id: "image-to-pixel",
title: "图片转像素画",
description: "将图片转换为像素艺术风格",
icon: ,
href: "/image-to-pixel",
color: "text-pink-600",
},
{
id: "radix-converter",
title: "进制转换器",
description: "二/八/十/十六进制互转",
icon: ,
href: "/radix-converter",
color: "text-indigo-500",
},
{
id: "csv-json",
title: "CSV/JSON 互转",
description: "CSV 与 JSON 格式互相转换",
icon: ,
href: "/csv-json",
color: "text-green-600",
},
{
id: "image-base64",
title: "图片 Base64",
description: "图片与 Base64 字符串互转",
icon: ,
href: "/image-base64",
color: "text-purple-600",
},
{
id: "ip-radix",
title: "IP 地址转换",
description: "IP 在不同进制间相互转换",
icon: ,
href: "/ip-radix",
color: "text-cyan-600",
},
],
},
{
id: "generation-tools",
name: "生成工具",
icon: ,
tools: [
{
id: "uuid",
title: "UUID 生成",
description: "生成 UUID/GUID 唯一标识符",
icon: ,
href: "/uuid",
color: "text-indigo-500",
},
{
id: "random-string",
title: "随机密码生成",
description: "生成安全的随机密码",
icon: ,
href: "/random-string",
color: "text-purple-500",
},
{
id: "qrcode",
title: "二维码生成",
description: "快速生成自定义样式的二维码",
icon: ,
href: "/qrcode",
color: "text-green-500",
},
{
id: "barcode",
title: "条形码生成",
description: "生成各种格式的条形码",
icon: ,
href: "/barcode",
color: "text-zinc-700",
},
{
id: "ascii-art",
title: "ASCII 艺术",
description: "将文本转换为字符艺术",
icon: ,
href: "/ascii-art",
color: "text-emerald-700",
},
{
id: "wheel",
title: "大转盘抽奖",
description: "随机抽奖决策工具",
icon: ,
href: "/wheel",
color: "text-rose-500",
},
{
id: "coin-flip",
title: "抛硬币",
description: "随机正反面决策",
icon: ,
href: "/coin-flip",
color: "text-amber-600",
},
],
},
{
id: "utility-tools",
name: "实用工具",
icon: ,
tools: [
{
id: "color-picker",
title: "颜色选择器",
description: "HEX/RGB/HSL 格式互转",
icon: ,
href: "/color-picker",
color: "text-pink-500",
},
{
id: "regex",
title: "正则测试器",
description: "测试和调试正则表达式",
icon: ,
href: "/regex",
color: "text-blue-600",
},
{
id: "cron",
title: "Cron 解析器",
description: "解析和验证 Cron 表达式",
icon: ,
href: "/cron",
color: "text-orange-600",
},
{
id: "user-agent",
title: "UA 解析器",
description: "解析浏览器 UA 字符串",
icon: ,
href: "/user-agent",
color: "text-slate-600",
},
{
id: "keyboard",
title: "键盘检测器",
description: "检测键盘按键事件详情",
icon: ,
href: "/keyboard",
color: "text-zinc-600",
},
{
id: "tts",
title: "文字转语音",
description: "将文本转换为语音播放",
icon: ,
href: "/tts",
color: "text-cyan-600",
},
{
id: "random-group",
title: "随机分组",
description: "快速公平地生成随机团队",
icon: ,
href: "/random-group",
color: "text-indigo-600",
},
{
id: "scoreboard",
title: "记分板",
description: "红蓝双方比分记录",
icon: ,
href: "/scoreboard",
color: "text-rose-600",
},
{
id: "pomodoro",
title: "番茄钟",
description: "番茄工作法计时器",
icon: ,
href: "/pomodoro",
color: "text-red-500",
},
{
id: "counter",
title: "计数器",
description: "简单的计数工具",
icon: ,
href: "/counter",
color: "text-zinc-500",
},
{
id: "countdown",
title: "倒数计时器",
description: "设置倒计时到时提醒",
icon: ,
href: "/countdown",
color: "text-amber-500",
},
{
id: "stopwatch",
title: "秒表",
description: "精确计时支持记圈",
icon: ,
href: "/stopwatch",
color: "text-blue-500",
},
{
id: "ip-calc",
title: "IP 地址计算",
description: "子网掩码与网络划分计算",
icon: ,
href: "/ip-calc",
color: "text-blue-600",
},
],
},
{
id: "crypto-tools",
name: "加密工具",
icon: ,
tools: [
{
id: "hash",
title: "MD5/SHA 哈希",
description: "计算 MD5、SHA1/256/512 哈希",
icon: ,
href: "/hash",
color: "text-rose-500",
},
{
id: "jwt",
title: "JWT 解码器",
description: "解析和查看 JWT 内容",
icon: ,
href: "/jwt",
color: "text-purple-600",
},
{
id: "aes-des",
title: "AES/DES 加密",
description: "对称加密解密工具",
icon: ,
href: "/aes-des",
color: "text-red-600",
},
{
id: "bcrypt",
title: "Bcrypt 哈希",
description: "生成和验证 Bcrypt 密码",
icon: ,
href: "/bcrypt",
color: "text-slate-700",
},
],
},
// {
// id: "life-tools",
// name: "生活工具",
// icon: ,
// tools: [
// {
// id: "move-car",
// title: "挪车码牌",
// description: "生成专属挪车码牌,支持微信推送",
// icon: ,
// href: "/move-car",
// color: "text-yellow-500",
// },
// {
// id: "alipan-tv-token",
// title: "阿里云盘 Token",
// description: "获取阿里云盘 TV 端授权令牌",
// icon: ,
// href: "/alipan-tv-token",
// color: "text-teal-500",
// },
// ],
// },
];
// --- Main Layout Component ---
export default function HomePage() {
const [searchQuery, setSearchQuery] = useState("");
const [activeCategory, setActiveCategory] = useState("all");
// Flatten tools for easier filtering
const allTools = useMemo(() => {
return categories.flatMap((cat) =>
cat.tools.map((tool) => ({ ...tool, categoryId: cat.id }))
);
}, []);
// Filter Logic
const filteredTools = useMemo(() => {
let tools = allTools;
// 1. Category Filter
if (activeCategory !== "all") {
tools = tools.filter((tool) => tool.categoryId === activeCategory);
}
// 2. Search Filter
if (searchQuery.trim()) {
const query = searchQuery.toLowerCase();
tools = tools.filter(
(tool) =>
tool.title.toLowerCase().includes(query) ||
tool.description.toLowerCase().includes(query)
);
}
return tools;
}, [allTools, activeCategory, searchQuery]);
return (
{/* Hero Section */}
{/* Main Content Area */}
{/* Category Navigation */}
{categories.map((cat) => (
))}
{/* Tools Grid */}
{filteredTools.length > 0 ? (
filteredTools.map((tool) => (
tool.isPlanned && e.preventDefault()}
>
{tool.title}
{tool.isPlanned && (
敬请期待
)}
{tool.description}
))
) : (
未找到相关工具
换个关键词试试,或者浏览其他分类。
)}
);
}