Skip to content

About

跨平台文本润色对比工具 · 逐词高亮 diff,中英日多语言 (Electron + React)

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

文本润色对比工具 · Text Diff App

一个跨平台桌面应用,用来对比「润色前 / 润色后」两段文本,逐词高亮出到底改了哪里。特别适合看 AI 润色、人工校对、翻译前后的差异。

An Electron desktop app that compares two versions of a text ("original" vs "polished") and highlights the changes word by word. Handles Chinese, English, Japanese and other languages correctly.


为什么做这个 / Why

大多数 diff 工具用的是「按空格分词」的算法(diffWords)。中文、日文没有空格,一整句会被当成一个词——于是改一个字,整句都被划掉重写,你根本看不出改了哪里:

Most diff tools tokenize on whitespace. Chinese/Japanese sentences have no spaces, so the whole sentence becomes a single token — change one character and the entire sentence gets struck through and rewritten:

❌ 旧算法:  [我今天去公园散步](整句删除) [我今天去了公园散步](整句新增)
✅ 本工具:  我今天去[了]公园散步          ← 只高亮真正改动的 "了"

❌ 旧算法:  [a man killed a girl](整句删除) [a man kills a girl](整句新增)
✅ 本工具:  a man [killed→kills] a girl     ← 只高亮改动的词

本工具用浏览器内置的 Intl.Segmenter 做语言感知的分词,再逐词比对,因此任何语言都能精确定位到「改了哪个词」。

This app uses the built-in Intl.Segmenter for language-aware word segmentation, then diffs token by token — so it pinpoints the exact changed word in any language.


功能 / Features

  • 🔤 逐词高亮:中英日等多语言,精确到词而非整句
  • 🟥🟩 三栏视图:原文 / 润色后 / 对比预览,一目了然
  • 🔗 滚动同步:三栏跟随滚动
  • 🕑 历史记录:自动保存最近 50 次对比(存在本地,不上传)
  • 🧮 改动统计:新增 / 删除数量
  • 🖥️ 跨平台:Windows + macOS

安装 / Installation

方式一:下载安装包(推荐 / Recommended)

到 Releases 页面下载对应系统的安装包:

系统 文件 说明
Windows TextDiffTool-Setup-x.x.x.exe 双击运行,可自选安装目录
macOS 文本润色对比工具-x.x.x.dmg 打开后拖入「应用程序」文件夹

macOS 提示:首次打开若提示「无法打开,因为无法验证开发者」,请到「系统设置 → 隐私与安全性」点「仍要打开」;或在终端执行:

xattr -cr "/Applications/文本润色对比工具.app"

这是因为安装包未做 Apple 付费签名,属正常现象。

方式二:从源码运行 / Run from source

需要 Node.js 18+。

git clone [email protected]:wsxwj123/text-diff-app.git
cd text-diff-app
npm install
npm run dev        # 开发模式,热重载

从源码打包 / Build from source

npm install

npm run build         # 打当前系统的安装包
npm run build:win     # 生成 Windows .exe  → release/
npm run build:mac     # 生成 macOS  .dmg   → release/

产物在 release/ 目录。

跨平台打包说明:electron-builder 打 Windows 包最好在 Windows 上进行;在 macOS 上打 Windows 包需要额外安装 Wine。建议在对应系统上分别打包,或用 CI。


使用 / Usage

  1. 左栏粘贴原文,中栏粘贴润色后文本
  2. 右栏「对比预览」自动逐词高亮:红色删除 / 绿色新增
  3. 点右上角 🕑 保存 / 查看历史,🧹 清空

技术栈 / Tech Stack


许可 / License

MIT © wsxwj123

About

跨平台文本润色对比工具 · 逐词高亮 diff,中英日多语言 (Electron + React)

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages