Skip to content

Zoroaaa/FileConverter

Repository files navigation

FileConverter

功能强大的在线文件格式转换工具

支持 40+ 种格式互转,包括文档、图像、音频、视频、数据格式

License: MIT React TypeScript Vite Cloudflare zread

功能特性 · 快速开始 · 贡献指南


🔗 快速访问

资源类型 链接 备注
📖 项目文档 👉 完整介绍 详细的项目说明和使用指南
🚀 在线体验 👉 https://fileconverter.neutronx.uk 体验完整功能

📖 项目简介

FileConverter 是一个现代化的文件格式转换平台,采用前后端分离架构,支持单文件和批量转换两种模式。文档转换由 Gotenberg(LibreOffice 引擎)驱动,图像和数据转换在浏览器本地完成,保护用户隐私。

效果图

92cb70da-7404-4ade-b3a9-16c10b136e90

✨ 功能特性

特性 描述
🚀 边缘加速 基于 Cloudflare Pages 全球部署,就近访问
🔒 隐私优先 图像、数据、音视频转换在浏览器本地完成,文件不离开设备
🆓 完全免费 无需注册,无广告,无使用限制
📱 响应式设计 完美适配移动端和桌面端
🎨 现代化 UI 毛玻璃效果、渐变色、流畅动画、深色模式
批量处理 支持多文件并行转换,独立选择目标格式
👁️ 实时预览 转换完成后可直接预览 PDF、HTML、图像等格式

📁 支持的格式

📄 文档格式

源格式 可转换为 转换引擎
PDF DOCX, XLSX, PPTX, TXT, HTML Adobe API / pdfjs
DOCX PDF, TXT, HTML, MD Gotenberg / mammoth
DOC PDF, DOCX, TXT, HTML Gotenberg
ODT / RTF PDF, TXT, HTML Gotenberg
XLSX / XLS / ODS PDF, CSV, HTML Gotenberg / SheetJS
PPTX / PPT / ODP PDF, TXT Gotenberg
VSD / VSDX PDF Gotenberg
Markdown PDF, DOCX, HTML, TXT Gotenberg / docx
TXT / HTML PDF, DOCX, MD Gotenberg

🖼️ 图像格式

源格式 可转换为 转换引擎
JPG / JPEG PNG, WebP, GIF, BMP, ICO, TIFF Canvas API
PNG JPG, WebP, GIF, BMP, ICO, TIFF Canvas API
WebP JPG, PNG, GIF, BMP, TIFF Canvas API
GIF JPG, PNG, WebP, BMP Canvas API
BMP JPG, PNG, WebP, GIF, ICO Canvas API
ICO JPG, PNG, WebP, BMP Canvas API
SVG PNG, JPG, WebP Canvas API
TIFF JPG, PNG, WebP, GIF, BMP Canvas API

🎵 音频格式

源格式 可转换为 转换引擎
MP3 / WAV / OGG / FLAC / AAC / M4A 互转 FFmpeg.wasm

🎬 视频格式

源格式 可转换为 转换引擎
MP4 / WebM / AVI / MOV / MKV 互转 FFmpeg.wasm

📊 数据格式

源格式 可转换为 转换引擎
JSON XML, CSV, YAML, TOML 纯 JS
XML JSON, CSV, YAML 纯 JS
CSV XLSX, JSON, XML SheetJS / 纯 JS
YAML JSON, XML, CSV, TOML 纯 JS
TOML JSON, YAML, CSV 纯 JS

🛠️ 技术栈

前端

技术 版本 用途
React 19.x UI 框架
TypeScript 5.9 类型安全
Vite 7.x 构建工具
Tailwind CSS 4.x 样式方案
Lucide React - 图标库

后端

技术 用途
Cloudflare Pages Functions Serverless API
Gotenberg 文档转换引擎
LibreOffice Office 格式处理

核心依赖

用途
docx Word 文档生成
mammoth DOCX 文件解析
SheetJS Excel/CSV 处理
FFmpeg.wasm 音视频转码
pdf.js PDF 文本提取

🚀 快速开始

环境要求

  • Node.js >= 18.x
  • npm >= 9.x

安装步骤

# 克隆项目
git clone https://github.com/yourusername/fileconverter.git
cd fileconverter

# 安装依赖
npm install

开发模式

# 启动前端开发服务器(仅前端,端口 5173)
npm run dev

# 启动完整开发环境(前端 + Cloudflare Functions,端口 8788)
npm run dev:full

构建部署

# 构建生产版本
npm run build

