Compare commits
23
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39ec9347e2 | ||
|
|
7992c83421 | ||
|
|
e48d165741 | ||
|
|
f73d7247bb | ||
|
|
f6ef20eef3 | ||
|
|
fdcd1f8de8 | ||
|
|
f4f1b373de | ||
|
|
aea420df79 | ||
|
|
458b508d7e | ||
|
|
7f915b07ec | ||
|
|
07ba0b3f24 | ||
|
|
704fabb9cb | ||
|
|
4410d6f055 | ||
|
|
a12886ea90 | ||
|
|
c54799fd89 | ||
|
|
e65eb89fa9 | ||
|
|
263d52475f | ||
|
|
d9d306956d | ||
|
|
72e06b24fe | ||
|
|
83d98a348e | ||
|
|
41f7f0671c | ||
|
|
a0b63f9a18 | ||
|
|
c7586f9c63 |
No files matched your search
+3
-1
@@ -32,4 +32,6 @@ coverage
|
||||
/playwright-report/
|
||||
/playwright/.cache/
|
||||
# Webkit with playwright creates a salt file
|
||||
salt
|
||||
salt
|
||||
# 本地离线构建用(基于已有镜像,非仓库产物)
|
||||
Dockerfile.offline
|
||||
+181
@@ -2,6 +2,187 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## Version 2026.11.01-it-tools-pro
|
||||
|
||||
### 📦 本次更新(2026-11-01)
|
||||
- **本机IP查询**(`/my-ip`,免费不授权):打开即显示**用户自己设备**的公网 IPv4 / IPv6 地址与中文归属地(多源容错、一键复制、不显示任何服务器信息);自动测量到 9 个热门地点(本站/清华TUNA/阿里云/腾讯云/华为云/中科大/香港Fedora/日本JAIST/Cloudflare)的延迟
|
||||
- **IPv6 直连通道**:新增 `itv6.88531.cn`(4443 端口,双栈 nginx + DDNS);支持 IPv6 的用户页面横幅一键切换直连,访问速度更快;不支持的用户给出五步开启教程
|
||||
- **网速测试**:测量**你到本站服务器**的真实吞吐(下载/上传/到站延迟),走当前访问线路,浏览器真实收发计时(relay 新增 `/relay/speed` 端点),约 13MB 流量
|
||||
- **测速历史记录**:每次测速自动记录时间/线路(公网中转 vs IPv6 直连)/下载/上传/延迟,存本机浏览器最多 20 条、可清空——切换线路前后各测一次即可直接对比两条线路差距
|
||||
- **文档翻译支持扫描件/图片**:扫描版 PDF、截图、照片自动 OCR 识别后整篇翻译,标注「已OCR识别 N 页」
|
||||
- **翻译切换本地引擎(LibreTranslate)**:中英翻译走本机 Docker 引擎,稳定不限流、不耗 AI 额度,告别 429 报错
|
||||
- **缓存修复**:`index.html`/`sw.js` 强制 `no-cache, must-revalidate`、内容哈希资源 `immutable` 长缓存——部署后用户无需强刷即见新版
|
||||
|
||||
### 🏠 站点功能总览(10 大分类 · 110+ 工具)
|
||||
|
||||
**AI 智能(本站核心,本地算力驱动)**
|
||||
- AI 图片实验室:本地模型智能抠图去背景、AI 无损放大变清晰(2x/4x + 5 档降噪)、一键证件照(一寸/二寸/护照,白红蓝底)
|
||||
- AI 修图:涂抹去水印/智能修复、抠图去背景、4x 超分辨率、人脸修复,10 秒级出图
|
||||
- AI 生图:文生图创作
|
||||
- AI 看图(截图理解):截图/票据/合同/报错图丢进去,多模态 AI 读懂并提取关键信息,金额日期编号原样保留
|
||||
- 在线翻译:16 种语言互译,中英走本地引擎不限流;Word/PDF/TXT 整篇文档翻译,扫描件/图片自动 OCR
|
||||
- 文案工具箱:一键改写、降 AIGC 率、爆款标题、小红书文案、朋友圈文案
|
||||
- AI 客服:只答本站功能相关问题(全站工具清单加持,越界自动拒绝),多会话、登录后云端同步
|
||||
- 视频字幕 AI:Whisper 本地转录生成 SRT、AI 一键翻译英日文
|
||||
- 音频工具:文字转音频(本地神经音色)、音频转文字(中英日粤自动检测)
|
||||
- 每日资讯 5 列:GitHub 热榜/国际新闻/AI 资讯/IT 技术/AI 最热股票,每天 08:00 自动更新;AI 股票交易时段 60 秒实时刷新,支持自选股云端同步
|
||||
- 每个工具页左上角「🤖 问AI」:弹窗即看该工具用法与亮点,无需翻文档
|
||||
|
||||
**深度改造的原版工具(比上游更强)**
|
||||
- PDF 工具:合并/拆分/旋转/重排/压缩/加密/解密/水印/提取文本/页码/转图片,11 功能全程浏览器本地处理
|
||||
- 图片工具:压缩/转换/裁剪/旋转/滤镜/打码 + PS 风格编辑器(图层+画笔+选区+历史记录+OCR 改字+文字模板)
|
||||
- 视频工具:格式转换/压缩/裁剪/旋转/变速/消音/提取音频/截图/GIF 互转/加去水印等 13 项
|
||||
- 二维码条码:识别(本地 WASM 不上传,多码批量)+ 生成(自定义颜色、中间插 Logo)+ 批量条码(12 种码制、打包下载)
|
||||
- 图片 OCR / PDF 文字识别:本地引擎,准确率 99%+,逐页识别导出 TXT
|
||||
- 面单设计:20 个快递面单模板(顺丰/中通/圆通/韵达/申通/京东/邮政/极兔/德邦/国际)
|
||||
- 文档格式转换:Word/PDF/TXT/RTF/ODT/EPUB/MOBI/AZW3/HTML 九格式互转
|
||||
- 印章生成器(mm 标尺画布)、多图拼接(6 种方式)、JSON 双栏工作台、Base64 图片互转、IT 网站收藏(91 个精选站点)
|
||||
|
||||
**网络与开发**
|
||||
- 本机IP查询、IPv4 子网/地址/范围计算、MAC 查询生成、IPv6 ULA、IP 子网掩码
|
||||
- 开发工具 14 项(git 备忘/crontab/JSON/Docker 转换/正则…)、密码学 11 项(Hash/Bcrypt/RSA/HMAC/BIP39…)、转换器 20 项、文本 13 项等
|
||||
|
||||
**账户与授权**
|
||||
- 用户中心:收藏/最近使用/生成记录(翻译/OCR/修图/条码等 9 工具留痕)/AI 对话/自选股全部云端同步,换电脑登录即恢复
|
||||
- 卡密授权:高级功能**每天免费试用 30 分钟**(每天 0 点重置),卡密激活全站通用,支持换卡密/自助撤销
|
||||
- 管理后台:首页推荐配置、用户管理、文件管理、使用统计
|
||||
|
||||
👉 体验地址:https://it.88531.cn
|
||||
|
||||
## Version 2026.10.30-it-tools-pro
|
||||
|
||||
### ✨ 新功能
|
||||
- **测速历史记录(多线路对比)**:每次测速完成自动记录时间、所走线路(公网中转/IPv6 直连)、下载/上传速度与到站延迟,以表格展示在测速卡片下方(仅存本机浏览器 localStorage,最多 20 条,可一键清空);切换 IPv6 直连前后各测一次即可直接对照两条线路差距
|
||||
- **文档翻译支持扫描件/图片自动 OCR**:非纯文字文档(扫描版 PDF、截图、照片、带文字图片)先自动 OCR 识别文字再整篇翻译,扫描版 PDF 逐页渲染识别(单文档最多 30 页),图片可直接上传翻译;结果标注「已OCR识别 N 页」,页面附处理说明
|
||||
- **修复「改版后用户看到旧页面」缓存问题**:nginx 对 `index.html`/`sw.js`/`manifest` 强制 `Cache-Control: no-cache, must-revalidate`(每次重新校验,杜绝 PWA 预缓存赖旧),对内容哈希静态资源 `immutable` 长缓存(加载更快),部署后无需用户强刷即见新版
|
||||
- **新增「本机IP查询」**(`/my-ip`,Network 分组,免费不授权):仅显示**用户端**公网 IPv4/IPv6 地址与所属地(多源容错、中文归属地、一键复制),不显示服务器地址;IPv6 不支持时明示「不支持 IPv6」并给出五步开启教程
|
||||
- **本站 IPv6 直连(速度更快)**:新增 `itv6.88531.cn`(AAAA→本机移动原生 v6,4443 防封端口 + 443,宝塔 nginx 双栈 + acme 证书 + DDNS 覆盖);页面顶部横幅「本站已支持 IPv6 访问,速度更快」,支持 IPv6 的用户一键切换直连
|
||||
- **连接热门地点延迟**:进入页面自动测量到 9 个热门地点(本站/清华 TUNA/阿里云/腾讯云/华为云/中科大/香港 Fedora/日本 JAIST/Cloudflare)的网络延迟,支持一键重新测速
|
||||
- **网速测试改测「你的设备 ↔ 本站服务器」**:relay 新增 `/relay/speed` 端点(GET 吐数据测下载、POST 收数据测上传),浏览器真实收发计时,测的是用户到本站服务器的实际吞吐(含到本站延迟),走当前访问线路(公网中转或 IPv6 直连,切换后可对比),约消耗 13MB 流量
|
||||
|
||||
### 🔧 优化
|
||||
- **文档翻译切换本地开源引擎(LibreTranslate)**:此前走 NewAPI LLM 被上游限流报 429「Too Many Requests」;现与文本翻译同用本机 Docker 引擎,不限流、不耗 AI 额度;目标语种支持中文/英文,其他语种给出明确提示(不再静默失败)
|
||||
|
||||
## Version 2026.10.16-it-tools-pro
|
||||
|
||||
### ✨ 二维码条码识别 → 新增「生成」页签(识别/生成一页双能力)
|
||||
- **二维码生成**:内容输入实时生成(网址/文本/名片),尺寸 256/512/1024/2048px,实时防抖渲染
|
||||
- **改颜色**:前景色/背景色取色器 + 各 6 个快捷色票,任意搭配
|
||||
- **中心本地图片(Logo)**:选择本地图插入二维码中心,大小 10%~35% 滑杆可调,自动切换 H 级纠错(容错 ~30%)+ 按背景色圆角白垫保可扫;文件全程浏览器本地处理
|
||||
- **自动自扫验证**:每次生成后用本页 ZXing 立即回扫一次,显示「✓ 可正常扫出(QR_CODE)· 与输入内容一致」或对比度/Logo 过大提示,生成即自证
|
||||
- 页面顶部「📷 识别 / 🧩 生成」Tab 切换;code-reader 加入 WIDE_TOOLS 宽屏;窗口加入「生成」关键词
|
||||
- 同步:zh/en 描述、About「二维码条码识别与生成」条目、首页近期新功能条目
|
||||
|
||||
### 🆕 首页「近期新功能」与「新功能介绍」页补录近期新功能
|
||||
- 首页 NEW_FEATURES 手动清单(注释约定"新工具上线时加一条")漏加近期工具,补 2 条置顶:**Base64图片互转**、**图片编辑·无痕改字**(PS式图层画笔选区+OCR自动匹配字号颜色角度无缝改字)
|
||||
- 新功能介绍页(About)「原创工具」组补 **Base64图片互转** 条目;「图片工具」条目原已覆盖 OCR 改字无需重复
|
||||
- 教训:新工具上线 checklist = 工具注册 + i18n + About + 首页 NEW_FEATURES + relay 推荐种子(可选),四页同步缺一不可
|
||||
|
||||
### ✨ 新工具「Base64图片互转」(/base64-image-converter):一页双向,纯浏览器本地
|
||||
- **Base64 转图片**:三种输入形态全吃(裸 base64 串 / `data:mediatype;base64,...` / `url("data:...")`),多行自动去空白、URL-safe 字符(- _)归一 + 自动补 = 填充;「图片类型」下拉(自动识别/png/jpeg/webp/gif/bmp/svg/ico),输入不含 mediatype 时手动类型优先、自动模式读文件魔数嗅探真实格式;Blob→objectURL 预览 + 转换后 Image 探针校验(数据损坏给友好错误)+ 下载
|
||||
- **图片 转 Base64**:点击/拖拽上传(图片文件校验),输出格式三档实时切换(纯 base64 / data:URI / CSS url(),按记录的 mime+裸串重排不重读文件);「复制结果」(clipboard API + 1.5s 回执)、「Base64 转图片」按钮带输出直跳另一半页并自动转换(双向闭环)
|
||||
- 顶部说明条「使用浏览器 API 实现,文件不上传云端」;双 Tab 一页承载参考图的两个独立页
|
||||
- i18n zh/en;注册于「图片与视频」分组(image-tools 旁)
|
||||
- 实测:①data URI 40598 字符→转换 1280×800 预览 ②裸多行 base64 魔数嗅探为 png 成功 ③上传→data URI 40598 字符头尾正确 ④三档格式切换 ⑤互转按钮回带自动转换闭环
|
||||
- 修复:输出格式从「纯 base64」切「CSS url()」时正则只认 data: 开头导致重排未执行 → 改记录值直排
|
||||
|
||||
### 🔧 隐藏「AI 无痕改字」(/ai-text-edit)
|
||||
- 从工具注册表/「图片与视频」分组/About 页推荐/relay 首页推荐种子四处摘除,界面与搜索不再出现;源码与 relay 端点保留(恢复只需重新注册三行)
|
||||
- 受控授权配置(PROTECTED_TOOLS)与 relay 管线不动,恢复即生效
|
||||
|
||||
### ✨ 新工具「AI 无痕改字」(/ai-text-edit):描述要改什么,AI 全自动无缝替换
|
||||
- **三段本地管线**:本地 OCR(rapidocr)定位全图文字块 → 本地 vision 模型(qwen3.8-max / qwen3.7-plus / kimi-k3 / deepseek-v4-flash-vision-exp 等 7 款,NewAPI 内网直连)理解需求选字块+定新文字 → relay 像素引擎(PIL+numpy)无缝重绘
|
||||
- **像素引擎**:从 OCR 框像素自动检测原字角度/字号/颜色/粗细(与 PS 编辑器同算法),Jacobi 迭代 320 轮背景扩散擦原字(非色块覆盖),按检测样式原位重绘新字,NotoSansCJK 粗细匹配,过框宽自动缩号
|
||||
- **产品页布局**(参考同类产品):左侧上传(拖拽/点击,JPEG/PNG/WEBP ≤24MB)+ 提示词(0/200 + 5 个示例快捷填充:改数字/改姓名/改价格/删除文字/改金额)+ 尺寸(默认/4:3/3:4/1:1/自定义,比例自动补边不裁内容)+ 输出数量(1~3 张 = 字号微调档位挑最像)+ 模型下拉(7 款本地 vision 模型)+ 橙色提交;右侧「最近任务」前后对比历史(localStorage 缩略图,仅本机)
|
||||
- **结果区**:原始文字/新文字两列对比图 + 改字记录行(「人数8」→「31」109px·粗体·5.2°)+ 多变体切换 + 下载/新窗口打开
|
||||
- **支持纯删除**:提示词写"删除/无痕去除"→ 只擦除不重绘
|
||||
- 受控工具(授权+每日试用覆盖);首页推荐种子置顶;About 页「AI 智能」分组新条目
|
||||
- 实测:①"人数8→31"(渐变背景白粗体倾斜)→ vision 正确选块,检出 109px·粗体·5.2°,无缝替换无残影(导出像素梯度 0.38)②删除左下角小字 → 白字 px 8028→0、中心大字保留、1:1 补边梯度 0.26 自然 ③浏览器 E2E:上传→提示→提交→对比图/记录/下载/历史全链路通过
|
||||
|
||||
### ✨ OCR 无痕改字:自动匹配原字样式,输入新字即改
|
||||
- **点字框自动检测原文字样式**:角度(OCR 框顶边斜率)、字号(行高×0.82)、颜色(框内墨迹中位色,白/黑/灰/彩色识别)、粗细(中心行带墨迹横向行程中位数判粗体)
|
||||
- **实时预览**:输入新文字时画布按检测样式原位重绘(所见即所得),新字过原框宽 1.15 倍自动缩号
|
||||
- **无缝替换**:inpainting 背景扩散重建擦掉原字(非色块覆盖)→ 按检测样式重绘新字 → 一步历史「无痕改字」整体撤销
|
||||
- 选项栏显示「检出 白色·粗·109px·-10°」检测徽标;「🧹 只消除」保留纯删除路径
|
||||
- 实测(渐变背景+白色粗体"人数8"倾斜-10°):检出 白色·109px·5.2°;输入"31"实时预览;回车后图层=文字「31」+智能消除+背景;导出像素验证原区域无白字残影、背景平滑无痕
|
||||
|
||||
### ✨ 文字模板扩到 47 套 · 新增 7 大平台分类
|
||||
- **新增 6 平台各 5 套共 30 套**(原 17 套经典款归入「通用」):
|
||||
- **小红书**:品牌红 #FF2442 种草/探店/避坑/好物/vlog(「今日份宝藏」「魔都探店」)
|
||||
- **抖音**:黑底霓虹青 #25F4EE / 玫红 #FE2C55 悬念/教程/卡点/BGM(「千万别划走」「3秒学会」)
|
||||
- **B站**:B站蓝 #00AEEC / 粉 #FB7299 三连/硬核/番剧/高能(「一键三连!」「前方高能」)
|
||||
- **公众号**:深蓝红金 长文/干货/头条/金句/观点(「深度长文」「这个行业要变天」)
|
||||
- **视频号**:微信绿 #07C160 直播/热转/私域/带货(「直播预告」「3步做出爆款封面」)
|
||||
- **封面图**:高冲击封面主标/数字/大标题/科技感/极简(「封面主标题」「10个神器」)
|
||||
- **分类标签条**(全部/通用/小红书/抖音/B站/公众号/视频号/封面图):上传前模板墙 + 编辑器侧栏模板区同步切换,一次只看一个平台
|
||||
- 实测:墙 47 套 8 标签默认全部;分类计数 17/5/5/5/5/5/5 全对;点小红书模板→选图→自动插入2行白字粉描边;侧栏切抖音→5 套;截图验收无溢出错位
|
||||
|
||||
### ✨ 文字默认 100 号 + 选框拖角直接缩放字号
|
||||
- **默认字号 36 → 100**(换 storage key 清掉旧缓存,新建文字/套模板均为 100 号起)
|
||||
- **选框四角新增白色方块缩放手柄**:拖任意角直接调字号(以文字中心为锚点,只变大小不漂移),拖动实时重绘,松手进历史(「缩放文字 Npx」),属性面板字号同步;范围 6~600px
|
||||
- 与顶部蓝点旋转手柄并存:四角缩放、顶点旋转、框内拖动=移动
|
||||
- 实测:插字默认 100;右下角外拖 100→219、左上角内拖 219→107,历史逐步可撤销;截图验收四角手柄+旋转点渲染正常
|
||||
|
||||
### ✨ 上传前模板墙:未选图就能看到全部模板
|
||||
- 图片编辑 tab **未上传图片时,上传区直接平铺 17 套文字模板预览墙**(真实文案小样+花字样式),不再是空白上传框
|
||||
- 点任意模板 → 直接弹出选图 → 选完图片**该模板整组文案自动套入画布**(无需再回编辑器找模板)
|
||||
- 底部一行"点这里选择图片"随时可直接上传(不套模板);模板墙几何验收首屏 17/17 全露出、无需滚动
|
||||
- 模板定义抽为共享模块 text-tpls.ts(画布内侧栏模板区与上传前模板墙共用一套数据)
|
||||
|
||||
### ✨ 文字模板升级为成套文案(17套,主副标题整组插入)
|
||||
- 每套模板不再是单个占位词,而是**完整标题组**(取自封面模板库真实文案):主标题+副标题 1~3 行成组——如「B站史上/点击最高的10首MV」「辣到没朋友!川菜/辣子鸡 · 水煮肉片」「秀翻全场!/ALL KILL!」「合法打工人/SLAVE の一天 DAILY」等 17 套
|
||||
- 点击一次插入整组:逐行独立居中、主大副小按比例递减、总高自动适配画布;**连续点击插入多组时自动级联排到已有文字下方**,空间不足自动缩字号塞入,绝不互相叠压
|
||||
- 模板小样直接显示真实文案(两行截断预览),hover 标题含全套内容
|
||||
- 交互定稿:点击=插入新组;**点中某行文字后再点模板=仅换该行样式**(保留内容/位置/旋转)
|
||||
|
||||
### ✨ 文字旋转 + 14 款花字模板(点击即套用)
|
||||
- **画布直旋**:选中文字后拖顶部蓝色圆点手柄实时旋转(拖动即所见),松手进历史(「旋转文字 N°」);按住 Shift 吸附 15°;旋转以文字框中心为锚点,命中检测同步旋转(斜着也能点中)
|
||||
- **旋转滑条**:属性面板「旋转」-180°~180° 精调 + 数字输入 + 一键回正
|
||||
- **14 款花字模板**(B站封面风格):白/黄/青字描边、红/蓝/黑/粉底白字、鎏金/烈焰渐变、白字投影、空心描边、荧光绿——右侧面板点击即套:未选文字层则插入画布并应用,已选中则原地换样式(保留内容/字号/位置/旋转),随后可继续改字/调号/拖动/旋转
|
||||
- 模板带 CSS 实时小样预览;渲染管线支持:色块底→投影→描边→渐变/纯色填充
|
||||
- 修复:侧栏内容超高时可滚动(模板库+属性+历史不再互相挤出可视区)
|
||||
- 文字层新增 rot/grad/stroke/shadow/badge 字段,旧历史数据自动兼容
|
||||
|
||||
### ✨ 消除实时预览 + 智能消除笔(橡皮升级)
|
||||
- **实时预览**:点 OCR 文字框或选框松手的**瞬间**,画布立即显示消除后的效果(蓝标「👁 实时预览已生成」+「预览(未应用)」角标),满意点「✓ 应用消除」落图层,不满意「✕ 取消预览」还原——先看效果再确认,不再是盲操作
|
||||
- **智能消除笔(橡皮 E 升级)**:直接在底图的文字/水印上涂抹(红色半透明笔迹实时跟随),**松手立即无痕消除**,无需框选、无需 OCR、无需点按钮;选中画笔层时仍是传统擦除
|
||||
- 消除层改为置顶图层(盖住底图及其上的文字/色块);导出前自动应用未确认预览(所见即所得);Escape/重框选自动清预览
|
||||
- 大区域消除加迭代预算(防卡顿)
|
||||
|
||||
### ✨ 图片编辑:智能消除(无痕删除图中文字/水印)
|
||||
- **OCR 路径**:识别文字后点框 →「🧹 消除文字」自动识别文字笔画像素,从周边背景扩散重建(inpainting),渐变/纹理背景自然补全,不再是纯色覆盖
|
||||
- **选框路径**:框选任意区域(文字/水印/杂物)→「🧹 消除选区内容」一键无痕消除,无需 OCR
|
||||
- 消除结果写入独立「智能消除」画笔图层:非破坏性、可撤销(Ctrl+Z)、可调不透明度、可再编辑
|
||||
- 修复:mask 检测覆盖选区全部像素(原实现跳过边缘 2px,选区边缘的字符会残留);视口尺寸变化时按中心补偿平移(原实现布局稳定后图片偏移导致交互坐标错位)
|
||||
|
||||
### ✨ 图片编辑升级为 PS 风格图层编辑器
|
||||
- **9 工具**:移动/选框/画笔/橡皮/文字/油漆桶(容差可调)/吸管取色/裁剪/抓手,快捷键 V M B E T G I C H,`[ ]` 调笔刷、`0` 适应、`1` 原尺寸
|
||||
- **图层面板**:背景/画笔/文字/色块四类图层,显示隐藏、不透明度、上移下移、删除、新建画笔层;文字层改内容/字号/颜色/加粗,色块改底色
|
||||
- **历史记录面板**:快照式撤销重做(Ctrl+Z / Ctrl+Y,最多 20 步),点击任意步骤可跳转
|
||||
- **画布**:滚轮缩放(3%-3200%)、空格/抓手平移、棋盘格透明背景、画笔光圈预览、选区/裁剪框蚂蚁线
|
||||
- **选区操作**:框选后填充/清除选区、Delete 快捷清除;裁剪框选后一键应用(全图层同步裁剪)
|
||||
- **保留 OCR 强项**:一键识别图中文字 → 点框替换(自动取底色)/只擦除,生成独立图层可再编辑
|
||||
- 重构:image-tools.vue 2284→1660 行,编辑器拆分为独立组件 PsEditor.vue;功能数 12 → 13
|
||||
|
||||
### 🔧 授权系统:通用卡激活传 project_id(适配 CardAuth 新版)
|
||||
- CardAuth 新版支持「通用卡」(不绑定项目的跨项目卡),激活时必须指定项目;relay 激活请求现在固定携带 `project_id`(IT-TOOLS-PRO=6),通用卡可在本站正常激活,专属卡不受影响
|
||||
- 授权校验/撤销同步改用 `project_id` + 历史项目名(IT-Tools / IT-TOOLS-PRO)双重匹配,项目改名后新旧授权都能正确识别
|
||||
- 新增环境变量 `PROJECT_ID`(默认 6)与 `PROJECT_ALIASES`(默认两个历史名),换项目无需改代码
|
||||
|
||||
### ✨ 图片工具新增「图片编辑」:改图中文字 + 加文字
|
||||
- **改图中文字**:一键 OCR 自动定位图内文字(复用本机 rapidocr,带坐标),画布上画红色虚线框+文字标签;点框选中 → 输入新文字 → 「✓ 替换」自动采样框外圈中位色作底色覆盖原字,再在原位生成可编辑文字图层(字号按原文字高度推算,也可「只擦除」不加字)
|
||||
- **涂改/加字**:画布拖拽框选任意区域按底色涂掉(自动取图/手动指定颜色);「+ 添加文字」放置新文字图层,支持字号/颜色/加粗
|
||||
- **图层面板**:所有文字图层(改字内容/字号/颜色/删除)和擦除区域(改底色/删除)统一列表管理,画布上可直接拖动文字调整位置
|
||||
- 执行后原尺寸导出(PNG 保 PNG,其他保 JPEG),擦除区与文字层逐像素合成
|
||||
- 图片工具功能数 12 → 13,About/关键词/中英文案同步
|
||||
|
||||
### 📈 「当天最热股票」改为「AI 最热股票」
|
||||
- 股票列选项卡「最热」→「AI最热」,列标题 → 「AI最热股票」
|
||||
- 数据源从「全市场涨幅榜」改为**聚合 12 个 AI 概念板块**(人工智能、AI 芯片、算力概念、AI 应用、AI 智能体、多模态 AI、AIGC 概念、CPO 概念、智谱 AI 概念、AI 语料、国产芯片、存储芯片),约 580 只成分股去重
|
||||
- **按成交额降序**取最热 10 只(涨幅榜常年被小盘股占据,成交额榜才是资金真正关注的主线龙头),行内显示「现价 · 成交额」
|
||||
- 交易时段每 60 秒自动刷新,标题行显示 交易中/休市 徽章
|
||||
- 自选股选项卡不变
|
||||
|
||||
## Version 2026.10.14-it-tools-pro
|
||||
|
||||
### 🎨 面单模板全部去掉头部背景色带
|
||||
|
||||
Vendored
+4
@@ -16,12 +16,14 @@ declare module '@vue/runtime-core' {
|
||||
AiGen: typeof import('./src/tools/ai-gen/ai-gen.vue')['default']
|
||||
AiImageLab: typeof import('./src/tools/ai-image-lab/ai-image-lab.vue')['default']
|
||||
AiRetouch: typeof import('./src/tools/ai-retouch/ai-retouch.vue')['default']
|
||||
AiTextEdit: typeof import('./src/tools/ai-text-edit/ai-text-edit.vue')['default']
|
||||
App: typeof import('./src/App.vue')['default']
|
||||
AsciiTextDrawer: typeof import('./src/tools/ascii-text-drawer/ascii-text-drawer.vue')['default']
|
||||
AudioTools: typeof import('./src/tools/audio-tools/audio-tools.vue')['default']
|
||||
BarcodeBatchGenerator: typeof import('./src/tools/batch-barcode-generator/barcode-batch-generator.vue')['default']
|
||||
'Base.layout': typeof import('./src/layouts/base.layout.vue')['default']
|
||||
Base64FileConverter: typeof import('./src/tools/base64-file-converter/base64-file-converter.vue')['default']
|
||||
Base64ImageConverter: typeof import('./src/tools/base64-image-converter/base64-image-converter.vue')['default']
|
||||
Base64StringConverter: typeof import('./src/tools/base64-string-converter/base64-string-converter.vue')['default']
|
||||
BasicAuthGenerator: typeof import('./src/tools/basic-auth-generator/basic-auth-generator.vue')['default']
|
||||
Bcrypt: typeof import('./src/tools/bcrypt/bcrypt.vue')['default']
|
||||
@@ -155,6 +157,7 @@ declare module '@vue/runtime-core' {
|
||||
MenuLayout: typeof import('./src/components/MenuLayout.vue')['default']
|
||||
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
|
||||
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
|
||||
MyIp: typeof import('./src/tools/my-ip/my-ip.vue')['default']
|
||||
NAlert: typeof import('naive-ui')['NAlert']
|
||||
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
|
||||
NButton: typeof import('naive-ui')['NButton']
|
||||
@@ -207,6 +210,7 @@ declare module '@vue/runtime-core' {
|
||||
PhoneParserAndFormatter: typeof import('./src/tools/phone-parser-and-formatter/phone-parser-and-formatter.vue')['default']
|
||||
PinyinConverter: typeof import('./src/tools/pinyin-converter/pinyin-converter.vue')['default']
|
||||
'Pricing.page': typeof import('./src/pages/Pricing.page.vue')['default']
|
||||
PsEditor: typeof import('./src/tools/image-tools/PsEditor.vue')['default']
|
||||
QrCodeGenerator: typeof import('./src/tools/qr-code-generator/qr-code-generator.vue')['default']
|
||||
RandomPortGenerator: typeof import('./src/tools/random-port-generator/random-port-generator.vue')['default']
|
||||
RegexMemo: typeof import('./src/tools/regex-memo/regex-memo.vue')['default']
|
||||
|
||||
@@ -42,6 +42,16 @@ CARD_AUTH_KEY = os.environ.get("CARD_AUTH_KEY", "")
|
||||
AUTH_USER = os.environ.get("AUTH_USER", "")
|
||||
AUTH_PASS = os.environ.get("AUTH_PASS", "")
|
||||
PROJECT_NAME = os.environ.get("PROJECT_NAME", "IT-Tools")
|
||||
# CardAuth project id of THIS deployment. Universal cards carry no project of
|
||||
# their own -> activation must name one; the backend rejects them without it.
|
||||
PROJECT_ID = int(os.environ.get("PROJECT_ID", "6")) # 6 = IT-TOOLS-PRO
|
||||
# Names that also count as "this project": CardAuth renamed the project
|
||||
# (old activations store project_name "IT-Tools", new ones "IT-TOOLS-PRO").
|
||||
PROJECT_ALIASES = {
|
||||
n.strip()
|
||||
for n in os.environ.get("PROJECT_ALIASES", "IT-Tools,IT-TOOLS-PRO").split(",")
|
||||
if n.strip()
|
||||
} or {PROJECT_NAME}
|
||||
TRIAL_FILE = os.environ.get("TRIAL_FILE", "/app/data/trials.json")
|
||||
TRIAL_MS = int(os.environ.get("TRIAL_MS_MIN", "30")) * 60 * 1000
|
||||
DAY_MS = 24 * 60 * 60 * 1000
|
||||
@@ -72,6 +82,21 @@ _auth_cache: dict = {}
|
||||
AUTH_CACHE_TTL = 60
|
||||
|
||||
|
||||
def _is_this_project(item: dict) -> bool:
|
||||
"""True when a query/admin result belongs to THIS site's project.
|
||||
|
||||
Matches by project_id (new records) or by any historical project name
|
||||
(CardAuth renamed IT-Tools -> IT-TOOLS-PRO; old rows keep the old name).
|
||||
"""
|
||||
try:
|
||||
pid = item.get("project_id")
|
||||
if pid is not None and int(pid) == PROJECT_ID:
|
||||
return True
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
return item.get("project_name") in PROJECT_ALIASES
|
||||
|
||||
|
||||
def _list_has_ittools_auth(data: dict) -> bool:
|
||||
"""Only cards of PROJECT_NAME with active status count.
|
||||
|
||||
@@ -89,12 +114,12 @@ def _list_has_ittools_auth(data: dict) -> bool:
|
||||
if not isinstance(item, dict):
|
||||
continue
|
||||
name = item.get("project_name")
|
||||
if name is None:
|
||||
if name is None and item.get("project_id") is None:
|
||||
# shape unknown -> do not filter
|
||||
return bool(data.get("has_valid_auth"))
|
||||
matched = True
|
||||
if (
|
||||
name == PROJECT_NAME
|
||||
_is_this_project(item)
|
||||
and item.get("status") == "active"
|
||||
and not item.get("is_expired", False)
|
||||
):
|
||||
@@ -183,7 +208,7 @@ def deactivate_card(machine_id: str) -> tuple[int, dict]:
|
||||
try:
|
||||
res = _get_json(f"/authorizations?bot_qq={machine_id}&status=active&page=1&page_size=20", auth_hdr)
|
||||
for item in ((res or {}).get("data") or {}).get("list") or []:
|
||||
if item.get("project_name") != PROJECT_NAME:
|
||||
if not _is_this_project(item):
|
||||
continue
|
||||
try:
|
||||
r = _put_json(f"/authorizations/{item['id']}/revoke", {"reason": "用户在客户端自助撤销"}, auth_hdr)
|
||||
@@ -631,12 +656,16 @@ def activate_card(card_key: str, machine_id: str, contact_qq: str, replace: bool
|
||||
# NOTE: do NOT call /public/verify with an unused card here - in this
|
||||
# CardAuth version the first verify call binds & consumes the card.
|
||||
|
||||
# activate (web channel, with admin session if configured)
|
||||
# activate (web channel, with admin session if configured).
|
||||
# project_id: universal cards carry no project of their own - the backend
|
||||
# rejects them unless the caller names one. Named-card activations ignore
|
||||
# it (their own project wins), so always send it.
|
||||
payload = {
|
||||
"card_key": card_key,
|
||||
"bot_qq": machine_id,
|
||||
"contact_qq": contact_qq or machine_id,
|
||||
"device_info": "IT-Tools Web",
|
||||
"project_id": PROJECT_ID,
|
||||
}
|
||||
# Retry ONLY on explicit 401 (stale token). Any other failure is returned
|
||||
# as-is: re-sending an activate that already consumed the card would burn it.
|
||||
@@ -2613,6 +2642,22 @@ _ITHOME_RSS = "https://www.ithome.com/rss/" # IT之家:权威中文 IT 资讯
|
||||
_STOCK_URL = ("https://push2.eastmoney.com/api/qt/clist/get?pn=1&pz=10&po=1&np=1"
|
||||
"&fltt=2&invt=2&fid=f3&fs=m:0+t:6,m:0+t:80,m:1+t:2,m:1+t:23&fields=f12,f14,f3")
|
||||
|
||||
# AI 相关概念板块(东方财富 board code)——「AI 最热」股票列的股票池来源
|
||||
_AI_STOCK_BOARDS = [
|
||||
"BK0800", # 人工智能
|
||||
"BK1127", # AI 芯片
|
||||
"BK1134", # 算力概念
|
||||
"BK1629", # AI 应用
|
||||
"BK0809", # AI 智能体
|
||||
"BK1153", # 多模态 AI
|
||||
"BK1111", # AIGC 概念
|
||||
"BK1128", # CPO 概念
|
||||
"BK1182", # 智谱 AI 概念
|
||||
"BK1172", # AI 语料
|
||||
"BK0891", # 国产芯片
|
||||
"BK1137", # 存储芯片
|
||||
]
|
||||
|
||||
|
||||
def _cst_now():
|
||||
return _dt.now(_CST)
|
||||
@@ -2716,6 +2761,48 @@ def _fetch_stock():
|
||||
return out
|
||||
|
||||
|
||||
def _fetch_ai_stock():
|
||||
"""「AI 最热」:聚合 AI 概念板块成分股,按成交额降序取前 10。
|
||||
用成交额而非涨幅排序——涨幅榜常年被小盘股占据,成交额榜才是资金真正关注的主线龙头。"""
|
||||
pool = {}
|
||||
for bk in _AI_STOCK_BOARDS:
|
||||
url = ("https://push2.eastmoney.com/api/qt/clist/get?pn=1&pz=200&po=1&np=1"
|
||||
"&fltt=2&invt=2&fid=f6"
|
||||
f"&fs=b:{bk}&fields=f2,f3,f6,f12,f14")
|
||||
try:
|
||||
j = json.loads(_http_get(OPENER_DIRECT, url))
|
||||
except Exception as e: # noqa: BLE001
|
||||
print(f"[news] ai board {bk} failed: {e}", flush=True)
|
||||
continue
|
||||
diff = ((j.get("data") or {}).get("diff")) or []
|
||||
if isinstance(diff, dict):
|
||||
diff = list(diff.values())
|
||||
for r in diff:
|
||||
code, name = str(r.get("f12") or ""), str(r.get("f14") or "")
|
||||
pct, price, turn = r.get("f3"), r.get("f2"), r.get("f6")
|
||||
if not code or not name or not isinstance(pct, (int, float)):
|
||||
continue
|
||||
turn = turn if isinstance(turn, (int, float)) else 0
|
||||
# 同一只股票可能属于多个板块,取最大成交额并集
|
||||
if code not in pool or turn > pool[code]["turn"]:
|
||||
pool[code] = {"code": code, "name": name, "pct": pct,
|
||||
"price": price, "turn": turn}
|
||||
if not pool:
|
||||
return []
|
||||
today = _cst_now().strftime("%m-%d")
|
||||
out = []
|
||||
for s in sorted(pool.values(), key=lambda x: -x["turn"])[:10]:
|
||||
price = s["price"]
|
||||
price_s = f"{price}" if isinstance(price, (int, float)) else "-"
|
||||
out.append({
|
||||
"title": f"{s['name']} {s['code']} {s['pct']:+.2f}%",
|
||||
"desc": f"现价 {price_s} · 成交额 {s['turn'] / 1e8:.1f}亿",
|
||||
"url": f"https://quote.eastmoney.com/{s['code']}.html",
|
||||
"time": today,
|
||||
})
|
||||
return out
|
||||
|
||||
|
||||
_STOCK_QUOTE_CACHE = {"t": 0, "key": "", "val": []}
|
||||
|
||||
|
||||
@@ -2854,7 +2941,7 @@ def _fetch_news():
|
||||
lambda: _parse_rss(_http_get(OPENER_PROXY, _TC_AI_RSS)))
|
||||
_col("it", "IT\u6700\u65b0\u6280\u672f", "\U0001f4bb",
|
||||
lambda: _parse_rss(_http_get(OPENER_DIRECT, _ITHOME_RSS)))
|
||||
_col("stock", "\u5f53\u5929\u6700\u70ed\u80a1\u7968", "\U0001f4c8", _fetch_stock)
|
||||
_col("stock", "AI\u6700\u70ed\u80a1\u7968", "\U0001f4c8", _fetch_ai_stock)
|
||||
|
||||
# 翻译:world/ai 英文标题与简介、github 英文简介(it=IT之家中文、stock 中文均免翻)
|
||||
en_title_keys = {"world", "ai"}
|
||||
@@ -2930,14 +3017,14 @@ def _market_status():
|
||||
|
||||
|
||||
def _refresh_stock_if_stale(data, max_age=60):
|
||||
"""「当天最热股票」列高频刷新:交易时段内按需重抓(其余 4 列仍每天 08:00 更新)。
|
||||
"""「AI 最热股票」列高频刷新:交易时段内按需重抓(其余 4 列仍每天 08:00 更新)。
|
||||
失败/非交易时段直接返回原数据,绝不影响 /news 正常返回。"""
|
||||
try:
|
||||
if not data.get("columns") or not _is_trading_time():
|
||||
return data
|
||||
if time.time() - float(data.get("stock_updated") or 0) < max_age:
|
||||
return data
|
||||
fresh = _fetch_stock()
|
||||
fresh = _fetch_ai_stock()
|
||||
if not fresh:
|
||||
return data
|
||||
for c in data["columns"]:
|
||||
|
||||
+10
-3
@@ -179,6 +179,9 @@ tools:
|
||||
title: BIP39 passphrase generator
|
||||
description: Generate a BIP39 passphrase from an existing or random mnemonic, or get the mnemonic from the passphrase.
|
||||
|
||||
base64-image-converter:
|
||||
title: Base64 Image Converter
|
||||
description: "Base64 to image and image to Base64 in one page - accepts bare string / data:URI / CSS url(), sniffs image type from magic bytes, fully local in your browser."
|
||||
base64-file-converter:
|
||||
title: Base64 file converter
|
||||
description: Convert a string, file, or image into its base64 representation.
|
||||
@@ -269,7 +272,7 @@ tools:
|
||||
|
||||
translator:
|
||||
title: Translator
|
||||
description: Translate text between 16 languages (Chinese, English, Japanese, Korean, French, ...) with automatic language detection, powered by Google Translate with a MyMemory fallback.
|
||||
description: Text translation in 16 languages with automatic detection - Chinese/English runs on a local open-source engine (no rate limits), other languages automatically fall back to MyMemory. Full-document translation (Chinese/English); scanned PDFs and images are OCR-recognized before translation.
|
||||
|
||||
image-ocr:
|
||||
title: Image OCR
|
||||
@@ -302,7 +305,7 @@ tools:
|
||||
|
||||
code-reader:
|
||||
title: QR & barcode reader
|
||||
description: Upload, drag & drop or paste an image to decode QR codes and barcodes in one shot (multiple codes supported). Decoding runs locally via WASM - images never leave your browser.
|
||||
description: "Read: decode QR codes and barcodes from upload/drag/paste (multiple codes, local WASM, images never leave your browser). Generate: custom foreground/background colors, local image logo in the center, self-scan verification, PNG download."
|
||||
|
||||
doc-convert:
|
||||
title: Document converter
|
||||
@@ -310,7 +313,7 @@ tools:
|
||||
|
||||
image-tools:
|
||||
title: Image tools
|
||||
description: "In-browser image toolbox: compress, convert, resize, crop, rotate, filters, mosaic/redaction, EXIF viewer, QR generate/scan, watermark and stitching. Images never leave your device."
|
||||
description: "In-browser image toolbox: compress, convert, resize, crop, rotate, filters, mosaic/redaction, Photoshop-style editor (layers, brush, text, selection, OCR text replacement, 47 full-copy artistic text templates (7 categories: general/XHS/Douyin/Bilibili/WeChat/Channels/Cover) with canvas rotation, content-aware erase with live preview), EXIF viewer, QR generate/scan, watermark and stitching. Images never leave your device."
|
||||
|
||||
pdf-tools:
|
||||
title: PDF tools
|
||||
@@ -380,6 +383,10 @@ tools:
|
||||
title: IPv6 ULA generator
|
||||
description: Generate your own local, non-routable IP addresses for your network according to RFC4193.
|
||||
|
||||
my-ip:
|
||||
title: My IP address
|
||||
description: Check your device's public IPv4/IPv6 address and location (with an IPv6 setup guide when unsupported). This site supports IPv6 direct connection. Measure latency to popular places and test your download/upload speed to this server.
|
||||
|
||||
hash-text:
|
||||
title: Hash text
|
||||
description: 'Hash a text string using the function you need : MD5, SHA1, SHA256, SHA224, SHA512, SHA384, SHA3 or RIPEMD160'
|
||||
|
||||
+10
-3
@@ -177,6 +177,9 @@ tools:
|
||||
title: BIP39密码生成器
|
||||
description: 从现有或随机助记符生成BIP39密码短语,或从密码短语获取助记符。
|
||||
|
||||
base64-image-converter:
|
||||
title: Base64图片互转
|
||||
description: Base64转图片与图片转Base64合一页:三种输入格式(裸串/data:URI/CSS url())自动识别,图片类型魔数嗅探,纯浏览器本地处理不上传。
|
||||
base64-file-converter:
|
||||
title: Base64 文件转换器
|
||||
description: 将字符串、文件或图像转换为其 Base64 表示形式。
|
||||
@@ -266,7 +269,7 @@ tools:
|
||||
|
||||
translator:
|
||||
title: 在线翻译
|
||||
description: 支持中英日韩法德等16种语言互译,自动检测源语言,谷歌翻译主线路 + MyMemory 备用线路,修改文本自动翻译。
|
||||
description: 文本翻译支持中英日韩法德等 16 种语言,自动识别源语言:中英互译走本地开源引擎不限流,其他语种自动切 MyMemory 备用线路;文档整篇翻译(中英),扫描件/图片自动 OCR 识别后翻译,修改文本自动翻译。
|
||||
|
||||
image-ocr:
|
||||
title: 图片OCR文字识别
|
||||
@@ -299,7 +302,7 @@ tools:
|
||||
|
||||
code-reader:
|
||||
title: 二维码条码识别
|
||||
description: 上传、拖拽或粘贴图片,一键识别图中的二维码和条形码(支持多码混合、批量输出),本地 WASM 解码,图片不上传服务器。
|
||||
description: 识别:上传/拖拽/粘贴图片一键解码二维码和条形码(多码混合、批量输出,本地 WASM 解码不上传);生成:自定义前景/背景颜色、中间插入本地图片 Logo,生成后自动自扫验证,可下载 PNG。
|
||||
|
||||
doc-convert:
|
||||
title: 文档格式转换
|
||||
@@ -307,7 +310,7 @@ tools:
|
||||
|
||||
image-tools:
|
||||
title: 图片工具
|
||||
description: 浏览器本地处理的图片工具箱:图片压缩、格式转换、调整尺寸、裁剪、旋转、滤镜、打码、EXIF 查看、二维码生成/识别、加水印、多图拼接,图片全程不上传。
|
||||
description: 浏览器本地处理的图片工具箱:图片压缩、格式转换、调整尺寸、裁剪、旋转、滤镜、打码、PS 风格图片编辑(图层/画笔/文字/选区/OCR 改字/47套成套文案花字模板(通用/小红书/抖音/B站/公众号/视频号/封面图7类)+画布旋转拖角缩放/智能消除笔实时预览无痕去文字水印、OCR无痕改字(自动匹配原字字号/颜色/角度))、EXIF 查看、二维码生成/识别、加水印、多图拼接,图片全程不上传。
|
||||
|
||||
pdf-tools:
|
||||
title: PDF工具
|
||||
@@ -376,6 +379,10 @@ tools:
|
||||
title: IPv6 ULA生成器
|
||||
description: 根据RFC4193在网络上生成您自己的本地不可路由IP地址。
|
||||
|
||||
my-ip:
|
||||
title: 本机IP查询
|
||||
description: 查询你设备的公网IPv4/IPv6地址与所属地(IPv6不支持时提供开启教程),本站已支持IPv6直连,测连接热门地点延迟,一键测试你到本站服务器的下载/上传网速。
|
||||
|
||||
hash-text:
|
||||
title: Hash 文本
|
||||
description: '使用所需的函数哈希文本字符串:MD5、SHA1、SHA256、SHA224、SHA512、SHA384、SHA3或RIPEMD160'
|
||||
|
||||
+27
@@ -20,6 +20,8 @@ server {
|
||||
# license relay (card activation etc; auth gate itself must stay open)
|
||||
location /relay/ {
|
||||
client_max_body_size 2g;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_pass http://it-tools-relay:8091/;
|
||||
proxy_connect_timeout 5s;
|
||||
proxy_read_timeout 600s;
|
||||
@@ -62,7 +64,32 @@ server {
|
||||
proxy_read_timeout 30s;
|
||||
}
|
||||
|
||||
# ---- SPA shell & service worker: MUST revalidate every load ----
|
||||
# Without this header browsers heuristically cache index.html/sw.js and the
|
||||
# PWA keeps serving a stale precache after deploys (2026-10-30: users were
|
||||
# stuck on an old my-ip page that leaked the server egress IP).
|
||||
location = /index.html {
|
||||
add_header Cache-Control "no-cache, must-revalidate";
|
||||
try_files $uri =404;
|
||||
}
|
||||
location = /sw.js {
|
||||
add_header Cache-Control "no-cache, must-revalidate";
|
||||
add_header Service-Worker-Allowed "/";
|
||||
try_files $uri =404;
|
||||
}
|
||||
location = /manifest.webmanifest {
|
||||
add_header Cache-Control "no-cache, must-revalidate";
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# hashed build assets are content-addressed: cache forever
|
||||
location /assets/ {
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
location / {
|
||||
add_header Cache-Control "no-cache, must-revalidate";
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ useHead(head);
|
||||
const { t } = useI18n();
|
||||
|
||||
// 宽屏工具:不受 600px 限宽,占满可用宽度(画布/多栏类工具)
|
||||
const WIDE_TOOLS = new Set(['/label-designer', '/json-prettify', '/pdf-tools', '/image-tools', '/doc-convert', '/video-tools', '/seal-maker', '/signature-pad', '/ai-image-lab', '/ai-chat', '/copywriting', '/ai-gen']);
|
||||
const WIDE_TOOLS = new Set(['/label-designer', '/json-prettify', '/pdf-tools', '/image-tools', '/doc-convert', '/video-tools', '/seal-maker', '/signature-pad', '/ai-image-lab', '/ai-chat', '/copywriting', '/ai-gen', '/code-reader', '/my-ip']);
|
||||
const isWide = computed(() => WIDE_TOOLS.has(route.path));
|
||||
|
||||
const i18nKey = computed<string>(() => route.path.trim().replace('/', ''));
|
||||
|
||||
+7
-5
@@ -26,8 +26,8 @@ const groups: { title: string; items: Item[] }[] = [
|
||||
{
|
||||
title: '首页资讯',
|
||||
items: [
|
||||
{ name: '每日资讯 5 列', icon: '讯', desc: '首页顶部并排 5 列:GitHub 热榜、国际新闻、AI 资讯、IT 最新技术、当天最热股票;每天 08:00 自动抓取更新,英文标题与简介自动翻译中文,点标题新标签打开原文', tag: '全新' },
|
||||
{ name: '最热股票实时刷新', icon: '股', desc: '交易时段(工作日 9:30-15:00)每 60 秒自动拉取东方财富最新涨幅;标题行显示 交易中/休市 状态徽章,收盘后与周末自动休市', tag: '全新' },
|
||||
{ name: '每日资讯 5 列', icon: '讯', desc: '首页顶部并排 5 列:GitHub 热榜、国际新闻、AI 资讯、IT 最新技术、AI 最热股票;每天 08:00 自动抓取更新,英文标题与简介自动翻译中文,点标题新标签打开原文', tag: '全新' },
|
||||
{ name: 'AI 最热股票实时刷新', icon: '股', desc: '交易时段(工作日 9:30-15:00)每 60 秒自动拉取东方财富数据;聚合人工智能、AI 芯片、算力概念、AI 应用等 12 个 AI 概念板块(约 580 只成分股)按成交额排序取最热 10 只,标题行显示 交易中/休市 状态徽章', tag: '全新' },
|
||||
{ name: '自选股', icon: '自', desc: '股票列「自选」选项卡:输入 6 位代码即可添加,行内看 名称·涨跌幅·现价,红涨绿跌,一键移出;自选股登录后云端同步,换电脑即恢复', tag: '全新' },
|
||||
{ name: '首页推荐与全部工具', icon: '首', desc: '管理员可配置首页「精选推荐」工具位;「近期新功能」随版本滚动更新;「全部工具」默认折叠并显示总数徽章,各分组标题右侧均显示功能数量', tag: '全新' },
|
||||
],
|
||||
@@ -35,9 +35,11 @@ const groups: { title: string; items: Item[] }[] = [
|
||||
{
|
||||
title: '原创工具',
|
||||
items: [
|
||||
{ name: '本机IP查询', icon: '网', desc: '仅显示你设备的公网IPv4/IPv6地址与所属地(多源容错+中文归属地+一键复制),IPv6不支持时明示并给出开启教程,本站已支持IPv6直连(速度更快),网速测试为你的设备↔本站服务器真实收发计时,进入页面自动测9个热门地点延迟', tag: '全新' },
|
||||
{ name: 'Base64图片互转', icon: 'B', desc: 'Base64转图片与图片转Base64合一页双 Tab:三种输入形态(裸串/data:URI/CSS url())自动识别、图片类型魔数嗅探、输出三档格式实时切换、互转按钮带结果闭环跳转,纯浏览器本地不上传', tag: '全新' },
|
||||
{ name: '批量条码生成', icon: '条', desc: 'EAN/UPC/Code128/Code39/DataMatrix 等 12 种码制,批量生成、打包下载,尺寸颜色字号可调', tag: '全新' },
|
||||
{ name: '二维码条码识别', icon: '扫', desc: '上传/拖拽/粘贴图片一键识别,支持多码混合批量输出,本地 WASM 解码,图片不上传', tag: '全新' },
|
||||
{ name: '在线翻译', icon: '译', desc: '中英日韩等 16 种语言互译,自动识别源语言,支持导入 Word/PDF/TXT 等文档整篇翻译、并发处理大文档、译文可下载 TXT/DOCX', tag: '全新' },
|
||||
{ name: '二维码条码识别与生成', icon: '扫', desc: '识别:上传/拖拽/粘贴一键解码(多码混合批量输出,本地 WASM 不上传);生成:自定义前景/背景颜色、中间插入本地 Logo 图片,生成后自动自扫验证可下载 PNG', tag: '全新' },
|
||||
{ name: '在线翻译', icon: '译', desc: '文本翻译 16 种语言(中英走本地引擎不限流,其他语种自动备用线路),Word/PDF/TXT 整篇翻译,扫描件/图片自动 OCR 识别后翻译,译文可下载 TXT/DOCX', tag: '全新' },
|
||||
{ name: '图片OCR / PDF文字识别', icon: '识', desc: '本地 OCR 引擎,截图扫描件文字提取(准确率 99%+);PDF 逐页识别、预览、导出 TXT', tag: '全新' },
|
||||
{ name: '面单设计', icon: '单', desc: '内置 **20 个面单模板**并按「国内快递 / 国外快递 / 通用面单」三组归类——顺丰、中通、圆通、韵达、申通、京东、极兔、EMS,DHL、FedEx、UPS、USPS、TNT、亚马逊 FBA 等开箱即用;**每个模板按该快递真实电子面单独立排版**(尺寸/品牌色/三段码/撕开线/专属字段各不相同);上传 PDF 自动把**文字、条码、二维码、图片**全部提取成可编辑元素(可改内容、移动、删除)并**擦除底图原内容**,不产生重影;新增**实线/虚线 × 横线/竖线**线条组件可调粗度长度;300dpi 高清导出', tag: '全新' },
|
||||
{ name: 'IT网站收藏', icon: '藏', desc: '内置 91 个精选开发站点(社区/文档/工具/AI/设计/视频/媒体平台),数据存用户本地,可自选目录', tag: '全新' },
|
||||
@@ -53,7 +55,7 @@ const groups: { title: string; items: Item[] }[] = [
|
||||
{ name: '多图拼接', icon: '拼', desc: '横向/纵向长图/九宫格/瀑布流/交错双列/拍立得 6 种方式,网格类 2-4 列可调,间距可调', tag: '改造' },
|
||||
{ name: 'JSON 美化和格式化', icon: 'J', desc: '双栏专业工作台:左侧行号编辑,右侧树视图/语法高亮切换,含 Dict/Get参数/XML/CSV 等 7 种转换', tag: '改造' },
|
||||
{ name: 'PDF工具', icon: 'P', desc: '合并/拆分/旋转/重排/压缩/加密/解密/水印/提取文本/页码/转图片,11 功能全程浏览器本地处理,需授权使用', tag: '授权' },
|
||||
{ name: '图片工具', icon: '图', desc: '压缩/转换/尺寸/裁剪/旋转/滤镜/打码/EXIF/二维码生成识别/水印/拼接,12 功能本地处理,需授权使用', tag: '授权' },
|
||||
{ name: '图片工具', icon: '图', desc: '压缩/转换/尺寸/裁剪/旋转/滤镜/打码/PS 风格编辑器(图层+画笔+文字+选区+历史记录+OCR 改字/文字模板+画布旋转、智能消除笔实时预览无痕去文字水印)/EXIF/二维码生成识别/水印/拼接,13 功能本地处理,需授权使用', tag: '授权' },
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -10,6 +10,10 @@ import { useRecentTools } from '@/composable/recent-tools';
|
||||
|
||||
// 近期新功能亮点(手动维护,新工具上线时加一条)
|
||||
const NEW_FEATURES = [
|
||||
{ path: '/my-ip', icon: '🌍', name: '本机IP查询', desc: '公网IPv4/IPv6地址与所属地一键查询,自动测9个热门地点延迟,一键测试当前下载上传网速' },
|
||||
{ path: '/code-reader', icon: '🧩', name: '二维码生成', desc: '识别工具内新能力:自定义颜色、中间插入本地 Logo 图,生成后自动自扫验证' },
|
||||
{ path: '/base64-image-converter', icon: '🔁', name: 'Base64图片互转', desc: 'Base64转图片与图片转Base64合一页,三格式自动识别,纯浏览器本地不上传' },
|
||||
{ path: '/image-tools', icon: '🖌️', name: '图片编辑·无痕改字', desc: 'PS式图层画笔选区,OCR点字框自动匹配字号颜色角度无缝改字' },
|
||||
{ path: '/seal-maker', icon: '🔴', name: '印章生成器', desc: '圆形公章一键生成,盖章到图片/PDF,支持骑缝章' },
|
||||
{ path: '/signature-pad', icon: '✍️', name: '手写签名', desc: '真实笔触模拟,透明 PNG,签合同一步到位' },
|
||||
{ path: '/text-to-image', icon: '🖼️', name: '文字生成图片', desc: '多行文字排版出图,字体颜色可调,2x/3x 高清' },
|
||||
@@ -43,8 +47,8 @@ onMounted(async () => {
|
||||
catch { /* 无推荐则隐藏 */ }
|
||||
});
|
||||
|
||||
// 每日 5 列资讯:GITHUB/国际新闻/AI资讯/IT最新技术/当天最热股票
|
||||
// 前 4 列 relay 每天 08:00 抓取;「当天最热股票」交易时段 60s 高频刷新
|
||||
// 每日 5 列资讯:GITHUB/国际新闻/AI资讯/IT最新技术/AI最热股票
|
||||
// 前 4 列 relay 每天 08:00 抓取;「AI最热股票」交易时段 60s 高频刷新
|
||||
const newsCols = ref<any[]>([]);
|
||||
const newsDate = ref('');
|
||||
const newsMarket = ref<'open' | 'closed' | ''>('');
|
||||
@@ -74,7 +78,7 @@ onUnmounted(() => {
|
||||
if (newsTimer) clearInterval(newsTimer);
|
||||
});
|
||||
|
||||
// ===== 股票列选项卡:最热 / 自选(自选实时行情,登录后随云同步)=====
|
||||
// ===== 股票列选项卡:AI最热 / 自选(自选实时行情,登录后随云同步)=====
|
||||
const MY_STOCKS_KEY = 'it-tools-my-stocks';
|
||||
const stockTab = ref<'hot' | 'mine'>('hot');
|
||||
const stockInput = ref('');
|
||||
@@ -213,7 +217,7 @@ function onUpdateFavoriteTools() {
|
||||
>{{ newsMarket === 'open' ? '交易中' : '休市' }}</span>
|
||||
</div>
|
||||
<div v-if="col.key === 'stock'" class="stock-tabs">
|
||||
<button class="stock-tab" :class="{ on: stockTab === 'hot' }" @click="switchStockTab('hot')">最热</button>
|
||||
<button class="stock-tab" :class="{ on: stockTab === 'hot' }" @click="switchStockTab('hot')">AI最热</button>
|
||||
<button class="stock-tab" :class="{ on: stockTab === 'mine' }" @click="switchStockTab('mine')">自选<template v-if="myStocks.length">·{{ myStocks.length }}</template></button>
|
||||
</div>
|
||||
<div class="news-list">
|
||||
@@ -233,7 +237,7 @@ function onUpdateFavoriteTools() {
|
||||
<button class="mystock-x" title="移出自选" @click="removeMyStock(q.code)">✕</button>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 最热(默认) -->
|
||||
<!-- AI 最热(默认):AI 概念板块成分股按成交额排序 -->
|
||||
<template v-else>
|
||||
<a
|
||||
v-for="(it, i) in col.items"
|
||||
|
||||
@@ -16,7 +16,7 @@ const FEATURES: Feature[] = [
|
||||
path: '/translator',
|
||||
name: '在线翻译',
|
||||
icon: '🌐',
|
||||
points: ['支持中英日韩等 16 种语言互译', '谷歌翻译主线 + MyMemory 备用双线路', '粘贴即译,自动识别源语言'],
|
||||
points: ['文本翻译 16 种语言,自动识别源语言', '中英互译走本地开源引擎不限流,其他语种自动切备用线路', '文档整篇翻译(中英),扫描件/图片自动 OCR,译文可下载'],
|
||||
},
|
||||
{
|
||||
path: '/image-ocr',
|
||||
|
||||
@@ -0,0 +1,427 @@
|
||||
<script setup lang="ts">
|
||||
import { getMachineId, licenseHeaders } from '@/tools/license/license';
|
||||
|
||||
// ---------- 状态 ----------
|
||||
const file = ref<File | null>(null);
|
||||
const previewUrl = ref('');
|
||||
const prompt = ref('');
|
||||
const size = ref('default');
|
||||
const customW = ref(1024);
|
||||
const customH = ref(1024);
|
||||
const count = ref(1);
|
||||
const model = ref('qwen3.8-max');
|
||||
const models = ref<string[]>([]);
|
||||
const loading = ref(false);
|
||||
const error = ref('');
|
||||
const note = ref('');
|
||||
const edits = ref<{ old: string; new: string; style: string }[]>([]);
|
||||
const results = ref<{ url: string; scale: number }[]>([]);
|
||||
|
||||
const SIZES = [
|
||||
{ k: 'default', label: '默认' },
|
||||
{ k: '4:3', label: '4:3' },
|
||||
{ k: '3:4', label: '3:4' },
|
||||
{ k: '1:1', label: '1:1' },
|
||||
{ k: 'custom', label: '自定义' },
|
||||
];
|
||||
|
||||
const EXAMPLES = [
|
||||
{ n: '改数字', p: '把图中"人数8"改成"31",保持原字体样式、大小和颜色' },
|
||||
{ n: '改姓名', p: '把名字"张三"改成"李四",完全匹配原字体、字号和颜色,融合背景纹理' },
|
||||
{ n: '改价格', p: '把价格"99元"改成"199元",保持促销海报的立体金色渐变效果' },
|
||||
{ n: '删除文字', p: '把图片底部的水印文字无痕删除' },
|
||||
{ n: '改金额', p: '把转账金额"¥1000.00"改成"¥5000.00",保持界面原字体和绿色气泡背景' },
|
||||
];
|
||||
|
||||
const canGo = computed(() => !!file.value && !!prompt.value.trim() && !loading.value);
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const res = await fetch('/relay/ai/vision-models');
|
||||
const j = await res.json();
|
||||
if (j.code === 200 && Array.isArray(j.data) && j.data.length) {
|
||||
models.value = j.data;
|
||||
if (!j.data.includes(model.value)) model.value = j.data[0];
|
||||
}
|
||||
}
|
||||
catch { /* 用默认 */ }
|
||||
loadTasks();
|
||||
});
|
||||
|
||||
// ---------- 最近任务(localStorage 缩略图) ----------
|
||||
interface SETask { id: string; time: number; prompt: string; before: string; after: string; count: number }
|
||||
const tasks = ref<SETask[]>([]);
|
||||
const LS_KEY = 'it-ai-text-edit:tasks';
|
||||
|
||||
function loadTasks() {
|
||||
try {
|
||||
const arr = JSON.parse(localStorage.getItem(LS_KEY) ?? '[]');
|
||||
tasks.value = Array.isArray(arr) ? arr.slice(0, 12) : [];
|
||||
}
|
||||
catch { tasks.value = []; }
|
||||
}
|
||||
|
||||
function saveTasks() {
|
||||
try {
|
||||
localStorage.setItem(LS_KEY, JSON.stringify(tasks.value.slice(0, 12)));
|
||||
}
|
||||
catch { /* 缩略图过大则丢弃历史 */ }
|
||||
}
|
||||
|
||||
/** 200px 宽 JPEG 缩略图(控制 localStorage 体积) */
|
||||
function thumbOf(url: string): Promise<string> {
|
||||
return new Promise((resolve) => {
|
||||
const im = new Image();
|
||||
im.onload = () => {
|
||||
const k = 200 / Math.max(im.width, im.height);
|
||||
const c = document.createElement('canvas');
|
||||
c.width = Math.max(1, Math.round(im.width * k));
|
||||
c.height = Math.max(1, Math.round(im.height * k));
|
||||
c.getContext('2d')!.drawImage(im, 0, 0, c.width, c.height);
|
||||
resolve(c.toDataURL('image/jpeg', 0.7));
|
||||
};
|
||||
im.onerror = () => resolve('');
|
||||
im.src = url;
|
||||
});
|
||||
}
|
||||
|
||||
function fmtTime(t: number): string {
|
||||
const d = new Date(t);
|
||||
const p = (n: number) => String(n).padStart(2, '0');
|
||||
return `${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`;
|
||||
}
|
||||
|
||||
// ---------- 上传 ----------
|
||||
function onPick(e: Event) {
|
||||
const f = (e.target as HTMLInputElement).files?.[0];
|
||||
if (f) setFile(f);
|
||||
}
|
||||
|
||||
function onDrop(e: DragEvent) {
|
||||
const f = e.dataTransfer?.files?.[0];
|
||||
if (f) setFile(f);
|
||||
}
|
||||
|
||||
function setFile(f: File) {
|
||||
if (!/^image\/(jpeg|png|webp)$/.test(f.type)) {
|
||||
error.value = '仅支持 JPEG / PNG / WEBP';
|
||||
return;
|
||||
}
|
||||
if (f.size > 24 * 1024 * 1024) {
|
||||
error.value = '图片超过 24MB';
|
||||
return;
|
||||
}
|
||||
file.value = f;
|
||||
error.value = '';
|
||||
if (previewUrl.value) URL.revokeObjectURL(previewUrl.value);
|
||||
previewUrl.value = URL.createObjectURL(f);
|
||||
}
|
||||
|
||||
function b64DataUrl(b64: string) {
|
||||
let mime = 'image/png';
|
||||
if (b64.startsWith('/9j/')) mime = 'image/jpeg';
|
||||
else if (b64.startsWith('UklGR')) mime = 'image/webp';
|
||||
return `data:${mime};base64,${b64}`;
|
||||
}
|
||||
|
||||
// ---------- 提交 ----------
|
||||
async function submit() {
|
||||
if (!canGo.value) return;
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
note.value = '';
|
||||
edits.value = [];
|
||||
results.value = [];
|
||||
try {
|
||||
const fd = new FormData();
|
||||
fd.append('image', file.value!, file.value!.name || 'image.png');
|
||||
fd.append('prompt', prompt.value.trim());
|
||||
fd.append('model', model.value);
|
||||
fd.append('size', size.value);
|
||||
fd.append('count', String(count.value));
|
||||
if (size.value === 'custom') {
|
||||
fd.append('custom_w', String(customW.value));
|
||||
fd.append('custom_h', String(customH.value));
|
||||
}
|
||||
const res = await fetch('/relay/ai/seamless-edit', {
|
||||
method: 'POST',
|
||||
headers: licenseHeaders('ai-text-edit'),
|
||||
body: fd,
|
||||
});
|
||||
const j = await res.json().catch(() => ({}));
|
||||
if (!res.ok || j.code !== 200) throw new Error(j.message || `HTTP ${res.status}`);
|
||||
const d = j.data || {};
|
||||
edits.value = Array.isArray(d.edits) ? d.edits : [];
|
||||
note.value = String(d.note || '');
|
||||
results.value = (Array.isArray(d.images) ? d.images : []).map((x: any) => ({ url: b64DataUrl(x.b64), scale: x.scale }));
|
||||
if (results.value.length) {
|
||||
const [before, after] = await Promise.all([thumbOf(previewUrl.value), thumbOf(results.value[0].url)]);
|
||||
tasks.value.unshift({
|
||||
id: `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`,
|
||||
time: Date.now(),
|
||||
prompt: prompt.value.trim(),
|
||||
before,
|
||||
after,
|
||||
count: results.value.length,
|
||||
});
|
||||
tasks.value = tasks.value.slice(0, 12);
|
||||
saveTasks();
|
||||
}
|
||||
else if (!note.value) {
|
||||
note.value = '未产生结果,请调整描述后重试';
|
||||
}
|
||||
}
|
||||
catch (e: any) {
|
||||
error.value = String(e?.message || e);
|
||||
}
|
||||
finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function clearAll() {
|
||||
file.value = null;
|
||||
if (previewUrl.value) URL.revokeObjectURL(previewUrl.value);
|
||||
previewUrl.value = '';
|
||||
results.value = [];
|
||||
edits.value = [];
|
||||
note.value = '';
|
||||
error.value = '';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="se-root">
|
||||
<div class="se-head">
|
||||
<div class="se-title">无痕改字</div>
|
||||
<div class="se-sub">AI 智能修改图片文字 · 自动匹配原字体/字号/颜色/角度 · 本地模型驱动</div>
|
||||
</div>
|
||||
|
||||
<div class="se-grid">
|
||||
<!-- 左:输入面板 -->
|
||||
<div class="se-ctrl">
|
||||
<!-- 上传 -->
|
||||
<div
|
||||
class="se-upload"
|
||||
:class="{ has: !!previewUrl }"
|
||||
@click="!previewUrl && ($refs.fileInput as HTMLInputElement).click()"
|
||||
@dragover.prevent
|
||||
@drop.prevent="onDrop"
|
||||
>
|
||||
<template v-if="previewUrl">
|
||||
<img :src="previewUrl" class="se-upload-img" alt="">
|
||||
<div class="se-upload-bar">
|
||||
<span class="se-upload-name">{{ file?.name }}</span>
|
||||
<a href="javascript:;" class="se-upload-x" @click.stop="clearAll">✕ 重新选择</a>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="se-upload-icon">☁️⬆️</div>
|
||||
<div class="se-upload-t">拖拽图片到此处 · 点击上传</div>
|
||||
<div class="se-upload-s">支持最大 24MB 的 JPEG、PNG 或 WEBP 格式,全程本地+内网处理</div>
|
||||
</template>
|
||||
<input ref="fileInput" type="file" accept="image/jpeg,image/png,image/webp" style="display: none" @change="onPick">
|
||||
</div>
|
||||
|
||||
<!-- 提示词 -->
|
||||
<div class="se-sec">
|
||||
<div class="se-h">提示</div>
|
||||
<textarea
|
||||
v-model="prompt"
|
||||
class="se-prompt"
|
||||
maxlength="200"
|
||||
placeholder="填写无痕改字的具体要求,包括需要修改的文字内容和样式,例如:把图中「人数8」改成「31」,保持原字体样式和背景"
|
||||
/>
|
||||
<div class="se-count">{{ prompt.length }}/200</div>
|
||||
<div class="se-examples">
|
||||
<button v-for="ex in EXAMPLES" :key="ex.n" class="se-example" @click="prompt = ex.p">{{ ex.n }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 尺寸 -->
|
||||
<div class="se-sec">
|
||||
<div class="se-h">尺寸</div>
|
||||
<div class="se-btns">
|
||||
<button
|
||||
v-for="s in SIZES"
|
||||
:key="s.k"
|
||||
class="se-btn"
|
||||
:class="{ on: size === s.k }"
|
||||
@click="size = s.k"
|
||||
>{{ s.label }}</button>
|
||||
</div>
|
||||
<div v-if="size === 'custom'" class="se-custom">
|
||||
<input v-model.number="customW" type="number" min="64" max="2048" class="se-num">
|
||||
<span>×</span>
|
||||
<input v-model.number="customH" type="number" min="64" max="2048" class="se-num">
|
||||
<span class="se-custom-s">px(自动补边不裁内容)</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 输出数量 -->
|
||||
<div class="se-sec">
|
||||
<div class="se-h">输出数量</div>
|
||||
<div class="se-btns">
|
||||
<button v-for="n in [1, 2, 3]" :key="n" class="se-btn se-btn-n" :class="{ on: count === n }" @click="count = n">{{ n }}</button>
|
||||
</div>
|
||||
<div class="se-tip-s">多张输出为新文字大小的微调档位(字号自动估计有误差,出 2~3 张挑最像的)</div>
|
||||
</div>
|
||||
|
||||
<!-- 模型 -->
|
||||
<div class="se-sec">
|
||||
<div class="se-h">模型</div>
|
||||
<select v-model="model" class="se-model">
|
||||
<option v-for="m in models" :key="m" :value="m">{{ m }}(本地)</option>
|
||||
<option v-if="!models.length" value="qwen3.8-max">qwen3.8-max(本地)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button class="se-go" :disabled="!canGo" @click="submit()">
|
||||
<span v-if="loading" class="se-spin">⏳</span>
|
||||
<span v-else>✨</span>
|
||||
{{ loading ? '处理中:识别 → AI 定位 → 无缝重绘…' : '提交' }}
|
||||
</button>
|
||||
|
||||
<div v-if="error" class="se-err">⚠️ {{ error }}</div>
|
||||
|
||||
<!-- 结果 -->
|
||||
<div v-if="results.length" class="se-results">
|
||||
<div class="se-h">修改结果</div>
|
||||
<div class="se-cmp">
|
||||
<div class="se-cmp-col">
|
||||
<div class="se-cmp-t">原始文字</div>
|
||||
<img :src="previewUrl" class="se-cmp-img" alt="">
|
||||
</div>
|
||||
<div class="se-cmp-col">
|
||||
<div class="se-cmp-t se-cmp-t-new">新文字</div>
|
||||
<img :src="results[0].url" class="se-cmp-img" alt="">
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="edits.length" class="se-edits">
|
||||
<div v-for="(e, i) in edits" :key="i" class="se-edit-row">
|
||||
「{{ e.old }}」→「{{ e.new }}」<span class="se-edit-style">{{ e.style }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="results.length > 1" class="se-variants">
|
||||
<a v-for="(r, i) in results" :key="i" class="se-variant" :href="r.url" target="_blank" rel="noopener">
|
||||
变体 {{ i + 1 }}({{ Math.round(r.scale * 100) }}%字号)
|
||||
</a>
|
||||
</div>
|
||||
<div class="se-acts">
|
||||
<a class="se-dl" :href="results[0].url" target="_blank" rel="noopener" download>⬇ 下载图片</a>
|
||||
<a class="se-dl" :href="results[0].url" target="_blank" rel="noopener">🔗 新窗口打开</a>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="note" class="se-note">💡 {{ note }}</div>
|
||||
</div>
|
||||
|
||||
<!-- 右:最近任务 -->
|
||||
<div class="se-side">
|
||||
<div class="se-side-h">
|
||||
最近任务
|
||||
<a href="javascript:;" class="se-refresh" @click="loadTasks()">刷新</a>
|
||||
</div>
|
||||
<div v-if="!tasks.length" class="se-side-empty">
|
||||
还没有任务——左侧上传图片并描述要改的文字,提交后这里会保留前后对比记录(仅本机浏览器)
|
||||
</div>
|
||||
<div v-for="t in tasks" :key="t.id" class="se-task">
|
||||
<div class="se-task-time">{{ fmtTime(t.time) }}<span v-if="t.count > 1" class="se-task-n">{{ t.count }}张</span></div>
|
||||
<div class="se-task-p">{{ t.prompt }}</div>
|
||||
<div class="se-task-imgs">
|
||||
<div class="se-task-col">
|
||||
<img :src="t.before" class="se-task-img" alt="">
|
||||
<div class="se-task-lb">原始文字</div>
|
||||
</div>
|
||||
<div class="se-task-col">
|
||||
<img :src="t.after" class="se-task-img" alt="">
|
||||
<div class="se-task-lb se-task-lb-new">新文字</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.se-root { max-width: 1200px; margin: 0 auto; padding: 18px 12px 40px; color: var(--n-text-color, #333); }
|
||||
.se-head { text-align: center; margin-bottom: 18px; }
|
||||
.se-title { font-size: 30px; font-weight: 800; letter-spacing: 2px; }
|
||||
.se-sub { margin-top: 6px; font-size: 13px; opacity: 0.6; }
|
||||
|
||||
.se-grid { display: grid; grid-template-columns: 380px 1fr; gap: 16px; align-items: start; }
|
||||
@media (max-width: 900px) { .se-grid { grid-template-columns: 1fr; } }
|
||||
|
||||
.se-ctrl { background: #fff; border: 1px solid rgba(128,128,128,0.18); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
|
||||
html.dark .se-ctrl { background: rgba(255,255,255,0.04); }
|
||||
|
||||
.se-upload { border: 2px dashed rgba(128,128,128,0.45); border-radius: 10px; min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; transition: border-color 0.15s; overflow: hidden; }
|
||||
.se-upload:hover { border-color: #ff7a1a; }
|
||||
.se-upload.has { padding: 8px; cursor: default; }
|
||||
.se-upload-icon { font-size: 28px; }
|
||||
.se-upload-t { margin-top: 8px; font-size: 14px; font-weight: 600; }
|
||||
.se-upload-s { margin-top: 5px; font-size: 11.5px; opacity: 0.55; text-align: center; padding: 0 14px; }
|
||||
.se-upload-img { max-width: 100%; max-height: 220px; border-radius: 8px; display: block; margin: 0 auto; }
|
||||
.se-upload-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 7px; font-size: 12px; }
|
||||
.se-upload-name { opacity: 0.7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.se-upload-x { color: #e53935; text-decoration: none; flex-shrink: 0; margin-left: 8px; }
|
||||
|
||||
.se-sec { display: flex; flex-direction: column; gap: 7px; }
|
||||
.se-h { font-size: 13px; font-weight: 700; opacity: 0.85; }
|
||||
.se-prompt { width: 100%; min-height: 86px; resize: vertical; border: 1px solid rgba(128,128,128,0.35); border-radius: 8px; padding: 9px 11px; font-size: 13px; line-height: 1.55; background: transparent; color: inherit; }
|
||||
.se-prompt:focus { outline: none; border-color: #ff7a1a; }
|
||||
.se-count { font-size: 11px; opacity: 0.45; text-align: right; }
|
||||
.se-examples { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
.se-example { border: 1px solid rgba(128,128,128,0.3); background: transparent; color: inherit; border-radius: 999px; font-size: 11.5px; padding: 4px 10px; cursor: pointer; opacity: 0.8; transition: all 0.12s; }
|
||||
.se-example:hover { border-color: #ff7a1a; color: #ff7a1a; opacity: 1; }
|
||||
|
||||
.se-btns { display: flex; gap: 7px; flex-wrap: wrap; }
|
||||
.se-btn { border: 1.5px solid rgba(128,128,128,0.35); background: transparent; color: inherit; border-radius: 8px; font-size: 12.5px; padding: 6px 14px; cursor: pointer; transition: all 0.12s; }
|
||||
.se-btn.on { border-color: #ff7a1a; color: #ff7a1a; background: rgba(255,122,26,0.08); font-weight: 700; }
|
||||
.se-btn-n { width: 44px; text-align: center; }
|
||||
.se-custom { display: flex; align-items: center; gap: 6px; font-size: 12px; }
|
||||
.se-num { width: 70px; border: 1px solid rgba(128,128,128,0.35); border-radius: 6px; padding: 4px 6px; background: transparent; color: inherit; font-size: 12px; }
|
||||
.se-custom-s, .se-tip-s { opacity: 0.5; font-size: 11px; }
|
||||
|
||||
.se-model { border: 1px solid rgba(128,128,128,0.35); border-radius: 8px; padding: 7px 10px; font-size: 12.5px; background: transparent; color: inherit; }
|
||||
|
||||
.se-go { margin-top: 2px; border: none; background: #ff7a1a; color: #fff; font-size: 15.5px; font-weight: 700; border-radius: 10px; padding: 12px; cursor: pointer; transition: filter 0.12s, opacity 0.12s; }
|
||||
.se-go:hover:not(:disabled) { filter: brightness(1.06); }
|
||||
.se-go:disabled { opacity: 0.45; cursor: not-allowed; }
|
||||
.se-spin { display: inline-block; animation: se-rot 1s linear infinite; }
|
||||
@keyframes se-rot { to { transform: rotate(360deg); } }
|
||||
|
||||
.se-err { background: rgba(229,57,53,0.08); border: 1px solid rgba(229,57,53,0.35); color: #e53935; border-radius: 8px; font-size: 12.5px; padding: 9px 11px; }
|
||||
.se-note { background: rgba(255,122,26,0.08); border: 1px solid rgba(255,122,26,0.3); border-radius: 8px; font-size: 12.5px; padding: 9px 11px; }
|
||||
|
||||
.se-results { display: flex; flex-direction: column; gap: 10px; }
|
||||
.se-cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
|
||||
.se-cmp-col { text-align: center; }
|
||||
.se-cmp-t { font-size: 12px; font-weight: 700; opacity: 0.7; margin-bottom: 5px; }
|
||||
.se-cmp-t-new { color: #ff7a1a; opacity: 1; }
|
||||
.se-cmp-img { max-width: 100%; border-radius: 8px; border: 1px solid rgba(128,128,128,0.2); }
|
||||
.se-edits { font-size: 12px; background: rgba(128,128,128,0.07); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
|
||||
.se-edit-style { opacity: 0.5; margin-left: 6px; font-size: 11px; }
|
||||
.se-variants { display: flex; gap: 7px; flex-wrap: wrap; }
|
||||
.se-variant { font-size: 12px; border: 1px solid rgba(128,128,128,0.35); border-radius: 999px; padding: 4px 11px; text-decoration: none; color: inherit; }
|
||||
.se-variant:hover { border-color: #ff7a1a; color: #ff7a1a; }
|
||||
.se-acts { display: flex; gap: 9px; }
|
||||
.se-dl { flex: 1; text-align: center; font-size: 13px; font-weight: 700; text-decoration: none; color: #fff; background: #ff7a1a; border-radius: 9px; padding: 9px 0; }
|
||||
.se-dl + .se-dl { background: rgba(128,128,128,0.18); color: inherit; }
|
||||
|
||||
.se-side { background: #fff; border: 1px solid rgba(128,128,128,0.18); border-radius: 12px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
|
||||
html.dark .se-side { background: rgba(255,255,255,0.04); }
|
||||
.se-side-h { font-size: 15px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
|
||||
.se-refresh { font-size: 12px; font-weight: 400; color: #ff7a1a; text-decoration: none; border: 1px solid rgba(255,122,26,0.5); border-radius: 999px; padding: 3px 12px; }
|
||||
.se-side-empty { font-size: 12.5px; opacity: 0.5; line-height: 1.7; padding: 18px 6px; }
|
||||
|
||||
.se-task { border: 1px solid rgba(128,128,128,0.16); border-radius: 10px; padding: 11px; margin-bottom: 11px; }
|
||||
.se-task-time { font-size: 11px; opacity: 0.5; display: flex; align-items: center; gap: 6px; }
|
||||
.se-task-n { background: rgba(255,122,26,0.12); color: #ff7a1a; border-radius: 999px; padding: 1px 7px; font-size: 10.5px; }
|
||||
.se-task-p { font-size: 12.5px; margin: 6px 0 8px; line-height: 1.5; }
|
||||
.se-task-imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
|
||||
.se-task-col { text-align: center; }
|
||||
.se-task-img { max-width: 100%; border-radius: 7px; border: 1px solid rgba(128,128,128,0.18); }
|
||||
.se-task-lb { font-size: 11px; opacity: 0.55; margin-top: 4px; }
|
||||
.se-task-lb-new { color: #ff7a1a; opacity: 1; font-weight: 700; }
|
||||
</style>
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Edit } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'AI 无痕改字',
|
||||
path: '/ai-text-edit',
|
||||
description: '上传图片说出改什么,AI 自动匹配原字体/字号/颜色/角度无缝替换,支持删除文字',
|
||||
keywords: ['ai', '无痕改字', '改字', '换字', '修改图片文字', '文字替换', '图片文字', '去文字', 'seamless', 'text', 'edit'],
|
||||
component: () => import('./ai-text-edit.vue'),
|
||||
icon: Edit,
|
||||
});
|
||||
@@ -0,0 +1,468 @@
|
||||
<script setup lang="ts">
|
||||
// Base64图片互转:Base64→图片 + 图片→Base64,一页双功能,纯浏览器本地(不上传)
|
||||
type TabKey = 'b2i' | 'i2b';
|
||||
|
||||
const tab = ref<TabKey>('b2i');
|
||||
|
||||
// ---------- Tab A:Base64 → 图片 ----------
|
||||
const b64Input = ref('');
|
||||
const imgType = ref('auto');
|
||||
const TYPES = [
|
||||
{ v: 'auto', t: '自动识别' },
|
||||
{ v: 'image/png', t: 'png' },
|
||||
{ v: 'image/jpeg', t: 'jpeg' },
|
||||
{ v: 'image/webp', t: 'webp' },
|
||||
{ v: 'image/gif', t: 'gif' },
|
||||
{ v: 'image/bmp', t: 'bmp' },
|
||||
{ v: 'image/svg+xml', t: 'svg' },
|
||||
{ v: 'image/x-icon', t: 'ico' },
|
||||
];
|
||||
const b2iErr = ref('');
|
||||
const b2iInfo = ref('');
|
||||
const b2iUrl = ref(''); // objectURL
|
||||
const b2iMime = ref('');
|
||||
const b2iExt = ref('png');
|
||||
|
||||
const EXT: Record<string, string> = {
|
||||
'image/png': 'png', 'image/jpeg': 'jpg', 'image/webp': 'webp', 'image/gif': 'gif',
|
||||
'image/bmp': 'bmp', 'image/svg+xml': 'svg', 'image/x-icon': 'ico', 'image/avif': 'avif',
|
||||
};
|
||||
|
||||
/** 三种输入形态都吃:裸 base64 / data:mediatype;base64,xxx / url("data:...") */
|
||||
function parseB64(raw: string): { mediatype: string; data: string } {
|
||||
let s = raw.trim();
|
||||
if (!s) throw new Error('请输入 Base64 内容');
|
||||
// url("data:...") 或 url(data:...)
|
||||
const urlM = s.match(/^url\(\s*(['"]?)([\s\S]*?)\1\s*\)$/i);
|
||||
if (urlM) s = urlM[2].trim();
|
||||
// data:mediatype;base64,xxx
|
||||
const dataM = s.match(/^data:([^;,]+)?(?:;[^;,]*)*;base64,([\s\S]*)$/i);
|
||||
if (dataM) return { mediatype: (dataM[1] || '').toLowerCase().split(';')[0], data: dataM[2].replace(/\s+/g, '') };
|
||||
// 裸 base64(去空白)
|
||||
return { mediatype: '', data: s.replace(/\s+/g, '') };
|
||||
}
|
||||
|
||||
/** 魔数嗅探真实类型 */
|
||||
function sniffMime(bytes: Uint8Array): string {
|
||||
if (bytes.length >= 8 && bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47) return 'image/png';
|
||||
if (bytes.length >= 3 && bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff) return 'image/jpeg';
|
||||
if (bytes.length >= 6 && bytes[0] === 0x47 && bytes[1] === 0x49 && bytes[2] === 0x46) return 'image/gif';
|
||||
if (bytes.length >= 12 && bytes[0] === 0x52 && bytes[1] === 0x49 && bytes[2] === 0x46 && bytes[3] === 0x46 && bytes[8] === 0x57 && bytes[9] === 0x45 && bytes[10] === 0x42 && bytes[11] === 0x50) return 'image/webp';
|
||||
if (bytes.length >= 2 && bytes[0] === 0x42 && bytes[1] === 0x4d) return 'image/bmp';
|
||||
if (bytes.length >= 4 && bytes[0] === 0x00 && bytes[1] === 0x00 && bytes[2] === 0x01 && bytes[3] === 0x00) return 'image/x-icon';
|
||||
return '';
|
||||
}
|
||||
|
||||
function b64ToBytes(data: string): Uint8Array {
|
||||
const clean = data.replace(/-/g, '+').replace(/_/g, '/');
|
||||
const pad = clean.length % 4 === 0 ? '' : '='.repeat(4 - (clean.length % 4));
|
||||
const bin = atob(clean + pad); // 非法字符会抛错
|
||||
const out = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
|
||||
return out;
|
||||
}
|
||||
|
||||
function convertB2I() {
|
||||
b2iErr.value = '';
|
||||
b2iInfo.value = '';
|
||||
try {
|
||||
const { mediatype, data } = parseB64(b64Input.value);
|
||||
const bytes = b64ToBytes(data);
|
||||
if (!bytes.length) throw new Error('Base64 内容为空');
|
||||
const sniffed = sniffMime(bytes);
|
||||
let mime = mediatype || sniffed || (imgType.value !== 'auto' ? imgType.value : '');
|
||||
if (!mime) throw new Error('无法识别图片类型:请在「图片类型」中手动选择');
|
||||
if (imgType.value !== 'auto' && !mediatype) mime = imgType.value; // 手动选择优先(对应参考图提示)
|
||||
// SVG 特判:无魔数,按文本嗅探
|
||||
if (mime === 'image/svg+xml' && !sniffed) {
|
||||
const head = new TextDecoder().decode(bytes.slice(0, 400));
|
||||
if (!/\<svg|\<\?xml/i.test(head)) throw new Error('内容不是有效的 SVG');
|
||||
}
|
||||
const blob = new Blob([bytes], { type: mime });
|
||||
const url = URL.createObjectURL(blob);
|
||||
// 用 Image 验证可解码,失败给友好错误
|
||||
const probe = new Image();
|
||||
probe.onload = () => {
|
||||
if (b2iUrl.value) URL.revokeObjectURL(b2iUrl.value);
|
||||
b2iUrl.value = url;
|
||||
b2iMime.value = mime;
|
||||
b2iExt.value = EXT[mime] || 'bin';
|
||||
b2iInfo.value = `类型 ${mime} · 尺寸 ${probe.naturalWidth}×${probe.naturalHeight} · 大小 ${(blob.size / 1024).toFixed(1)} KB`;
|
||||
};
|
||||
probe.onerror = () => {
|
||||
URL.revokeObjectURL(url);
|
||||
b2iUrl.value = '';
|
||||
b2iErr.value = `解码出的 ${mime} 数据无法渲染为有效图片,请检查 Base64 是否完整或图片类型选择是否正确`;
|
||||
};
|
||||
probe.src = url;
|
||||
}
|
||||
catch (e: any) {
|
||||
b2iErr.value = String(e?.message || e);
|
||||
b2iUrl.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
function downloadB2I() {
|
||||
if (!b2iUrl.value) return;
|
||||
const a = document.createElement('a');
|
||||
a.href = b2iUrl.value;
|
||||
a.download = `converted-image.${b2iExt.value}`;
|
||||
a.click();
|
||||
}
|
||||
|
||||
function clearB2I() {
|
||||
b64Input.value = '';
|
||||
b2iErr.value = '';
|
||||
b2iInfo.value = '';
|
||||
if (b2iUrl.value) URL.revokeObjectURL(b2iUrl.value);
|
||||
b2iUrl.value = '';
|
||||
}
|
||||
|
||||
// ---------- Tab B:图片 → Base64 ----------
|
||||
const file = ref<File | null>(null);
|
||||
const fileUrl = ref('');
|
||||
const i2bErr = ref('');
|
||||
const i2bInfo = ref('');
|
||||
const outFormat = ref<'raw' | 'data' | 'css'>('data');
|
||||
const b64Out = ref('');
|
||||
const copied = ref(false);
|
||||
const lastRaw = ref(''); // 本图的裸 base64,供格式切换重排
|
||||
const lastMime = ref('');
|
||||
|
||||
const FORMATS = [
|
||||
{ v: 'raw', t: '纯 base64' },
|
||||
{ v: 'data', t: 'data: URI' },
|
||||
{ v: 'css', t: 'CSS url()' },
|
||||
];
|
||||
|
||||
function setFile(f: File) {
|
||||
if (!f.type.startsWith('image/')) {
|
||||
i2bErr.value = '仅支持图片文件';
|
||||
return;
|
||||
}
|
||||
clearI2B(false);
|
||||
file.value = f;
|
||||
if (fileUrl.value) URL.revokeObjectURL(fileUrl.value);
|
||||
fileUrl.value = URL.createObjectURL(f);
|
||||
i2bErr.value = '';
|
||||
}
|
||||
|
||||
function onPick(e: Event) {
|
||||
const f = (e.target as HTMLInputElement).files?.[0];
|
||||
if (f) setFile(f);
|
||||
}
|
||||
|
||||
function onDrop(e: DragEvent) {
|
||||
const f = e.dataTransfer?.files?.[0];
|
||||
if (f) setFile(f);
|
||||
}
|
||||
|
||||
function convertI2B() {
|
||||
i2bErr.value = '';
|
||||
b64Out.value = '';
|
||||
if (!file.value) {
|
||||
i2bErr.value = '请先选择图片';
|
||||
return;
|
||||
}
|
||||
const fr = new FileReader();
|
||||
fr.onload = () => {
|
||||
const dataUrl = String(fr.result || '');
|
||||
const m = dataUrl.match(/^data:([^;,]+)?(?:;[^;,]*)*;base64,([\s\S]*)$/);
|
||||
if (!m) {
|
||||
i2bErr.value = '读取图片失败';
|
||||
return;
|
||||
}
|
||||
const mime = m[1] || file.value!.type || 'image/png';
|
||||
i2bInfo.value = `原始:${file.value!.name} · ${mime} · ${(file.value!.size / 1024).toFixed(1)} KB`;
|
||||
lastRaw.value = m[2];
|
||||
lastMime.value = mime;
|
||||
emitOut(mime, m[2]);
|
||||
};
|
||||
fr.onerror = () => {
|
||||
i2bErr.value = '读取图片失败(文件可能被占用)';
|
||||
};
|
||||
fr.readAsDataURL(file.value);
|
||||
}
|
||||
|
||||
function emitOut(mime: string, raw: string) {
|
||||
if (outFormat.value === 'raw') b64Out.value = raw;
|
||||
else if (outFormat.value === 'data') b64Out.value = `data:${mime};base64,${raw}`;
|
||||
else b64Out.value = `url("data:${mime};base64,${raw}")`;
|
||||
}
|
||||
|
||||
/** 切换输出格式时按记录的 mime+裸串重排(不重读文件) */
|
||||
function onFormatChange() {
|
||||
if (!lastRaw.value) return;
|
||||
emitOut(lastMime.value || file.value?.type || 'image/png', lastRaw.value);
|
||||
}
|
||||
|
||||
async function copyOut() {
|
||||
if (!b64Out.value) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(b64Out.value);
|
||||
copied.value = true;
|
||||
setTimeout(() => {
|
||||
copied.value = false;
|
||||
}, 1500);
|
||||
}
|
||||
catch {
|
||||
i2bErr.value = '复制失败,请手动全选复制';
|
||||
}
|
||||
}
|
||||
|
||||
function clearI2B(resetFile = true) {
|
||||
if (resetFile) {
|
||||
file.value = null;
|
||||
lastRaw.value = '';
|
||||
lastMime.value = '';
|
||||
if (fileUrl.value) URL.revokeObjectURL(fileUrl.value);
|
||||
fileUrl.value = '';
|
||||
i2bInfo.value = '';
|
||||
b64Out.value = '';
|
||||
}
|
||||
i2bErr.value = '';
|
||||
}
|
||||
|
||||
function onGoToB2I() {
|
||||
// 参考图的「Base64转图片」按钮:带当前输出切到另一半页
|
||||
if (b64Out.value) {
|
||||
b64Input.value = b64Out.value;
|
||||
tab.value = 'b2i';
|
||||
nextTick(convertB2I);
|
||||
}
|
||||
else {
|
||||
tab.value = 'b2i';
|
||||
}
|
||||
}
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (b2iUrl.value) URL.revokeObjectURL(b2iUrl.value);
|
||||
if (fileUrl.value) URL.revokeObjectURL(fileUrl.value);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="b64c-root">
|
||||
<div class="b64c-note">
|
||||
说明:使用浏览器 API 实现,您的文件不会被上传到云端,完全本地处理。
|
||||
</div>
|
||||
|
||||
<!-- 双功能切换 -->
|
||||
<div class="b64c-tabs">
|
||||
<button class="b64c-tab" :class="{ on: tab === 'b2i' }" @click="tab = 'b2i'">Base64 转图片</button>
|
||||
<button class="b64c-tab" :class="{ on: tab === 'i2b' }" @click="tab = 'i2b'">图片 转 Base64</button>
|
||||
</div>
|
||||
|
||||
<!-- ============ Tab A:Base64 → 图片 ============ -->
|
||||
<div v-show="tab === 'b2i'" class="b64c-panel">
|
||||
<div class="b64c-label">输入内容</div>
|
||||
<textarea
|
||||
v-model="b64Input"
|
||||
class="b64c-textarea"
|
||||
rows="7"
|
||||
spellcheck="false"
|
||||
placeholder="base64-string 或者 data:mediatype;base64,base64-string 或者 url("data:mediatype;base64,base64-string")"
|
||||
/>
|
||||
|
||||
<div class="b64c-row">
|
||||
<span class="b64c-label b64c-label-inline">图片类型</span>
|
||||
<select v-model="imgType" class="b64c-select">
|
||||
<option v-for="t in TYPES" :key="t.v" :value="t.v">{{ t.t }}</option>
|
||||
</select>
|
||||
<span class="b64c-hint">如果输入内容中不包含 mediatype,则按此处选择的类型处理(自动识别优先读文件魔数)</span>
|
||||
</div>
|
||||
|
||||
<div class="b64c-btns">
|
||||
<button class="b64c-btn b64c-btn-pri" @click="convertB2I">转换</button>
|
||||
<button class="b64c-btn" :disabled="!b2iUrl" @click="downloadB2I">下载</button>
|
||||
<button class="b64c-btn" @click="clearB2I">清空</button>
|
||||
</div>
|
||||
|
||||
<div v-if="b2iErr" class="b64c-err">{{ b2iErr }}</div>
|
||||
<div v-else-if="b2iInfo" class="b64c-info">{{ b2iInfo }}</div>
|
||||
|
||||
<div v-if="b2iUrl" class="b64c-preview">
|
||||
<img :src="b2iUrl" alt="preview">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ============ Tab B:图片 → Base64 ============ -->
|
||||
<div v-show="tab === 'i2b'" class="b64c-panel">
|
||||
<div
|
||||
class="b64c-drop"
|
||||
@click="!file && ($refs.pickInput as HTMLInputElement).click()"
|
||||
@dragover.prevent
|
||||
@drop.prevent="onDrop"
|
||||
>
|
||||
<template v-if="fileUrl">
|
||||
<img :src="fileUrl" class="b64c-drop-img" alt="">
|
||||
<div class="b64c-drop-bar">
|
||||
<span class="b64c-drop-name">{{ file?.name }}</span>
|
||||
<a href="javascript:;" class="b64c-drop-x" @click.stop="clearI2B()">✕ 重新选择</a>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="b64c-drop-icon">☁️⬆️</div>
|
||||
<div class="b64c-drop-t">点击选择,或将文件拖拽到此处</div>
|
||||
<div class="b64c-drop-s">支持 png / jpeg / webp / gif / bmp / svg / ico</div>
|
||||
</template>
|
||||
<input ref="pickInput" type="file" accept="image/*" style="display: none" @change="onPick">
|
||||
</div>
|
||||
|
||||
<div class="b64c-row">
|
||||
<span class="b64c-label b64c-label-inline">输出格式</span>
|
||||
<div class="b64c-segs">
|
||||
<button
|
||||
v-for="f in FORMATS"
|
||||
:key="f.v"
|
||||
class="b64c-seg"
|
||||
:class="{ on: outFormat === f.v }"
|
||||
@click="outFormat = f.v; onFormatChange()"
|
||||
>{{ f.t }}</button>
|
||||
</div>
|
||||
<span class="b64c-hint">三种格式都可直接粘回「Base64 转图片」侧</span>
|
||||
</div>
|
||||
|
||||
<div class="b64c-btns">
|
||||
<button class="b64c-btn b64c-btn-pri" @click="convertI2B()">图片转 Base64</button>
|
||||
<button class="b64c-btn b64c-btn-pri2" @click="onGoToB2I">Base64 转图片</button>
|
||||
<button class="b64c-btn" :disabled="!b64Out" @click="copyOut">{{ copied ? '✓ 已复制' : '复制结果' }}</button>
|
||||
<button class="b64c-btn" @click="clearI2B()">清空</button>
|
||||
</div>
|
||||
|
||||
<div v-if="i2bErr" class="b64c-err">{{ i2bErr }}</div>
|
||||
<div v-else-if="i2bInfo" class="b64c-info">{{ i2bInfo }}</div>
|
||||
|
||||
<div class="b64c-out">
|
||||
<div class="b64c-out-h">Base64内容</div>
|
||||
<textarea v-model="b64Out" class="b64c-textarea b64c-out-ta" rows="8" readonly spellcheck="false" placeholder="转换后的内容会显示在这里" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.b64c-root { max-width: 860px; }
|
||||
|
||||
.b64c-note {
|
||||
background: rgba(13, 148, 136, 0.08);
|
||||
border-left: 4px solid #0d9488;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
padding: 10px 14px;
|
||||
margin-bottom: 16px;
|
||||
opacity: 0.95;
|
||||
}
|
||||
|
||||
.b64c-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
|
||||
.b64c-tab {
|
||||
border: 1.5px solid rgba(128, 128, 128, 0.35);
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
padding: 9px 22px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: all 0.12s;
|
||||
}
|
||||
.b64c-tab.on { border-color: #0d9488; background: #0d9488; color: #fff; }
|
||||
|
||||
.b64c-panel { display: flex; flex-direction: column; gap: 12px; }
|
||||
|
||||
.b64c-label { font-size: 13.5px; font-weight: 700; opacity: 0.85; }
|
||||
.b64c-label-inline { flex-shrink: 0; margin-right: 2px; }
|
||||
|
||||
.b64c-textarea {
|
||||
width: 100%;
|
||||
border: 1px solid rgba(128, 128, 128, 0.4);
|
||||
border-radius: 8px;
|
||||
padding: 11px 13px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
font-size: 12.5px;
|
||||
line-height: 1.6;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
resize: vertical;
|
||||
word-break: break-all;
|
||||
}
|
||||
.b64c-textarea:focus { outline: none; border-color: #0d9488; }
|
||||
.b64c-textarea::placeholder { opacity: 0.42; }
|
||||
.b64c-out-ta { background: rgba(128, 128, 128, 0.04); }
|
||||
|
||||
.b64c-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
|
||||
.b64c-select {
|
||||
border: 1px solid rgba(128, 128, 128, 0.4);
|
||||
border-radius: 7px;
|
||||
padding: 6px 10px;
|
||||
font-size: 13px;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
.b64c-hint { font-size: 12px; opacity: 0.5; }
|
||||
|
||||
.b64c-segs { display: flex; gap: 6px; }
|
||||
.b64c-seg {
|
||||
border: 1.5px solid rgba(128, 128, 128, 0.35);
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
font-size: 12.5px;
|
||||
padding: 5px 13px;
|
||||
border-radius: 999px;
|
||||
cursor: pointer;
|
||||
transition: all 0.12s;
|
||||
}
|
||||
.b64c-seg.on { border-color: #0d9488; color: #0d9488; background: rgba(13, 148, 136, 0.1); font-weight: 700; }
|
||||
|
||||
.b64c-btns { display: flex; gap: 9px; flex-wrap: wrap; }
|
||||
.b64c-btn {
|
||||
border: 1px solid rgba(128, 128, 128, 0.4);
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
font-size: 13.5px;
|
||||
font-weight: 600;
|
||||
padding: 9px 20px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: all 0.12s;
|
||||
}
|
||||
.b64c-btn:hover:not(:disabled) { border-color: #0d9488; color: #0d9488; }
|
||||
.b64c-btn:disabled { opacity: 0.4; cursor: not-allowed; }
|
||||
.b64c-btn-pri { background: #0d9488; border-color: #0d9488; color: #fff; }
|
||||
.b64c-btn-pri:hover:not(:disabled) { filter: brightness(1.08); color: #fff; }
|
||||
.b64c-btn-pri2 { background: transparent; border-color: #0d9488; color: #0d9488; }
|
||||
|
||||
.b64c-err { background: rgba(229, 57, 53, 0.08); border: 1px solid rgba(229, 57, 53, 0.35); color: #e53935; border-radius: 8px; font-size: 12.5px; padding: 9px 12px; word-break: break-all; }
|
||||
.b64c-info { background: rgba(13, 148, 136, 0.07); border: 1px solid rgba(13, 148, 136, 0.28); border-radius: 8px; font-size: 12.5px; padding: 9px 12px; }
|
||||
|
||||
.b64c-preview { border: 1px dashed rgba(128, 128, 128, 0.45); border-radius: 8px; padding: 14px; display: flex; justify-content: center; align-items: center; min-height: 120px; background: rgba(128, 128, 128, 0.03); }
|
||||
.b64c-preview img { max-width: 100%; max-height: 340px; border-radius: 6px; }
|
||||
|
||||
.b64c-drop {
|
||||
border: 2px dashed rgba(13, 148, 136, 0.5);
|
||||
border-radius: 10px;
|
||||
min-height: 150px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s;
|
||||
overflow: hidden;
|
||||
padding: 8px;
|
||||
}
|
||||
.b64c-drop:hover { border-color: #0d9488; background: rgba(13, 148, 136, 0.03); }
|
||||
.b64c-drop-icon { font-size: 30px; }
|
||||
.b64c-drop-t { margin-top: 8px; font-size: 14px; font-weight: 600; color: #0d9488; }
|
||||
.b64c-drop-s { margin-top: 5px; font-size: 11.5px; opacity: 0.5; }
|
||||
.b64c-drop-img { max-width: 100%; max-height: 230px; border-radius: 7px; display: block; margin: 0 auto; }
|
||||
.b64c-drop-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 7px; font-size: 12px; width: 100%; }
|
||||
.b64c-drop-name { opacity: 0.7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.b64c-drop-x { color: #e53935; text-decoration: none; flex-shrink: 0; margin-left: 8px; }
|
||||
|
||||
.b64c-out { border: 1px solid rgba(128, 128, 128, 0.35); border-radius: 8px; overflow: hidden; }
|
||||
.b64c-out-h { background: rgba(128, 128, 128, 0.1); font-size: 12.5px; font-weight: 700; padding: 7px 13px; opacity: 0.8; }
|
||||
.b64c-out-ta { border: none; border-radius: 0; }
|
||||
.b64c-out-ta:focus { border: none; }
|
||||
</style>
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Exchange } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
import { translate } from '@/plugins/i18n.plugin';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: translate('tools.base64-image-converter.title'),
|
||||
path: '/base64-image-converter',
|
||||
description: translate('tools.base64-image-converter.description'),
|
||||
keywords: ['base64', 'image', '图片', '互转', '转图片', '图片转base64', 'base64转图片', 'data uri', '编码', '解码', 'img'],
|
||||
component: () => import('./base64-image-converter.vue'),
|
||||
icon: Exchange,
|
||||
});
|
||||
@@ -140,6 +140,193 @@ function reRecognize() {
|
||||
|
||||
const allText = computed(() => results.value.map(r => r.text).join('\n'));
|
||||
|
||||
// ================= 生成二维码 =================
|
||||
import QRCode from 'qrcode';
|
||||
|
||||
const mode = ref<'read' | 'gen'>('read');
|
||||
const genText = ref('https://it.88531.cn');
|
||||
const genSize = ref(512);
|
||||
const genDark = ref('#000000');
|
||||
const genLight = ref('#ffffff');
|
||||
const genLogo = ref(''); // 本地图片 dataURL
|
||||
const genLogoName = ref('');
|
||||
const genLogoRatio = ref(0.22); // 中心图片占 QR 比例
|
||||
const genPng = ref(''); // 生成结果 dataURL
|
||||
const genScanning = ref(false);
|
||||
const genScanMsg = ref('');
|
||||
const genScanOk = ref(false);
|
||||
const genError = ref('');
|
||||
const logoInput = ref<HTMLInputElement>();
|
||||
|
||||
const DARK_PRESETS = ['#000000', '#165DFF', '#00B42A', '#D03050', '#722ED1', '#FF7D00'];
|
||||
const LIGHT_PRESETS = ['#ffffff', '#F7F9FC', '#FFF7E8', '#E8F3FF', '#F0FFF4', '#FFF0F0'];
|
||||
|
||||
function pickLogo() {
|
||||
logoInput.value?.click();
|
||||
}
|
||||
|
||||
function onLogoChange(e: Event) {
|
||||
const input = e.target as HTMLInputElement;
|
||||
const f = input.files?.[0];
|
||||
input.value = '';
|
||||
if (!f) {
|
||||
return;
|
||||
}
|
||||
if (!f.type.startsWith('image/')) {
|
||||
genError.value = '中间图片请选择图片文件';
|
||||
return;
|
||||
}
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
genLogo.value = String(reader.result ?? '');
|
||||
genLogoName.value = f.name;
|
||||
genError.value = '';
|
||||
renderGen();
|
||||
};
|
||||
reader.readAsDataURL(f);
|
||||
}
|
||||
|
||||
function removeLogo() {
|
||||
genLogo.value = '';
|
||||
genLogoName.value = '';
|
||||
renderGen();
|
||||
}
|
||||
|
||||
let genTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
function renderGenDebounced() {
|
||||
clearTimeout(genTimer);
|
||||
genTimer = setTimeout(renderGen, 250);
|
||||
}
|
||||
|
||||
async function renderGen() {
|
||||
genError.value = '';
|
||||
genScanMsg.value = '';
|
||||
const text = genText.value.trim();
|
||||
if (!text) {
|
||||
genPng.value = '';
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// 有中心图片时必须 H 级纠错(容 ~30% 损毁)
|
||||
const dataUrl = await QRCode.toDataURL(text, {
|
||||
width: genSize.value,
|
||||
margin: 2,
|
||||
errorCorrectionLevel: genLogo.value ? 'H' : 'M',
|
||||
color: { dark: genDark.value, light: genLight.value },
|
||||
});
|
||||
if (!genLogo.value) {
|
||||
genPng.value = dataUrl;
|
||||
autoScan();
|
||||
return;
|
||||
}
|
||||
// 中心贴本地图片(白色圆角垫底,保证可扫)
|
||||
const qrImg = await loadImage(dataUrl);
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = genSize.value;
|
||||
canvas.height = genSize.value;
|
||||
const ctx = canvas.getContext('2d')!;
|
||||
ctx.drawImage(qrImg, 0, 0, canvas.width, canvas.height);
|
||||
const logo = await loadImage(genLogo.value);
|
||||
const side = Math.round(canvas.width * genLogoRatio.value);
|
||||
// 白垫比 logo 大 12%,留静区
|
||||
const pad = Math.round(side * 1.12);
|
||||
const cx = canvas.width / 2;
|
||||
const cy = canvas.height / 2;
|
||||
ctx.fillStyle = genLight.value;
|
||||
roundRect(ctx, cx - pad / 2, cy - pad / 2, pad, pad, Math.round(pad * 0.18));
|
||||
ctx.fill();
|
||||
const k = Math.min(side / logo.width, side / logo.height);
|
||||
const lw = Math.round(logo.width * k);
|
||||
const lh = Math.round(logo.height * k);
|
||||
ctx.drawImage(logo, cx - lw / 2, cy - lh / 2, lw, lh);
|
||||
genPng.value = canvas.toDataURL('image/png');
|
||||
autoScan();
|
||||
}
|
||||
catch (e: any) {
|
||||
genPng.value = '';
|
||||
genError.value = `生成失败:${e?.message ?? e}(内容过长?二维码上限约 2000 字符)`;
|
||||
}
|
||||
}
|
||||
|
||||
function loadImage(src: string): Promise<HTMLImageElement> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const im = new Image();
|
||||
im.onload = () => resolve(im);
|
||||
im.onerror = () => reject(new Error('图片加载失败'));
|
||||
im.src = src;
|
||||
});
|
||||
}
|
||||
|
||||
function roundRect(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, r: number) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x + r, y);
|
||||
ctx.arcTo(x + w, y, x + w, y + h, r);
|
||||
ctx.arcTo(x + w, y + h, x, y + h, r);
|
||||
ctx.arcTo(x, y + h, x, y, r);
|
||||
ctx.arcTo(x, y, x + w, y, r);
|
||||
ctx.closePath();
|
||||
}
|
||||
|
||||
// 生成后自扫验证:复用本页 ZXing,证明颜色/中心图片没破坏可扫性
|
||||
async function autoScan() {
|
||||
if (!genPng.value) {
|
||||
return;
|
||||
}
|
||||
genScanning.value = true;
|
||||
genScanMsg.value = '';
|
||||
try {
|
||||
const blob = await (await fetch(genPng.value)).blob();
|
||||
const found = await readBarcodes(blob, { tryHarder: true, tryInvert: true, maxNumberOfSymbols: 0 });
|
||||
const hit = found.find(f => f.text === genText.value.trim());
|
||||
if (hit) {
|
||||
genScanOk.value = true;
|
||||
genScanMsg.value = `可正常扫出(${hit.format})· 与输入内容一致`;
|
||||
}
|
||||
else if (found.length) {
|
||||
genScanOk.value = false;
|
||||
genScanMsg.value = `扫出内容与输入不一致,请检查颜色对比度`;
|
||||
}
|
||||
else {
|
||||
genScanOk.value = false;
|
||||
genScanMsg.value = '扫不出来:请增大前景/背景对比度,或缩小中心图片比例';
|
||||
}
|
||||
genHist.add({ title: genText.value.trim().slice(0, 60), detail: `生成 ${genSize.value}px${genLogo.value ? ' + 中心图片' : ''}` });
|
||||
}
|
||||
catch (e: any) {
|
||||
genScanOk.value = false;
|
||||
genScanMsg.value = `自扫异常:${e?.message ?? e}`;
|
||||
}
|
||||
finally {
|
||||
genScanning.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function downloadGen() {
|
||||
if (!genPng.value) {
|
||||
return;
|
||||
}
|
||||
const a = document.createElement('a');
|
||||
a.href = genPng.value;
|
||||
a.download = 'qr-code.png';
|
||||
a.click();
|
||||
}
|
||||
|
||||
function clearGen() {
|
||||
genText.value = '';
|
||||
genLogo.value = '';
|
||||
genLogoName.value = '';
|
||||
genPng.value = '';
|
||||
genScanMsg.value = '';
|
||||
genError.value = '';
|
||||
}
|
||||
|
||||
function setMode(m: 'read' | 'gen') {
|
||||
mode.value = m;
|
||||
if (m === 'gen' && !genPng.value) {
|
||||
renderGen();
|
||||
}
|
||||
}
|
||||
|
||||
async function copyText(text: string) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
@@ -197,6 +384,7 @@ function fit() {
|
||||
let observer: ResizeObserver | undefined;
|
||||
onMounted(() => {
|
||||
fit();
|
||||
renderGen();
|
||||
window.addEventListener('resize', fit);
|
||||
window.addEventListener('paste', onPaste);
|
||||
observer = new ResizeObserver(() => fit());
|
||||
@@ -221,28 +409,53 @@ onUnmounted(() => {
|
||||
style="display:none"
|
||||
@change="onInputChange"
|
||||
>
|
||||
<input
|
||||
ref="logoInput"
|
||||
type="file"
|
||||
accept="image/*"
|
||||
style="display:none"
|
||||
@change="onLogoChange"
|
||||
>
|
||||
|
||||
<div class="toolbar">
|
||||
<div class="stats">
|
||||
<div class="cr-tabs">
|
||||
<button type="button" :class="{ on: mode === 'read' }" @click="setMode('read')">
|
||||
📷 识别
|
||||
</button>
|
||||
<button type="button" :class="{ on: mode === 'gen' }" @click="setMode('gen')">
|
||||
🧩 生成
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="mode === 'read'" class="stats">
|
||||
<template v-if="results.length">
|
||||
识别到 {{ results.length }} 个码 · {{ elapsed }}ms
|
||||
</template>
|
||||
</div>
|
||||
<c-button :disabled="!imageSrc || loading" @click="reRecognize">
|
||||
重新识别
|
||||
</c-button>
|
||||
<c-button :disabled="!results.length" @click="copyText(allText)">
|
||||
复制全部
|
||||
</c-button>
|
||||
<c-button :disabled="!results.length" @click="downloadTxt">
|
||||
下载TXT
|
||||
</c-button>
|
||||
<c-button @click="clearAll">
|
||||
清空
|
||||
</c-button>
|
||||
<template v-if="mode === 'read'">
|
||||
<c-button :disabled="!imageSrc || loading" @click="reRecognize">
|
||||
重新识别
|
||||
</c-button>
|
||||
<c-button :disabled="!results.length" @click="copyText(allText)">
|
||||
复制全部
|
||||
</c-button>
|
||||
<c-button :disabled="!results.length" @click="downloadTxt">
|
||||
下载TXT
|
||||
</c-button>
|
||||
<c-button @click="clearAll">
|
||||
清空
|
||||
</c-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<c-button :disabled="!genPng" @click="downloadGen">
|
||||
下载PNG
|
||||
</c-button>
|
||||
<c-button :disabled="!genText.trim() && !genLogo" @click="clearGen">
|
||||
清空
|
||||
</c-button>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div class="body">
|
||||
<div v-if="mode === 'read'" class="body">
|
||||
<!-- left: image -->
|
||||
<div class="pane">
|
||||
<div
|
||||
@@ -298,6 +511,103 @@ onUnmounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 生成面板 -->
|
||||
<div v-else-if="mode === 'gen'" class="body">
|
||||
<!-- left: form -->
|
||||
<div class="pane gen-form">
|
||||
<div class="f-sec">
|
||||
<div class="f-label">
|
||||
二维码内容
|
||||
</div>
|
||||
<textarea v-model="genText" class="gen-text" rows="4" spellcheck="false" placeholder="网址 / 文本 / 名片信息…" @input="renderGenDebounced" />
|
||||
<div class="f-count">
|
||||
{{ genText.length }} 字符
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="f-sec">
|
||||
<div class="f-label">
|
||||
尺寸
|
||||
</div>
|
||||
<div class="row">
|
||||
<select v-model.number="genSize" class="sel" @change="renderGen()">
|
||||
<option :value="256">
|
||||
256 px
|
||||
</option>
|
||||
<option :value="512">
|
||||
512 px
|
||||
</option>
|
||||
<option :value="1024">
|
||||
1024 px
|
||||
</option>
|
||||
<option :value="2048">
|
||||
2048 px(高清)
|
||||
</option>
|
||||
</select>
|
||||
<span class="tip">输出图片边长</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="f-sec">
|
||||
<div class="f-label">
|
||||
颜色
|
||||
</div>
|
||||
<div class="row color-row">
|
||||
<span>前景</span>
|
||||
<input v-model="genDark" type="color" class="color" @input="renderGenDebounced">
|
||||
<span class="hex">{{ genDark }}</span>
|
||||
<span>背景</span>
|
||||
<input v-model="genLight" type="color" class="color" @input="renderGenDebounced">
|
||||
<span class="hex">{{ genLight }}</span>
|
||||
</div>
|
||||
<div class="row presets-row">
|
||||
<span class="tip">前景快捷</span>
|
||||
<button v-for="c in DARK_PRESETS" :key="c" type="button" class="swatch" :style="{ background: c }" @click="genDark = c; renderGen()" />
|
||||
<span class="tip">背景快捷</span>
|
||||
<button v-for="c in LIGHT_PRESETS" :key="c" type="button" class="swatch" :style="{ background: c }" @click="genLight = c; renderGen()" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="f-sec">
|
||||
<div class="f-label">
|
||||
中心图片(本地图片,不上传云端)
|
||||
</div>
|
||||
<div class="row">
|
||||
<c-button @click="pickLogo">
|
||||
{{ genLogo ? '更换图片' : '选择图片' }}
|
||||
</c-button>
|
||||
<c-button v-if="genLogo" size="small" @click="removeLogo">
|
||||
移除
|
||||
</c-button>
|
||||
<span v-if="genLogoName" class="tip">{{ genLogoName }}</span>
|
||||
</div>
|
||||
<div v-if="genLogo" class="row">
|
||||
<span class="tip">大小</span>
|
||||
<input v-model.number="genLogoRatio" type="range" min="0.10" max="0.35" step="0.01" class="ratio" @input="renderGenDebounced">
|
||||
<span class="tip">{{ Math.round(genLogoRatio * 100) }}%(自动 H 级纠错)</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- right: preview -->
|
||||
<div class="pane">
|
||||
<div class="gen-preview">
|
||||
<img v-if="genPng" :src="genPng" class="qr-img" alt="二维码预览">
|
||||
<div v-else class="empty">
|
||||
输入内容后自动生成
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="genError" class="cr-error">
|
||||
{{ genError }}
|
||||
</div>
|
||||
<div class="scan-line">
|
||||
<n-spin v-if="genScanning" :size="14" />
|
||||
<span v-if="genScanMsg" class="scan-msg" :class="{ ok: genScanOk }">{{ genScanMsg }}</span>
|
||||
<span v-else-if="!genScanning && genPng" class="scan-msg">自扫验证中…</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<GenHistory tool="code-reader" position="bottom" label="识别记录" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -436,6 +746,173 @@ onUnmounted(() => {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.cr-tabs {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
|
||||
button {
|
||||
border: 1.5px solid rgba(128, 128, 128, 0.35);
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
font-size: 13.5px;
|
||||
font-weight: 600;
|
||||
padding: 6px 18px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
|
||||
&.on {
|
||||
border-color: #18a058;
|
||||
background: #18a058;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.gen-form {
|
||||
overflow-y: auto;
|
||||
gap: 14px;
|
||||
padding-right: 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.f-sec {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 7px;
|
||||
}
|
||||
|
||||
.f-label {
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.gen-text {
|
||||
width: 100%;
|
||||
border: 1px solid rgba(128, 128, 128, 0.4);
|
||||
border-radius: 8px;
|
||||
padding: 9px 11px;
|
||||
font-size: 13px;
|
||||
line-height: 1.55;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
resize: vertical;
|
||||
box-sizing: border-box;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: #18a058;
|
||||
}
|
||||
}
|
||||
|
||||
.f-count {
|
||||
font-size: 11px;
|
||||
opacity: 0.45;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 9px;
|
||||
flex-wrap: wrap;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
|
||||
.sel {
|
||||
border: 1px solid rgba(128, 128, 128, 0.4);
|
||||
border-radius: 7px;
|
||||
padding: 6px 9px;
|
||||
font-size: 12.5px;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.tip {
|
||||
opacity: 0.5;
|
||||
font-size: 11.5px;
|
||||
}
|
||||
|
||||
.color {
|
||||
width: 34px;
|
||||
height: 28px;
|
||||
border: 1px solid rgba(128, 128, 128, 0.35);
|
||||
border-radius: 6px;
|
||||
padding: 2px;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.hex {
|
||||
font-family: ui-monospace, Menlo, Consolas, monospace;
|
||||
font-size: 11.5px;
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
.swatch {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 2px solid rgba(128, 128, 128, 0.4);
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
|
||||
&:hover {
|
||||
border-color: #18a058;
|
||||
transform: scale(1.1);
|
||||
}
|
||||
}
|
||||
|
||||
.presets-row {
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.ratio {
|
||||
flex: 1;
|
||||
min-width: 100px;
|
||||
accent-color: #18a058;
|
||||
}
|
||||
|
||||
.gen-preview {
|
||||
flex: 1;
|
||||
min-height: 180px;
|
||||
border: 1px dashed rgba(128, 128, 128, 0.45);
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
|
||||
.qr-img {
|
||||
max-width: 100%;
|
||||
max-height: calc(100vh - 420px);
|
||||
min-height: 160px;
|
||||
object-fit: contain;
|
||||
}
|
||||
}
|
||||
|
||||
.scan-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-shrink: 0;
|
||||
min-height: 26px;
|
||||
font-size: 12.5px;
|
||||
margin-top: 8px;
|
||||
|
||||
.scan-msg {
|
||||
color: #d03050;
|
||||
}
|
||||
|
||||
.scan-msg.ok {
|
||||
color: #18a058;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.result-item {
|
||||
border: 1px solid rgba(128, 128, 128, 0.22);
|
||||
border-radius: 6px;
|
||||
|
||||
@@ -6,7 +6,7 @@ export const tool = defineTool({
|
||||
name: translate('tools.code-reader.title'),
|
||||
path: '/code-reader',
|
||||
description: translate('tools.code-reader.description'),
|
||||
keywords: ['scan', 'reader', 'decode', 'qr', 'barcode', 'zxing', 'camera', 'image', '识别', '扫码', '读取', '解码', '二维码', '条码'],
|
||||
keywords: ['scan', 'reader', 'decode', 'generate', 'qr', 'barcode', 'zxing', 'camera', 'image', '识别', '扫码', '读取', '解码', '二维码', '条码', '生成', '改色', 'logo'],
|
||||
component: () => import('./code-reader.vue'),
|
||||
icon: Scan,
|
||||
});
|
||||
File diff suppressed because it is too large.
Load diff
@@ -8,6 +8,8 @@ import { useStorage } from '@vueuse/core';
|
||||
import GenHistory from '@/tools/gen-history/GenHistory.vue';
|
||||
import { useGenHistory } from '@/tools/gen-history/gen-history';
|
||||
import { getMachineId, licenseHeaders } from '@/tools/license/license';
|
||||
import PsEditor from './PsEditor.vue';
|
||||
import { TEXT_TPLS, TPL_CATS, tplStyle, filterTpls, type TextTpl } from './text-tpls';
|
||||
|
||||
prepareZXingModule({ overrideWasmUrl: wasmUrl });
|
||||
const genHist = useGenHistory('image-tools');
|
||||
@@ -22,6 +24,7 @@ const TABS: TabDef[] = [
|
||||
{ key: 'rotate', label: '旋转', desc: '旋转或翻转图片' },
|
||||
{ key: 'filter', label: '滤镜', desc: '为图片应用滤镜效果(灰度/复古/模糊等)' },
|
||||
{ key: 'mosaic', label: '打码', desc: '在图片上拖拽框选区域,马赛克或涂黑打码' },
|
||||
{ key: 'edit', label: '图片编辑', desc: 'PS 风格图层编辑器:画笔/智能消除笔/文字/选区/油漆桶/吸管/裁剪,文字支持画布拖拽旋转+47套成套标题文案模板(通用/小红书/抖音/B站/公众号/视频号/封面图7类切换)点击即插(主副标题整组),消除实时预览,OCR 无痕改字(自动检出原字字号/颜色/粗细/角度,输入新字实时预览无缝替换)' },
|
||||
{ key: 'exif', label: 'EXIF 查看', desc: '查看拍摄设备、时间、参数等 EXIF 信息' },
|
||||
{ key: 'qrgen', label: '二维码生成', desc: '把文字/链接生成为二维码图片', noFile: true },
|
||||
{ key: 'qrread', label: '二维码识别', desc: '识别图片中的二维码/条码内容' },
|
||||
@@ -141,7 +144,9 @@ function loadMainImage() {
|
||||
const img = new Image();
|
||||
img.onload = () => {
|
||||
mainImg.value = img;
|
||||
nextTick(drawMosaicCanvas);
|
||||
nextTick(() => {
|
||||
drawMosaicCanvas();
|
||||
});
|
||||
};
|
||||
img.src = url;
|
||||
}
|
||||
@@ -272,6 +277,37 @@ function mosaicPos(e: MouseEvent) {
|
||||
return { x: e.clientX - r.left, y: e.clientY - r.top };
|
||||
}
|
||||
|
||||
// ---------- 图片编辑(PS 风格编辑器,组件内自带工具栏/图层/历史) ----------
|
||||
const psEditor = ref<{ exportDoc: () => Promise<{ blob: Blob; detail: string; w: number; h: number }> } | null>(null);
|
||||
// 上传前模板墙:先点模板记住,选图后由 PsEditor 自动套入
|
||||
const pendingTpl = ref<TextTpl | null>(null);
|
||||
// 模板分类:默认"全部",一次只看一个平台
|
||||
const tplCat = ref('全部');
|
||||
const wallTpls = computed(() => filterTpls(tplCat.value));
|
||||
|
||||
function chooseTpl(t: TextTpl) {
|
||||
pendingTpl.value = t;
|
||||
pickFiles(); // 选完图自动套用该模板
|
||||
}
|
||||
|
||||
function onPsError(msg: string) {
|
||||
errorMsg.value = msg;
|
||||
}
|
||||
|
||||
async function doEdit() {
|
||||
const ed = psEditor.value;
|
||||
if (!ed) {
|
||||
throw new Error('编辑器未就绪,请重新选择图片');
|
||||
}
|
||||
const { blob, detail, w, h } = await ed.exportDoc();
|
||||
setOutput(blob, `${baseName(files.value[0])}-edited.${extOf(blob.type)}`, {
|
||||
title: `编辑 ${files.value[0].name}`,
|
||||
detail,
|
||||
});
|
||||
resultDim.value = `${w}×${h}`;
|
||||
}
|
||||
|
||||
|
||||
function onMosaicDown(e: MouseEvent) {
|
||||
if (tab.value.key !== 'mosaic') {
|
||||
return;
|
||||
@@ -336,6 +372,9 @@ async function execute() {
|
||||
else if (k === 'mosaic') {
|
||||
await doMosaic();
|
||||
}
|
||||
else if (k === 'edit') {
|
||||
await doEdit();
|
||||
}
|
||||
else if (k === 'exif') {
|
||||
await doExif();
|
||||
}
|
||||
@@ -856,7 +895,9 @@ function fit() {
|
||||
rootStyle.value = { height: `${height}px`, flex: '1 1 100%' };
|
||||
}
|
||||
|
||||
watch(tabKey, () => nextTick(drawMosaicCanvas));
|
||||
watch(tabKey, () => nextTick(() => {
|
||||
drawMosaicCanvas();
|
||||
}));
|
||||
|
||||
onMounted(() => {
|
||||
fit();
|
||||
@@ -905,7 +946,7 @@ onUnmounted(() => {
|
||||
<div
|
||||
v-if="!tab.noFile"
|
||||
class="it-upload"
|
||||
:class="{ active: dragActive, has: files.length }"
|
||||
:class="{ active: dragActive, has: files.length, wall: !files.length && tab.key === 'edit' }"
|
||||
@click="!files.length && pickFiles()"
|
||||
@dragover.prevent="dragActive = true"
|
||||
@dragleave.prevent="dragActive = false"
|
||||
@@ -923,6 +964,9 @@ onUnmounted(() => {
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="files.length && tab.key === 'edit'">
|
||||
<PsEditor ref="psEditor" :file="files[0]" :auto-tpl="pendingTpl" @error="onPsError" @applied="pendingTpl = null" />
|
||||
</template>
|
||||
<template v-else-if="files.length">
|
||||
<div class="it-files">
|
||||
<div v-for="(f, i) in files" :key="i" class="it-file">
|
||||
@@ -933,6 +977,37 @@ onUnmounted(() => {
|
||||
<a v-if="tab.multi" href="javascript:;" class="it-add-more" @click.stop="pickFiles">+ 继续添加</a>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="tab.key === 'edit'">
|
||||
<div class="it-tpl-wall">
|
||||
<div class="it-tpl-wall-t">
|
||||
✨ 文字模板({{ TEXT_TPLS.length }} 套 · 7 类)
|
||||
<span class="it-tpl-wall-sub">点模板选图 → 整组标题自动套入画布</span>
|
||||
</div>
|
||||
<div class="it-tpl-cats">
|
||||
<button
|
||||
v-for="c in ['全部', ...TPL_CATS]"
|
||||
:key="c"
|
||||
class="it-tpl-cat"
|
||||
:class="{ on: tplCat === c }"
|
||||
@click.stop="tplCat = c"
|
||||
>{{ c }}</button>
|
||||
</div>
|
||||
<div class="it-tpl-wall-grid">
|
||||
<button
|
||||
v-for="t in wallTpls"
|
||||
:key="t.id"
|
||||
class="it-tpl-chip"
|
||||
:title="`[${t.cat}] ${t.name}:${t.parts.join(' / ')} — 点击后选图自动套用`"
|
||||
@click.stop="chooseTpl(t)"
|
||||
>
|
||||
<span class="it-tpl-chip-txt" :style="tplStyle(t)">{{ t.parts[0] }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="it-tpl-wall-foot" @click.stop="pickFiles">
|
||||
⬆️ 点这里选择图片({{ MAX_MB }} MB 内 · 本地处理不上传)
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="it-upload-icon">⬆️</div>
|
||||
<div class="it-upload-big">
|
||||
@@ -1001,6 +1076,9 @@ onUnmounted(() => {
|
||||
</button>
|
||||
<span class="it-hint">在左侧图片上按住拖拽框选打码区域</span>
|
||||
</template>
|
||||
<template v-else-if="tab.key === 'edit'">
|
||||
<span class="it-hint">编辑器内含:工具栏(移动/选框/画笔/橡皮/文字/油漆桶/吸管/裁剪/抓手)、图层面板、历史记录;Ctrl+Z 撤销、滚轮缩放、空格拖动。编辑完成后点下方「执行」导出成品。</span>
|
||||
</template>
|
||||
<template v-else-if="tab.key === 'qrgen'">
|
||||
<label>尺寸</label>
|
||||
<select v-model.number="qrSize" class="it-select">
|
||||
@@ -1285,6 +1363,13 @@ onUnmounted(() => {
|
||||
padding: 10px 14px;
|
||||
}
|
||||
|
||||
&.wall {
|
||||
justify-content: flex-start;
|
||||
padding: 12px 14px;
|
||||
overflow-y: auto;
|
||||
min-height: 322px;
|
||||
}
|
||||
|
||||
.it-upload-icon {
|
||||
font-size: 36px;
|
||||
}
|
||||
@@ -1301,6 +1386,117 @@ onUnmounted(() => {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.it-tpl-wall {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.it-tpl-wall-t {
|
||||
width: 100%;
|
||||
margin-bottom: 8px;
|
||||
font-size: 13.5px;
|
||||
font-weight: 600;
|
||||
text-align: left;
|
||||
opacity: 0.9;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 10px;
|
||||
|
||||
.it-tpl-wall-sub {
|
||||
font-size: 11.5px;
|
||||
font-weight: 400;
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
|
||||
.it-tpl-cats {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 5px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.it-tpl-cat {
|
||||
border: 1px solid rgba(128, 128, 128, 0.32);
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
border-radius: 999px;
|
||||
font-size: 11.5px;
|
||||
line-height: 1;
|
||||
padding: 5px 10px;
|
||||
cursor: pointer;
|
||||
opacity: 0.75;
|
||||
transition: all 0.12s;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
border-color: #2563eb;
|
||||
}
|
||||
|
||||
&.on {
|
||||
background: #2563eb;
|
||||
border-color: #2563eb;
|
||||
color: #fff;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.it-tpl-wall-grid {
|
||||
width: 100%;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.it-tpl-wall-foot {
|
||||
width: 100%;
|
||||
margin-top: 10px;
|
||||
padding-top: 8px;
|
||||
border-top: 1px dashed rgba(128, 128, 128, 0.3);
|
||||
font-size: 12.5px;
|
||||
text-align: center;
|
||||
opacity: 0.65;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.12s;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
color: #18a058;
|
||||
}
|
||||
}
|
||||
|
||||
.it-tpl-chip {
|
||||
height: 40px;
|
||||
border: 1px solid rgba(128, 128, 128, 0.32);
|
||||
border-radius: 8px;
|
||||
background: rgba(128, 128, 128, 0.07);
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 6px;
|
||||
transition: border-color 0.12s, transform 0.12s;
|
||||
|
||||
&:hover {
|
||||
border-color: #2563eb;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.it-tpl-chip-txt {
|
||||
font-size: 11.5px;
|
||||
line-height: 1.12;
|
||||
text-align: center;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
word-break: break-all;
|
||||
}
|
||||
}
|
||||
|
||||
.it-files {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
@@ -1363,6 +1559,18 @@ onUnmounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 图片编辑(组件内样式见 PsEditor.vue) ----------
|
||||
|
||||
.it-colorswatch {
|
||||
width: 34px;
|
||||
height: 26px;
|
||||
padding: 1px 2px;
|
||||
border: 1px solid rgba(128, 128, 128, 0.35);
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.it-qrbox {
|
||||
flex: 1;
|
||||
min-height: 120px;
|
||||
|
||||
@@ -6,7 +6,7 @@ export const tool = defineTool({
|
||||
name: translate('tools.image-tools.title'),
|
||||
path: '/image-tools',
|
||||
description: translate('tools.image-tools.description'),
|
||||
keywords: ['image', 'compress', 'convert', 'resize', 'crop', 'rotate', 'filter', 'mosaic', 'exif', 'watermark', 'stitch', '图片', '压缩', '转换', '裁剪', '旋转', '滤镜', '打码', '水印', '拼接'],
|
||||
keywords: ['image', 'compress', 'convert', 'resize', 'crop', 'rotate', 'filter', 'mosaic', 'exif', 'watermark', 'stitch', 'edit', 'text', 'replace', 'photoshop', 'layer', 'brush', 'history', '图片', '压缩', '转换', '裁剪', '旋转', '滤镜', '打码', '水印', '拼接', '编辑', '改文字', '文字替换', '加文字', '画笔', '图层', '历史记录'],
|
||||
component: () => import('./image-tools.vue'),
|
||||
icon: Photo,
|
||||
});
|
||||
@@ -0,0 +1,110 @@
|
||||
// 文字花字模板(成套文案):画布内与上传前模板墙共用
|
||||
// cat 分类:通用(经典17套)+ 小红书 / 抖音 / B站 / 公众号 / 视频号 / 封面图
|
||||
export interface TextTpl {
|
||||
id: string; name: string; color: string;
|
||||
cat: string; // 平台分类
|
||||
parts: string[]; // 主标题 → 副标题 → 小字,逐行成组插入
|
||||
grad?: [string, string]; bold?: boolean;
|
||||
stroke?: string; strokeW?: number; shadow?: string; badge?: string;
|
||||
}
|
||||
|
||||
/** 分类标签('全部' 由 UI 拼在最前) */
|
||||
export const TPL_CATS = ['通用', '小红书', '抖音', 'B站', '公众号', '视频号', '封面图'];
|
||||
|
||||
export const TEXT_TPLS: TextTpl[] = [
|
||||
// ---------- 通用(经典 17 套) ----------
|
||||
{ id: 'wp', cat: '通用', name: '白字黑描边·搞怪', color: '#ffffff', stroke: '#1a1a1a', strokeW: 0.10, bold: true, parts: ['最强拉轰!', '《躲汉子》'] },
|
||||
{ id: 'yp', cat: '通用', name: '黄字紫描边·热榜', color: '#ffe14d', stroke: '#7b2cbf', strokeW: 0.10, bold: true, parts: ['B站史上', '点击最高的10首MV'] },
|
||||
{ id: 'wpu', cat: '通用', name: '白字紫描边·科普', color: '#ffffff', stroke: '#8e44ad', strokeW: 0.09, bold: true, parts: ['熬夜', '如何科学修仙'] },
|
||||
{ id: 'yc', cat: '通用', name: '黄字青描边·美食', color: '#ffeb3b', stroke: '#00e5ff', strokeW: 0.11, bold: true, parts: ['辣到没朋友!川菜', '辣子鸡 · 水煮肉片'] },
|
||||
{ id: 'rb', cat: '通用', name: '红底白字·冠军', color: '#ffffff', badge: '#e53935', bold: true, parts: ['收视冠军?'] },
|
||||
{ id: 'bb', cat: '通用', name: '蓝底白字·力作', color: '#ffffff', badge: '#1e88e5', bold: true, parts: ['翻身力作?'] },
|
||||
{ id: 'kb', cat: '通用', name: '黑底黄字·高光', color: '#ffd600', badge: '#212121', bold: true, parts: ['秀翻全场!', 'ALL KILL!'] },
|
||||
{ id: 'gd', cat: '通用', name: '鎏金渐变·打卡', color: '#ffcc00', grad: ['#fff3b0', '#ff9500'], stroke: '#7a4a00', strokeW: 0.07, bold: true, parts: ['香浓拿铁', '网红打卡'] },
|
||||
{ id: 'fg', cat: '通用', name: '烈焰渐变·社会', color: '#ff4d4f', grad: ['#ff5252', '#ff8f00'], stroke: '#7a1f00', strokeW: 0.08, bold: true, parts: ['男子医院体验', '竟查出有孕在身'] },
|
||||
{ id: 'ws', cat: '通用', name: '白字投影·Vlog', color: '#ffffff', shadow: 'rgba(0,0,0,0.75)', bold: true, parts: ['Vlog', '我的旅行日记'] },
|
||||
{ id: 'cb', cat: '通用', name: '青字黑描边·热梗', color: '#18ffff', stroke: '#00364d', strokeW: 0.10, bold: true, parts: ['年轻人', '耗子尾汁'] },
|
||||
{ id: 'pb', cat: '通用', name: '粉底白字·生活', color: '#ffffff', badge: '#ec407a', bold: true, parts: ['我的', '上海日租生活'] },
|
||||
{ id: 'ol', cat: '通用', name: '空心描边·搞笑', color: 'rgba(255,255,255,0.06)', stroke: '#2962ff', strokeW: 0.10, bold: true, parts: ['你根本', '不会上厕所'] },
|
||||
{ id: 'gb', cat: '通用', name: '荧光绿描边·攻略', color: '#76ff03', stroke: '#1b3d00', strokeW: 0.09, bold: true, parts: ['角色养成攻略', '躺平吧 赶紧的'] },
|
||||
{ id: 'wp2', cat: '通用', name: '白字蓝边·职场', color: '#ffffff', stroke: '#0d47a1', strokeW: 0.10, bold: true, parts: ['合法打工人', 'SLAVE の一天 DAILY'] },
|
||||
{ id: 'gd2', cat: '通用', name: '金渐变·B站', color: '#ffe082', grad: ['#fffde7', '#ffb300'], stroke: '#5d4037', strokeW: 0.07, bold: true, parts: ['B站', '崛起的十二年'] },
|
||||
{ id: 'rb2', cat: '通用', name: '红底白字·毕业', color: '#ffffff', badge: '#c62828', bold: true, parts: ['毕业后找工作', '如此简单!'] },
|
||||
|
||||
// ---------- 小红书(品牌红 #FF2442,种草/探店/避雷风) ----------
|
||||
{ id: 'xhs1', cat: '小红书', name: '小红红底·种草', color: '#ffffff', badge: '#FF2442', bold: true, parts: ['今日份宝藏', '这款APP真的绝了'] },
|
||||
{ id: 'xhs2', cat: '小红书', name: '白字粉描边·探店', color: '#ffffff', stroke: '#FF6B8B', strokeW: 0.10, bold: true, parts: ['魔都探店', '藏在弄堂里的咖啡馆'] },
|
||||
{ id: 'xhs3', cat: '小红书', name: '粉底白字·好物', color: '#ffffff', badge: '#FF85A2', bold: true, parts: ['平价好物', '均价30的快乐'] },
|
||||
{ id: 'xhs4', cat: '小红书', name: '黄字红描边·避坑', color: '#FFE14D', stroke: '#FF2442', strokeW: 0.11, bold: true, parts: ['避雷!', '这5款千万别买'] },
|
||||
{ id: 'xhs5', cat: '小红书', name: '玫红底白字·vlog', color: '#ffffff', badge: '#FF3B5C', bold: true, parts: ['周末vlog', '把日子过成诗'] },
|
||||
|
||||
// ---------- 抖音(黑底+霓虹青 #25F4EE / 玫红 #FE2C55,爆款悬念风) ----------
|
||||
{ id: 'dy1', cat: '抖音', name: '抖音黑底青字·爆款', color: '#25F4EE', badge: '#161823', bold: true, parts: ['一招教你', '播放量翻10倍'] },
|
||||
{ id: 'dy2', cat: '抖音', name: '白字玫红描边·悬念', color: '#ffffff', stroke: '#FE2C55', strokeW: 0.11, bold: true, parts: ['千万别划走', '结局没想到…'] },
|
||||
{ id: 'dy3', cat: '抖音', name: '霓虹青黑描边·教程', color: '#25F4EE', stroke: '#000000', strokeW: 0.11, bold: true, parts: ['3秒学会', '手机拍大片'] },
|
||||
{ id: 'dy4', cat: '抖音', name: '玫红底白字·挑战', color: '#ffffff', badge: '#FE2C55', bold: true, parts: ['挑战全网', '最火BGM卡点'] },
|
||||
{ id: 'dy5', cat: '抖音', name: '青玫渐变·音乐', color: '#ffffff', grad: ['#25F4EE', '#FE2C55'], stroke: '#101014', strokeW: 0.08, bold: true, parts: ['循环100遍', '这歌也太上头'] },
|
||||
|
||||
// ---------- B站(B站蓝 #00AEEC / 粉 #FB7299,三连/硬核风) ----------
|
||||
{ id: 'bili1', cat: 'B站', name: 'B站蓝底白字·三连', color: '#ffffff', badge: '#00AEEC', bold: true, parts: ['一键三连!', '这期真的爆肝'] },
|
||||
{ id: 'bili2', cat: 'B站', name: '白字B站蓝描边·硬核', color: '#ffffff', stroke: '#00AEEC', strokeW: 0.10, bold: true, parts: ['硬核拆解', '全网最全攻略'] },
|
||||
{ id: 'bili3', cat: 'B站', name: 'B站粉底白字·番剧', color: '#ffffff', badge: '#FB7299', bold: true, parts: ['新番速报', '本季必追TOP5'] },
|
||||
{ id: 'bili4', cat: 'B站', name: '黄字B站蓝描边·高能', color: '#FFEB3B', stroke: '#00AEEC', strokeW: 0.11, bold: true, parts: ['前方高能', '第3次神转折'] },
|
||||
{ id: 'bili5', cat: 'B站', name: '白字投影·UP主', color: '#ffffff', shadow: 'rgba(0,60,90,0.85)', bold: true, parts: ['UP主精选', '百大UP合集'] },
|
||||
|
||||
// ---------- 公众号(深蓝/红金,深度长文风) ----------
|
||||
{ id: 'gzh1', cat: '公众号', name: '深蓝底白字·深度', color: '#ffffff', badge: '#1E3A5F', bold: true, parts: ['深度长文', '普通人逆袭的3条路'] },
|
||||
{ id: 'gzh2', cat: '公众号', name: '白字深蓝描边·干货', color: '#ffffff', stroke: '#2B6CB0', strokeW: 0.10, bold: true, parts: ['干货|', '一篇讲透提示词'] },
|
||||
{ id: 'gzh3', cat: '公众号', name: '红底白字·头条', color: '#ffffff', badge: '#C53030', bold: true, parts: ['头条', '这个行业要变天'] },
|
||||
{ id: 'gzh4', cat: '公众号', name: '黑字黄底·金句', color: '#1a1a1a', badge: '#F6E05E', bold: true, parts: ['句句戳心', '别再无效努力'] },
|
||||
{ id: 'gzh5', cat: '公众号', name: '白字深投影·观点', color: '#ffffff', shadow: 'rgba(20,40,80,0.9)', bold: true, parts: ['观点', '高手都在做减法'] },
|
||||
|
||||
// ---------- 视频号(微信绿 #07C160,直播/私域风) ----------
|
||||
{ id: 'sph1', cat: '视频号', name: '微信绿底白字·直播', color: '#ffffff', badge: '#07C160', bold: true, parts: ['直播预告', '今晚8点不见不散'] },
|
||||
{ id: 'sph2', cat: '视频号', name: '白字绿描边·热转', color: '#ffffff', stroke: '#07C160', strokeW: 0.10, bold: true, parts: ['热转|', '这条视频火了'] },
|
||||
{ id: 'sph3', cat: '视频号', name: '绿渐变·私域', color: '#ffffff', grad: ['#8CE99A', '#07C160'], stroke: '#04421f', strokeW: 0.08, bold: true, parts: ['私域干货', '3步做出爆款封面'] },
|
||||
{ id: 'sph4', cat: '视频号', name: '白底绿字·教程', color: '#07C160', badge: '#ffffff', bold: true, parts: ['手把手教', '视频号涨粉秘籍'] },
|
||||
{ id: 'sph5', cat: '视频号', name: '深底青字·带货', color: '#69F0AE', badge: '#0B1F17', bold: true, parts: ['爆单节奏', '这样挂车转化翻倍'] },
|
||||
|
||||
// ---------- 封面图(大标题冲击力,点击率优先) ----------
|
||||
{ id: 'cov1', cat: '封面图', name: '金渐变·封面主标', color: '#FFE58F', grad: ['#FFF7CC', '#FFB300'], stroke: '#7A4A00', strokeW: 0.08, bold: true, parts: ['封面主标题', '点击率翻倍的秘密'] },
|
||||
{ id: 'cov2', cat: '封面图', name: '撞色红块·数字', color: '#ffffff', badge: '#FF4D4F', bold: true, parts: ['10个神器', '第7个我真的吹爆'] },
|
||||
{ id: 'cov3', cat: '封面图', name: '白字粗黑边·大标题', color: '#ffffff', stroke: '#000000', strokeW: 0.13, bold: true, parts: ['超全合集', '2026必装软件'] },
|
||||
{ id: 'cov4', cat: '封面图', name: '蓝紫渐变·科技感', color: '#ffffff', grad: ['#4F46E5', '#9333EA'], stroke: '#1a1040', strokeW: 0.08, bold: true, parts: ['AI革命', '这5款工具先冲'] },
|
||||
{ id: 'cov5', cat: '封面图', name: '黑底白字·极简', color: '#ffffff', badge: '#111111', bold: true, parts: ['极简封面', '留白高级感'] },
|
||||
];
|
||||
|
||||
/** 按分类筛选(cat='' 表示全部) */
|
||||
export function filterTpls(cat: string): TextTpl[] {
|
||||
return !cat || cat === '全部' ? TEXT_TPLS : TEXT_TPLS.filter(t => t.cat === cat);
|
||||
}
|
||||
|
||||
// 模板 chip 的 CSS 预览样式
|
||||
export function tplStyle(t: TextTpl): Record<string, string> {
|
||||
const s: Record<string, string> = { fontWeight: '700' };
|
||||
if (t.badge) {
|
||||
s.background = t.badge;
|
||||
s.color = t.color;
|
||||
s.padding = '4px 7px';
|
||||
s.borderRadius = '5px';
|
||||
}
|
||||
else if (t.grad) {
|
||||
s.backgroundImage = `linear-gradient(90deg, ${t.grad[0]}, ${t.grad[1]})`;
|
||||
s.backgroundClip = 'text';
|
||||
s.WebkitBackgroundClip = 'text';
|
||||
s.color = 'transparent';
|
||||
if (t.stroke) {
|
||||
s.WebkitTextStroke = `1px ${t.stroke}`;
|
||||
}
|
||||
}
|
||||
else {
|
||||
s.color = t.color;
|
||||
if (t.stroke) {
|
||||
s.WebkitTextStroke = `${Math.max(1, Math.round((t.strokeW ?? 0.08) * 16))}px ${t.stroke}`;
|
||||
}
|
||||
}
|
||||
if (t.shadow) {
|
||||
s.textShadow = `2px 2px 3px ${t.shadow}`;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
+4
-2
@@ -87,6 +87,7 @@ import { tool as sealMaker } from './seal-maker';
|
||||
import { tool as signaturePad } from './signature-pad';
|
||||
import { tool as textToImage } from './text-to-image';
|
||||
import { tool as aiGen } from './ai-gen';
|
||||
import { tool as base64ImageConverter } from './base64-image-converter';
|
||||
import { tool as zhConvert } from './zh-convert';
|
||||
import { tool as pinyinConverter } from './pinyin-converter';
|
||||
import { tool as aiImageLab } from './ai-image-lab';
|
||||
@@ -107,6 +108,7 @@ import { tool as urlEncoder } from './url-encoder';
|
||||
import { tool as urlParser } from './url-parser';
|
||||
import { tool as uuidGenerator } from './uuid-generator';
|
||||
import { tool as macAddressLookup } from './mac-address-lookup';
|
||||
import { tool as myIp } from './my-ip';
|
||||
import { tool as xmlFormatter } from './xml-formatter';
|
||||
import { tool as yamlViewer } from './yaml-viewer';
|
||||
|
||||
@@ -163,7 +165,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
},
|
||||
{
|
||||
name: 'Images and videos',
|
||||
components: [qrCodeGenerator, wifiQrCodeGenerator, batchBarcodeGenerator, codeReader, imageOcr, pdfOcr, pdfTools, imageTools, videoTools, audioTools, sealMaker, signaturePad, textToImage, aiGen, docConvert, aiRetouch, labelDesigner, siteBookmarks, svgPlaceholderGenerator, cameraRecorder],
|
||||
components: [qrCodeGenerator, wifiQrCodeGenerator, batchBarcodeGenerator, codeReader, imageOcr, pdfOcr, pdfTools, imageTools, base64ImageConverter, videoTools, audioTools, sealMaker, signaturePad, textToImage, aiGen, docConvert, aiRetouch, labelDesigner, siteBookmarks, svgPlaceholderGenerator, cameraRecorder],
|
||||
},
|
||||
{
|
||||
name: 'Development',
|
||||
@@ -186,7 +188,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
},
|
||||
{
|
||||
name: 'Network',
|
||||
components: [ipv4SubnetCalculator, ipv4AddressConverter, ipv4RangeExpander, macAddressLookup, macAddressGenerator, ipv6UlaGenerator],
|
||||
components: [ipv4SubnetCalculator, ipv4AddressConverter, ipv4RangeExpander, macAddressLookup, macAddressGenerator, ipv6UlaGenerator, myIp],
|
||||
},
|
||||
{
|
||||
name: 'Math',
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { World } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
import { translate } from '@/plugins/i18n.plugin';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: translate('tools.my-ip.title'),
|
||||
path: '/my-ip',
|
||||
description: translate('tools.my-ip.description'),
|
||||
keywords: ['ip', 'ipv4', 'ipv6', '本机', '公网', '内网', '归属地', '网速', '测速', '延迟', 'ping', 'speed', 'address', 'location'],
|
||||
component: () => import('./my-ip.vue'),
|
||||
icon: World,
|
||||
});
|
||||
@@ -0,0 +1,979 @@
|
||||
<script setup lang="ts">
|
||||
// 本机IP查询:用户端公网 IPv4/IPv6 + 归属地 + 本站IPv6直连 + 热门地点延迟 + 网速测试(浏览器 <-> 本站服务器真实收发)
|
||||
type Geo = { country?: string; region?: string; city?: string; isp?: string; as?: string; lan?: boolean } | null;
|
||||
|
||||
// ---------- IP 查询(仅用户端视角,不显示服务器地址) ----------
|
||||
const ipLoading = ref(true);
|
||||
const v4 = ref('');
|
||||
const v4Geo = ref<Geo>(null);
|
||||
const v6 = ref('');
|
||||
const v6Geo = ref<Geo>(null);
|
||||
const copied = ref('');
|
||||
|
||||
// 本站 IPv6 直连入口(4443 防封端口,AAAA 已指向本机原生 v6)
|
||||
const V6_HOST = 'itv6.88531.cn';
|
||||
const V6_PORT = 4443;
|
||||
const onV6Host = location.hostname === V6_HOST;
|
||||
const onPublicHost = location.hostname === 'it.88531.cn' || onV6Host;
|
||||
|
||||
function switchToV6() {
|
||||
window.open(`https://${V6_HOST}:${V6_PORT}/my-ip`, '_self');
|
||||
}
|
||||
|
||||
async function jfetch(url: string, ms = 8000): Promise<any> {
|
||||
const ctrl = new AbortController();
|
||||
const t = setTimeout(() => ctrl.abort(), ms);
|
||||
try {
|
||||
const r = await fetch(url, { cache: 'no-store', signal: ctrl.signal });
|
||||
if (!r.ok) throw new Error('HTTP ' + r.status);
|
||||
return await r.json();
|
||||
} finally {
|
||||
clearTimeout(t);
|
||||
}
|
||||
}
|
||||
|
||||
async function tfetch(url: string, ms = 6000): Promise<string> {
|
||||
const ctrl = new AbortController();
|
||||
const t = setTimeout(() => ctrl.abort(), ms);
|
||||
try {
|
||||
const r = await fetch(url, { cache: 'no-store', signal: ctrl.signal });
|
||||
if (!r.ok) throw new Error('HTTP ' + r.status);
|
||||
const txt = (await r.text()).trim();
|
||||
if (txt.startsWith('{')) {
|
||||
try {
|
||||
const j = JSON.parse(txt);
|
||||
return String(j.ip || '');
|
||||
} catch {
|
||||
/* 非 JSON 就当纯文本 */
|
||||
}
|
||||
}
|
||||
return txt;
|
||||
} finally {
|
||||
clearTimeout(t);
|
||||
}
|
||||
}
|
||||
|
||||
async function firstOf(urls: string[]): Promise<string> {
|
||||
for (const u of urls) {
|
||||
try {
|
||||
const ip = await tfetch(u);
|
||||
if (ip) return ip;
|
||||
} catch {
|
||||
/* 换下一个源 */
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
const V4_SRC = ['https://v4.ident.me/', 'https://api.ipify.org?format=json', 'https://ip.3322.org/'];
|
||||
// IPv6 多源并发:任一源返回含冒号的地址即认为支持(防中间页劫持 + 双栈源误判)
|
||||
const V6_SRC = ['https://api6.ipify.org?format=json', 'https://v6.ident.me/'];
|
||||
|
||||
function isV6(s: string): boolean {
|
||||
return s.includes(':');
|
||||
}
|
||||
|
||||
async function geoFor(ip: string): Promise<Geo> {
|
||||
if (!ip) return null;
|
||||
try {
|
||||
const j = await jfetch(`/relay/ip-geo?ip=${encodeURIComponent(ip)}`, 9000);
|
||||
return (j && j.data) || null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadIps() {
|
||||
ipLoading.value = true;
|
||||
// 用户端 IPv4/IPv6 全部由浏览器向外部 IP 服务实测(与服务器无关)
|
||||
const [t4, t6s] = await Promise.all([
|
||||
firstOf(V4_SRC),
|
||||
Promise.all(V6_SRC.map((u) => tfetch(u).catch(() => ''))),
|
||||
]);
|
||||
v4.value = t4;
|
||||
// IPv6 必须含冒号才认(双栈源在无 v6 网络下会返回 v4)
|
||||
v6.value = t6s.find(isV6) || '';
|
||||
const [g4, g6] = await Promise.all([geoFor(v4.value), geoFor(v6.value)]);
|
||||
v4Geo.value = g4;
|
||||
v6Geo.value = g6;
|
||||
ipLoading.value = false;
|
||||
}
|
||||
|
||||
function geoLine(g: Geo): string {
|
||||
if (!g) return '';
|
||||
if (g.lan) return '内网地址(局域网),无公网归属地';
|
||||
const place = [g.country, g.region, g.city].filter(Boolean).join(' · ');
|
||||
const isp = g.isp ? ` · ${g.isp}` : '';
|
||||
const asn = g.as ? `(${g.as})` : '';
|
||||
return (place || '未知归属地') + isp + asn;
|
||||
}
|
||||
|
||||
async function copyIp(text: string, key: string) {
|
||||
if (!text) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
} catch {
|
||||
const ta = document.createElement('textarea');
|
||||
ta.value = text;
|
||||
document.body.appendChild(ta);
|
||||
ta.select();
|
||||
try {
|
||||
document.execCommand('copy');
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
document.body.removeChild(ta);
|
||||
}
|
||||
copied.value = key;
|
||||
setTimeout(() => {
|
||||
if (copied.value === key) copied.value = '';
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
// ---------- 热门地点延迟(你的浏览器到各地点的实测延迟) ----------
|
||||
type LatNode = { name: string; url: string; ms: number | null; st: 'wait' | 'run' | 'ok' | 'fail' };
|
||||
const latTesting = ref(false);
|
||||
const nodes = ref<LatNode[]>([
|
||||
{ name: '本站服务器', url: `${location.origin}/favicon.ico`, ms: null, st: 'wait' },
|
||||
{ name: '清华 TUNA(北京)', url: 'https://mirrors.tuna.tsinghua.edu.cn/', ms: null, st: 'wait' },
|
||||
{ name: '阿里云镜像(杭州)', url: 'https://mirrors.aliyun.com/', ms: null, st: 'wait' },
|
||||
{ name: '腾讯云镜像(广州)', url: 'https://mirrors.cloud.tencent.com/', ms: null, st: 'wait' },
|
||||
{ name: '华为云镜像', url: 'https://mirrors.huaweicloud.com/', ms: null, st: 'wait' },
|
||||
{ name: '中科大 USTC(合肥)', url: 'https://mirrors.ustc.edu.cn/', ms: null, st: 'wait' },
|
||||
{ name: '香港 Fedora', url: 'https://mirror.hk.fedoraproject.org/', ms: null, st: 'wait' },
|
||||
{ name: '日本 JAIST', url: 'https://mirror.jaist.ac.jp/', ms: null, st: 'wait' },
|
||||
{ name: 'Cloudflare(海外)', url: 'https://speed.cloudflare.com/__down?bytes=0', ms: null, st: 'wait' },
|
||||
]);
|
||||
|
||||
const latSummary = computed(() => {
|
||||
const ok = nodes.value.filter((n) => n.st === 'ok' && n.ms != null);
|
||||
if (!ok.length) return '';
|
||||
const avg = Math.round(ok.reduce((s, n) => s + (n.ms || 0), 0) / ok.length);
|
||||
const best = Math.min(...ok.map((n) => n.ms || 0));
|
||||
return `平均 ${avg} ms · 最快 ${best} ms · ${ok.length}/${nodes.value.length} 个节点可达`;
|
||||
});
|
||||
|
||||
async function ping(n: LatNode) {
|
||||
n.st = 'run';
|
||||
const ctrl = new AbortController();
|
||||
const timer = setTimeout(() => ctrl.abort(), 8000);
|
||||
const t0 = performance.now();
|
||||
try {
|
||||
const same = n.url.startsWith(location.origin);
|
||||
await fetch(n.url + (n.url.includes('?') ? '&' : '?') + '_t=' + Date.now(), {
|
||||
mode: same ? 'cors' : 'no-cors',
|
||||
cache: 'no-store',
|
||||
signal: ctrl.signal,
|
||||
});
|
||||
n.ms = Math.round(performance.now() - t0);
|
||||
n.st = 'ok';
|
||||
} catch {
|
||||
n.ms = null;
|
||||
n.st = 'fail';
|
||||
} finally {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
}
|
||||
|
||||
async function runAllLatency() {
|
||||
if (latTesting.value) return;
|
||||
latTesting.value = true;
|
||||
await Promise.all(nodes.value.map(ping));
|
||||
latTesting.value = false;
|
||||
}
|
||||
|
||||
function latCls(n: LatNode): string {
|
||||
if (n.st === 'fail') return 'is-fail';
|
||||
if (n.st !== 'ok' || n.ms == null) return 'is-wait';
|
||||
if (n.ms < 60) return 'is-good';
|
||||
if (n.ms < 150) return 'is-ok';
|
||||
if (n.ms < 300) return 'is-mid';
|
||||
return 'is-slow';
|
||||
}
|
||||
|
||||
// ---------- 网速测试(你的浏览器 <-> 本站服务器,真实收发数据计时) ----------
|
||||
const SPEED_BASE = `${location.origin}/relay/speed`;
|
||||
const sp = ref<'idle' | 'down' | 'up' | 'done' | 'error'>('idle');
|
||||
const spPct = ref(0);
|
||||
const spBytes = ref(0);
|
||||
const downMbps = ref(0);
|
||||
const upMbps = ref(0);
|
||||
const serverMs = ref<number | null>(null);
|
||||
const spMsg = ref('');
|
||||
|
||||
const transferredMb = computed(() => (spBytes.value / 1048576).toFixed(1));
|
||||
|
||||
async function fetchBytes(url: string, ms = 30000) {
|
||||
const ctrl = new AbortController();
|
||||
const t = setTimeout(() => ctrl.abort(), ms);
|
||||
try {
|
||||
const r = await fetch(url, { cache: 'no-store', signal: ctrl.signal });
|
||||
if (!r.ok) throw new Error('HTTP ' + r.status);
|
||||
const buf = await r.arrayBuffer();
|
||||
return buf.byteLength;
|
||||
} finally {
|
||||
clearTimeout(t);
|
||||
}
|
||||
}
|
||||
|
||||
function randBuf(len: number): ArrayBuffer {
|
||||
const buf = new Uint8Array(len);
|
||||
const W = 65536;
|
||||
for (let o = 0; o < len; o += W) crypto.getRandomValues(buf.subarray(o, Math.min(o + W, len)));
|
||||
return buf.buffer as ArrayBuffer;
|
||||
}
|
||||
|
||||
async function runSpeedTest() {
|
||||
if (sp.value === 'down' || sp.value === 'up') return;
|
||||
sp.value = 'down';
|
||||
spPct.value = 0;
|
||||
spBytes.value = 0;
|
||||
downMbps.value = 0;
|
||||
upMbps.value = 0;
|
||||
spMsg.value = '';
|
||||
try {
|
||||
// 1) 到本站服务器的延迟(一次小请求计时)
|
||||
const l0 = performance.now();
|
||||
await fetchBytes(`${SPEED_BASE}?bytes=4096&_t=${Date.now()}`, 10000);
|
||||
serverMs.value = Math.max(1, Math.round(performance.now() - l0));
|
||||
|
||||
// 2) 下载:预热 512KB 不计速,再 3 轮 × 3MB 计总吞吐
|
||||
await fetchBytes(`${SPEED_BASE}?bytes=524288&_t=${Date.now()}`, 20000);
|
||||
const DCH = 3 * 1024 * 1024;
|
||||
let got = 0;
|
||||
const t0 = performance.now();
|
||||
for (let i = 0; i < 3; ++i) {
|
||||
const gotChunk = await fetchBytes(`${SPEED_BASE}?bytes=${DCH}&_t=${Date.now() + i}`);
|
||||
got += gotChunk;
|
||||
spBytes.value = got;
|
||||
spPct.value = 10 + Math.round(((i + 1) / 3) * 48);
|
||||
}
|
||||
const del = (performance.now() - t0) / 1000;
|
||||
downMbps.value = Math.round((got * 8) / del / 1e4) / 100;
|
||||
|
||||
// 3) 上传:预热 256KB 不计速,再 3 轮 × 1MB 随机数据(服务器收满丢弃)
|
||||
sp.value = 'up';
|
||||
await postBytes(randBuf(256 * 1024), 20000);
|
||||
const UCH = 1024 * 1024;
|
||||
const payload = randBuf(UCH);
|
||||
let sent = 0;
|
||||
const u0 = performance.now();
|
||||
for (let i = 0; i < 3; ++i) {
|
||||
const n = await postBytes(payload, 30000);
|
||||
sent += n;
|
||||
spBytes.value = got + sent;
|
||||
spPct.value = 58 + Math.round(((i + 1) / 3) * 42);
|
||||
}
|
||||
const uel = (performance.now() - u0) / 1000;
|
||||
upMbps.value = Math.round((sent * 8) / uel / 1e4) / 100;
|
||||
spPct.value = 100;
|
||||
sp.value = 'done';
|
||||
pushSpeedRec(); // 记入本机测速历史,方便多线路对比
|
||||
} catch (e: any) {
|
||||
sp.value = 'error';
|
||||
spMsg.value =
|
||||
e && e.name === 'AbortError'
|
||||
? '测速超时:到本站服务器连接超时,请稍后重试'
|
||||
: '测速失败:无法连接本站服务器测速接口,请稍后重试';
|
||||
}
|
||||
}
|
||||
|
||||
async function postBytes(buf: ArrayBuffer, ms = 30000): Promise<number> {
|
||||
const ctrl = new AbortController();
|
||||
const timer = setTimeout(() => ctrl.abort(), ms);
|
||||
try {
|
||||
const r = await fetch(SPEED_BASE, {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
cache: 'no-store',
|
||||
headers: { 'Content-Type': 'application/octet-stream' },
|
||||
body: buf,
|
||||
signal: ctrl.signal,
|
||||
});
|
||||
if (!r.ok) throw new Error('HTTP ' + r.status);
|
||||
const j = await r.json().catch(() => null);
|
||||
return (j && j.data && j.data.received) || buf.byteLength;
|
||||
} finally {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
}
|
||||
|
||||
function grade(mbps: number): string {
|
||||
if (mbps >= 200) return '🚀 极速:多路 4K / 秒下大文件';
|
||||
if (mbps >= 100) return '⚡ 很快:4K 视频与大文件下载流畅';
|
||||
if (mbps >= 50) return '✅ 良好:1080p~4K 视频流畅';
|
||||
if (mbps >= 20) return '👍 中等:1080p 视频流畅';
|
||||
if (mbps >= 10) return '📶 偏慢:720p 视频可用';
|
||||
return '🐢 较慢:建议检查网络或更换线路';
|
||||
}
|
||||
|
||||
// ---------- 测速历史(存本机浏览器 localStorage,按线路对比,最多 20 条) ----------
|
||||
const SPEED_HISTORY_KEY = 'itp_my_ip_speed_history';
|
||||
interface SpeedRec {
|
||||
t: number; // 时间戳
|
||||
down: number; // 下载 Mbps
|
||||
up: number; // 上传 Mbps
|
||||
ms: number; // 到本站延迟
|
||||
route: 'IPv6 直连' | '公网中转'; // 测试时所走线路
|
||||
host: string; // 测试时的访问域名
|
||||
}
|
||||
const speedHistory = ref<SpeedRec[]>([]);
|
||||
|
||||
function loadSpeedHistory() {
|
||||
try {
|
||||
const arr = JSON.parse(localStorage.getItem(SPEED_HISTORY_KEY) || '[]');
|
||||
speedHistory.value = Array.isArray(arr)
|
||||
? arr.filter((r) => r && typeof r.down === 'number' && typeof r.t === 'number').slice(0, 20)
|
||||
: [];
|
||||
} catch {
|
||||
speedHistory.value = [];
|
||||
}
|
||||
}
|
||||
|
||||
function saveSpeedHistory() {
|
||||
try {
|
||||
localStorage.setItem(SPEED_HISTORY_KEY, JSON.stringify(speedHistory.value.slice(0, 20)));
|
||||
} catch {
|
||||
/* 隐私模式下写入失败则仅本次会话展示 */
|
||||
}
|
||||
}
|
||||
|
||||
function pushSpeedRec() {
|
||||
speedHistory.value.unshift({
|
||||
t: Date.now(),
|
||||
down: downMbps.value,
|
||||
up: upMbps.value,
|
||||
ms: serverMs.value ?? 0,
|
||||
route: onV6Host ? 'IPv6 直连' : '公网中转',
|
||||
host: location.host,
|
||||
});
|
||||
speedHistory.value = speedHistory.value.slice(0, 20);
|
||||
saveSpeedHistory();
|
||||
}
|
||||
|
||||
function clearSpeedHistory() {
|
||||
speedHistory.value = [];
|
||||
saveSpeedHistory();
|
||||
}
|
||||
|
||||
function fmtTime(t: number): string {
|
||||
const d = new Date(t);
|
||||
const p = (n: number) => String(n).padStart(2, '0');
|
||||
return `${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadIps();
|
||||
runAllLatency();
|
||||
loadSpeedHistory();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="myip-root">
|
||||
<!-- 本站 IPv6 直连横幅 -->
|
||||
<div v-if="v6 && onPublicHost && !onV6Host" class="v6-banner ok">
|
||||
<div class="vb-text">
|
||||
<b>本站已支持 IPv6 访问,速度更快</b>
|
||||
<span>检测到你的网络支持 IPv6。本站已开通 IPv6 直连(免公网中转),切换后访问本站更快、延迟更低。</span>
|
||||
</div>
|
||||
<button class="vb-btn" @click="switchToV6()">切换 IPv6 直连</button>
|
||||
</div>
|
||||
<div v-else-if="onV6Host" class="v6-banner ok">
|
||||
<div class="vb-text">
|
||||
<b>当前已通过 IPv6 直连访问本站</b>
|
||||
<span>你正走 IPv6 直连线路(免公网中转),访问本站速度更快、延迟更低。</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="!v6 && !ipLoading" class="v6-banner info">
|
||||
<div class="vb-text">
|
||||
<b>本站已支持 IPv6 访问,速度更快</b>
|
||||
<span>你的网络暂未检测到 IPv6 地址。按下方「如何开启 IPv6」开通后即可直连本站。</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 用户端 IP 卡片(IPv4 / IPv6,均为你的设备视角) -->
|
||||
<div class="ip-row">
|
||||
<div class="ip-card">
|
||||
<div class="ip-card-head">
|
||||
<span class="ip-tag v4">IPv4</span>
|
||||
<span class="ip-label">你的公网地址</span>
|
||||
<button class="copy-btn" :disabled="!v4" @click="copyIp(v4, 'v4')">
|
||||
{{ copied === 'v4' ? '✓ 已复制' : '复制' }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="ip-value" :class="{ loading: ipLoading && !v4 }">
|
||||
{{ v4 || (ipLoading ? '查询中…' : '未获取到(网络可能屏蔽了 IP 查询服务)') }}
|
||||
</div>
|
||||
<div class="ip-geo">{{ geoLine(v4Geo) }}</div>
|
||||
</div>
|
||||
|
||||
<div class="ip-card">
|
||||
<div class="ip-card-head">
|
||||
<span class="ip-tag v6">IPv6</span>
|
||||
<span class="ip-label">你的公网地址</span>
|
||||
<button class="copy-btn" :disabled="!v6" @click="copyIp(v6, 'v6')">
|
||||
{{ copied === 'v6' ? '✓ 已复制' : '复制' }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="v6" class="ip-value" :class="{ loading: ipLoading && !v6 }">{{ v6 }}</div>
|
||||
<div v-else class="ip-value unsupported">
|
||||
{{ ipLoading ? '检测中…' : '不支持 IPv6' }}
|
||||
</div>
|
||||
<div class="ip-geo">{{ v6 ? geoLine(v6Geo) : ipLoading ? '' : '你的网络未检测到 IPv6 地址(运营商或路由器未开启 IPv6)' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ip-hint">
|
||||
进入页面自动查询:IPv4/IPv6 地址均由你的浏览器向外部 IP 服务实测(多源容错),归属地由本站服务端按你的 IP 查询(中文数据);点击卡片右上角「复制」可复制地址。
|
||||
<button class="refresh-btn" :disabled="ipLoading" @click="loadIps()">{{ ipLoading ? '刷新中…' : '刷新 IP' }}</button>
|
||||
</div>
|
||||
|
||||
<!-- 如何开启 IPv6(不支持时展示) -->
|
||||
<div v-if="!v6 && !ipLoading" class="sec guide">
|
||||
<div class="sec-head"><h3>如何开启 IPv6?</h3><span class="sec-sub">按顺序检查,多数家宽用户开完第 ② ③ 步即可获得 IPv6</span></div>
|
||||
<ol class="guide-list">
|
||||
<li><b>① 运营商侧确认已开通</b>:电信/移动/联通家宽默认已启用 IPv6,不确定就打客服电话报"开通 IPv6"。</li>
|
||||
<li><b>② 光猫改桥接或开双栈</b>:登录光猫管理页(常为 192.168.1.1),上网方式改"桥接"(推荐,由路由器拨号),或把连接模式改为"双栈"。</li>
|
||||
<li><b>③ 路由器开启 IPv6</b>:路由器外网/WAN 设置里启用 IPv6,方式选 Native(原生)或 Dual-Stack(双栈),LAN 侧会自动向下分发 v6 前缀。</li>
|
||||
<li><b>④ 终端确认拿到地址</b>:Windows 在 网络适配器属性 里查看"IPv6 地址";手机在 Wi-Fi 详情里查看。没有就重连 Wi-Fi/重启路由器。</li>
|
||||
<li><b>⑤ 回到本页刷新</b>:IPv6 卡显示地址即成功,顶部会出现「切换 IPv6 直连」入口。</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<!-- 网速测试(你的设备 <-> 本站服务器真实收发) -->
|
||||
<div class="sec">
|
||||
<div class="sec-head">
|
||||
<h3>网速测试(你的设备 ↔ 本站服务器)</h3>
|
||||
<span class="sec-sub">从你的浏览器向本站服务器真实收发数据并计时,测的是你连接本站服务器的实际速度(走你当前的访问线路:公网中转或 IPv6 直连),约消耗 13MB 流量</span>
|
||||
<n-button
|
||||
size="large"
|
||||
type="primary"
|
||||
:loading="sp === 'down' || sp === 'up'"
|
||||
@click="runSpeedTest()"
|
||||
>
|
||||
{{ sp === 'idle' ? '开始测速' : sp === 'down' ? '测速中(下载)…' : sp === 'up' ? '测速中(上传)…' : '重新测速' }}
|
||||
</n-button>
|
||||
</div>
|
||||
<div class="sp-bar">
|
||||
<div class="sp-fill" :style="{ width: spPct + '%' }"></div>
|
||||
</div>
|
||||
<div class="sp-meta">
|
||||
<span v-if="sp === 'down' || sp === 'up'">测速中,已传输 {{ transferredMb }} MB…</span>
|
||||
<span v-else-if="sp === 'done'">测速完成 · 共传输 {{ transferredMb }} MB</span>
|
||||
<span v-else-if="sp === 'error'">—</span>
|
||||
<span v-else>点击「开始测速」后自动进行延迟、下载与上传测试</span>
|
||||
</div>
|
||||
<div class="sp-results">
|
||||
<div class="sp-item">
|
||||
<div class="sp-num">{{ downMbps || '—' }}</div>
|
||||
<div class="sp-unit">Mbps 下载速度</div>
|
||||
<div class="sp-grade">{{ downMbps ? grade(downMbps) : '' }}</div>
|
||||
</div>
|
||||
<div class="sp-item">
|
||||
<div class="sp-num up">{{ upMbps || '—' }}</div>
|
||||
<div class="sp-unit">Mbps 上传速度</div>
|
||||
<div class="sp-grade">{{ upMbps ? grade(upMbps) : '' }}</div>
|
||||
</div>
|
||||
<div class="sp-item">
|
||||
<div class="sp-num ms">{{ serverMs ?? '—' }}</div>
|
||||
<div class="sp-unit">ms 到本站服务器延迟</div>
|
||||
<div class="sp-grade">{{ serverMs ? (serverMs < 50 ? '🟢 延迟很低' : serverMs < 150 ? '🟡 延迟正常' : '🔴 延迟偏高') : '' }}</div>
|
||||
</div>
|
||||
<div class="sp-item tip">
|
||||
<div class="sp-tip-t">测速原理</div>
|
||||
<div class="sp-tip">下载从本站服务器拉取固定大小数据块计时,上传向本站服务器推送随机数据块计时,结果为你到本站服务器的实际吞吐。切换 IPv6 直连后重测可对比两条线路的差距。</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="sp === 'error'" class="sp-error">{{ spMsg }}</div>
|
||||
|
||||
<!-- 测速历史(存本机浏览器,按线路对比) -->
|
||||
<div v-if="speedHistory.length" class="sp-history">
|
||||
<div class="sp-hist-head">
|
||||
<span class="sp-hist-t">📋 测速历史(仅存于你的浏览器,共 {{ speedHistory.length }} 条,最多保留 20 条)</span>
|
||||
<n-button size="small" quaternary @click="clearSpeedHistory()">清空历史</n-button>
|
||||
</div>
|
||||
<div class="sp-hist-table">
|
||||
<div class="sp-hrow sp-hhead">
|
||||
<span>时间</span>
|
||||
<span>线路</span>
|
||||
<span>下载 Mbps</span>
|
||||
<span>上传 Mbps</span>
|
||||
<span>延迟 ms</span>
|
||||
</div>
|
||||
<div v-for="r in speedHistory" :key="r.t" class="sp-hrow">
|
||||
<span>{{ fmtTime(r.t) }}</span>
|
||||
<span><em :class="r.route === 'IPv6 直连' ? 'tag-v6' : 'tag-v4'">{{ r.route }}</em></span>
|
||||
<span class="c-down">{{ r.down }}</span>
|
||||
<span class="c-up">{{ r.up }}</span>
|
||||
<span class="c-ms">{{ r.ms }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sp-hist-tip">对比方法:在当前线路测一次 → 点横幅「切换 IPv6 直连」再测一次,两条线路的下载/上传/延迟直接在表里对照。</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 热门地点延迟 -->
|
||||
<div class="sec">
|
||||
<div class="sec-head">
|
||||
<h3>连接热门地点的速度</h3>
|
||||
<span class="sec-sub">进入页面自动测量你的浏览器到各地点的网络延迟(越低越快,点「重新测速」再测一轮)</span>
|
||||
<n-button size="large" :loading="latTesting" @click="runAllLatency()">重新测速</n-button>
|
||||
</div>
|
||||
<div class="lat-grid">
|
||||
<div v-for="n in nodes" :key="n.name" class="lat-card" :class="latCls(n)">
|
||||
<span class="lat-name">{{ n.name }}</span>
|
||||
<span class="lat-ms">
|
||||
{{ n.st === 'run' ? '测速中…' : n.st === 'fail' ? '超时' : n.st === 'ok' ? `${n.ms} ms` : '待测' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lat-summary">{{ latSummary }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="less">
|
||||
.myip-root {
|
||||
min-height: calc(100vh - 170px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 18px;
|
||||
font-size: 15px;
|
||||
color: #1f2a44;
|
||||
}
|
||||
|
||||
/* ---- IPv6 直连横幅 ---- */
|
||||
.v6-banner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
border-radius: 12px;
|
||||
padding: 14px 18px;
|
||||
flex-wrap: wrap;
|
||||
&.ok {
|
||||
background: #e9fbf1;
|
||||
border: 1px solid #a7e8c6;
|
||||
.vb-text b {
|
||||
color: #0d9f57;
|
||||
}
|
||||
}
|
||||
&.info {
|
||||
background: #eef4ff;
|
||||
border: 1px solid #c3d6f7;
|
||||
.vb-text b {
|
||||
color: #1d6fe0;
|
||||
}
|
||||
}
|
||||
}
|
||||
.vb-text {
|
||||
flex: 1;
|
||||
min-width: 240px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
b {
|
||||
font-size: 16px;
|
||||
}
|
||||
span {
|
||||
color: #46557a;
|
||||
font-size: 14.5px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
.vb-btn {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
padding: 8px 18px;
|
||||
border-radius: 9px;
|
||||
border: none;
|
||||
background: #0d9f57;
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
transition: all 0.15s;
|
||||
&:hover {
|
||||
background: #0b8a4b;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- IP 卡片 ---- */
|
||||
.ip-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
.ip-card {
|
||||
border: 1px solid #e5e9f2;
|
||||
border-radius: 12px;
|
||||
padding: 16px 18px;
|
||||
background: #fff;
|
||||
box-shadow: 0 1px 4px rgba(30, 60, 110, 0.05);
|
||||
}
|
||||
.ip-card-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.ip-tag {
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
padding: 2px 9px;
|
||||
border-radius: 6px;
|
||||
&.v4 {
|
||||
background: #e8f3ff;
|
||||
color: #1d6fe0;
|
||||
}
|
||||
&.v6 {
|
||||
background: #e9fbf1;
|
||||
color: #0d9f57;
|
||||
}
|
||||
}
|
||||
.ip-label {
|
||||
color: #5b6b85;
|
||||
font-size: 14.5px;
|
||||
}
|
||||
.copy-btn {
|
||||
margin-left: auto;
|
||||
font-size: 14px;
|
||||
padding: 4px 12px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #cfd8ea;
|
||||
background: #fff;
|
||||
color: #1d6fe0;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
&:hover:not(:disabled) {
|
||||
background: #e8f3ff;
|
||||
border-color: #1d6fe0;
|
||||
}
|
||||
&:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
.ip-value {
|
||||
font-family: ui-monospace, 'SF Mono', Consolas, monospace;
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
word-break: break-all;
|
||||
line-height: 1.35;
|
||||
min-height: 30px;
|
||||
&.loading {
|
||||
color: #94a3b8;
|
||||
font-size: 16px;
|
||||
font-weight: 400;
|
||||
}
|
||||
&.unsupported {
|
||||
color: #dc2626;
|
||||
font-family: inherit;
|
||||
font-size: 19px;
|
||||
}
|
||||
}
|
||||
.ip-geo {
|
||||
margin-top: 8px;
|
||||
color: #5b6b85;
|
||||
font-size: 14.5px;
|
||||
min-height: 21px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.ip-hint {
|
||||
color: #5b6b85;
|
||||
font-size: 14.5px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.refresh-btn {
|
||||
margin-left: 8px;
|
||||
font-size: 14px;
|
||||
padding: 3px 12px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #cfd8ea;
|
||||
background: #fff;
|
||||
color: #1d6fe0;
|
||||
cursor: pointer;
|
||||
&:hover:not(:disabled) {
|
||||
background: #e8f3ff;
|
||||
}
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- 通用区块 ---- */
|
||||
.sec {
|
||||
border: 1px solid #e5e9f2;
|
||||
border-radius: 12px;
|
||||
padding: 18px 20px;
|
||||
background: #fff;
|
||||
flex: 1;
|
||||
}
|
||||
.sec-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 14px;
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 19px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
.sec-sub {
|
||||
color: #5b6b85;
|
||||
font-size: 14.5px;
|
||||
flex: 1;
|
||||
min-width: 220px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* ---- IPv6 开启教学 ---- */
|
||||
.guide-list {
|
||||
margin: 0;
|
||||
padding-left: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
li {
|
||||
font-size: 15px;
|
||||
line-height: 1.65;
|
||||
color: #33415c;
|
||||
b {
|
||||
color: #1f2a44;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- 延迟网格 ---- */
|
||||
.lat-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
.lat-card {
|
||||
border: 1px solid #e8edf6;
|
||||
border-radius: 10px;
|
||||
padding: 12px 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
background: #fafcff;
|
||||
}
|
||||
.lat-name {
|
||||
font-size: 14.5px;
|
||||
color: #33415c;
|
||||
}
|
||||
.lat-ms {
|
||||
font-size: 17px;
|
||||
font-weight: 700;
|
||||
font-variant-numeric: tabular-nums;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.is-good .lat-ms {
|
||||
color: #0d9f57;
|
||||
}
|
||||
.is-ok .lat-ms {
|
||||
color: #1d6fe0;
|
||||
}
|
||||
.is-mid .lat-ms {
|
||||
color: #d97706;
|
||||
}
|
||||
.is-slow .lat-ms {
|
||||
color: #dc2626;
|
||||
}
|
||||
.is-fail .lat-ms,
|
||||
.is-wait .lat-ms {
|
||||
color: #94a3b8;
|
||||
font-size: 14.5px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.is-fail {
|
||||
background: #fff5f5;
|
||||
}
|
||||
.lat-summary {
|
||||
margin-top: 12px;
|
||||
color: #5b6b85;
|
||||
font-size: 14.5px;
|
||||
min-height: 21px;
|
||||
}
|
||||
|
||||
/* ---- 网速 ---- */
|
||||
.sp-bar {
|
||||
height: 14px;
|
||||
background: #eef2f8;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
margin: 6px 0 10px;
|
||||
}
|
||||
.sp-fill {
|
||||
height: 100%;
|
||||
width: 0;
|
||||
background: linear-gradient(90deg, #1d6fe0, #0d9f57);
|
||||
transition: width 0.3s;
|
||||
}
|
||||
.sp-meta {
|
||||
color: #5b6b85;
|
||||
font-size: 14.5px;
|
||||
margin-bottom: 14px;
|
||||
min-height: 21px;
|
||||
}
|
||||
.sp-results {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
.sp-item {
|
||||
background: #f7f9fd;
|
||||
border: 1px solid #e8edf6;
|
||||
border-radius: 10px;
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
.sp-num {
|
||||
font-size: 34px;
|
||||
font-weight: 800;
|
||||
color: #1d6fe0;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 1.2;
|
||||
&.up {
|
||||
color: #0d9f57;
|
||||
}
|
||||
&.ms {
|
||||
color: #7c3aed;
|
||||
}
|
||||
}
|
||||
.sp-unit {
|
||||
font-size: 14.5px;
|
||||
color: #5b6b85;
|
||||
margin-top: 2px;
|
||||
}
|
||||
.sp-grade {
|
||||
margin-top: 8px;
|
||||
font-size: 15px;
|
||||
color: #33415c;
|
||||
min-height: 22px;
|
||||
}
|
||||
.sp-item.tip {
|
||||
text-align: left;
|
||||
}
|
||||
.sp-tip-t {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: #33415c;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.sp-tip {
|
||||
font-size: 14.5px;
|
||||
color: #5b6b85;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.sp-error {
|
||||
color: #dc2626;
|
||||
font-size: 15px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* ---------- 测速历史 ---------- */
|
||||
.sp-history {
|
||||
margin-top: 14px;
|
||||
border: 1px solid var(--n-border, rgba(128, 128, 128, 0.25));
|
||||
border-radius: 10px;
|
||||
padding: 10px 14px 12px;
|
||||
background: rgba(128, 128, 128, 0.05);
|
||||
}
|
||||
|
||||
.sp-hist-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.sp-hist-t {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.sp-hist-table {
|
||||
font-size: 13.5px;
|
||||
|
||||
.sp-hrow {
|
||||
display: grid;
|
||||
grid-template-columns: 1.1fr 1.1fr 1fr 1fr 0.9fr;
|
||||
gap: 6px;
|
||||
padding: 6px 4px;
|
||||
align-items: center;
|
||||
border-bottom: 1px dashed rgba(128, 128, 128, 0.2);
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
&.sp-hhead {
|
||||
font-weight: 600;
|
||||
opacity: 0.75;
|
||||
font-size: 12.5px;
|
||||
border-bottom: 1px solid rgba(128, 128, 128, 0.3);
|
||||
}
|
||||
|
||||
.c-down {
|
||||
color: #18a058;
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.c-up {
|
||||
color: #2080f0;
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.c-ms {
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tag-v4,
|
||||
.tag-v6 {
|
||||
font-style: normal;
|
||||
font-size: 12px;
|
||||
padding: 1px 8px;
|
||||
border-radius: 999px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.tag-v4 {
|
||||
background: rgba(32, 128, 240, 0.14);
|
||||
color: #2080f0;
|
||||
}
|
||||
|
||||
.tag-v6 {
|
||||
background: rgba(24, 165, 88, 0.15);
|
||||
color: #18a058;
|
||||
}
|
||||
|
||||
.sp-hist-tip {
|
||||
margin-top: 8px;
|
||||
font-size: 12.5px;
|
||||
opacity: 0.7;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.sec-head {
|
||||
h3 {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.sp-hist-table .sp-hrow {
|
||||
grid-template-columns: 1fr 1fr 1fr 1fr 0.8fr;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -139,7 +139,8 @@ watch([source, from, to], () => {
|
||||
// ============ 文档翻译 ============
|
||||
const mode = ref<'text' | 'doc'>('text');
|
||||
const docTo = ref('zh-CN');
|
||||
const docLangOptions = langs.filter(l => l.value !== 'auto');
|
||||
// 文档翻译:本地引擎仅加载中英,下拉只给真实可选项
|
||||
const docLangOptions = langs.filter(l => l.value === 'zh-CN' || l.value === 'en');
|
||||
const docInput = ref<HTMLInputElement>();
|
||||
// 批量文档翻译:一次最多 10 个文件,每个文件一个任务
|
||||
const MAX_DOC_FILES = 10;
|
||||
@@ -183,7 +184,7 @@ async function translateOne(job: any) {
|
||||
try {
|
||||
const fd = new FormData();
|
||||
fd.append('file', job.file);
|
||||
fd.append('to', langName(docTo.value));
|
||||
fd.append('to', docTo.value); // 传语言码,服务端本地引擎按码翻译(旧标签格式也兼容)
|
||||
// 单文件超时保护:超过 8 分钟视为失败
|
||||
const ctrl = new AbortController();
|
||||
const timer = setTimeout(() => ctrl.abort(), 8 * 60 * 1000);
|
||||
@@ -199,7 +200,7 @@ async function translateOne(job: any) {
|
||||
throw new Error(j.message || `HTTP ${res.status}`);
|
||||
}
|
||||
job.text = j.data.text;
|
||||
job.info = `${j.data.chars} 字 · ${j.data.blocks} 块 · 译文 ${j.data.text.length} 字`;
|
||||
job.info = `${j.data.ocr ? `📷已OCR识别${j.data.ocr_pages > 1 ? ` ${j.data.ocr_pages} 页` : ''} · ` : ''}${j.data.chars} 字 · ${j.data.blocks} 块 · 译文 ${j.data.text.length} 字`;
|
||||
job.status = 'done';
|
||||
genHist.add({ title: `文档翻译: ${job.file.name}`, detail: `${j.data.chars} 字 → ${langName(docTo.value)}` });
|
||||
}
|
||||
@@ -336,16 +337,16 @@ onUnmounted(() => {
|
||||
📄 文档翻译
|
||||
<span class="mode-new">新</span>
|
||||
</button>
|
||||
<span class="mode-hint">{{ mode === 'doc' ? '上传 Word / PDF / TXT 等文档,AI 整篇翻译并保留段落格式,可下载译文' : '输入文本自动翻译' }}</span>
|
||||
<span class="mode-hint">{{ mode === 'doc' ? '上传 Word / PDF / TXT / 图片,整篇翻译并保留段落格式;非纯文字(扫描件/图片)自动 OCR 识别后再翻译' : '输入文本自动翻译' }}</span>
|
||||
</div>
|
||||
|
||||
<!-- 文档翻译面板 -->
|
||||
<div v-if="mode === 'doc'" class="doc-panel">
|
||||
<input ref="docInput" type="file" hidden multiple accept=".txt,.md,.docx,.doc,.pdf,.html,.htm,.epub,.rtf,.odt" @change="onDocInput">
|
||||
<input ref="docInput" type="file" hidden multiple accept=".txt,.md,.docx,.doc,.pdf,.html,.htm,.epub,.rtf,.odt,.png,.jpg,.jpeg,.webp,.bmp,.gif,.tiff,.tif" @change="onDocInput">
|
||||
<div class="doc-top">
|
||||
<div class="doc-drop" @click="pickDoc">
|
||||
<template v-if="!docJobs.length">
|
||||
📁 点击选择文档(可多选,最多 10 个)<br><span>Word / PDF / TXT / MD / HTML / EPUB · 每个 ≤20MB</span>
|
||||
📁 点击选择文档或图片(可多选,最多 10 个)<br><span>Word / PDF / TXT / MD / HTML / EPUB · 截图/扫描件/图片 · 每个 ≤20MB</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
📄 已选 {{ docJobs.length }} 个文件<span v-if="docJobs.length >= MAX_DOC_FILES" class="doc-size">(已达 10 个上限)</span>
|
||||
@@ -388,7 +389,8 @@ onUnmounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="doc-empty">
|
||||
支持整篇文档批量翻译(最多 10 个):AI 分块处理并保留原段落结构,逐个文件出译文,可下载 TXT 或 Word(DOCX)。
|
||||
支持整篇文档批量翻译(最多 10 个):分块处理并保留原段落结构,逐个文件出译文,可下载 TXT 或 Word(DOCX)。<br>
|
||||
<b>📌 非纯文字文档处理:</b>上传的文档或图片若不是纯文字(如扫描版 PDF、截图、照片、带文字的图片),系统会<b>先自动 OCR 识别出文字,再整篇翻译</b>——扫描件无需先手动转文字,直接传上来即可;识别结果可在译文里核对,建议图片清晰、光线均匀以保证识别准确率。
|
||||
</div>
|
||||
<n-spin v-if="docLoading" :show="docLoading" class="doc-spin" />
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user