# 预览构建结果
npm run preview

# 部署到 Cloudflare Pages
npm run deploy

📦 项目结构

fileconverter/
├── functions/                    # Cloudflare Pages Functions
│   └── api/
│       ├── convert.ts           # 通用转换 API
│       ├── doc-convert.ts       # 文档转换 API
│       └── gotenberg-health.ts  # Gotenberg 健康检查
├── src/
│   ├── components/              # React 组件
│   │   ├── converter/           # 转换器组件
│   │   │   ├── BatchConverter.tsx
│   │   │   └── ImageOptions.tsx
│   │   └── ui/                  # UI 组件
│   │       ├── Button.tsx
│   │       ├── ConversionProgress.tsx
│   │       ├── FileUpload.tsx
│   │       ├── FormatSelector.tsx
│   │       ├── GotenbergStatus.tsx
│   │       └── ThemeToggle.tsx
│   ├── contexts/                # React Context
│   │   └── ThemeContext.tsx
│   ├── lib/                     # 核心库
│   │   ├── converters/          # 转换器模块
│   │   │   ├── index.ts         # 统一入口
│   │   │   ├── imageConverter.ts
│   │   │   ├── dataConverter.ts
│   │   │   ├── docConvertConverter.ts
│   │   │   ├── docxParser.ts
│   │   │   ├── mdToDocxConverter.ts
│   │   │   └── types.ts
│   │   └── utils.ts
│   ├── types/                   # TypeScript 类型定义
│   │   └── index.ts
│   ├── App.tsx                  # 主应用组件
│   ├── index.css                # 全局样式
│   └── main.tsx                 # 应用入口
├── public/                      # 静态资源
├── package.json
├── tsconfig.json
├── vite.config.ts
├── wrangler.toml               # Cloudflare 配置
└── LICENSE                     # MIT 许可证

🔧 转换器架构

转换路由优先级

1. 图像 (JPG/PNG/WebP/...) → Canvas API(浏览器本地)
2. 数据 (JSON/XML/CSV/...) → 纯 JS 解析(浏览器本地)
3. 音视频 (MP3/MP4/...) → FFmpeg.wasm(CDN 懒加载)
4. 表格 (XLSX/CSV) → SheetJS(浏览器本地)
5. 文档 (DOCX/PDF/...) → Gotenberg / Adobe API(后端)

API 使用示例

import { convertFile, getConversionMethod } from '@/lib/converters'

// 转换文件
const result = await convertFile(file, 'docx', 'pdf', {
  quality: 0.92
})

// 获取转换方式
const method = getConversionMethod('docx', 'pdf')
// 返回: 'gotenberg' | 'frontend' | 'adobe' | 'backend'

// 下载结果
const url = URL.createObjectURL(result.blob)
// result.filename: 输出文件名
// result.mimeType: MIME 类型

🔒 安全特性

  • ✅ 图像和数据转换在浏览器本地完成,不上传服务器
  • ✅ 文件处理完成后立即释放内存
  • ✅ 输入验证和格式检查
  • ✅ 控制字符清理,防止注入攻击
  • ✅ 敏感配置通过环境变量管理

🤝 贡献指南

欢迎参与项目贡献!请遵循以下步骤:

提交 Issue

  • 使用清晰的标题描述问题
  • 提供复现步骤和环境信息
  • 添加适当的标签(bug / feature / documentation)

提交 Pull Request

  1. Fork 本仓库
  2. 创建功能分支:git checkout -b feature/amazing-feature
  3. 提交更改:git commit -m 'feat: add amazing feature'
  4. 推送分支:git push origin feature/amazing-feature
  5. 创建 Pull Request

代码规范

  • 遵循项目代码规范
  • 使用 ESLint 进行代码检查:npm run lint
  • 保持 TypeScript 类型完整
  • 添加必要的注释和文档

提交信息规范

遵循 Conventional Commits 规范:

feat: 新功能
fix: 修复 bug
docs: 文档更新
style: 代码格式调整
refactor: 代码重构
test: 测试相关
chore: 构建/工具相关

📄 许可证

本项目基于 MIT License 开源协议发布。

MIT License

Copyright (c) 2025 FileConverter Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

🙏 致谢


⬆ 返回顶部

Made with ❤️ by FileConverter Team

About

FileConverter 是一个现代化的文件格式转换平台,采用前后端分离架构,支持单文件和批量转换两种模式。文档转换由 Gotenberg(LibreOffice 引擎)驱动,图像和数据转换在浏览器本地完成,保护用户隐私。

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages