Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85d87f5db5 | ||
|
|
2af613d8be | ||
|
|
42e5b11c13 | ||
|
|
8689a350e3 | ||
|
|
8d0c86076f | ||
|
|
afc22416c0 | ||
|
|
71d00658c5 | ||
|
|
3f064d7412 | ||
|
|
5f57e154c1 | ||
|
|
9f99325936 | ||
|
|
f2ac228849 | ||
|
|
5b8e53f9c8 | ||
|
|
e06a3842fc | ||
|
|
c84c9c8bcc | ||
|
|
0d3a714438 | ||
|
|
8767f252a7 |
No files matched your search
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
@@ -27,6 +27,9 @@ ssh
|
||||
public/local-ai.json
|
||||
.env
|
||||
|
||||
# MCP 服务生成产物(工程 ZIP / 配音,运行时数据,勿提交)
|
||||
mcp-out/
|
||||
|
||||
# 数据质量检查的生成报告(每次运行都会变,不入库)
|
||||
data-quality/reports/
|
||||
|
||||
|
||||
@@ -4,6 +4,154 @@
|
||||
|
||||
---
|
||||
|
||||
## 2026-11-12
|
||||
|
||||
### ✨ 教程页三栏重排版(/article/* 可读性优化)
|
||||
|
||||
- 三栏布局:左浮动目录(224px sticky,`nav[aria-label="文章目录"]`,IntersectionObserver 滚动高亮 + 点击锚点平滑跳转,scroll-margin 让开 60px fixed 导航)+ 正文白卡(940px,段落/列表/标题/引用/代码间距全面加大,h2 加分隔线)+ 右浮动「更多教程」(256px sticky,原底部区块移至右侧固定)
|
||||
- `<1280px` 回退单栏:目录隐藏、更多教程回正文下方全宽
|
||||
- 验证:about / local-deploy-guide / mcp-guide 三页 1440 桌面三栏几何(toc x=28 / 正文 x=280 / 右栏 x=1141)、滚动 sticky 固定、目录点击跳转(scrollY=2589 + hash + active 同步)、900 窄屏单栏回退,验毕 FolderGuard 遮蔽还原(新 tab picker=function)
|
||||
|
||||
### 🐛 修复:文章列表被浏览器缓存导致「没有找到这篇文章」
|
||||
- 根因:`/articles/` 下的 `index.json`/`.md` 此前无 `Cache-Control`,浏览器走启发式缓存,新增文章后用户端仍读旧列表,`ArticleDetail` 找不到条目即报「没有找到这篇文章:<slug>」
|
||||
- nginx 修复:`location /articles/` 与 `location = /index.html` 加 `Cache-Control: no-cache`(每次协商校验,命中 304 不费流量;入口页不缓存可避免旧 html 引用已失效的 chunk hash);`/homeAssets/` 30 天 immutable 长缓存保留不变
|
||||
- 验证:线上三类响应头均为 `Cache-Control: no-cache`,构建产物仍 `max-age=2592000 + public, immutable`
|
||||
- 注意:已缓存旧列表的浏览器需强刷一次完成迁移,之后自动始终最新
|
||||
|
||||
### ✨ 新增「MCP 使用说明」教程
|
||||
|
||||
- 新文章 `public/articles/mcp-guide.md`(11.5KB 九节):MCP 概念与米剪 10 工具总览、端点与 Bearer 令牌(fail-closed/401)、**四种客户端接入模板**(Claude Desktop mcp-remote / Claude Code `claude mcp add` / Cursor mcp.json / Hermes config.yaml)、工具逐个详解(参数与默认值按 `mcp/server.py` 源码核实:`grab_url` 12000 字截断、`generate_script` 60 秒×4.5 字、`tts` 默认晓晓音色 ≤2000 字、`create_video_project` 30 图上限/160×120 门禁)、一句话生成视频实战链、curl 握手自检、`.env` 自部署配置、8 条常见问题
|
||||
- 顶栏菜单加「**MCP 使用说明**」(`Header.tsx` nav,置于「使用教程」后,当前页自动高亮)
|
||||
- `index.json` 新增 mcp-guide 条目(2026-11-12,标签 教程·MCP)
|
||||
- 构建部署 + 线上验证:md 11509B/200、index.json 四篇列表、浏览器实渲染 h2×9/代码块×8/li×51、菜单四项与高亮、内链互通,验毕 FolderGuard 还原
|
||||
- 事实来源:`mcp/README.md`、`mcp/server.py`(工具签名与 docstring)、`nginx.conf`(/mcp、/mcp-out/、/mcp-health 反代)
|
||||
|
||||
## 2026-11-11
|
||||
|
||||
### 🎬 /article/about 改为 AI 一键出片教程 + 菜单改名
|
||||
|
||||
**原「关于我们」页整体重定位为《AI 一键出片新手教程》**
|
||||
|
||||
- 路由:`routes.config.ts` 移除 aboutus 优先路由(`/article/about` 原走 `AboutUs.tsx` 硬编码 JSX),改为统一走文章详情页渲染 markdown;`public/articles/about.md` 新建教程正文(10.5KB 十节)——60 秒认识一键出片、配置模型(唯一前提、ai.88531.cn 取 Key、Key 只存浏览器)、两处入口(AI 创作面板常驻卡片 / 页签「开始一键出片」)、第 1 步素材与标题(图片 8 张上限可排序 / Word·PDF 自动提取含扫描件报错 / 网址抓取含失败提示、标题 30 字、5 种文案风格)、第 2 步生成文案(分段改写/换图/试听/加段)、第 3 步配置声音(人声/情绪/语速、合成进度与部分失败重试、全就绪才能下一步)、第 4 步确认生成(9 种转场、4 种动效、字幕四要素、红字字幕覆盖警告、预计时长)、生成后进时间轴编辑导出、8 条常见问题、相关链接
|
||||
- 全部按钮文案/Toast/校验提示按 `QuickVideo.tsx`/`AiMain.tsx`/`AiSetupGuide`/`localStorageService.ts` 源码逐一核实;不用表格(ReactMarkdown 无 remark-gfm)
|
||||
- 菜单改名:顶栏「关于我们」→**「AI 一键出片教程」**(`zhCN.ts` `common_about_us`;en 同步 `AI Quick Video Guide`)
|
||||
- `index.json` 新增 about 条目(标题/描述/日期 2026-11-11/标签 教程·AI)
|
||||
- 部署构建 +线上三重验证:`/articles/about.md` 10516B、index.json 新标题、浏览器实渲染 h1/h2×10/strong×57/li×54/内链与菜单名全部正常(FolderGuard 未选文件夹不渲染主界面属产品设计,验证用临时遮蔽 `showDirectoryPicker` 放行,验毕已还原)
|
||||
|
||||
### 📝 使用教程页面重写(面向新手)
|
||||
|
||||
**`/article/local-deploy-guide` 由旧部署指南全文替换为《米剪新手使用教程》**
|
||||
|
||||
- 正文重写 `public/articles/local-deploy-guide.md`(旧 60 行部署指南删除):十一节新手教程——三个常见疑问、首次「选择本地存储文件夹」引导、首页/项目页/素材页/编辑器界面总览、6 步做出第一个视频(创建项目→素材三选一→时间轴→字幕转场配音→预览→导出)、素材页与项目页详解(上传/下载更多素材/创建文件夹/批量管理删除/点名称改名/自动保存)、编辑器顶栏与左侧 13 面板逐个说明、AI 配置模型与一键出片三选一、快捷键表、工程文件备份迁移、8 条常见问题
|
||||
- 所有按钮名称、键位(Ctrl+B 分割等)、导出选项(480P~4K、MP4/MP3/GIF)均按源码逐一核实;因文章页 ReactMarkdown 未挂 remark-gfm,全文不用表格改用列表(旧文表格本就不渲染)
|
||||
- `public/articles/index.json` 条目同步:标题《米剪新手使用教程》、描述/日期 2026-11-11/标签 教程·新手;`offline-ready` 条目不动
|
||||
- 部署:`SKIP_LOCALIZE=1 SKIP_LINT=1 bash scripts/build.sh` 构建 `0dc5fba572ff` 并重启容器;线上实测 `/articles/local-deploy-guide.md` 11832 字节换新、`index.json` 新标题、页面渲染 h1/h2×12/strong×115/li×98/blockquote×3 与文内链全部正常
|
||||
|
||||
### 🔒 MCP 端点强制 Bearer 鉴权
|
||||
|
||||
**公网必须授权(使用 MCP 一定要授权)**
|
||||
|
||||
- `mcp/server.py` 新增入站鉴权中间件:`/mcp` 一律要求 `Authorization: Bearer <MCP_AUTH_TOKEN>`(`hmac.compare_digest` 恒定时间比较防时序侧信道),不带 / 错误令牌 → `401` + `WWW-Authenticate: Bearer`;`MCP_AUTH_TOKEN` 未配置时拒绝一切调用(fail-closed)
|
||||
- 放行两类路径:`/health`(nginx `/mcp-health` 监控探针)、`/out/*`(`/mcp-out/` 工程 ZIP / 配音 mp3 下载直链,浏览器点开无法附带请求头)
|
||||
- 部署:令牌写项目 `.env` 的 `MCP_AUTH_TOKEN`(git 已忽略不入仓库,`secrets.token_urlsafe(32)` 生成),`docker-compose.yml` 注入该环境变量并重建 `unicut-mcp`
|
||||
- 文档:mcp/README.md 连接示例全部更新为带鉴权头(Claude Desktop `mcp-remote --header` / Claude Code `--header` / Cursor `headers` / Hermes `mcp_servers.headers`),并修正 Hermes 旧示例错误键名 `mcp: servers:` → 官方 `mcp_servers:`;`.env` 清单与验证 curl 同步加令牌;主 README MCP 章节补授权说明
|
||||
- 验证:无令牌 / 错令牌 401 ✓、正确令牌完整握手(initialize 200 + session → initialized 202 → tools/list 9 工具 → `service_status` 真实调用成功)✓、`/mcp-health` 与 `/mcp-out/*.zip` 开放 200 ✓、空令牌 fail-closed 401 ✓
|
||||
|
||||
### ✨ 素材页下载入口
|
||||
|
||||
**工作台素材页新增「下载更多素材」按钮**
|
||||
|
||||
- 上传素材右侧新增独立按钮(样式与同排「图片分割 / 视频分割」一致),点击 `window.open` 新窗口直达素材下载文档站 `https://doc.88531.cn/docs/mrfx/mrfx-1g99qum57n5qk`,与编辑器素材面板的下拉入口互补
|
||||
- 仅素材类型(`props.type === 'material'`)下渲染,不影响其他内容页
|
||||
|
||||
### 🐛 修复(本地模式删除 / 移动)
|
||||
|
||||
**素材与文件夹删除失败、移动到文件夹失效(本地模式无后端)**
|
||||
|
||||
- 根因:素材/文件夹实际存浏览器 IndexedDB + 本地目录,但删除调的是不存在的 `materialServer.deleteMaterial` 与无后端的 `POST /user/categories/delete`(静态站 404,什么都不删);`moveMaterial` 同样调不存在的服务器接口
|
||||
- `SelectedSet.tsx` 删除改本地优先:文件夹走新增的 `deleteLocalCategory`(删分类记录并清空其下素材/项目的分类标记,素材保留在「全部」),素材走 `deleteLocalMaterial`(真删磁盘文件 + IndexedDB 记录,含封面/帧图/音波图)
|
||||
- `material/server.ts` 的 `moveMaterial` 改为直接更新 IndexedDB 分类标记
|
||||
- 浏览器端到端验证:批量删除后 UI 提示「删除成功」,IndexedDB 回读分类与素材记录均为空
|
||||
|
||||
### ✨ 素材存储位置展示
|
||||
|
||||
**素材页显示实际存储路径**
|
||||
|
||||
- `Material.tsx` 页面头部新增「📂 存储位置:〈你选的目录名〉/materials/」提示条,悬浮任一素材名可看该文件相对路径(如 `米剪素材测试目录/materials/abc123/path_test.png`)
|
||||
- 受浏览器 File System Access API 安全限制只能拿到目录名 + 相对路径,拿不到完整绝对路径
|
||||
|
||||
### ✨ 素材面板菜单
|
||||
|
||||
**素材面板新增「下载更多素材」直达入口**
|
||||
|
||||
- 上传素材右侧的下拉菜单(在线录音 / 文字转语音)新增第三项「下载更多素材」,点击在新窗口打开素材下载文档站 `https://doc.88531.cn/docs/mrfx/mrfx-1g99qum57n5qk`
|
||||
- 文案入语言表:`zhCN.my_download_more` / `enUS.my_download_more`,图标用 `Download`(@icon-park/react),菜单项渲染与既有项同构
|
||||
|
||||
### 🤖 MCP 接入
|
||||
|
||||
**新增 `unicut-mcp` 服务:AI 客户端直接调用米剪能力(Model Context Protocol)**
|
||||
|
||||
- 新增 `mcp/` 服务(Python FastMCP,Streamable HTTP):抓取文章 `grab_url`(与前端 `extractFromHtml` 同规则)、口播文案 `generate_script`(OpenAI 兼容网关)、配音 `tts` / `list_voices`(unicut-tts)、工程生成 `create_video_project`、文件夹模式工程读写 `list/read/write_project`、自检 `service_status`
|
||||
- `create_video_project` 产出与米剪导出同构的工程 ZIP(`project.json + materials/{type}/`,过 `checkNdata` 九键门禁):图片校验对齐前端(≥160×120 / ≤10MB)、有配音自动铺满时长、文案按字数加权切字幕,元素结构照抄官方 demo 工程真实字段
|
||||
- nginx 同源反代 `https://<站点>/mcp`(SSE 关缓冲长连接)与 `https://<站点>/mcp-out/*`(工程 ZIP 下载);compose 新增 `unicut-mcp` 服务,密钥走项目 `.env`(`MCP_LLM_KEY` 等,不入库)
|
||||
- 文档:`mcp/README.md`(工具明细 + Claude Desktop / Claude Code / Cursor / Hermes 接入配置 + docker run / compose 两种部署),主 README「AI」章新增 MCP 小节与更新表行
|
||||
- 版本号 `1.0.0 → 1.0.1`(`package.json` / README 发布 tag 同步;授权中心基线仍为 1.0.0,客户端上报 1.0.1 判定「已是最新」)
|
||||
|
||||
### 🐛 修复(/grab/ 抓取)
|
||||
|
||||
- 公众号图片防盗链:`/grab/` 向上游清空 `Referer`(带异源 Referer 时 `mmbiz.qpic.cn` 只给 140×140 降级缩略图,无 Referer 才给原图,实测 2KB vs 47KB)
|
||||
- 正文根节点优先 `#js_content`:微信文章页没有 `article`/`main`,旧选择器会退化到整页 `body` 混进账号栏/留言噪音
|
||||
|
||||
### ✨ 新功能
|
||||
|
||||
**AI 一键出片 · 素材三选一(图片 / Word·PDF 文档 / 网址)**
|
||||
|
||||
- 第 1 步素材来源新增三选一:默认「添加图片」;「上传文档」支持 Word(.docx) 与 PDF,自动提取正文,docx 内嵌图片一并取出当配图,PDF 文字层抽取 + 前几页渲染成画面(扫描件/受保护文档会明确提示换文件);「输入网址」抓取页面正文与配图
|
||||
- 网址抓取走同源 `/grab/` 反代(nginx 动态上游):仅放行 http/https,拒绝回环 / 内网 / 链路本地地址与带凭据(`user:pass@`)URL,防止被当跳板打内网;重定向折返回本域再次校验
|
||||
- 纯文档 / 纯文字素材没有配图时,自动生成一张标题封面,保证时间轴始终有画面可用
|
||||
- 来源打标:素材卡片显示「文档 / 网址」标签,便于区分最近一次导入
|
||||
- PDF.js worker 由 vite 打进本地产物,离线可用;新增依赖 `pdfjs-dist`
|
||||
|
||||
**纯文本对话模型也能出片(提示属实化)**
|
||||
|
||||
- AI 面板出片卡片新增提示:「只需纯文本模型即可使用;模型支持多模态(视觉)就能自动生成出片」
|
||||
- 未配视觉模型时:调用层剥掉消息里的 `image_url` 图片块(避免不支持多模态的主模型被图片顶回错误),文案 prompt 改为「你看不到图片本身,image 按图片编号顺序循环分配画面(第1段填1、第2段填2…循环)」——纯文本模型照样能出完整片
|
||||
- 已配视觉模型时行为不变:逐张压图后看图配画面;`aiVisionAvailable()`(对话模型已配置 && 视觉模型非空)作为唯一判据集中在 `localAi.ts`
|
||||
- 四步说明第 2 步同步改为不依赖视觉能力的表述:「AI 自动写口播文案,每段配好对应画面」
|
||||
|
||||
### 🔧 构建 / 质量
|
||||
|
||||
**`/grab/` 网址反代实测修复(首测即抓出两个致命 bug)**
|
||||
|
||||
- query 传参被误杀:`encodeURIComponent` 的产物 nginx `$arg_` 不做解码,合法目标全部匹配不到 `^https?://` 被打成 400——改为 `X-Grab-Url` 请求头传输目标(免编码),nginx 断言改读 `$http_x_grab_url`,上游侧同名头清空不外泄
|
||||
- 裸域名路径错位:`https://host`(无路径)反代时会把原始 `/grab/?url=…` 请求路径透给上游——前端 `new URL(cur).href` 规范化补默认路径 `/` 后再发
|
||||
- 实测断言:正例抓取成功;回环 127.0.0.1、内网 192.168.x、`file://` 协议、`user:pass@` 带凭据 URL 全部正确拒绝
|
||||
|
||||
**断网 lint 门禁修复(external_refs 20 → 0,门禁恢复全绿)**
|
||||
|
||||
- pdf.js 的 XFA/Adobe XML 命名空间字符串(w3.org / xfa.org / adobe.com 等 17 条)登记入 `NAMESPACE_HOSTS` —— 纯命名空间字符串,浏览器不发请求
|
||||
- pdf.worker 模板字面量 `http://${A}` 的提取截断产物入白名单(仅 `new URL()` 构造,不发起请求)
|
||||
- 代码内两处 `example.com` 示例域名删除:文章生成器占位域名改为中文示意文字、候选解析错误提示不再回显域名
|
||||
- 官方自有域名入白名单并注明理由:`ai.88531.cn`(官方 AI 网关默认接口 `https://ai.88531.cn/v1` +「获取 Key」引导链接)、`nav.88531.cn`(首页导航站入口)—— 产品默认配置本体,断网时静默降级,删掉功能即失效
|
||||
- 实测 `external_refs = 0`(`00_lint_dist.py --dist` 对构建产物复跑确认),`BUILD_EXIT=0`
|
||||
|
||||
### 🏠 首页调整
|
||||
|
||||
**移除「受到众多大品牌信赖」品牌背书块**
|
||||
- 删除首页 Trust Bar 区块(背书文案 + UCAP / YTO圆通 / 中国电信 / 中国移动 4 个 logo)
|
||||
- 同步清理 `home.module.less` 中 `.trustBar` / `.trustLogos` 死样式(含移动端媒体查询覆盖)
|
||||
- 验证:线上 6/6 文本断言通过——背书文案与品牌名全部消失,编辑器展示块(8 项AI / 12+ / 4K)与 AI 功能区完好;截图目检原位置直接衔接「AI 智能功能」区,无空洞错位
|
||||
|
||||
### 🧹 功能调整
|
||||
|
||||
**移除「AI 视频生成 / AI 图片生成」两个页签**
|
||||
- 编辑器左侧「AI创作」面板删除 Ai视频生成、Ai图片生成 页签及其组件(AiVideo / AiImage),保留「一键出片」与「生成结果」
|
||||
- AI 生图 / 生视频能力不受影响:仍可走右侧「AI 助手」对话的图片生成 / 视频生成模式,未配置引导与「配置模型」入口文案不变
|
||||
- 验证:线上面板页签仅剩「一键出片 / 生成结果」;页面文本断言 4/4 通过;构建产物 `main-0605b5a4.js` 中两页签名残留 0 处
|
||||
- 附带修复 ①:AiMain 补回被误删的 `Button` / `QuickVideo` / `useState` 引用,否则面板一渲染就报错
|
||||
- 附带修复 ②:`scripts/build.sh` 与 `docs/免登录改造.md` 硬编码的旧源码路径 `/vol1/1000/HD1/docker/unicut-src` 改为现行 `/vol3/1000/HD3/docker/unicut-src`(仓库迁移残留,此前构建必失败)
|
||||
- 附带修复 ③:构建改走 `DOCKER_BUILDKIT=0` legacy 构建器——本机 docker.io DNS 被污染,buildkit 查基础镜像元数据必然超时;本地已有 `node:20-alpine` / `nginx:1.27-alpine`,legacy 直接用本地镜像
|
||||
|
||||
## 2026-10-28
|
||||
|
||||
### ✨ 新功能
|
||||
|
||||
@@ -47,13 +47,26 @@
|
||||
| 官方 AI 网关默认 | AI 默认接入官方网关 `https://ai.88531.cn/v1`,对话 / 视觉 / 生图 / 生视频模型全部预填,用户只需粘贴自己的 API Key |
|
||||
| 「配置模型」统一入口 | 编辑器右上角一个按钮,统一管理接口地址、API Key 与四个模型 |
|
||||
| 开源入口 | 编辑器右上角新增「开源地址」按钮,一键直达源码仓库 gitee.com/jinghui111/unicut |
|
||||
| AI 面板瘦身 | 左侧「AI创作」移除「AI 视频生成 / AI 图片生成」页签,保留一键出片与生成结果;生图 / 生视频走 AI 助手对话 |
|
||||
| 首页去背书 | 移除首页「受到众多大品牌信赖」与 UCAP / 圆通 / 中国电信 / 中国移动 品牌 logo 背书区 |
|
||||
| AI 一键出片 | 添加图片 → AI 生成口播文案 → 13 种人声配音试听 → 一键排入时间轴,转场 / 动效 / 字幕样式可调 |
|
||||
| 模板导入修复 | 修复"导入第一个模板后,再导入会把浏览器拖崩"的问题,支持连续换模板 |
|
||||
| 品牌与首页 | 产品名改为米剪,首页新增导航站 / 开源地址入口,移除收费栏目与账号类外链 |
|
||||
| 接入授权中心 | 版本号、公告、检查更新(授权中心不可达时静默降级,绝不拦功能) |
|
||||
| MCP 接入 | 新增 `unicut-mcp` 服务:Claude / Cursor / Hermes 等 AI 客户端经 `https://<站点>/mcp` 调用抓取文章、生成口播、edge-tts 配音、生成米剪工程 ZIP;端点强制 `Authorization: Bearer` 鉴权(公网必须授权) |
|
||||
|
||||
### 最近更新(2026-10-28)
|
||||
### 最近更新(2026-11-11)
|
||||
|
||||
- **工作台素材页「下载更多素材」按钮**:上传素材旁新增独立按钮,点击新窗口直达素材下载文档站 https://doc.88531.cn/docs/mrfx/mrfx-1g99qum57n5qk;
|
||||
- **本地素材/文件夹删除修复**:批量删除原本调不存在的 `deleteMaterial` 与无后端的服务器接口,实际什么都没删;现改为本地删除(分类记录 + 磁盘文件 + 封面/帧图/音波图),端到端验证通过;
|
||||
- **素材页显示实际存储路径**:页面头部显示「📂 存储位置:〈目录名〉/materials/」,悬浮素材名可看单个文件路径;
|
||||
- **移动素材到文件夹修复**:`moveMaterial` 原调不存在的服务器接口,现直接更新本地分类标记;
|
||||
- **素材面板「下载更多素材」入口**:上传素材旁的下拉菜单(在线录音 / 文字转语音)新增第三项,点击新窗口直达素材下载文档站 https://doc.88531.cn/docs/mrfx/mrfx-1g99qum57n5qk;
|
||||
- **AI 一键出片素材三选一**:图片 / Word·PDF 文档(自动提取正文与配图,扫描件有提示)/ 网址自动抓取正文和配图(同源 `/grab/` 反代,拒绝内网回环目标);纯文字素材自动补标题封面;
|
||||
- **纯文本模型也能出片**:出片卡片新增提示「只需纯文本模型即可使用;模型支持多模态(视觉)就能自动生成出片」;未配视觉模型时剥掉图片块、按图片编号循环分配画面,纯文本主模型不再被顶回错误;
|
||||
- **断网 lint 门禁修复**:`external_refs` 20 → 0(PDF.js 命名空间入册、示例域名清除、官方自有域名注明理由入白名单),构建门禁恢复全绿;
|
||||
- **首页移除品牌背书块**:删掉「受到众多大品牌信赖」与 UCAP / 圆通 / 中国电信 / 中国移动 logo 区,功能展示与 AI 功能区直接衔接;
|
||||
- **移除 AI 视频生成 / AI 图片生成页签**:左侧「AI创作」面板只保留「一键出片」与「生成结果」,生图 / 生视频走 AI 助手对话;
|
||||
- **AI 默认接入官方网关**:接口地址与模型全部预填,用户只需粘贴 API Key;
|
||||
- **「配置模型」统一入口**:AI 面板里分散的设置按钮下线,全部收进编辑器右上角;
|
||||
- **模板导入连环崩溃修复**:连续导入多个模板不再拖崩浏览器;
|
||||
@@ -181,6 +194,22 @@ UNICUT 是一款面向创作者、开发者与企业团队的在线视频编辑
|
||||
> [!IMPORTANT]
|
||||
> AI 对话、AI 一键出片、AI 生图 / 生视频默认接入官方 AI 网关(`ai.88531.cn`),在编辑器右上角「配置模型」粘贴一个 API Key 即可解锁,对话 `mimo-v2.6-flash`、视觉 `deepseek-v4-flash-vision-exp`、生图 `flux-schnell`、生视频 `inkling` 均已预填。配音(本机 edge-tts)、抠图、字幕、导出等能力不消耗任何外部额度。
|
||||
|
||||
### MCP:让 AI 客户端直接调用米剪
|
||||
|
||||
米剪内置 [MCP](https://modelcontextprotocol.io)(Model Context Protocol)服务 `unicut-mcp`,站点同源端点 `https://<站点>/mcp`。接入后,Claude Desktop、Claude Code、Cursor、Hermes 等 AI 客户端可以把米剪当工具用:
|
||||
|
||||
> 🔒 **端点强制授权**:`/mcp` 暴露在公网,请求必须携带 `Authorization: Bearer <MCP_AUTH_TOKEN>`(令牌在项目 `.env`,未配置时拒绝一切调用),否则返回 401;各客户端带鉴权头的接入示例见 [mcp/README.md](./mcp/README.md)。
|
||||
|
||||
| 工具 | 能力 |
|
||||
| --- | --- |
|
||||
| `grab_url` | 抓网页正文与配图(公众号文章可用,规则与编辑器内抓取一致) |
|
||||
| `generate_script` | 大模型生成短视频口播文案 |
|
||||
| `tts` / `list_voices` | edge-tts 多音色配音(本机免费) |
|
||||
| `create_video_project` | 图片 + 文案 + 配音 → 生成米剪工程 ZIP,米剪「工程文件」一键导入即可出片 |
|
||||
| `list_projects` / `read_project` / `write_project` | 工作文件夹模式下的工程读写 |
|
||||
|
||||
典型工作流:*AI 抓文章 → 写口播 → 配音 → 生成工程 ZIP → 你在米剪导入*。部署、客户端接入配置与工具明细见 [mcp/README.md](./mcp/README.md)。
|
||||
|
||||
## 🧰 技术实现
|
||||
|
||||
米剪采用 React + TypeScript 构建编辑器界面与业务层,通过 MobX 管理复杂编辑状态;画布由 PixiJS / WebGL 实时渲染,音视频解码、处理和导出由 Web Worker、FFmpeg WebAssembly、MediaBunny 等能力协同完成。素材文件可写入用户授权的本地目录,工程元数据和文件句柄通过 Dexie / IndexedDB 管理。
|
||||
@@ -207,14 +236,65 @@ docker run -d --name unicut -p 3006:80 -p 3005:443 \
|
||||
gitea.88531.cn/jinghui/unicut:latest
|
||||
```
|
||||
|
||||
打开 `http://服务器IP:3006` 即用。Registry 地址 `gitea.88531.cn` 免登录可拉;镜像与源码构建产物完全一致,每次发版同步更新 `latest` 与 `v1.0.0` 两个 tag。
|
||||
打开 `http://服务器IP:3006` 即用。Registry 地址 `gitea.88531.cn` 免登录可拉;镜像与源码构建产物完全一致,每次发版同步更新 `latest` 与 `v1.0.1` 两个 tag。
|
||||
|
||||
### 方式二:源码 compose 构建
|
||||
### 方式二:Docker Compose部署(源码 compose 构建)
|
||||
|
||||
完整 `docker-compose.yml`(含全部参数,与仓库根目录文件一致):
|
||||
|
||||
```yaml
|
||||
services:
|
||||
unicut:
|
||||
build: .
|
||||
container_name: unicut
|
||||
restart: always
|
||||
ports:
|
||||
- "3005:443"
|
||||
- "3006:80"
|
||||
environment:
|
||||
# 公网部署:不注入任何模型密钥,AI 功能一律用户自带 Key
|
||||
# 授权中心(auth.88531.cn)项目密钥:只注入 nginx 反代头,不进前端
|
||||
- HUB_KEY=${HUB_KEY:-}
|
||||
# 项目编号(非机密):启动时由 entrypoint 替换进前端包,用于公告/装机统计归属
|
||||
- HUB_PROJECT_ID=${HUB_PROJECT_ID:-}
|
||||
volumes:
|
||||
- certs:/etc/nginx/certs
|
||||
|
||||
# 本机语音合成(edge-tts),给免登录版提供配音能力;源码在 ../unicut-tts
|
||||
unicut-tts:
|
||||
build: ../unicut-tts
|
||||
container_name: unicut-tts
|
||||
restart: always
|
||||
volumes:
|
||||
- ../unicut-tts/audio:/data/audio
|
||||
|
||||
# MCP 服务(Model Context Protocol):AI 客户端经 https://<站点>/mcp 调用米剪能力
|
||||
# (抓取正文配图 / 大模型口播文案 / edge-tts 配音 / 生成米剪工程 ZIP)。
|
||||
# 密钥与站点地址从项目 .env 注入(MCP_LLM_KEY 等,勿提交仓库)。
|
||||
unicut-mcp:
|
||||
build: ./mcp
|
||||
container_name: unicut-mcp
|
||||
restart: always
|
||||
environment:
|
||||
- MCP_LLM_BASE=${MCP_LLM_BASE:-http://192.168.68.19:3099/v1}
|
||||
- MCP_LLM_KEY=${MCP_LLM_KEY:-}
|
||||
- MCP_LLM_MODEL=${MCP_LLM_MODEL:-mimo-v2.6-flash}
|
||||
- MCP_PUBLIC_URL=${MCP_PUBLIC_URL:-https://127.0.0.1:3005}
|
||||
- MCP_AUTH_TOKEN=${MCP_AUTH_TOKEN:-}
|
||||
- MCP_PROJECTS_DIR=${MCP_PROJECTS_DIR:-}
|
||||
volumes:
|
||||
# 生成的工程 ZIP / 配音 mp3 落盘(nginx /mcp-out/ 提供下载)
|
||||
- ./mcp-out:/data/out
|
||||
|
||||
volumes:
|
||||
certs:
|
||||
```
|
||||
|
||||
```bash
|
||||
git clone https://gitee.com/jinghui111/unicut.git
|
||||
cd unicut
|
||||
docker compose up -d unicut
|
||||
docker compose up -d unicut # 只启动编辑器
|
||||
docker compose up -d # 全量(含配音 unicut-tts 与 MCP unicut-mcp)
|
||||
```
|
||||
|
||||
首次构建包含前端打包,约需几分钟。完成后浏览器访问:
|
||||
@@ -226,6 +306,7 @@ http://服务器IP:3006
|
||||
- 端口映射:`3006 → 80`(HTTP)、`3005 → 443`(HTTPS,自签证书,首次访问需接受一次证书警告);
|
||||
- 首次进入按提示选择一个本地文件夹并授权,工程与素材即保存在该文件夹;
|
||||
- 可选:在 `.env` 里配置 `HUB_KEY` / `HUB_PROJECT_ID` 接入授权中心(公告 / 版本检查),不配置不影响任何功能;
|
||||
- 可选:在 `.env` 里配置 `MCP_LLM_KEY`(OpenAI 兼容网关 Key)启用 MCP 的文案生成,AI 客户端连接 `https://<站点>/mcp`,工具明细见 [mcp/README.md](./mcp/README.md);不配置则除大模型类工具外均可使用;
|
||||
- 完整版另含配音服务 `unicut-tts`(本机 edge-tts),需单独部署该服务后用 `docker compose up -d` 全量启动;只用编辑器按上面的 `up -d unicut` 即可。
|
||||
|
||||
### 方式三:本地开发
|
||||
|
||||
@@ -109,7 +109,10 @@ def load_allowlist():
|
||||
return rules
|
||||
|
||||
|
||||
NAMESPACE_HOSTS = {'www.w3.org', 'purl.org', 'schemas.openxmlformats.org', 'www.opengis.net'}
|
||||
NAMESPACE_HOSTS = {'www.w3.org', 'purl.org', 'schemas.openxmlformats.org', 'www.opengis.net',
|
||||
# pdf.js XFA/XMP:XML 命名空间与 schema 标识符(xmlns:xfa=...、startsWith判断),
|
||||
# 浏览器不会发起请求,与 w3.org 同类
|
||||
'www.xfa.org', 'ns.adobe.com'}
|
||||
DOC_EXT = {'.md', '.map', '.txt'}
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
# 说明:unpkg.com / cdn.jsdelivr.net 不在清单里 —— 它们出现在 vendored ffmpeg/tesseract
|
||||
# 的默认参数中,已通过改写 public/ 下的文件指向本地路径,lint 必须能发现回归。
|
||||
|
||||
^http://\$$ allow pdf.worker 模板字面量 http://${A} 的提取截断产物,仅 new URL() 构造不发起请求
|
||||
^https://ai\.88531\.cn(/.*)?$ allow 自有域名:官方 AI 网关默认接口地址与「获取 Key」引导链接(产品默认配置本体,删掉功能即失效;断网时静默降级不拦功能)
|
||||
^https://nav\.88531\.cn(/.*)?$ allow 自有域名:首页导航站入口链接(纯跳转,断网时点击打不开但不影响编辑器功能)
|
||||
github\.com allow vendored 依赖(pixi/semi/opencv 等)压缩产物里的项目主页与许可证链接,仅字符串
|
||||
gist\.github\.com allow vendored 依赖 README 片段里的示例链接,仅字符串
|
||||
raw\.githubusercontent\.com allow vendored 依赖 README 片段里的源码链接,仅字符串
|
||||
|
||||
@@ -23,5 +23,23 @@ services:
|
||||
volumes:
|
||||
- ../unicut-tts/audio:/data/audio
|
||||
|
||||
# MCP 服务(Model Context Protocol):AI 客户端经 https://<站点>/mcp 调用米剪能力
|
||||
# (抓取正文配图 / 大模型口播文案 / edge-tts 配音 / 生成米剪工程 ZIP)。
|
||||
# 密钥与站点地址从项目 .env 注入(MCP_LLM_KEY 等,勿提交仓库)。
|
||||
unicut-mcp:
|
||||
build: ./mcp
|
||||
container_name: unicut-mcp
|
||||
restart: always
|
||||
environment:
|
||||
- MCP_LLM_BASE=${MCP_LLM_BASE:-http://192.168.68.19:3099/v1}
|
||||
- MCP_LLM_KEY=${MCP_LLM_KEY:-}
|
||||
- MCP_LLM_MODEL=${MCP_LLM_MODEL:-mimo-v2.6-flash}
|
||||
- MCP_PUBLIC_URL=${MCP_PUBLIC_URL:-https://127.0.0.1:3005}
|
||||
- MCP_AUTH_TOKEN=${MCP_AUTH_TOKEN:-}
|
||||
- MCP_PROJECTS_DIR=${MCP_PROJECTS_DIR:-}
|
||||
volumes:
|
||||
# 生成的工程 ZIP / 配音 mp3 落盘(nginx /mcp-out/ 提供下载)
|
||||
- ./mcp-out:/data/out
|
||||
|
||||
volumes:
|
||||
certs:
|
||||
@@ -100,7 +100,7 @@ POST /localtts/tts {text, voice} → {"url":"/localtts/audio/<hash>.mp3", "voi
|
||||
## 构建与发布
|
||||
|
||||
```bash
|
||||
cd /vol1/1000/HD1/docker/unicut-src
|
||||
cd /vol3/1000/HD3/docker/unicut-src
|
||||
docker compose build unicut
|
||||
docker compose up -d --no-build
|
||||
```
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# 米剪 MCP 服务:Streamable HTTP 端点 /mcp(8765),由 unicut nginx 同源反代
|
||||
FROM docker.1ms.run/library/python:3.11-slim
|
||||
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=1
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY server.py .
|
||||
|
||||
EXPOSE 8765
|
||||
|
||||
CMD ["python", "server.py"]
|
||||
@@ -0,0 +1,125 @@
|
||||
# 米剪 MCP 服务(unicut-mcp)
|
||||
|
||||
让 AI 客户端以 [Model Context Protocol](https://modelcontextprotocol.io) 工具的形式调用米剪的创作能力:抓文章、写口播、配语音、生成米剪工程,人在米剪里打开就能剪。
|
||||
|
||||
```
|
||||
AI(Claude / Cursor / Hermes …)
|
||||
│ MCP(Streamable HTTP)
|
||||
▼
|
||||
https://<米剪站点>/mcp ──► unicut-mcp 容器(本目录)
|
||||
├─ grab_url 抓网页正文与配图(公众号文章可用)
|
||||
├─ generate_script 大模型生成口播文案(OpenAI 兼容网关)
|
||||
├─ tts / list_voices edge-tts 配音(unicut-tts 容器)
|
||||
├─ create_video_project 生成米剪工程 ZIP → 米剪「工程文件」导入
|
||||
└─ list/read/write_project 工作文件夹(文件夹模式)工程读写
|
||||
```
|
||||
|
||||
## 工具一览
|
||||
|
||||
| 工具 | 作用 | 典型返回 |
|
||||
| --- | --- | --- |
|
||||
| `service_status` | 自检抓取/配音/大模型/工程目录可用性 | 各依赖状态 |
|
||||
| `grab_url(url)` | 抓取网页正文与配图(规则与前端 `extractFromHtml` 一致:`#js_content` 优先、懒加载属性、12000 字截断) | `{title, text, images[]}` |
|
||||
| `generate_script(source, requirement?, style?, target_seconds?, paragraph_count?)` | 大模型写口播文案,严格 JSON 输出 | `{title, paragraphs[], text}` |
|
||||
| `list_voices()` | edge-tts 音色列表 | `{count, voices[]}` |
|
||||
| `tts(text, voice?, rate?, pitch?, volume?)` | 合成配音,音频落盘并给出可播放 URL | `{url, path, duration}` |
|
||||
| `create_video_project(title, images, script?, audio?, width?, height?, …)` | 下载素材 → 组装 MovieData → 打包工程 ZIP(`project.json + materials/`,与米剪导出格式同构,过 `checkNdata` 九键门禁) | `{zip_path, zip_url, duration, captions, elements}` |
|
||||
| `list_projects()` / `read_project(id)` / `write_project(project)` | 工作文件夹模式下直接读写 `projects/*.json`(需配置 `MCP_PROJECTS_DIR`) | 工程 JSON |
|
||||
|
||||
`create_video_project` 细节:
|
||||
|
||||
- 图片校验与前端一致:≥160×120、≤10MB、识别失败自动跳过并在 `warnings` 里说明;
|
||||
- 有配音时图片自动拉伸平铺铺满配音时长,无配音时每图 `image_duration`(默认 3 秒);
|
||||
- `script` 按 `\n` 分段成字幕(单段超 24 字自动按句拆),按字数加权分配时间;
|
||||
- 字幕/图片/音频元素结构照抄官方 demo 工程(`public/assets/demo/test-app.json`)真实字段。
|
||||
|
||||
## 连接方式
|
||||
|
||||
**端点**:`https://<米剪站点>/mcp`(Streamable HTTP;本机默认 `https://127.0.0.1:3005/mcp`,自签证书需客户端允许 insecure)。局域网内也可直连容器端口 `http://<主机>:8765/mcp`(默认只在 compose 网络内,未映射宿主端口)。
|
||||
|
||||
> 🔒 **必须授权**:服务暴露在公网,`/mcp` 一律要求请求头 `Authorization: Bearer <MCP_AUTH_TOKEN>`(令牌取项目 `.env` 的 `MCP_AUTH_TOKEN`;未配置令牌时服务拒绝一切调用,fail-closed)。不带 / 错误令牌返回 `401 {"error":"unauthorized"}`。仅两类路径开放:`/mcp-health`(监控探针)与 `/mcp-out/*`(工程 ZIP / 配音 mp3 下载直链,浏览器点开无法附带请求头)。
|
||||
|
||||
**Claude Desktop**(`claude_desktop_config.json`):
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"unicut": {
|
||||
"command": "npx",
|
||||
"args": ["mcp-remote", "https://127.0.0.1:3005/mcp", "--allow-self-signed", "--header", "Authorization: Bearer <令牌>"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Claude Code**:
|
||||
|
||||
```bash
|
||||
claude mcp add unicut --transport http --header "Authorization: Bearer <令牌>" https://127.0.0.1:3005/mcp
|
||||
```
|
||||
|
||||
**Cursor**(`~/.cursor/mcp.json`):
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"unicut": {
|
||||
"url": "https://127.0.0.1:3005/mcp",
|
||||
"headers": { "Authorization": "Bearer <令牌>" }
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Hermes**(`~/.hermes` 或项目 `config.yaml`):
|
||||
|
||||
```yaml
|
||||
mcp_servers:
|
||||
unicut:
|
||||
url: https://127.0.0.1:3005/mcp
|
||||
headers:
|
||||
Authorization: "Bearer <令牌>"
|
||||
```
|
||||
|
||||
## 部署
|
||||
|
||||
compose 已内置 `unicut-mcp` 服务(本仓库 `docker-compose.yml`),密钥走项目 `.env`:
|
||||
|
||||
```bash
|
||||
# .env(勿提交)
|
||||
MCP_LLM_BASE=http://192.168.68.19:3099/v1 # OpenAI 兼容 /v1 网关
|
||||
MCP_LLM_KEY=sk-xxxx # 网关 Key
|
||||
MCP_LLM_MODEL=mimo-v2.6-flash
|
||||
MCP_PUBLIC_URL=https://127.0.0.1:3005 # 对外站点地址(生成 zip_url / 音频 URL 用)
|
||||
MCP_AUTH_TOKEN=<随机长串> # 必填:/mcp 的 Bearer 令牌(公网必须授权;python3 -c 'import secrets;print(secrets.token_urlsafe(32))' 生成)
|
||||
MCP_PROJECTS_DIR= # 可选:米剪「选择文件夹」的同一目录(文件夹模式)
|
||||
```
|
||||
|
||||
```bash
|
||||
docker compose up -d --build unicut-mcp
|
||||
```
|
||||
|
||||
单独运行(不走 nginx):
|
||||
|
||||
```bash
|
||||
docker build -t unicut-mcp ./mcp
|
||||
docker run -d --name unicut-mcp --restart always \
|
||||
-e MCP_LLM_KEY=sk-xxxx -e MCP_LLM_BASE=http://192.168.68.19:3099/v1 \
|
||||
-p 8765:8765 -v "$PWD/mcp-out:/data/out" unicut-mcp
|
||||
```
|
||||
|
||||
> 只有 `service_status` / `grab_url` / `generate_script` 需要网络依赖;`tts` 依赖同 compose 的 `unicut-tts`;不配置 `.env` 时除大模型类工具外均可使用。
|
||||
|
||||
## 验证
|
||||
|
||||
```bash
|
||||
# 协议握手(必须带 Authorization,否则 401)
|
||||
curl -sk https://127.0.0.1:3005/mcp -H 'Content-Type: application/json' \
|
||||
-H 'Accept: application/json, text/event-stream' \
|
||||
-H "Authorization: Bearer $MCP_AUTH_TOKEN" \
|
||||
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"0"}}}'
|
||||
|
||||
# 预期:不带令牌 → 401 {"ok":false,"error":"unauthorized"} + WWW-Authenticate: Bearer
|
||||
```
|
||||
|
||||
产物下载:`https://<站点>/mcp-out/<工程名>.zip`;健康检查:经 nginx 用 `https://<站点>/mcp-health`,直连容器用 `http://<容器>:8765/health`(`/mcp/health` 不是端点,会被 SPA 回退成首页 HTML)。
|
||||
@@ -0,0 +1,5 @@
|
||||
mcp>=1.9.0,<2
|
||||
httpx>=0.27.0
|
||||
beautifulsoup4>=4.12.0
|
||||
pillow>=10.0.0
|
||||
mutagen>=1.47.0
|
||||
@@ -0,0 +1,914 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
米剪(Unicut)MCP 服务
|
||||
======================
|
||||
|
||||
让 AI 客户端(Claude Desktop / Claude Code / Cursor / Hermes 等)以 MCP 工具的形式
|
||||
调用米剪的创作能力:
|
||||
|
||||
- grab_url 抓取网页正文与配图(公众号文章等,复用前端 extractFromHtml 规则)
|
||||
- generate_script 大模型生成短视频口播文案
|
||||
- tts / list_voices edge-tts 配音合成(unicut-tts)
|
||||
- create_video_project 组装米剪工程 ZIP(project.json + materials/),在米剪「工程文件」一键导入
|
||||
- list_projects / read_project 工作文件夹(文件夹模式)下的工程读写
|
||||
- service_status 各依赖服务可用性自检
|
||||
|
||||
传输:Streamable HTTP,端点 /mcp(容器 8765,nginx 同源反代 https://<站点>/mcp)。
|
||||
工程格式:与米剪 projectExport.ts 导出的 ZIP 完全同构——
|
||||
project.json MovieData(title/poster/width/height/background/transitions/
|
||||
captions/elements/resouces 九键齐全,过 checkNdata 门禁)
|
||||
materials/{type}/{文件名} 素材相对路径
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import hmac
|
||||
import io
|
||||
import ipaddress
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import socket
|
||||
import time
|
||||
import unicodedata
|
||||
import uuid
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
from urllib.parse import urljoin, urlparse
|
||||
|
||||
import httpx
|
||||
from bs4 import BeautifulSoup
|
||||
from mutagen.mp3 import MP3
|
||||
from PIL import Image
|
||||
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
# ---------------------------------------------------------------- 环境配置
|
||||
|
||||
UNICUT_URL = os.getenv("UNICUT_URL", "http://unicut") # nginx 80(回环到 443)
|
||||
TTS_URL = os.getenv("TTS_URL", "http://unicut-tts:8000")
|
||||
LLM_BASE = os.getenv("MCP_LLM_BASE", "http://192.168.68.19:3099/v1").rstrip("/")
|
||||
LLM_KEY = os.getenv("MCP_LLM_KEY", "")
|
||||
LLM_MODEL = os.getenv("MCP_LLM_MODEL", "mimo-v2.6-flash")
|
||||
PUBLIC_URL = os.getenv("MCP_PUBLIC_URL", "https://127.0.0.1:3005").rstrip("/")
|
||||
PROJECTS_DIR = os.getenv("MCP_PROJECTS_DIR", "") # 文件夹模式工作目录(可空)
|
||||
OUT_DIR = Path(os.getenv("MCP_OUT_DIR", "/data/out"))
|
||||
AUTH_TOKEN = os.getenv("MCP_AUTH_TOKEN", "").strip() # 入站 Bearer 令牌(公网必授权;为空则拒绝一切调用)
|
||||
|
||||
IMG_MIN_W, IMG_MIN_H = 160, 120 # 与前端 sourceImport.ts 常量一致
|
||||
IMG_MAX_BYTES = 10 * 1024 * 1024
|
||||
HTTP_HEADERS = {
|
||||
# 无 Referer:公众号图床 mmbiz.qpic.cn 带异源 Referer 时只给降级缩略图(实测)
|
||||
"User-Agent": (
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
|
||||
"(KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"
|
||||
),
|
||||
"Accept": "*/*",
|
||||
"Accept-Language": "zh-CN,zh;q=0.9",
|
||||
}
|
||||
|
||||
mcp = FastMCP(
|
||||
"unicut",
|
||||
instructions=(
|
||||
"米剪(Unicut)在线视频剪辑器的 MCP 服务。"
|
||||
"典型工作流:grab_url 抓文章 → generate_script 写口播 → tts 配音 → "
|
||||
"create_video_project 生成米剪工程 ZIP → 用户在米剪「工程文件」导入即可出片。"
|
||||
),
|
||||
host="0.0.0.0",
|
||||
port=8765,
|
||||
)
|
||||
|
||||
|
||||
def _client(timeout: float = 30.0) -> httpx.AsyncClient:
|
||||
# trust_env=False:不读宿主代理变量,容器网络行为可预期
|
||||
return httpx.AsyncClient(timeout=timeout, follow_redirects=True, trust_env=False)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 安全与小工具
|
||||
|
||||
def assert_public_url(url: str) -> str:
|
||||
"""拒绝非 http(s) 与内网/回环目标(与 nginx /grab/ 的断言同规则,防 SSRF 打内网)"""
|
||||
p = urlparse(url)
|
||||
if p.scheme not in ("http", "https"):
|
||||
raise ValueError(f"只支持 http/https URL:{url}")
|
||||
host = p.hostname
|
||||
if not host:
|
||||
raise ValueError(f"URL 缺少主机名:{url}")
|
||||
if host == "localhost" or host.endswith(".local"):
|
||||
raise ValueError(f"拒绝内网/回环目标:{host}")
|
||||
try:
|
||||
infos = socket.getaddrinfo(host, None, proto=socket.IPPROTO_TCP)
|
||||
except socket.gaierror as e:
|
||||
raise ValueError(f"域名解析失败:{host}({e})")
|
||||
for info in infos:
|
||||
ip = ipaddress.ip_address(info[4][0])
|
||||
if ip.is_private or ip.is_loopback or ip.is_link_local or ip.is_reserved or ip.is_multicast:
|
||||
raise ValueError(f"拒绝内网地址目标:{host} → {ip}")
|
||||
return str(p)
|
||||
|
||||
|
||||
def _uid() -> str:
|
||||
return uuid.uuid4().hex[:10]
|
||||
|
||||
|
||||
def _slug(name: str) -> str:
|
||||
"""文件名安全化:保留中英文数字,替换掉路径/控制字符"""
|
||||
s = unicodedata.normalize("NFKC", name or "project")
|
||||
s = re.sub(r'[\\/:*?"<>|\r\n\t]', "-", s).strip(" .")
|
||||
return (s or "project")[:60]
|
||||
|
||||
|
||||
def _ext_for(content_type: str, url: str, default: str = "bin") -> str:
|
||||
ct = (content_type or "").split(";")[0].strip().lower()
|
||||
table = {
|
||||
"image/jpeg": "jpg", "image/jpg": "jpg", "image/png": "png",
|
||||
"image/webp": "webp", "image/gif": "gif", "audio/mpeg": "mp3",
|
||||
"audio/mp3": "mp3", "audio/wav": "wav", "audio/x-wav": "wav",
|
||||
"audio/mp4": "m4a", "audio/aac": "aac",
|
||||
}
|
||||
if ct in table:
|
||||
return table[ct]
|
||||
suffix = Path(urlparse(url).path).suffix.lstrip(".").lower()
|
||||
return suffix or default
|
||||
|
||||
|
||||
def _is_local_path(s: str) -> bool:
|
||||
return s.startswith("/") and not s.startswith("//")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 抓取(对齐前端 extractFromHtml)
|
||||
|
||||
_BLOCK_TAGS = [
|
||||
"p", "h1", "h2", "h3", "h4", "h5", "h6", "li", "blockquote", "pre",
|
||||
"td", "th", "figcaption", "tr", "div", "br",
|
||||
]
|
||||
_NOISE_TAGS = [
|
||||
"script", "style", "noscript", "svg", "iframe", "canvas", "form",
|
||||
"nav", "footer", "header", "aside", "button",
|
||||
]
|
||||
|
||||
|
||||
def extract_from_html(html: str, base_url: str) -> dict:
|
||||
"""标题 / 正文 / 配图(相对转绝对、懒加载属性、去重)——与前端规则一致"""
|
||||
soup = BeautifulSoup(html, "html.parser")
|
||||
|
||||
og = soup.find("meta", attrs={"property": "og:title"})
|
||||
title = ((og.get("content") if og else None) or soup.title.get_text() if soup.title else "").strip()
|
||||
|
||||
for el in soup.find_all(_NOISE_TAGS):
|
||||
el.decompose()
|
||||
|
||||
root = (
|
||||
soup.find(id="js_content") # 公众号正文(微信页无 article/main)
|
||||
or soup.find("article")
|
||||
or soup.find("main")
|
||||
or soup.find(attrs={"role": "main"})
|
||||
or soup.body
|
||||
or soup
|
||||
)
|
||||
|
||||
# 图片:og:image 优先 + img 常见懒加载属性
|
||||
seen: set[str] = set()
|
||||
images: list[str] = []
|
||||
|
||||
def push(v: str | None) -> None:
|
||||
if not v:
|
||||
return
|
||||
s = v.strip()
|
||||
if not s or s.startswith("data:") or s.startswith("blob:"):
|
||||
return
|
||||
if re.search(r"\.svg(\?|#|$)", s, re.I):
|
||||
return
|
||||
try:
|
||||
absu = urljoin(base_url, s)
|
||||
except Exception:
|
||||
return
|
||||
if not re.match(r"^https?:", absu, re.I) or absu in seen:
|
||||
return
|
||||
seen.add(absu)
|
||||
images.append(absu)
|
||||
|
||||
og_img = soup.find("meta", attrs={"property": "og:image"})
|
||||
push(og_img.get("content") if og_img else None)
|
||||
for img in root.find_all("img"):
|
||||
for attr in ("src", "data-src", "data-original", "data-lazy-src", "data-actualsrc"):
|
||||
push(img.get(attr))
|
||||
|
||||
# 正文:块级边界补换行 → textContent → 压空白(照抄前端清洗链)
|
||||
for el in root.find_all(_BLOCK_TAGS):
|
||||
el.insert(0, "\n")
|
||||
el.append("\n")
|
||||
text = (
|
||||
root.get_text()
|
||||
.replace("\r", "")
|
||||
.replace("\t", " ")
|
||||
.replace(" ", " ")
|
||||
)
|
||||
lines = [seg.strip() for seg in text.split("\n")]
|
||||
kept: list[str] = []
|
||||
for i, seg in enumerate(lines):
|
||||
if seg or (i > 0 and lines[i - 1]):
|
||||
kept.append(seg)
|
||||
text = re.sub(r"\n{3,}", "\n\n", "\n".join(kept)).strip()[:12000]
|
||||
|
||||
return {"title": title, "text": text, "images": images[:20]}
|
||||
|
||||
|
||||
async def fetch_bytes(url: str, *, allow_local_file: bool = True, timeout: float = 25.0) -> tuple[bytes, str]:
|
||||
"""下载字节。url 可为公网 URL,或(默认允许)服务器本地文件路径。"""
|
||||
if _is_local_path(url):
|
||||
if not allow_local_file:
|
||||
raise ValueError("此上下文不允许本地路径")
|
||||
p = Path(url)
|
||||
if not p.is_file():
|
||||
raise ValueError(f"本地文件不存在:{url}")
|
||||
return p.read_bytes(), ""
|
||||
assert_public_url(url)
|
||||
async with _client(timeout) as c:
|
||||
r = await c.get(url, headers=HTTP_HEADERS)
|
||||
r.raise_for_status()
|
||||
return r.content, r.headers.get("content-type", "")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 大模型
|
||||
|
||||
async def _llm_chat(messages: list[dict], *, temperature: float = 0.7, max_tokens: int = 8000) -> str:
|
||||
if not LLM_KEY:
|
||||
raise ValueError("未配置 MCP_LLM_KEY(compose .env),无法调用大模型")
|
||||
async with _client(timeout=180.0) as c:
|
||||
r = await c.post(
|
||||
f"{LLM_BASE}/chat/completions",
|
||||
headers={"Authorization": f"Bearer {LLM_KEY}"},
|
||||
json={
|
||||
"model": LLM_MODEL,
|
||||
"messages": messages,
|
||||
"temperature": temperature,
|
||||
"max_tokens": max_tokens,
|
||||
},
|
||||
)
|
||||
if r.status_code >= 400:
|
||||
raise ValueError(f"大模型网关 {r.status_code}: {r.text[:300]}")
|
||||
data = r.json()
|
||||
return data["choices"][0]["message"]["content"]
|
||||
|
||||
|
||||
def _parse_json_block(s: str) -> dict | None:
|
||||
s = s.strip()
|
||||
m = re.search(r"\{.*\}", s, re.S)
|
||||
if not m:
|
||||
return None
|
||||
try:
|
||||
return json.loads(m.group(0))
|
||||
except json.JSONDecodeError:
|
||||
# 容忍 ```json 围栏 / 尾逗号
|
||||
cleaned = re.sub(r"^```(?:json)?|```$", "", m.group(0), flags=re.M).strip()
|
||||
cleaned = re.sub(r",\s*([}\]])", r"\1", cleaned)
|
||||
try:
|
||||
return json.loads(cleaned)
|
||||
except json.JSONDecodeError:
|
||||
return None
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 工程组装(MovieData)
|
||||
|
||||
def _split_captions(script: str, total: float, audio_dur: float | None) -> list[dict]:
|
||||
"""口播文案 → 字幕段(按字符数加权切分时间轴;有配音时铺满配音时长)"""
|
||||
raw = [ln.strip() for ln in re.split(r"\n+", script) if ln.strip()]
|
||||
lines: list[str] = []
|
||||
for ln in raw:
|
||||
if len(ln) <= 24:
|
||||
lines.append(ln)
|
||||
else: # 长段按句切(保留标点)
|
||||
parts = [s for s in re.split(r"(?<=[。!?!?;;])", ln) if s.strip()]
|
||||
lines.extend([p.strip() for p in parts] if parts else [ln])
|
||||
if not lines:
|
||||
return []
|
||||
|
||||
timeline = audio_dur if audio_dur else total
|
||||
if timeline <= 0:
|
||||
return []
|
||||
weights = [max(len(x), 1) for x in lines]
|
||||
s = sum(weights)
|
||||
caps: list[dict] = []
|
||||
t = 0.0
|
||||
for i, (line, w) in enumerate(zip(lines, weights)):
|
||||
dur = timeline * w / s
|
||||
if i == len(lines) - 1:
|
||||
dur = max(timeline - t, 0.3) # 末段补到结尾,避免浮点欠尾
|
||||
caps.append(_caption_element(line, t, max(dur, 0.3)))
|
||||
t += dur
|
||||
return caps
|
||||
|
||||
|
||||
def _caption_element(text: str, start: float, dur: float, height: int = 1920, fill: str = "rgba(255, 255, 255, 1)") -> dict:
|
||||
"""字幕元素:结构照抄 demo/test-app.json 的真实字幕(字号缩放随画布高度)"""
|
||||
scale = round(height / 1920, 4) or 1
|
||||
return {
|
||||
"id": _uid(),
|
||||
"name": text,
|
||||
"text": text,
|
||||
"textStyle": {
|
||||
"radius": [0, 0, 0, 0],
|
||||
"type": "newTextStyle",
|
||||
"direction": "horizontal",
|
||||
"fillType": "normal",
|
||||
"fill": fill,
|
||||
"padding": [5, 5, 5, 5],
|
||||
"fontSize": 200,
|
||||
"letterSpacing": 0,
|
||||
"lineHeight": 200,
|
||||
"align": "center",
|
||||
"fontFamily": "抖音美好体",
|
||||
"stroke": {"color": "rgba(51, 51, 51, 1)", "lineJoin": "round", "lineWidth": 18},
|
||||
"fontFamilyURL": "/assets/fonts/抖音美好体.otf",
|
||||
},
|
||||
"style": {
|
||||
"x": 540,
|
||||
"y": round(height * 0.77, 2),
|
||||
"alpha": 1,
|
||||
"width": 392.96,
|
||||
"height": 67.2,
|
||||
},
|
||||
"type": "caption",
|
||||
"trackIndex": 0.5,
|
||||
"startTime": round(start, 3),
|
||||
"duration": round(dur, 3),
|
||||
"textScale": round(0.32 * scale, 4),
|
||||
"scale": 1,
|
||||
"templateEnable": True,
|
||||
"sceneIndex": 1,
|
||||
}
|
||||
|
||||
|
||||
def _image_element(resource_id: str, name: str, start: float, dur: float, w: int, h: int, idx: int) -> dict:
|
||||
"""图片元素:字段集对齐 demo 视频元素(同一 BaseElement 血统)+ ImageElement 特有 matting"""
|
||||
return {
|
||||
"id": _uid(),
|
||||
"name": name,
|
||||
"type": "image",
|
||||
"trackIndex": 0,
|
||||
"resourceId": resource_id,
|
||||
"startTime": round(start, 3),
|
||||
"duration": round(dur, 3),
|
||||
"style": {"width": w, "height": h, "x": w / 2, "y": h / 2}, # x/y 是中心点(demo 实证)
|
||||
"blendMode": 0,
|
||||
"flipx": False,
|
||||
"scale": 1,
|
||||
"filters": [],
|
||||
"matting": {
|
||||
"enabled": False,
|
||||
"color": "#00FF00",
|
||||
"similarityThreshold": 0.5,
|
||||
"emergence": 0.5,
|
||||
},
|
||||
"sceneIndex": idx + 1,
|
||||
"templateEnable": False,
|
||||
}
|
||||
|
||||
|
||||
def _audio_element(resource_id: str, dur: float, volume: float, name: str = "配音.mp3") -> dict:
|
||||
return {
|
||||
"id": _uid(),
|
||||
"name": name,
|
||||
"type": "audio",
|
||||
"trackIndex": 1,
|
||||
"resourceId": resource_id,
|
||||
"startTime": 0,
|
||||
"duration": round(dur, 3),
|
||||
"muted": False,
|
||||
"volume": volume,
|
||||
"speed": 1,
|
||||
"curveSpeed": False,
|
||||
"clipTime": 0,
|
||||
"fadeInTime": 0,
|
||||
"fadeOutTime": 0,
|
||||
}
|
||||
|
||||
|
||||
def build_movie_data(
|
||||
title: str,
|
||||
w: int,
|
||||
h: int,
|
||||
images: list[dict], # [{res_id, zip_rel, name, iw, ih, mime, size}]
|
||||
audio: dict | None, # {res_id, zip_rel, name, dur, mime, size}
|
||||
caption_lines: str,
|
||||
with_caption: bool,
|
||||
caption_fill: str,
|
||||
voice_volume: float,
|
||||
image_duration: float,
|
||||
) -> dict:
|
||||
now = int(time.time() * 1000)
|
||||
resouces: list[dict] = []
|
||||
elements: list[dict] = []
|
||||
|
||||
n = len(images)
|
||||
if audio:
|
||||
total = float(audio["dur"])
|
||||
span = total / n if n else 0.0
|
||||
else:
|
||||
span = float(image_duration)
|
||||
total = n * span
|
||||
|
||||
for i, im in enumerate(images):
|
||||
resouces.append({
|
||||
"id": im["res_id"],
|
||||
"name": im["name"],
|
||||
"type": "image",
|
||||
"url": im["zip_rel"],
|
||||
"originId": im["res_id"],
|
||||
"thumb": "",
|
||||
"styleSize": {"width": im["iw"], "height": im["ih"]},
|
||||
"fileType": im["mime"],
|
||||
"from": "user",
|
||||
"mustFetch": False,
|
||||
"attrs": {"width": im["iw"], "height": im["ih"], "size": im["size"], "fileType": im["mime"]},
|
||||
})
|
||||
elements.append(_image_element(im["res_id"], im["name"], i * span, span, w, h, i))
|
||||
|
||||
if audio:
|
||||
resouces.append({
|
||||
"id": audio["res_id"],
|
||||
"name": audio["name"],
|
||||
"type": "audio",
|
||||
"url": audio["zip_rel"],
|
||||
"originId": audio["res_id"],
|
||||
"thumb": "",
|
||||
"styleSize": {"width": 0, "height": 0},
|
||||
"fileType": audio["mime"],
|
||||
"from": "user",
|
||||
"mustFetch": False,
|
||||
"duration": audio["dur"],
|
||||
"attrs": {"size": audio["size"], "fileType": audio["mime"], "duration": audio["dur"]},
|
||||
})
|
||||
elements.append(_audio_element(audio["res_id"], audio["dur"], voice_volume, audio["name"]))
|
||||
|
||||
captions = _split_captions(caption_lines, total, audio["dur"] if audio else None) if with_caption else []
|
||||
|
||||
# checkNdata 门禁九键 + demo 同款元数据
|
||||
return {
|
||||
"title": title,
|
||||
"createTime": now,
|
||||
"updateTime": now,
|
||||
"poster": "",
|
||||
"version": "1.1.0",
|
||||
"width": w,
|
||||
"height": h,
|
||||
"duration": round(total, 3),
|
||||
"background": {},
|
||||
"_hideLock": {},
|
||||
"transitions": [],
|
||||
"cameras": [],
|
||||
"captions": captions,
|
||||
"elements": elements,
|
||||
"resouces": resouces,
|
||||
}
|
||||
|
||||
|
||||
def write_project_zip(movie: dict, files: dict[str, bytes], zip_path: Path) -> None:
|
||||
"""project.json + materials/{type}/{file} —— 与 projectExport.ts 导出同构"""
|
||||
zip_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as z:
|
||||
z.writestr("project.json", json.dumps(movie, ensure_ascii=False))
|
||||
for rel, blob in files.items():
|
||||
z.writestr(rel, blob)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- MCP 工具
|
||||
|
||||
@mcp.tool()
|
||||
async def service_status() -> dict:
|
||||
"""自检:抓取反代 / 配音服务 / 大模型网关 / 工程目录 的可用性"""
|
||||
out: dict[str, object] = {"time": time.strftime("%Y-%m-%d %H:%M:%S")}
|
||||
|
||||
try:
|
||||
async with _client(8) as c:
|
||||
r = await c.get(f"{UNICUT_URL}/")
|
||||
out["unicut_nginx"] = f"OK({r.status_code})"
|
||||
except Exception as e:
|
||||
out["unicut_nginx"] = f"FAIL: {e}"
|
||||
|
||||
try:
|
||||
async with _client(8) as c:
|
||||
r = await c.get(f"{TTS_URL}/voices")
|
||||
v = r.json()
|
||||
n = len(v) if isinstance(v, list) else len(v.get("voices", [])) if isinstance(v, dict) else 0
|
||||
out["tts"] = f"OK, {n} 个音色"
|
||||
except Exception as e:
|
||||
out["tts"] = f"FAIL: {e}"
|
||||
|
||||
out["llm"] = {
|
||||
"base": LLM_BASE,
|
||||
"model": LLM_MODEL,
|
||||
"key": f"已配置({len(LLM_KEY)}位)" if LLM_KEY else "未配置 MCP_LLM_KEY",
|
||||
}
|
||||
out["projects_dir"] = PROJECTS_DIR or "未配置(文件夹模式工具不可用)"
|
||||
out["out_dir"] = str(OUT_DIR)
|
||||
out["public_url"] = PUBLIC_URL
|
||||
return out
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
async def grab_url(url: str, max_images: int = 20) -> dict:
|
||||
"""抓取网页正文与配图(支持公众号 mp.weixin.qq.com 文章)。
|
||||
|
||||
返回 {ok, url, title, text(≤12000字), images[](绝对地址, 最多 max_images 张)}。
|
||||
图片只是候选地址;create_video_project 下载时会再校验尺寸(≥160x120)与大小(≤10MB)。
|
||||
"""
|
||||
assert_public_url(url)
|
||||
async with _client(30) as c:
|
||||
r = await c.get(url, headers=HTTP_HEADERS)
|
||||
r.raise_for_status()
|
||||
final_url = str(r.url)
|
||||
ctype = r.headers.get("content-type", "")
|
||||
if "html" not in ctype and "xml" not in ctype:
|
||||
# 非 HTML(如直接是文本/JSON):原样返回文本
|
||||
return {"ok": True, "url": final_url, "title": final_url, "text": r.text[:12000], "images": []}
|
||||
ext = extract_from_html(r.text, final_url)
|
||||
return {
|
||||
"ok": True,
|
||||
"url": final_url,
|
||||
"title": ext["title"],
|
||||
"text": ext["text"],
|
||||
"images": ext["images"][: max(0, min(int(max_images), 20))],
|
||||
}
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
async def generate_script(
|
||||
source: str,
|
||||
requirement: str = "",
|
||||
style: str = "口播解说",
|
||||
target_seconds: int = 60,
|
||||
paragraph_count: int = 6,
|
||||
) -> dict:
|
||||
"""大模型生成短视频口播文案。
|
||||
|
||||
source:素材文本(抓取的文章正文)或主题描述;requirement:额外要求(受众/卖点/关键词)。
|
||||
返回 {ok, title, paragraphs[], text};paragraphs 每段一句,直接对应字幕与时间轴分段。
|
||||
"""
|
||||
sys_prompt = (
|
||||
"你是短视频口播文案编剧。只输出一个 JSON 对象,不要任何解释、不要 markdown 围栏:\n"
|
||||
'{"title": "视频标题", "paragraphs": ["第一段口播", "第二段口播", ...]}\n'
|
||||
"要求:口语化、有钩子、每段 1~2 句话适合做字幕;总字数 ≈ 目标秒数 × 4.5 字。"
|
||||
)
|
||||
user_prompt = (
|
||||
f"风格:{style}\n目标时长:约 {target_seconds} 秒\n段落数:约 {paragraph_count} 段\n"
|
||||
)
|
||||
if requirement:
|
||||
user_prompt += f"补充要求:{requirement}\n"
|
||||
user_prompt += f"\n素材:\n{source[:8000]}"
|
||||
|
||||
content = await _llm_chat([
|
||||
{"role": "system", "content": sys_prompt},
|
||||
{"role": "user", "content": user_prompt},
|
||||
])
|
||||
data = _parse_json_block(content)
|
||||
if data and isinstance(data.get("paragraphs"), list):
|
||||
paras = [str(p).strip() for p in data["paragraphs"] if str(p).strip()]
|
||||
title = str(data.get("title") or "").strip()
|
||||
else: # 兜底:按行切
|
||||
paras = [ln.strip() for ln in content.splitlines() if ln.strip()]
|
||||
title = ""
|
||||
if not paras:
|
||||
raise ValueError(f"模型未返回可用文案:{content[:300]}")
|
||||
return {"ok": True, "title": title, "paragraphs": paras, "text": "\n".join(paras)}
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
async def list_voices() -> dict:
|
||||
"""列出配音(edge-tts)可用音色 → {ok, count, voices[]}"""
|
||||
async with _client(15) as c:
|
||||
r = await c.get(f"{TTS_URL}/voices")
|
||||
r.raise_for_status()
|
||||
v = r.json()
|
||||
voices = v if isinstance(v, list) else v.get("voices", [])
|
||||
return {"ok": True, "count": len(voices), "voices": voices}
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
async def tts(
|
||||
text: str,
|
||||
voice: str = "zh-CN-XiaoxiaoNeural",
|
||||
rate: str = "+0%",
|
||||
pitch: str = "+0Hz",
|
||||
volume: str = "+0%",
|
||||
) -> dict:
|
||||
"""edge-tts 配音合成。返回 {ok, url(站点可直接播放), path(服务器文件), duration(秒), voice}。
|
||||
text 建议 ≤2000 字;传给 create_video_project 的 audio 用 path。
|
||||
"""
|
||||
if not text.strip():
|
||||
raise ValueError("text 不能为空")
|
||||
async with _client(180) as c:
|
||||
r = await c.post(
|
||||
f"{TTS_URL}/tts",
|
||||
json={"text": text, "voice": voice, "rate": rate, "pitch": pitch, "volume": volume},
|
||||
)
|
||||
if r.status_code >= 400:
|
||||
raise ValueError(f"TTS {r.status_code}: {r.text[:300]}")
|
||||
j = r.json()
|
||||
if not isinstance(j, dict) or not j.get("url"):
|
||||
raise ValueError(f"TTS 返回异常:{str(j)[:300]}")
|
||||
u = str(j["url"])
|
||||
internal = TTS_URL + (u[len("/localtts"):] if u.startswith("/localtts") else u)
|
||||
ar = await c.get(internal)
|
||||
ar.raise_for_status()
|
||||
blob = ar.content
|
||||
if not blob:
|
||||
raise ValueError("TTS 音频为空")
|
||||
|
||||
audio_dir = OUT_DIR / "audio"
|
||||
audio_dir.mkdir(parents=True, exist_ok=True)
|
||||
name = Path(urlparse(u).path).name or f"{_uid()}.mp3"
|
||||
dest = audio_dir / name
|
||||
dest.write_bytes(blob)
|
||||
try:
|
||||
dur = float(MP3(io.BytesIO(blob)).info.length)
|
||||
except Exception:
|
||||
dur = 0.0
|
||||
public = PUBLIC_URL + (u if u.startswith("/") else "/" + u)
|
||||
return {"ok": True, "url": public, "path": str(dest), "duration": round(dur, 3), "voice": voice}
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
async def create_video_project(
|
||||
title: str,
|
||||
images: list[str] | None = None,
|
||||
script: str = "",
|
||||
audio: str = "",
|
||||
width: int = 1080,
|
||||
height: int = 1920,
|
||||
image_duration: float = 3.0,
|
||||
caption: bool = True,
|
||||
caption_fill: str = "rgba(255, 255, 255, 1)",
|
||||
voice_volume: float = 1.0,
|
||||
) -> dict:
|
||||
"""生成米剪工程 ZIP(project.json + materials/),在米剪顶部「工程文件」导入即可出片。
|
||||
|
||||
images:图片 URL 或服务器本地路径(tts 工具产出的 path 也行);script:口播文案→自动做字幕
|
||||
(按\\n分段,单段过长自动按句拆);audio:配音 URL/path(通常来自 tts 工具)。
|
||||
有配音时图片自动拉伸铺满配音时长,否则每图 image_duration 秒。
|
||||
返回 {ok, zip_path, zip_url(可直接下载), id, duration, images_used, captions, elements}。
|
||||
"""
|
||||
images = images or []
|
||||
warnings: list[str] = []
|
||||
|
||||
# ---- 图片收集与校验
|
||||
im_items: list[dict] = []
|
||||
files: dict[str, bytes] = {}
|
||||
for raw in images:
|
||||
if len(im_items) >= 30:
|
||||
warnings.append("图片超过 30 张,多余已丢弃")
|
||||
break
|
||||
try:
|
||||
blob, ctype = await fetch_bytes(raw)
|
||||
except Exception as e:
|
||||
warnings.append(f"图片下载失败(跳过){raw[:80]}: {e}")
|
||||
continue
|
||||
if len(blob) > IMG_MAX_BYTES:
|
||||
warnings.append(f"图片超 10MB(跳过){raw[:80]}")
|
||||
continue
|
||||
try:
|
||||
im = Image.open(io.BytesIO(blob))
|
||||
iw, ih = im.size
|
||||
except Exception as e:
|
||||
warnings.append(f"图片无法识别(跳过){raw[:80]}: {e}")
|
||||
continue
|
||||
if iw < IMG_MIN_W or ih < IMG_MIN_H:
|
||||
warnings.append(f"图片太小 {iw}x{ih}(跳过){raw[:80]}")
|
||||
continue
|
||||
ext = _ext_for(ctype, raw, "jpg")
|
||||
if ext not in ("jpg", "png", "webp", "gif"):
|
||||
ext = "jpg" if im.format in ("JPEG", "PNG", "WEBP", "GIF") else "jpg"
|
||||
fname = f"{uuid.uuid4().hex}.{ext}"
|
||||
rel = f"materials/image/{fname}"
|
||||
files[rel] = blob
|
||||
im_items.append({
|
||||
"res_id": _uid(),
|
||||
"name": Path(urlparse(raw).path).name or fname,
|
||||
"zip_rel": rel,
|
||||
"iw": iw, "ih": ih,
|
||||
"mime": f"image/{'jpeg' if ext == 'jpg' else ext}",
|
||||
"size": len(blob),
|
||||
})
|
||||
|
||||
# ---- 配音收集
|
||||
aud: dict | None = None
|
||||
if audio:
|
||||
try:
|
||||
blob, ctype = await fetch_bytes(audio)
|
||||
ext = _ext_for(ctype, audio, "mp3")
|
||||
fname = f"voice_{uuid.uuid4().hex[:8]}.{ext}"
|
||||
rel = f"materials/audio/{fname}"
|
||||
files[rel] = blob
|
||||
try:
|
||||
dur = float(MP3(io.BytesIO(blob)).info.length)
|
||||
except Exception:
|
||||
dur = 0.0
|
||||
if dur <= 0:
|
||||
warnings.append("配音时长无法识别,时间轴将按图片时长排布")
|
||||
aud = None
|
||||
else:
|
||||
aud = {
|
||||
"res_id": _uid(),
|
||||
"name": Path(urlparse(audio).path).name or fname,
|
||||
"zip_rel": rel,
|
||||
"dur": dur,
|
||||
"mime": f"audio/{'mpeg' if ext == 'mp3' else ext}",
|
||||
"size": len(blob),
|
||||
}
|
||||
except Exception as e:
|
||||
warnings.append(f"配音获取失败(忽略): {e}")
|
||||
|
||||
if not im_items and not aud:
|
||||
raise ValueError("至少需要 1 张可用图片或 1 段配音")
|
||||
|
||||
# ---- 组装 MovieData
|
||||
movie = build_movie_data(
|
||||
title=title, w=int(width), h=int(height),
|
||||
images=im_items, audio=aud,
|
||||
caption_lines=script, with_caption=bool(caption and script.strip()),
|
||||
caption_fill=caption_fill, voice_volume=float(voice_volume),
|
||||
image_duration=float(image_duration),
|
||||
)
|
||||
|
||||
# ---- 落盘 ZIP
|
||||
ts = time.strftime("%Y%m%d-%H%M%S")
|
||||
zip_name = f"{_slug(title)}-{ts}.zip"
|
||||
zip_path = OUT_DIR / zip_name
|
||||
write_project_zip(movie, files, zip_path)
|
||||
|
||||
# ---- 门禁自检:checkNdata 九键
|
||||
required = ["title", "poster", "width", "height", "background", "transitions", "captions", "elements", "resouces"]
|
||||
missing = [k for k in required if k not in movie]
|
||||
if missing:
|
||||
raise ValueError(f"工程缺少必需键:{missing}")
|
||||
|
||||
return {
|
||||
"ok": True,
|
||||
"id": f"mcp-{ts}-{_uid()[:6]}",
|
||||
"zip_path": str(zip_path),
|
||||
"zip_url": f"{PUBLIC_URL}/mcp-out/{zip_name}",
|
||||
"duration": movie["duration"],
|
||||
"size": zip_path.stat().st_size,
|
||||
"images_used": len(im_items),
|
||||
"has_audio": bool(aud),
|
||||
"captions": len(movie["captions"]),
|
||||
"elements": len(movie["elements"]),
|
||||
"warnings": warnings,
|
||||
"import_hint": "下载该 ZIP → 米剪顶部「工程文件」→ 导入(需先选择过工作文件夹)",
|
||||
}
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
async def list_projects() -> dict:
|
||||
"""列出工作文件夹(文件夹模式 PROJECTS_DIR)里的米剪工程 → {ok, dir, projects[]}"""
|
||||
if not PROJECTS_DIR:
|
||||
return {"ok": False, "error": "未配置 MCP_PROJECTS_DIR(compose .env)。文件夹模式需把它指到米剪里选择的同一目录"}
|
||||
pdir = Path(PROJECTS_DIR) / "projects"
|
||||
if not pdir.is_dir():
|
||||
return {"ok": True, "dir": str(pdir), "projects": []}
|
||||
items = []
|
||||
for f in sorted(pdir.glob("*.json")):
|
||||
try:
|
||||
d = json.loads(f.read_text(encoding="utf-8"))
|
||||
items.append({
|
||||
"file": f.name,
|
||||
"id": d.get("id") or f.stem,
|
||||
"title": d.get("title") or f.stem,
|
||||
"width": d.get("width"),
|
||||
"height": d.get("height"),
|
||||
"updatedAt": d.get("updatedAt"),
|
||||
})
|
||||
except Exception as e:
|
||||
items.append({"file": f.name, "error": str(e)})
|
||||
return {"ok": True, "dir": str(pdir), "projects": items}
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
async def read_project(project_id: str) -> dict:
|
||||
"""读取工作文件夹里的工程 JSON(folder 形态 {id,title,width,height,data})"""
|
||||
if not PROJECTS_DIR:
|
||||
return {"ok": False, "error": "未配置 MCP_PROJECTS_DIR"}
|
||||
f = Path(PROJECTS_DIR) / "projects" / f"{_slug(project_id)}.json"
|
||||
if not f.is_file():
|
||||
return {"ok": False, "error": f"工程不存在:{f}"}
|
||||
data = json.loads(f.read_text(encoding="utf-8"))
|
||||
return {"ok": True, "path": str(f), "project": data}
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
async def write_project(project: dict) -> dict:
|
||||
"""写入/更新工作文件夹工程(folder 形态:{id,title,width,height,data})。谨慎调用:会覆盖同 id 文件"""
|
||||
if not PROJECTS_DIR:
|
||||
return {"ok": False, "error": "未配置 MCP_PROJECTS_DIR"}
|
||||
if not isinstance(project, dict) or not project.get("data"):
|
||||
return {"ok": False, "error": "需要 {id,title,width,height,data(MovieData)} 结构"}
|
||||
pid = _slug(str(project.get("id") or _uid()))
|
||||
project["id"] = pid
|
||||
project["updatedAt"] = int(time.time() * 1000)
|
||||
pdir = Path(PROJECTS_DIR) / "projects"
|
||||
pdir.mkdir(parents=True, exist_ok=True)
|
||||
f = pdir / f"{pid}.json"
|
||||
f.write_text(json.dumps(project, ensure_ascii=False), encoding="utf-8")
|
||||
return {"ok": True, "path": str(f), "id": pid}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 静态产物与健康检查路由
|
||||
|
||||
try:
|
||||
from starlette.responses import FileResponse, JSONResponse
|
||||
|
||||
@mcp.custom_route("/health", methods=["GET"])
|
||||
async def _health(_req):
|
||||
return JSONResponse({"ok": True, "service": "unicut-mcp"})
|
||||
|
||||
@mcp.custom_route("/out/{name}", methods=["GET"])
|
||||
async def _out(req):
|
||||
name = Path(req.path_params["name"]).name # 防目录穿越
|
||||
f = OUT_DIR / name
|
||||
if not f.is_file():
|
||||
return JSONResponse({"ok": False, "error": "not found"}, status_code=404)
|
||||
return FileResponse(f, filename=name)
|
||||
|
||||
except AttributeError: # 老版本 SDK 无 custom_route,静默降级
|
||||
pass
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- 入站鉴权
|
||||
class _AuthMiddleware:
|
||||
"""公网暴露的 MCP 端点强制 Bearer 鉴权(fail-closed:MCP_AUTH_TOKEN 未配置时全部 401)。
|
||||
|
||||
放行两类路径:
|
||||
- /health 监控探针(nginx /mcp-health 转发,无法附带鉴权头)
|
||||
- /out/* 工具产物下载直链(zip/mp3 交人浏览器点开,无法附带鉴权头)
|
||||
其余路径(含 MCP 协议端点 /mcp 与全部未知路径)必须携带
|
||||
Authorization: Bearer <MCP_AUTH_TOKEN>。
|
||||
"""
|
||||
|
||||
OPEN_EXACT = ("/health",)
|
||||
OPEN_PREFIX = ("/out/",)
|
||||
|
||||
def __init__(self, app):
|
||||
self.app = app
|
||||
|
||||
async def __call__(self, scope, receive, send):
|
||||
if scope["type"] != "http":
|
||||
await self.app(scope, receive, send)
|
||||
return
|
||||
|
||||
path = scope.get("path", "")
|
||||
if path in self.OPEN_EXACT or path.startswith(self.OPEN_PREFIX):
|
||||
await self.app(scope, receive, send)
|
||||
return
|
||||
|
||||
headers = {k.decode("latin-1").lower(): v.decode("latin-1") for k, v in scope.get("headers", [])}
|
||||
got = headers.get("authorization", "")
|
||||
authorized = (
|
||||
bool(AUTH_TOKEN)
|
||||
and got.startswith("Bearer ")
|
||||
and hmac.compare_digest(got[7:].strip(), AUTH_TOKEN) # 恒定时间比较,防时序侧信道
|
||||
)
|
||||
if authorized:
|
||||
await self.app(scope, receive, send)
|
||||
return
|
||||
|
||||
detail = (
|
||||
"MCP_AUTH_TOKEN not configured on server (fail-closed)"
|
||||
if not AUTH_TOKEN
|
||||
else "missing or invalid bearer token"
|
||||
)
|
||||
body = json.dumps({"ok": False, "error": "unauthorized", "detail": detail}, ensure_ascii=False).encode()
|
||||
await send(
|
||||
{
|
||||
"type": "http.response.start",
|
||||
"status": 401,
|
||||
"headers": [
|
||||
(b"content-type", b"application/json"),
|
||||
(b"content-length", str(len(body)).encode("ascii")),
|
||||
(b"www-authenticate", b'Bearer realm="unicut-mcp", charset="UTF-8"'),
|
||||
],
|
||||
}
|
||||
)
|
||||
await send({"type": "http.response.body", "body": body})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
OUT_DIR.mkdir(parents=True, exist_ok=True)
|
||||
if not AUTH_TOKEN:
|
||||
print("[auth] MCP_AUTH_TOKEN 未配置:MCP 端点将拒绝一切调用(公网必须授权,fail-closed)", flush=True)
|
||||
else:
|
||||
print(f"[auth] MCP Bearer 鉴权已启用(令牌 {len(AUTH_TOKEN)} 字符)", flush=True)
|
||||
|
||||
import anyio
|
||||
import uvicorn
|
||||
|
||||
app = mcp.streamable_http_app() # 含 /mcp 路由、自定义路由与 session-manager lifespan
|
||||
app.add_middleware(_AuthMiddleware) # 鉴权中间件(最外层)
|
||||
config = uvicorn.Config(
|
||||
app,
|
||||
host=mcp.settings.host,
|
||||
port=mcp.settings.port,
|
||||
log_level=mcp.settings.log_level.lower(),
|
||||
)
|
||||
anyio.run(uvicorn.Server(config).serve)
|
||||
@@ -41,6 +41,18 @@ server {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# 文章目录禁止启发式缓存:index.json 更新(新增文章/改标题)后必须立即可见,
|
||||
# 否则浏览器按 ETag/Last-Modified 自行推断新鲜度会命中旧列表 → 详情页报
|
||||
# 「没有找到这篇文章」。no-cache = 每次协商校验(命中 304,不费流量)。
|
||||
location /articles/ {
|
||||
add_header Cache-Control "no-cache";
|
||||
}
|
||||
|
||||
# 入口页同样不缓存:旧 index.html 会引用已不存在的旧 chunk hash
|
||||
location = /index.html {
|
||||
add_header Cache-Control "no-cache";
|
||||
}
|
||||
|
||||
# 长缓存带 hash 的构建产物
|
||||
location /homeAssets/ {
|
||||
expires 30d;
|
||||
@@ -99,6 +111,31 @@ server {
|
||||
client_max_body_size 1m;
|
||||
}
|
||||
|
||||
# 网址抓取(AI 一键出片「输入网址」):同源动态反代任意公网 URL。
|
||||
# 浏览器只请求 /grab/,避开跨域限制;只放行 http/https,
|
||||
# 并拒绝回环/内网/链路本地地址,防止被当成跳板打内网服务。
|
||||
# 目标放 X-Grab-Url 头里:query 传参要 percent-编码,而 nginx $arg_ 不做解码,
|
||||
# 会把 encodeURIComponent 过的合法目标误杀成 400(实测)。3xx 原样透传给前端,
|
||||
# 由 redirect:manual 逐跳重进 /grab/(每跳重新过一遍下面的断言)。
|
||||
location = /grab/ {
|
||||
resolver 223.5.5.5 119.29.29.29 valid=30s ipv6=off;
|
||||
if ($http_x_grab_url = '') { return 400; }
|
||||
if ($http_x_grab_url !~* '^https?://') { return 400; }
|
||||
if ($http_x_grab_url ~* '^https?://[^/?#]*@') { return 403; }
|
||||
if ($http_x_grab_url ~* '^https?://(localhost|127\.|0\.0\.0\.0|10\.|192\.168\.|169\.254\.|172\.(1[6-9]|2[0-9]|3[01])\.|\[?::1)') { return 403; }
|
||||
proxy_pass $http_x_grab_url;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_set_header Host $proxy_host;
|
||||
proxy_set_header Connection "";
|
||||
proxy_set_header X-Grab-Url "";
|
||||
# 公众号图片防盗链:带异源 Referer 时 mmbiz.qpic.cn 只给降级缩略图
|
||||
# (实测 2KB/140x140,无 Referer 则 47KB/原尺寸),向上游清空该头
|
||||
proxy_set_header Referer "";
|
||||
proxy_http_version 1.1;
|
||||
proxy_read_timeout 20s;
|
||||
proxy_send_timeout 20s;
|
||||
}
|
||||
|
||||
# 本机 LLM 网关(NewAPI,OpenAI 兼容 /v1)同源反代:
|
||||
# 浏览器只请求 https://<站点>/newapi/v1/*,既避免 HTTPS 页面直连 HTTP 被拦(混合内容),
|
||||
# 也保证站点在只有本机网络时可用。密钥仍留在服务端,前端不出现。
|
||||
@@ -121,6 +158,46 @@ server {
|
||||
client_max_body_size 8m;
|
||||
}
|
||||
|
||||
# MCP 服务(Model Context Protocol,unicut-mcp 容器)同源反代:
|
||||
# AI 客户端(Claude Desktop / Claude Code / Cursor / Hermes 等)用
|
||||
# https://<站点>/mcp
|
||||
# 连接即可把米剪当工具用(抓取文章 / 生成口播文案 / edge-tts 配音 / 生成工程 ZIP)。
|
||||
# Streamable HTTP 走 SSE 流:必须关缓冲、保持 HTTP/1.1 长连接、拉长读超时。
|
||||
# 注:/mcp-out 前缀比 /mcp 更长,nginx 最长前缀匹配规则会优先后者,不冲突。
|
||||
location /mcp {
|
||||
proxy_pass http://unicut-mcp:8765;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Connection "";
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
proxy_cache off;
|
||||
proxy_read_timeout 600s;
|
||||
proxy_send_timeout 600s;
|
||||
client_max_body_size 20m;
|
||||
}
|
||||
|
||||
# MCP 生成产物下载(工程 ZIP、配音 mp3),配合米剪「工程文件」导入
|
||||
location /mcp-out/ {
|
||||
proxy_pass http://unicut-mcp:8765/out/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_read_timeout 300s;
|
||||
client_max_body_size 100m;
|
||||
}
|
||||
|
||||
# MCP 健康检查(容器 /health;注意 /mcp/health 不是端点,SPA 会回退成首页 HTML)
|
||||
location = /mcp-health {
|
||||
proxy_pass http://unicut-mcp:8765/health;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_read_timeout 10s;
|
||||
}
|
||||
|
||||
# UNICUT 在线服务反代(账号/素材/AI 等在线能力), 对应官方 dev server 的代理配置
|
||||
location /api/ {
|
||||
proxy_pass https://video.h5ds.com;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "aacut",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "yarn clean && node scripts/patch-sdk-offline.mjs && yarn build:worker && vite build",
|
||||
@@ -48,6 +48,7 @@
|
||||
"p-limit": "^4.0.0",
|
||||
"pixi-color-effects": "^1.0.0",
|
||||
"pixi-filters": "^5.2.1",
|
||||
"pdfjs-dist": "^4.7.76",
|
||||
"pixi.js": "^7.3.0",
|
||||
"pubsub-js": "^1.9.4",
|
||||
"qrcode": "^1.5.4",
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
# AI 一键出片新手教程
|
||||
|
||||
> 这篇教程专讲「AI 一键出片」:怎么从零开始,四步做出一条带配音、字幕、转场的视频。
|
||||
> 界面操作的通用说明(首页 / 项目页 / 素材页 / 导出)看《米剪新手使用教程》。
|
||||
|
||||
## 一、60 秒认识一键出片
|
||||
|
||||
一句话:**你给素材和标题,AI 帮你写口播文案、配真人感配音、加字幕、排画面、压转场,最后直接排进时间轴。**
|
||||
|
||||
- 产出不是"黑盒成片",而是一条**可以继续手动编辑的工程**:图片、配音、字幕都是独立素材,哪段不满意都能改
|
||||
- 全程分四步走,弹窗顶部有进度条:**素材与标题 → 生成文案 → 配置声音 → 确认生成**
|
||||
- 对模型要求很低:**纯文本模型就能用**(AI 只负责写文案);如果你配置的模型支持看图(多模态/视觉),AI 还能"看懂"你上传的图片来写文案,效果更好
|
||||
|
||||
## 二、开始前的唯一前提:配置模型
|
||||
|
||||
一键出片属于 AI 功能,**第一次用必须先填一次 API Key**(之后一直有效):
|
||||
|
||||
1. 打开任意工程进入编辑器,点**右上角「配置模型」**
|
||||
2. 弹窗里三项都要填:**接口地址 / API Key / 模型**
|
||||
- 接口地址和模型名**已默认填好官方服务**(ai.88531.cn),你只需要填 Key
|
||||
- 官方 Key 到**ai.88531.cn**获取,拿到后粘贴(形如 `sk-xxxx`)
|
||||
3. 点「保存」,看到提示「AI 配置已保存」就完成了
|
||||
|
||||
几个新手常问的点:
|
||||
|
||||
- **Key 只保存在你这台浏览器里**,不上传服务器,本站无法代付,Key 由你自行申请
|
||||
- 没填 Key 时,AI 面板整体显示引导卡「AI 功能需要你自己的 API Key」——AI 对话、一键出片、生图、生视频都先不放出来;**基础剪辑不受影响**(导入素材、时间轴、字幕、转场、导出都能用)
|
||||
- **配音和抠图是本机模型,免费,不需要 Key**
|
||||
- 想换模型随时再点右上角「配置模型」修改;接口需 OpenAI 兼容(官方值或你自建网关的 `/v1` 地址)
|
||||
|
||||

|
||||
*图:在编辑器右上角点「配置模型」,填入接口地址与 API Key*
|
||||
|
||||
## 三、入口在哪
|
||||
|
||||
配置好 Key 后,进编辑器 → 左侧面板点 **「AI 创作」**,你会看到两个入口:
|
||||
|
||||
- **顶部常驻大卡片**:带橙色「推荐」标、标题「AI 一键出片」,下面四个小标签(AI 文案 / 真人配音 / 字幕动效 / 画面转场),底部按钮 **「立即生成 →」**——这是主入口,切到别的页签它也一直在
|
||||
- **页签「一键出片」**:里面是「四步出一条视频」的简要说明和 **「开始一键出片」** 按钮
|
||||
|
||||
两个按钮点开的都是同一个四步弹窗。旁边的页签 **「生成结果」** 是 AI 生图 / 生视频等任务的记录列表,和一键出片(直接进时间轴)不是一条流程。
|
||||
|
||||

|
||||
*图:编辑器全貌:左侧「AI 创作」面板里的「AI 一键出片」入口*
|
||||
|
||||
## 四、第 1 步:素材与标题(素材三选一)
|
||||
|
||||
弹窗第一步顶部先选素材方式,三个按钮:**图片 / Word / PDF / 输入网址**。
|
||||
|
||||
### 方式 A:图片(最常用)
|
||||
|
||||
- 点「添加图片」选择本地图片,**最多 8 张**
|
||||
- 每张图右上角可**前移 / 后移 / 删除**——顺序很重要:**图片顺序 = 视频段落顺序**
|
||||
- 建议 3~8 张,每张对应一段口播和一条字幕
|
||||
|
||||
### 方式 B:Word / PDF 文档
|
||||
|
||||
- 点击选择 `.docx` 或 `.pdf` 文件,**自动提取正文和配图**
|
||||
- 提取成功会提示「已读取文档:…」;如果提示「没读到内容:文档可能是扫描件或受保护,请换一个文件」,说明是扫描版 PDF,换图文正常的文件
|
||||
- 文档类素材没有配图时,系统会**自动生成一张标题封面**兜底,保证时间轴有画面
|
||||
|
||||
### 方式 C:输入网址
|
||||
|
||||
- 粘贴文章 / 博客 / 详情页链接,点 **「抓取内容和图片」**
|
||||
- 成功后出现来源卡片:显示标签、字数、正文前 160 字预览,可点「移除」重来
|
||||
- 抓不到时提示「这个页面没抓到文字和图片,换个网址试试」——换个内容型页面即可
|
||||
|
||||
**然后填两项:**
|
||||
|
||||
- **标题**(最多 30 字,例:三步搞定一张海报)——它决定文案的主题方向,别留空
|
||||
- **文案风格**五选一:口播解说(自然口语)/ 教程讲解(步骤清晰)/ 种草安利(卖点前置)/ 情感旁白(文艺留白)/ 新闻播报(客观密度高)
|
||||
|
||||
底部实时显示「素材池 N/8 张图片 · 正文 X 字」。素材齐了点右下角主按钮——按钮文案随方式变化:**「① 识别图片 · 生成文案」/「① 读取文档 · 生成文案」/「① 分析网页 · 生成文案」**。没选素材就点,会提示「请先添加图片」/「请先上传 Word / PDF 文档」/「请先抓取网址内容」。
|
||||
|
||||

|
||||
*图:第 1 步:选素材类型、上传图片、填标题、挑文案风格*
|
||||
|
||||
## 五、第 2 步:生成文案(每段都能改)
|
||||
|
||||
按钮点下去后按所选方式显示进度:「正在识别图片写文案…」/「正在读取文档写文案…」/「正在分析网页写文案…」,几秒到几十秒出结果。
|
||||
|
||||
生成的文案**按段拆分,每段对应一张图,每段自动生成一条字幕**。这一屏你可以随便改:
|
||||
|
||||
- **直接改写**某段文字(改了字数会实时显示)
|
||||
- **换配图**:段落下方「配图」下拉选第几张图
|
||||
- **试听**:单段点「试听」先听效果
|
||||
- **删除**某段、点 **「加一段」** 手动补段
|
||||
- 绿色标签「已配音」/ 橙色标签「需重合成」表示该段配音状态
|
||||
|
||||
如果提示「文案生成失败」:检查配置模型是否有效(Key 额度是否用完),或稍后重试。
|
||||
|
||||
改满意后点 **「下一步:配置声音」**(没有文案时该按钮灰色)。
|
||||
|
||||

|
||||
*图:第 2 步:AI 写好分段文案,每段都能改、能删、能重写*
|
||||
|
||||
## 六、第 3 步:配置声音
|
||||
|
||||
提示文案写得很清楚:**「先挑好人声、情绪和语速,试听满意后再合成全部配音;改了任何参数,已合成的段需要重新合成。」**
|
||||
|
||||
- **人声**:下拉可搜索,挑一个顺耳的
|
||||
- **情绪**:微调语速与音调
|
||||
- **语速**:滑杆 -50% ~ +100%,默认常速
|
||||
|
||||
挑好后点 **「② 合成全部配音(N 段)」**:
|
||||
|
||||
- 底部出现「正在合成第 x/N 段配音…」进度
|
||||
- 全部成功后每段亮绿色「就绪」,底部显示「已配音 N/N 段」
|
||||
- 如果部分失败会提示「合成 x/N 段,失败的可单独重试」——回到对应段落单独点「试听」触发重试,或点「重新合成全部配音」整体再来一遍
|
||||
- **必须全部就绪才能点「下一步:确认生成」**(否则按钮灰色;强行提示「还有 N 段没有配音,请先合成」)
|
||||
|
||||

|
||||
*图:第 3 步:挑选配音音色,调节语速与情绪*
|
||||
|
||||
## 七、第 4 步:确认生成
|
||||
|
||||
先挑**画面效果**(顶部一句话:「先挑好转场和字幕效果,确认下面的信息,点『确认生成视频』直接排进时间轴」):
|
||||
|
||||
- **图片转场**:自动轮换(推荐,相邻两张自动换花样)/ 交叉缩放 / 推进穿门 / 水波涟漪 / 左侧擦除 / 立方翻转 / 柔和溶解 / 平滑缩放 / 不加转场
|
||||
- **图片动效**:缓慢推近 / 缓慢拉远 / 左右平移 / 静止——让静态图不呆板
|
||||
- **字幕**:位置(底部 / 居中 / 顶部)、大小(百分比滑杆)、配色(黄字黑边 / 白字黑边 / 橙字白边)、入场(无 / 放大弹入 / 淡入 / 放大 + 淡入)
|
||||
|
||||
下方信息栏逐项汇总你要生成的东西:
|
||||
|
||||
- 图片 N 张 · 口播 M 段 · **预计成片 X 秒**
|
||||
- 转场 / 动效选择 · 共 N-1 个转场
|
||||
- 字幕位置 · 大小 · 配色 · 入场
|
||||
- 人声 · 情绪 · 语速
|
||||
- 配音进度 x/N(「全部就绪」/「有段落参数已变更,需重新合成」)
|
||||
|
||||
⚠ **注意红字提示:「生成字幕会覆盖当前工程已有的字幕。」**——如果你在时间轴上已有手动字幕,先想清楚再继续(建议新工程做一键出片)。
|
||||
|
||||
确认无误点 **「③ 确认生成视频(总长约 X 秒)」**(某段配音没就绪时按钮灰色)。成功提示:
|
||||
|
||||
> 已生成 N 段:图片(带动效)、配音、字幕已就位,X 个转场
|
||||
|
||||
弹窗自动关闭。失败时显示「生成失败:原因」,按提示处理后重来。
|
||||
|
||||

|
||||
*图:第 4 步:素材总览确认无误后点「开始生成」*
|
||||
|
||||
## 八、生成之后:编辑与导出
|
||||
|
||||
回到时间轴,你会看到:
|
||||
|
||||
- **图片**按顺序排在同一条轨道(转场要求同轨道相邻,别挪散)
|
||||
- **配音**在另一条独立轨道,与图片错开避免撞车
|
||||
- **字幕**已按段生成
|
||||
- 图片带运镜动效(推近 / 拉远 / 平移的关键帧)
|
||||
|
||||
接下来就像普通工程一样:**拖动调整、双击修改、右上角「导出」** 选分辨率(480P ~ 4K)和格式(MP4 / MP3 / GIF)出片。哪段文案、配音、配图不满意,重新打开「AI 创作 → 一键出片」从头再来一遍即可——**参数都会重置,不污染旧工程**。
|
||||
|
||||

|
||||
*图:导出:分辨率 / 帧率 / 格式任选,支持 4K*
|
||||
|
||||
## 九、常见问题
|
||||
|
||||
**1. 点「AI 创作」只看到一张引导卡,没有一键出片?**
|
||||
说明还没配置 API Key。按第二节填好再回来;基础剪辑不受影响。
|
||||
|
||||
**2. 一步点生成就报「文案生成失败」?**
|
||||
多为 Key 失效 / 额度用完 / 接口地址改错。重开「配置模型」核对三项,或到 ai.88531.cn 检查 Key 状态。
|
||||
|
||||
**3. 配音合成一半失败?**
|
||||
提示「合成 x/N 段」不等于报废:失败段单独点「试听」重试,或「重新合成全部配音」整体重跑;全部「就绪」才能进下一步。
|
||||
|
||||
**4. 文档提示是扫描件?**
|
||||
扫描版 PDF 没有文字层,读不出正文——换成正常图文的 Word / PDF,或改用「输入网址」方式。
|
||||
|
||||
**5. 网址抓不到内容?**
|
||||
部分页面(纯 JS 渲染 / 登录墙 / 图片站)抓不到文字图片,换内容型页面(文章、博客、商品详情页)成功率高。
|
||||
|
||||
**6. 会把我原来的字幕覆盖吗?**
|
||||
**会。** 确认页红字写明「生成字幕会覆盖当前工程已有的字幕」。已有重要字幕的工程,先导出备份或换新工程再做一键出片。
|
||||
|
||||
**7. 传的纯文档没有一张图怎么办?**
|
||||
不用管:无配图时自动生成一张标题封面兜底,时间轴一定有画面;想要更好效果就在第 1 步补传图片。
|
||||
|
||||
**8. 生成的文案太书面 / 太长?**
|
||||
第 2 步整段随便改,或回第 1 步换「文案风格」重新生成;段落之间换图、删段都很方便。
|
||||
|
||||
## 十、相关链接
|
||||
|
||||
- [米剪新手使用教程](/article/local-deploy-guide) —— 界面总览、时间轴、字幕、导出的完整入门
|
||||
- [断网也能用:米剪 离线能力说明](/article/offline-ready) —— 哪些功能离线可用
|
||||
- **ai.88531.cn**—— 获取官方 API Key(接口地址与模型名已默认配好官方服务)
|
||||
|
After Width: | Height: | Size: 443 KiB |
|
After Width: | Height: | Size: 632 KiB |
|
After Width: | Height: | Size: 557 KiB |
|
After Width: | Height: | Size: 417 KiB |
|
After Width: | Height: | Size: 675 KiB |
|
After Width: | Height: | Size: 675 KiB |
|
After Width: | Height: | Size: 286 KiB |
|
After Width: | Height: | Size: 110 KiB |
|
After Width: | Height: | Size: 415 KiB |
|
After Width: | Height: | Size: 409 KiB |
|
After Width: | Height: | Size: 430 KiB |
|
After Width: | Height: | Size: 693 KiB |
@@ -1,10 +1,24 @@
|
||||
[
|
||||
{
|
||||
"id": "mcp-guide",
|
||||
"title": "米剪 MCP 使用说明",
|
||||
"description": "把米剪接入 Claude/Cursor 等 AI 客户端:端点与令牌、四种客户端配置模板、10 个工具逐个详解、一句话生成视频实战、curl 连通验证、.env 自部署配置与常见问题。",
|
||||
"date": "2026-11-12",
|
||||
"tags": ["教程", "MCP"]
|
||||
},
|
||||
{
|
||||
"id": "about",
|
||||
"title": "AI 一键出片新手教程",
|
||||
"description": "四步做出带配音、字幕、转场的视频:配置模型、素材三选一、生成文案、配置声音、确认生成到时间轴,新手常见问题解答。",
|
||||
"date": "2026-11-11",
|
||||
"tags": ["教程", "AI"]
|
||||
},
|
||||
{
|
||||
"id": "local-deploy-guide",
|
||||
"title": "米剪 本机部署指南",
|
||||
"description": "一条命令把在线剪辑工具装进自己的机器,浏览器打开即用",
|
||||
"date": "2026-10-26",
|
||||
"tags": ["部署", "Docker"]
|
||||
"title": "米剪新手使用教程",
|
||||
"description": "从零开始做出第一个视频:首次设置、界面总览、素材与工程管理、AI 功能配置、导出全流程与常见问题",
|
||||
"date": "2026-11-11",
|
||||
"tags": ["教程", "新手"]
|
||||
},
|
||||
{
|
||||
"id": "offline-ready",
|
||||
|
||||
@@ -1,60 +1,238 @@
|
||||
# 米剪 本机部署指南
|
||||
# 米剪新手使用教程
|
||||
|
||||
米剪是一个跑在浏览器里的视频剪辑工具。本机部署版把它做成一个 Docker 站点:
|
||||
装好之后打开网页就能剪辑,工程数据全部存在浏览器本地,不需要注册、不需要登录。
|
||||
> 这篇教程写给**第一次打开米剪**的朋友:从认识界面,到做出并导出你的第一个视频,一步一步照着做。文中出现的按钮名称都和界面上完全一致。
|
||||
|
||||
## 一、准备
|
||||
## 一、开始之前:三个常见疑问
|
||||
|
||||
- 一台 Linux 机器(内网 NAS、服务器、虚拟机都可以)
|
||||
- 已安装 Docker 与 Docker Compose
|
||||
- 一台同网段的电脑,用浏览器访问
|
||||
- **要注册、要登录吗?** 不用。打开网页直接用。
|
||||
- **要安装软件吗?** 不用。米剪是纯网页剪辑,推荐使用最新版 Chrome 或 Edge 浏览器。
|
||||
- **收费吗?** 剪辑全免费:导入素材、时间轴、字幕、转场、导出都不限次数;配音、抠图走本机服务,同样免费。只有「AI 对话 / 一键出片 / 生图 / 生视频」需要自己配置一个模型 Key(见第八节),不配置也不影响任何基础剪辑功能。
|
||||
|
||||
## 二、部署
|
||||
## 二、第一次打开:先选一个本地文件夹
|
||||
|
||||
站点源码在 `docker/unicut-src`,构建与发布只有两条命令:
|
||||
首次打开站点,会弹出一个 **「选择本地存储文件夹」** 弹窗,上面写着:
|
||||
|
||||
```bash
|
||||
cd docker/unicut-src
|
||||
docker compose build unicut
|
||||
docker compose up -d --no-build
|
||||
```
|
||||
> 请选择一个本地文件夹用于存放素材和项目数据,素材将不会上传到服务器
|
||||
|
||||
首次启动会自动生成自签证书(浏览器的 File System Access API 要求 HTTPS 安全上下文),
|
||||
证书保存在 named volume `certs` 里,重建容器不会丢。
|
||||
操作步骤:
|
||||
|
||||
## 三、访问
|
||||
1. 点弹窗里的 **「选择文件夹」** 按钮
|
||||
2. 在电脑上选一个目录(建议专门新建一个,比如 `米剪素材`,方便以后找)
|
||||
3. 浏览器会记住这次授权,以后打开不再弹这个窗
|
||||
|
||||
| 入口 | 地址 |
|
||||
| --- | --- |
|
||||
| HTTPS(推荐) | `https://<机器IP>:3005/` |
|
||||
| HTTP | `http://<机器IP>:3006/` |
|
||||

|
||||
*图:首次打开时的文件夹授权弹窗,点「选择文件夹」即可*
|
||||
|
||||
自签证书第一次打开会有告警,点「高级 → 继续访问」即可。
|
||||
**要点:**
|
||||
|
||||
## 四、配套服务
|
||||
- 素材和工程数据都存在**你自己的电脑**上,不上传服务器,断网也能继续剪
|
||||
- 如果浏览器不支持文件夹选择(少数老浏览器),米剪会自动退回浏览器内置存储,功能照常,不会卡住
|
||||
- 打开后如果一直停在这个弹窗进不去:刷新一次页面再点「选择文件夹」即可
|
||||
|
||||
| 服务 | 容器 | 作用 |
|
||||
| --- | --- | --- |
|
||||
| 站点 | `unicut` | nginx:静态产物 + 同源反代 |
|
||||
| 配音 | `unicut-tts` | edge-tts,经 `/localtts/` 同源反代 |
|
||||
| 生图 | `omniroute` | 经 `/omniai/` 同源反代,密钥只在服务端 |
|
||||
| 对话 | NewAPI | 经 `/newapi/` 同源反代 |
|
||||
## 三、认识三个页面
|
||||
|
||||
浏览器侧只看到 `https://<站点>/localtts`、`/omniai`、`/newapi` 这些同源路径,
|
||||
既避免 HTTPS 页面直连 HTTP 被浏览器拦截,也不会把任何密钥暴露给前端。
|
||||
**1. 首页(`/`)**
|
||||
|
||||
## 五、构建与发布脚本
|
||||
产品介绍页,底部有常见问题。顶部导航里的「**使用教程**」打开的就是本文。想开始干活,点页面上的 **「开始创作 →」**。
|
||||
|
||||
```bash
|
||||
bash scripts/build.sh
|
||||
```
|
||||

|
||||
*图:首页:产品介绍与「开始创作」入口*
|
||||
|
||||
脚本会:拿构建锁(避免并发构建互相覆盖)→ 构建镜像 → 发布容器 →
|
||||
导出产物跑断网 lint → curl 检查首页与详情页是否 200。
|
||||
**2. 项目页(`/workspace/draft`)**
|
||||
|
||||
## 六、常见问题
|
||||
管理你的剪辑工程:创建项目、进入编辑、改名、删除、文件夹分类都在这里。
|
||||
|
||||
- **打不开网页**:确认 3005 端口没有被占用,`docker ps` 里 `unicut` 状态应为 `Up`。
|
||||
- **配音没声音**:`curl -k https://127.0.0.1:3005/localtts/health`,确认 `unicut-tts` 容器在跑。
|
||||
- **AI 生图失败**:确认 `omniroute` 健康,且项目根目录 `.env` 里配置了 `OMNI_KEY`。
|
||||
- **工程数据在哪**:都在浏览器的 IndexedDB 与你选择的本地文件夹里,服务器上没有副本。
|
||||

|
||||
*图:项目页:创建、进入、改名、删除、文件夹分类*
|
||||
|
||||
**3. 素材页(`/workspace/material`)**
|
||||
|
||||
管理你的素材库:上传素材、下载更多素材、建文件夹归类、批量删除。
|
||||
|
||||
**4. 编辑器(`/editor/...`)**
|
||||
|
||||
真正剪视频的地方,从项目页点工程卡片进入。布局分五块:
|
||||
|
||||

|
||||
*图:编辑器:顶栏 / 左侧 13 个面板 / 预览窗 / 时间轴 / AI 对话窗*
|
||||
|
||||
- **顶栏**:返回、工程文件、快捷键、配置模型、导出
|
||||
- **左侧面板**:模板、AI 创作、我的、字幕、图片、视频、音频、文字、贴纸、滤镜、特效、转场、更多(共 13 个)
|
||||
- **中间预览窗**:播放、看效果
|
||||
- **底部时间轴**:所有素材在这里排列、裁剪、拼接
|
||||
- **右侧 AI 对话窗**:可拖宽、可收起,让 AI 帮你写文案、改脚本
|
||||
|
||||
## 四、做出你的第一个视频(跟着做 6 步)
|
||||
|
||||
### 第 1 步:创建项目
|
||||
|
||||
1. 首页点 **「开始创作 →」** 进入项目页
|
||||
2. 点 **「创建项目」** 卡片(上面写着"点击这里创建一个视频混剪项目")
|
||||
3. 项目立即创建,**自动进入编辑器**
|
||||
|
||||
> 以后要继续剪:在项目页点一下工程卡片就能再次进入。
|
||||
|
||||
### 第 2 步:准备素材(三选一)
|
||||
|
||||
- **方式 A:自己上传**—— 切到素材页,点 **「上传素材」**,把手机拍的视频、图片、音乐传进来
|
||||
- **方式 B:下载现成素材**—— 素材页点 **「下载更多素材」**,会新窗口打开素材下载文档站(免费素材合集 + 配套教程),下载完再上传回来
|
||||
- **方式 C:直接套模板**—— 编辑器左侧「**模板**」面板,选一个喜欢的模板,画面、音乐、字幕一次成型,替换里面的素材即可
|
||||
|
||||
### 第 3 步:把素材放进时间轴
|
||||
|
||||
- 编辑器左侧切到「**图片 / 视频 / 音频**」面板,**点击素材**即可添加到下方时间轴
|
||||
- 在时间轴上**拖动片段**可以调整先后顺序
|
||||
- 点选一个片段,拖动两端可以裁剪长短;要切成两段就按**Ctrl + B**(分割)
|
||||
|
||||
### 第 4 步:加字幕、转场、配音
|
||||
|
||||
- **字幕**:左侧「字幕」面板可以手动添加;也可以点**AI 字幕识别**,自动识别视频里的说话内容生成字幕(会覆盖当前字幕,确认即可)
|
||||
- **转场**:左侧「转场」面板,选一个效果放到两个片段之间
|
||||
- **背景音乐**:左侧「音频」面板选曲拖入
|
||||
- **人声配音**:左侧「我的」→ **配音**:搜索音色、调语速、选情绪/方言,输入文字生成语音,直接进时间轴(本机服务,免费)
|
||||
|
||||
### 第 5 步:预览
|
||||
|
||||
中间预览窗点播放看效果,**空格键** = 播放/暂停。
|
||||
|
||||
### 第 6 步:导出视频
|
||||
|
||||
1. 点右上角 **「导出」**
|
||||
2. 在弹窗里设置:
|
||||
- **视频名称**:随便起,比如"我的第一条视频"
|
||||
- **视频封面**:可选,不改也行
|
||||
- **分辨率**:480P / 720P / 1080P / 2K / 4K 都能选
|
||||
- **帧率**:不确定就用默认
|
||||
- **导出格式**:MP4(视频)/ MP3(只要音频)/ GIF(动图)
|
||||
3. 点开始导出,看两段进度:**资源加载进度 → 视频编码进度**
|
||||
4. 完成后点 **「下载」**,视频保存到浏览器的下载目录(一般是电脑的"下载"文件夹)
|
||||
|
||||

|
||||
*图:第 6 步:导出设置——分辨率最高 4K,支持 MP4 / MP3 / GIF*
|
||||
|
||||
到这里,你的第一个视频就做完了。
|
||||
|
||||
## 五、素材页使用详解
|
||||
|
||||
- **上传素材**:点按钮或直接拖文件进来,支持视频、图片、音频
|
||||
- **下载更多素材**:一键打开素材下载文档站(新标签页),有素材合集和教程
|
||||
- **创建文件夹**:给素材分类归档,左侧文件夹列表切换查看
|
||||
- **批量管理**:点「批量管理」→ 勾选素材(可「全选」)→「删除」,一次清掉一批;删掉的素材会连同本地文件一起删除,删之前想清楚
|
||||
- **找文件**:素材卡片上显示名称,鼠标悬停可看它在存储文件夹里的相对路径,方便你在电脑上直接定位原文件
|
||||
|
||||
## 六、项目页使用详解
|
||||
|
||||
- **创建项目**:点「创建项目」卡片,立即创建并进入编辑器
|
||||
- **进入编辑**:点工程卡片
|
||||
- **修改名称**:卡片下方的名称就是输入框,**点击修改名称**,改完点一下别处自动保存
|
||||
- **删除**:点「批量管理」→ 勾选工程 →「删除」(删除不可恢复,重要工程先用工程文件备份)
|
||||
- **整理归类**:「创建文件夹」把工程分门别类
|
||||
- **自动保存**:编辑过程中每隔约 10 秒自动保存一次,也可以随时按**Ctrl + S**手动保存
|
||||
|
||||
## 七、编辑器面板逐个认识
|
||||
|
||||
### 顶栏(从左到右)
|
||||
|
||||
- **返回**:回到项目页
|
||||
- **工程标题**:当前工程名
|
||||
- **编辑模式切换**:按需切换界面模式
|
||||
- **工程文件**:「导出工程文件 / 导入工程文件」——换电脑、备份用(见第十节)
|
||||
- **快捷键**:弹出完整快捷键列表
|
||||
- **配置模型**:给 AI 功能填 API Key(见第八节)
|
||||
- **导出**:做完视频点这里
|
||||
|
||||
### 左侧 13 个面板
|
||||
|
||||
- **模板**:整套现成效果,一键套用后替换素材
|
||||
- **AI 创作**:一键出片、AI 对话、图片生成、生视频(需配置模型)
|
||||
- **我的**:自己的素材、**配音(TTS)**、录音、扫码上传
|
||||
- **字幕**:手动加字幕 + AI 字幕识别
|
||||
- **图片 / 视频 / 音频**:各类素材,点击加入时间轴
|
||||
- **文字**:标题、花字、字幕样式
|
||||
- **贴纸**:贴纸装饰
|
||||
- **滤镜**:画面调色滤镜
|
||||
- **特效**:光影、动感等画面特效
|
||||
- **转场**:片段之间的衔接效果
|
||||
- **更多**:其余工具入口
|
||||
|
||||
### 右侧 AI 对话窗
|
||||
|
||||
一个常驻的聊天窗:直接打字让 AI **写文案、改脚本、出分镜**,生成的内容配合「AI 创作」面板使用;不需要时可收起。
|
||||
|
||||
## 八、AI 功能怎么开(配置模型)
|
||||
|
||||
以下功能需要模型 API Key:**AI 对话、AI 一键出片、AI 生图、AI 生视频**。
|
||||
|
||||
配置步骤(只需一次):
|
||||
|
||||
1. 在编辑器右上角点 **「配置模型」**
|
||||
2. 接口地址和模型名**已默认填好官方配置**(`https://ai.88531.cn/v1` + `mimo-v2.6-flash`),什么都不用改;也支持换成你自己的 OpenAI 兼容接口和模型
|
||||
3. 打开 https://ai.88531.cn 获取 API Key,粘贴进 Key 输入框,保存
|
||||
4. Key **只存在你这台电脑的浏览器里**,不上传服务器,本平台也不需要注册登录
|
||||
|
||||

|
||||
*图:配置模型:接口地址与模型已默认填好,只需贴入 API Key*
|
||||
|
||||
没配置 Key 时:AI 面板会显示配置引导,其余剪辑功能一切照常;**配音和抠图走本机服务,免费且不需要 Key**。
|
||||
|
||||
### 重点功能:AI 一键出片
|
||||
|
||||
入口:左侧「**AI 创作**」→ 顶部「**AI 一键出片**」卡片 → **「立即生成 →」**
|
||||
|
||||
素材**三选一**:
|
||||
|
||||
- **图片**:几张图片 + 一个标题,AI 自动写文案、配真人感配音、加字幕动效和画面转场,直接出成片
|
||||
- **Word / PDF 文档**:上传或粘贴文档内容,自动提取正文和文档里的配图生成视频
|
||||
- **输入网址**:粘贴文章链接,自动抓取正文和配图生成视频
|
||||
|
||||
说明:只需文本模型即可使用;配置的模型如果支持"视觉"(看图),还能根据图片内容写文案。生成的成片在「**生成结果**」页签里查看和下载。
|
||||
|
||||
### 其他 AI 小功能
|
||||
|
||||
- **AI 字幕识别**:字幕面板 → 识别按钮 → 确认(会覆盖现有字幕)
|
||||
- **AI 人物抠像 / 图片去背景**:支持 PNG、JPEG、GIF,本机免费
|
||||
- **配音**:我的 → 配音,海量音色可搜索,支持语速、情绪、方言设置
|
||||
|
||||
## 九、常用快捷键
|
||||
|
||||
- **分割**:Ctrl + B(Mac:⌘ + B)
|
||||
- **复制 / 剪切 / 粘贴**:Ctrl + C / Ctrl + X / Ctrl + V
|
||||
- **删除**:Delete 或 Backspace
|
||||
- **撤销 / 回退**:Ctrl + Z / Ctrl + Shift + Z
|
||||
- **播放 / 暂停**:空格
|
||||
- **时间轴放大 / 缩小**:Ctrl + + / Ctrl + -
|
||||
- **微调位置**:方向键 ← → ↑ ↓
|
||||
- **保存**:Ctrl + S
|
||||
|
||||
(编辑器顶栏「快捷键」按钮可随时查看完整列表,Mac 对应 ⌘ 键。)
|
||||
|
||||
## 十、换电脑 / 备份:工程文件
|
||||
|
||||
- 编辑器顶栏 **「工程文件 → 导出工程文件」**:把工程**连同全部素材**打成一个包
|
||||
- 拷到新电脑 → 打开米剪 → **「工程文件 → 导入工程文件」**,继续剪
|
||||
- 平时的素材和工程都存在本机浏览器和所选文件夹里;**清理浏览器数据会导致素材丢失**,重要项目务必定期用工程文件导出备份
|
||||
|
||||
## 十一、常见问题
|
||||
|
||||
1. **打开就弹"选择本地存储文件夹"?**
|
||||
首次使用的正常引导,点「选择文件夹」选一个目录即可;卡住就刷新页面重试。
|
||||
2. **导出的视频去哪了?**
|
||||
浏览器的下载目录(一般叫"下载"文件夹)。
|
||||
3. **支持什么格式?**
|
||||
导入:主流视频(MP4、MOV、AVI、MKV 等)、图片(JPG、PNG、WebP 等)、音频(MP3、WAV、AAC 等);导出:MP4、MP3、GIF。
|
||||
4. **AI 面板是空的 / 提示配置模型?**
|
||||
说明还没填模型 Key,按第八节配置即可;不配置也不影响基础剪辑。
|
||||
5. **换浏览器或者清理了浏览器数据,素材没了?**
|
||||
素材存在浏览器里,清理会丢;重要素材提前用「工程文件」导出备份。
|
||||
6. **推荐用什么浏览器?**
|
||||
最新版 Chrome 或 Edge(完整支持本地文件夹存储);Firefox、Safari 也能用,走浏览器内置存储。
|
||||
7. **断网能用吗?**
|
||||
基础剪辑、导出都可以;需要联网的是素材下载站和 AI 功能。详见[断网也能用:米剪离线能力说明](/article/offline-ready)。
|
||||
8. **页面白屏、卡住不动?**
|
||||
先刷新一次;还不行联系站长处理。
|
||||
|
||||
## 相关链接
|
||||
|
||||
- 素材下载文档站(配合「下载更多素材」按钮):https://doc.88531.cn/docs/mrfx/mrfx-1g99qum57n5qk
|
||||
- 官方 AI 模型站(获取 API Key):https://ai.88531.cn
|
||||
- [断网也能用:米剪离线能力说明](/article/offline-ready)
|
||||
@@ -0,0 +1,234 @@
|
||||
# 米剪 MCP 使用说明
|
||||
|
||||
> 一句话:把米剪变成 AI 客户端的工具——你在 Claude / Cursor 等工具里说一句「抓这篇文章做成视频」,AI 自己调米剪抓正文、写口播、配语音、打包工程,你回来打开就能剪。
|
||||
|
||||
## 一、MCP 是什么,米剪 MCP 能干什么
|
||||
|
||||
**MCP(Model Context Protocol)** 是 AI 客户端连接外部工具的通用标准:AI 负责理解你的意图,MCP 工具负责真正干活。接上米剪 MCP 后,你的 AI 客户端就多了一组「剪视频」的能力。
|
||||
|
||||
米剪 MCP 的链路:
|
||||
|
||||
- AI 客户端(Claude / Cursor / Claude Code / Hermes …)
|
||||
- → `https://<米剪站点>/mcp`(Streamable HTTP,带 Bearer 令牌)
|
||||
- → unicut-mcp 服务(抓取 / 大模型文案 / edge-tts 配音 / 工程打包)
|
||||
- → 返回工程 ZIP 下载链接,米剪顶部「工程文件」导入即可出片
|
||||
|
||||
**10 个工具按用途分四组:**
|
||||
|
||||
- **自检**:`service_status`——一键检查抓取、配音、大模型、工程目录是否可用
|
||||
- **内容**:`grab_url` 抓网页正文与配图(支持公众号文章);`generate_script` 大模型写口播文案
|
||||
- **配音**:`list_voices` 列出可用音色;`tts` 合成配音(edge-tts)
|
||||
- **工程**:`create_video_project` 把图 + 文案 + 配音打包成米剪工程 ZIP;`list_projects` / `read_project` / `write_project` 直接读写工作文件夹里的工程(需服务端配置 `MCP_PROJECTS_DIR`)
|
||||
|
||||
## 二、连接前准备:端点与令牌
|
||||
|
||||
- **端点**:`https://cut.88531.cn/mcp`(本教程以米剪站为例;自部署站点换成你自己的地址)
|
||||
- **令牌**:`/mcp` 强制要求请求头 `Authorization: Bearer <令牌>`,令牌由站点管理员在服务端 `.env` 的 `MCP_AUTH_TOKEN` 配置
|
||||
- **没配令牌时服务拒绝一切调用**(fail-closed),这是故意的安全设计
|
||||
- 接入时向站点管理员索取令牌;自部署的按第七节自己生成
|
||||
- 令牌错误或没带 → 返回 `401 {"error":"unauthorized"}`,客户端里表现为「连接失败 / 401」
|
||||
- **健康检查**:`https://cut.88531.cn/mcp-health`(返回容器健康状态 JSON)
|
||||
- ⚠ `/mcp/health` **不是**端点——它会被前端回退成首页 HTML,别拿它测
|
||||
|
||||
## 三、接入你的 AI 客户端(四选一)
|
||||
|
||||
所有客户端的共同要求:**URL 用端点 + 请求头带 `Authorization: Bearer <令牌>`**。自部署站点若是自签证书,客户端需允许自签名(`--allow-self-signed` / `insecure`)。
|
||||
|
||||
**1. Claude Desktop**(编辑 `claude_desktop_config.json`):
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"unicut": {
|
||||
"command": "npx",
|
||||
"args": [
|
||||
"mcp-remote",
|
||||
"https://cut.88531.cn/mcp",
|
||||
"--allow-self-signed",
|
||||
"--header",
|
||||
"Authorization: Bearer <你的令牌>"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**2. Claude Code**(命令行一条命令):
|
||||
|
||||
```bash
|
||||
claude mcp add unicut --transport http \
|
||||
--header "Authorization: Bearer <你的令牌>" \
|
||||
https://cut.88531.cn/mcp
|
||||
```
|
||||
|
||||
**3. Cursor**(编辑 `~/.cursor/mcp.json`):
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"unicut": {
|
||||
"url": "https://cut.88531.cn/mcp",
|
||||
"headers": { "Authorization": "Bearer <你的令牌>" }
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**4. Hermes**(`config.yaml`):
|
||||
|
||||
```yaml
|
||||
mcp_servers:
|
||||
unicut:
|
||||
url: https://cut.88531.cn/mcp
|
||||
headers:
|
||||
Authorization: "Bearer <你的令牌>"
|
||||
```
|
||||
|
||||
配置保存后重开客户端,在工具/MCP 面板里应能看到 `unicut` 服务器和它的工具列表。看不到就先跑第五节的连通性验证。
|
||||
|
||||
## 四、工具逐个详解
|
||||
|
||||
以下参数为源码默认值,AI 会按需传参;你只要用自然语言说要求即可。
|
||||
|
||||
**1. `service_status()`——连通自检(无参数)**
|
||||
|
||||
接入后第一句话建议就是「检查米剪 MCP 服务状态」。返回:抓取反代、配音服务(含音色数)、大模型网关(地址/模型/Key 是否配置)、工程目录、对外地址五项状态。哪项 FAIL 一眼定位。
|
||||
|
||||
**2. `grab_url(url, max_images=20)`——抓网页正文与配图**
|
||||
|
||||
- 支持普通网页和公众号 `mp.weixin.qq.com` 文章
|
||||
- 返回 `{title, text(≤12000字), images[](最多20张)}`
|
||||
- 图片只是候选地址,后面打包时还会再校验(≥160×120、≤10MB)
|
||||
- 抓不到内容会明确报错,换一个页面重试即可
|
||||
|
||||
**3. `generate_script(source, requirement?, style?, target_seconds?, paragraph_count?)`——写口播文案**
|
||||
|
||||
- `source`:素材文本(上面抓的文章正文)或主题描述
|
||||
- `requirement`:额外要求(受众、卖点、关键词)
|
||||
- `style`:文案风格,默认「口播解说」
|
||||
- `target_seconds`:目标时长,默认 60 秒(总字数 ≈ 秒数 × 4.5 字)
|
||||
- `paragraph_count`:段落数,默认 6 段,**每段一句,直接对应一条字幕**
|
||||
- 返回 `{title, paragraphs[], text}`,模型输出是严格 JSON,解析失败会自动兜底按行切分
|
||||
|
||||
**4. `list_voices()`——列配音音色(无参数)**
|
||||
|
||||
返回 edge-tts 全部可用音色(`{count, voices[]}`)。想换人声先问它「有哪些女声/男声」。
|
||||
|
||||
**5. `tts(text, voice?, rate?, pitch?, volume?)`——合成配音**
|
||||
|
||||
- 默认音色 `zh-CN-XiaoxiaoNeural`,语速/音调/音量默认 `+0%`
|
||||
- `text` 建议 ≤2000 字
|
||||
- 返回 `{url(可直接播放), path(服务器文件路径), duration(秒)}`
|
||||
- **`path` 要记下来**——传给下一步打包工具的 `audio` 参数用它
|
||||
|
||||
**6. `create_video_project(title, images, script?, audio?, …)`——生成米剪工程**
|
||||
|
||||
- `title`:工程名
|
||||
- `images`:图片 URL 列表(最多 30 张,`grab_url` 的 images 直接可用)
|
||||
- `script`:口播文案,按换行自动切字幕(单段超 24 字自动按句拆)
|
||||
- `audio`:配音,填 `tts` 返回的 `path`
|
||||
- 画面默认竖屏 1080×1920;有配音时图片自动拉伸铺满配音时长,无配音每图 3 秒(`image_duration` 可调)
|
||||
- 返回 `{zip_path, zip_url, duration, captions, elements}`——**`zip_url` 就是下载链接**(形如 `https://cut.88531.cn/mcp-out/<工程名>.zip`)
|
||||
- 图片不合规(太小/太大/下载失败)会自动跳过并在 `warnings` 里说明,不会整单失败
|
||||
|
||||
**7. `list_projects()` / `read_project(id)` / `write_project(project)`——工作文件夹模式**
|
||||
|
||||
直接读写服务端「选择文件夹」对应目录里的 `projects/*.json`,适合长期批量改工程。**需要服务端配置 `MCP_PROJECTS_DIR`**,没配时这几个工具返回未启用(第七节)。
|
||||
|
||||
## 五、实战:一句话生成一条视频
|
||||
|
||||
把客户端配好后,直接对 AI 说:
|
||||
|
||||
> 「抓 https://mp.weixin.qq.com/s/xxxx 这篇文章,写一条 60 秒口播解说风格的文案,配晓晓的音色,做成竖屏工程给我。」
|
||||
|
||||
AI 会自动走这条链:
|
||||
|
||||
1. `grab_url` → 拿到标题、正文、配图
|
||||
2. `generate_script` → 60 秒、口播解说风格的分段文案
|
||||
3. `list_voices` 挑音色 + `tts` 合成配音 → 拿到 `path`
|
||||
4. `create_video_project` → 传标题、图片、文案、配音 → 拿到 `zip_url`
|
||||
5. 你下载 ZIP → 打开米剪 → 顶部「**工程文件**」导入 → 时间轴上图、配音、字幕、转场已就位 → 微调后右上角「导出」
|
||||
|
||||
也可以拆开单用:只要文案(跳过抓取直接给主题)、只要配音(把文案给它配成 mp3)、只要打包(素材都齐了让它组装)。
|
||||
|
||||

|
||||
*图:ZIP 导入后:图、配音、字幕、转场已在时间轴上就位*
|
||||
|
||||

|
||||
*图:微调后点右上角「导出」即可出片*
|
||||
|
||||
## 六、连通性验证(命令行自查)
|
||||
|
||||
怀疑连不上时,用 curl 直接做协议握手(把令牌替换进去):
|
||||
|
||||
```bash
|
||||
curl -s https://cut.88531.cn/mcp \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Accept: application/json, text/event-stream' \
|
||||
-H 'Authorization: Bearer <你的令牌>' \
|
||||
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"0"}}}'
|
||||
```
|
||||
|
||||
- **返回 JSON-RPC 响应**(含 `serverInfo`)→ 通了,去客户端里正常用
|
||||
- **返回 `401 {"error":"unauthorized"}`** → 令牌没带或不对,回第二节核对
|
||||
- **超时 / 连接被拒** → 网络或反代问题,跑 `https://cut.88531.cn/mcp-health` 看服务是否在线
|
||||
|
||||
## 七、自部署者:.env 配置(站点管理员视角)
|
||||
|
||||
compose 已内置 `unicut-mcp` 服务,密钥全部走项目 `.env`(勿提交):
|
||||
|
||||
```bash
|
||||
MCP_LLM_BASE=http://192.168.68.19:3099/v1 # OpenAI 兼容 /v1 网关地址
|
||||
MCP_LLM_KEY=sk-xxxx # 网关 Key(generate_script 用)
|
||||
MCP_LLM_MODEL=mimo-v2.6-flash # 文案生成模型
|
||||
MCP_PUBLIC_URL=https://cut.88531.cn # 对外站点地址(拼 zip_url / 音频 URL 用)
|
||||
MCP_AUTH_TOKEN=<随机长串> # 必填:/mcp 的 Bearer 令牌
|
||||
MCP_PROJECTS_DIR= # 可选:工作文件夹模式的工程目录
|
||||
```
|
||||
|
||||
令牌生成一条命令:
|
||||
|
||||
```bash
|
||||
python3 -c 'import secrets;print(secrets.token_urlsafe(32))'
|
||||
```
|
||||
|
||||
改完 `.env` 重建服务:
|
||||
|
||||
```bash
|
||||
docker compose up -d --build unicut-mcp
|
||||
```
|
||||
|
||||
> 只有 `service_status` / `grab_url` / `generate_script` 需要网络依赖;`tts` 依赖同 compose 的 `unicut-tts` 配音容器;`.env` 没配时除大模型类工具外其余照常可用。局域网内也可绕过 nginx 直连容器 `http://<主机>:8765/mcp`(默认只在 compose 网络内,未映射宿主端口)。
|
||||
|
||||
## 八、常见问题
|
||||
|
||||
**1. 客户端一直「连接失败」或 401?**
|
||||
九成是令牌:没带、带错、或服务端 `MCP_AUTH_TOKEN` 未配置(未配置 = 一律拒绝)。按第二节核对请求头格式 `Authorization: Bearer ***令牌>`,注意 `Bearer` 后有一个空格。
|
||||
|
||||
**2. 浏览器打开 `/mcp` 显示的是米剪首页?**
|
||||
正常——`/mcp` 要用 MCP 客户端以 POST + SSE 方式访问,浏览器 GET 会被前端路由接住。健康检查请用 `/mcp-health`。
|
||||
|
||||
**3. 提示证书错误(self-signed certificate)?**
|
||||
自部署站点默认自签证书:Claude Desktop 加 `--allow-self-signed`,其他客户端把 URL 换成局域网地址或给客户端开 insecure 忽略自签。
|
||||
|
||||
**4. `generate_script` 报「模型未返回可用文案」?**
|
||||
服务端大模型网关没配好或 Key 额度用完——管理员检查 `MCP_LLM_BASE` / `MCP_LLM_KEY`,跑 `service_status` 看 `llm` 项。
|
||||
|
||||
**5. 配音工具报错或没有想要的音色?**
|
||||
先 `list_voices` 看服务是否在线、有哪些音色;`tts` 依赖同 compose 的配音容器,管理员看 `service_status` 的 `tts` 项。
|
||||
|
||||
**6. 生成的工程里图片少了?**
|
||||
被自动过滤了:尺寸 <160×120、文件 >10MB、或下载失败的图会跳过(返回的 `warnings` 里写明原因),单次最多 30 张。换清晰合规的图重跑即可。
|
||||
|
||||
**7. `list_projects` 说未启用?**
|
||||
服务端没配 `MCP_PROJECTS_DIR`,文件夹模式工具自然不存在;需要的话管理员在 `.env` 加上并重建容器。
|
||||
|
||||
**8. AI 说「找不到 unicut 这组工具」?**
|
||||
客户端没加载成功:确认配置文件路径、URL、令牌后**重启客户端**;命令行客户端可用第六节 curl 先验证服务本身是通的。
|
||||
|
||||
## 九、相关链接
|
||||
|
||||
- [AI 一键出片新手教程](/article/about) —— 站内四步出片的完整操作
|
||||
- [米剪新手使用教程](/article/local-deploy-guide) —— 界面、时间轴、字幕、导出入门
|
||||
- [断网也能用:米剪 离线能力说明](/article/offline-ready) —— 哪些功能离线可用
|
||||
- **`https://cut.88531.cn/mcp-health`**—— MCP 服务健康检查端点
|
||||
@@ -14,7 +14,7 @@
|
||||
# 构建日志统一写 /tmp/unicut_build_site.log。
|
||||
set -euo pipefail
|
||||
|
||||
SRC=/vol1/1000/HD1/docker/unicut-src
|
||||
SRC=/vol3/1000/HD3/docker/unicut-src
|
||||
LOCK=/tmp/unicut_build.lock
|
||||
LOG=/tmp/unicut_build_site.log
|
||||
SITE=https://127.0.0.1:3005
|
||||
@@ -45,7 +45,8 @@ fi
|
||||
# ---------- 3. 构建 + 发布 ----------
|
||||
echo "[build] docker compose build unicut(日志:$LOG)"
|
||||
{
|
||||
docker compose build unicut
|
||||
# docker.io DNS 污染环境:legacy 构建器直接用本地基础镜像,不向 docker.io 查元数据
|
||||
DOCKER_BUILDKIT=0 docker compose build unicut
|
||||
docker compose up -d --no-build unicut
|
||||
} 2>&1 | tee "$LOG"
|
||||
|
||||
|
||||
@@ -8,11 +8,12 @@
|
||||
# 即可拉取(拉取是 GET 响应,不受请求体积限制影响)。
|
||||
#
|
||||
# 用法:bash scripts/push_registry.sh [镜像:tag] [版本tag]
|
||||
# 默认:unicut-src-unicut:latest → :latest + :v1.0.0
|
||||
# 默认:unicut-src-unicut:latest → :latest + :v<package.json 版本>
|
||||
set -euo pipefail
|
||||
|
||||
IMG="${1:-unicut-src-unicut:latest}"
|
||||
VERSION_TAG="${2:-v1.0.0}"
|
||||
DEFAULT_VER="v$(grep -oP '"version":\s*"\K[^"]+' package.json | head -1)"
|
||||
VERSION_TAG="${2:-${DEFAULT_VER:-v1.0.0}}"
|
||||
REG="192.168.68.19:3200" # 内网 Gitea(绕开公网 nginx)
|
||||
OWNER="jinghui"
|
||||
PKG="unicut"
|
||||
|
||||
@@ -9,7 +9,7 @@ import Folders from './Folders';
|
||||
import { pubsub } from '@utils/pubsub';
|
||||
import { util } from '@utils/index';
|
||||
import _remove from 'lodash/remove';
|
||||
import { FailPicture, Right, Scissors, Upload as UploadIcon } from '@icon-park/react';
|
||||
import { FailPicture, Right, Scissors, Upload as UploadIcon, Download } from '@icon-park/react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import SelectedSet from './SelectedSet';
|
||||
import { user } from '@stores/user';
|
||||
@@ -499,6 +499,17 @@ function Content(props: IProps, ref: any) {
|
||||
</Button>
|
||||
</Upload>
|
||||
)}
|
||||
{props.type === 'material' && (
|
||||
<Button
|
||||
icon={<Download theme="outline" size="20" fill="#FFF" />}
|
||||
size="large"
|
||||
onClick={() => {
|
||||
window.open('https://doc.88531.cn/docs/mrfx/mrfx-1g99qum57n5qk', '_blank');
|
||||
}}
|
||||
>
|
||||
<span style={{ color: 'var(--theme-text)' }}>{language.val('my_download_more')}</span>
|
||||
</Button>
|
||||
)}
|
||||
{!props.categoryName && (
|
||||
<Button
|
||||
onClick={async () => {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import styles from './content.module.less';
|
||||
import { server as draftServer } from '@pages/workspace/draft/server';
|
||||
import { server as materialServer } from '@pages/workspace/material/server';
|
||||
import { Button, Space, Checkbox, Modal, Toast, Popover } from '@douyinfe/semi-ui';
|
||||
import { observer } from 'mobx-react';
|
||||
import { layout } from '@stores/layout';
|
||||
@@ -8,6 +7,7 @@ import { userService } from '@server/user.service';
|
||||
import { pubsub } from '@utils/pubsub';
|
||||
import _remove from 'lodash/remove';
|
||||
import { language, Intl } from '@language/index';
|
||||
import { deleteLocalCategory, deleteMaterial as deleteLocalMaterial } from '@services/localStorageService';
|
||||
|
||||
export interface IProps {
|
||||
items: any[];
|
||||
@@ -61,13 +61,19 @@ function SelectedSet(props: IProps) {
|
||||
title: language.val('draft_batch_modal_title'),
|
||||
content: language.val('draft_batch_modal_content'),
|
||||
onOk: async () => {
|
||||
// 删除分类
|
||||
// 删除分类(文件夹):本地优先(本部署无 /user 后端),本地没有该分类时回退服务器接口
|
||||
const ids = layout.selects.filter(d => d.type === 'folder').map(d => d.id);
|
||||
if (ids.length) {
|
||||
const [res, err] = await userService.deleteCategory(ids);
|
||||
if (err) {
|
||||
Toast.error(err);
|
||||
return;
|
||||
const t = props.type === 'draft' ? 'project' : 'material';
|
||||
for (const fid of ids) {
|
||||
let [res, err] = await deleteLocalCategory(t as 'project' | 'material', fid);
|
||||
if (err === '分类不存在') {
|
||||
[res, err] = await userService.deleteCategory([fid]);
|
||||
}
|
||||
if (err) {
|
||||
Toast.error(err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
pubsub.publish('updateFolders');
|
||||
}
|
||||
@@ -89,17 +95,17 @@ function SelectedSet(props: IProps) {
|
||||
}
|
||||
}
|
||||
|
||||
// 删除素材
|
||||
// 删除素材:列表数据源就是 localDB,删除磁盘文件 + IndexedDB 记录(含封面/帧图/音波图)
|
||||
if (props.type === 'material') {
|
||||
const ids2 = layout.selects.filter(d => d.type === 'item').map(d => d.id);
|
||||
if (ids2.length) {
|
||||
deleteIds.push(...ids2);
|
||||
const [res2, err2] = await materialServer.deleteMaterial({
|
||||
id: ids2,
|
||||
});
|
||||
if (err2) {
|
||||
Toast.error(err2);
|
||||
return;
|
||||
for (const id of ids2) {
|
||||
try {
|
||||
await deleteLocalMaterial(id);
|
||||
} catch (e) {
|
||||
/* 单个失败不阻断其余删除 */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +109,13 @@ const Header = (props: IProps) => {
|
||||
>
|
||||
使用教程
|
||||
</NavLink>
|
||||
<NavLink
|
||||
to="/article/mcp-guide"
|
||||
className={styles.text}
|
||||
activeClassName={styles.active}
|
||||
>
|
||||
MCP 使用说明
|
||||
</NavLink>
|
||||
{/* <a
|
||||
href={languageType === 'en-US' ? '/docs/en' : '/docs'}
|
||||
target="_blank"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
border-radius: 12px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 1px solid rgba(127, 127, 127, 0.35);
|
||||
color: inherit;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.2px;
|
||||
@@ -59,8 +59,8 @@
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
border-radius: 50%;
|
||||
color: inherit;
|
||||
opacity: 0.85;
|
||||
color: #fff;
|
||||
opacity: 1;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s ease;
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ export const enUS = {
|
||||
my_upload: 'Upload',
|
||||
my_upload_mobile_link: 'Upload Mobile',
|
||||
my_upload_refresh: 'Refresh List',
|
||||
my_download_more: 'Download More Assets',
|
||||
my_tab_material: 'Current Materials',
|
||||
my_tab_all_material: 'All Materials',
|
||||
my_tab_no_material: 'No materials in this project. Please upload first.',
|
||||
@@ -413,7 +414,7 @@ export const enUS = {
|
||||
user_profile: 'User Profile',
|
||||
common_create_video: 'Create Video',
|
||||
common_tech_docs: 'Docs',
|
||||
common_about_us: 'About Us',
|
||||
common_about_us: 'AI Quick Video Guide',
|
||||
common_tools: 'Tools',
|
||||
common_home: 'Home',
|
||||
common_navigation: 'Navigation',
|
||||
|
||||
@@ -91,6 +91,7 @@ export const zhCN = {
|
||||
my_upload: '上传素材',
|
||||
my_upload_mobile_link: '手机上传',
|
||||
my_upload_refresh: '刷新列表',
|
||||
my_download_more: '下载更多素材',
|
||||
my_tab_material: '当前素材',
|
||||
my_tab_all_material: '全部素材',
|
||||
my_tab_no_material: '该项目暂无素材,请先上传',
|
||||
@@ -412,7 +413,7 @@ export const zhCN = {
|
||||
user_profile: '用户中心',
|
||||
common_create_video: '创建视频',
|
||||
common_tech_docs: '技术文档',
|
||||
common_about_us: '关于我们',
|
||||
common_about_us: 'AI 一键出片教程',
|
||||
common_tools: '快捷工具',
|
||||
common_home: '首页',
|
||||
common_navigation: '导航',
|
||||
|
||||
@@ -6,8 +6,11 @@
|
||||
* - 正文:public/articles/<slug>.md
|
||||
* - 索引:public/articles/index.json(id 必须等于 slug)
|
||||
* - slug:^[a-z0-9]+(?:-[a-z0-9]+)*$,≤64 字符
|
||||
*
|
||||
* 版式:左侧浮动目录(锚点快速定位 + 滚动高亮)+ 中间正文 + 右侧浮动「更多教程」,
|
||||
* 两侧面板 position: sticky 固定显示;窄屏(≤1280px)自动收起为单栏。
|
||||
*/
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Link, useParams } from 'react-router-dom';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import SubHeader from '@components/header/Header';
|
||||
@@ -26,12 +29,34 @@ interface ArticleMeta {
|
||||
tags?: string[];
|
||||
}
|
||||
|
||||
interface TocItem {
|
||||
id: string;
|
||||
text: string;
|
||||
level: 2 | 3;
|
||||
}
|
||||
|
||||
/** 标题文本 → 锚点 id:小写、空白转连字符、仅保留字母数字(含中文)与连字符 */
|
||||
function slugify(s: string): string {
|
||||
return (
|
||||
s
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/\s+/g, '-')
|
||||
.replace(/[^\p{L}\p{N}-]/gu, '')
|
||||
.replace(/-{2,}/g, '-')
|
||||
.replace(/^-+|-+$/g, '') || 'section'
|
||||
);
|
||||
}
|
||||
|
||||
function ArticleDetail() {
|
||||
const { slug } = useParams<{ slug: string }>();
|
||||
const [meta, setMeta] = useState<ArticleMeta | null>(null);
|
||||
const [list, setList] = useState<ArticleMeta[]>([]);
|
||||
const [md, setMd] = useState<string>('');
|
||||
const [state, setState] = useState<'loading' | 'ok' | 'notfound' | 'badslug'>('loading');
|
||||
const [toc, setToc] = useState<TocItem[]>([]);
|
||||
const [active, setActive] = useState<string>('');
|
||||
const articleRef = useRef<HTMLElement | null>(null);
|
||||
|
||||
const valid = useMemo(() => !!slug && slug.length <= SLUG_MAX && SLUG_RE.test(slug), [slug]);
|
||||
|
||||
@@ -69,6 +94,65 @@ function ArticleDetail() {
|
||||
};
|
||||
}, [slug, valid]);
|
||||
|
||||
// 正文渲染完成后:给 h2/h3 挂锚点 id,并生成左侧目录
|
||||
useEffect(() => {
|
||||
if (state !== 'ok' || !md) return;
|
||||
const root = articleRef.current;
|
||||
if (!root) return;
|
||||
const heads = Array.from(root.querySelectorAll<HTMLElement>('h2, h3'));
|
||||
const seen: Record<string, number> = {};
|
||||
const items: TocItem[] = heads.map(el => {
|
||||
const base = slugify(el.textContent || '');
|
||||
const n = (seen[base] = (seen[base] || 0) + 1);
|
||||
const id = n > 1 ? `${base}-${n}` : base;
|
||||
el.id = id;
|
||||
return { id, text: (el.textContent || '').trim(), level: el.tagName === 'H3' ? 3 : 2 };
|
||||
});
|
||||
setToc(items);
|
||||
setActive(items[0]?.id || '');
|
||||
// 带锚点进入(/article/xxx#heading)时直接定位
|
||||
if (location.hash) {
|
||||
const target = document.getElementById(decodeURIComponent(location.hash.slice(1)));
|
||||
if (target) requestAnimationFrame(() => target.scrollIntoView({ block: 'start' }));
|
||||
}
|
||||
}, [md, state]);
|
||||
|
||||
// 滚动时高亮目录当前节(rAF 节流)
|
||||
useEffect(() => {
|
||||
if (!toc.length) return;
|
||||
let raf = 0;
|
||||
const onScroll = () => {
|
||||
if (raf) return;
|
||||
raf = requestAnimationFrame(() => {
|
||||
raf = 0;
|
||||
const y = window.scrollY + 140;
|
||||
let cur = toc[0].id;
|
||||
for (const t of toc) {
|
||||
const el = document.getElementById(t.id);
|
||||
if (!el) continue;
|
||||
if (el.getBoundingClientRect().top + window.scrollY <= y) cur = t.id;
|
||||
else break;
|
||||
}
|
||||
setActive(prev => (prev === cur ? prev : cur));
|
||||
});
|
||||
};
|
||||
onScroll();
|
||||
window.addEventListener('scroll', onScroll, { passive: true });
|
||||
return () => {
|
||||
window.removeEventListener('scroll', onScroll);
|
||||
if (raf) cancelAnimationFrame(raf);
|
||||
};
|
||||
}, [toc]);
|
||||
|
||||
const goTo = (e: React.MouseEvent, id: string) => {
|
||||
e.preventDefault();
|
||||
const el = document.getElementById(id);
|
||||
if (!el) return;
|
||||
setActive(id);
|
||||
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
history.replaceState(null, '', '#' + id);
|
||||
};
|
||||
|
||||
const others = list.filter(d => d.id !== slug).slice(0, 6);
|
||||
|
||||
return (
|
||||
@@ -77,29 +161,52 @@ function ArticleDetail() {
|
||||
title={meta?.title || (state === 'badslug' ? '链接无效' : '米剪 教程')}
|
||||
desc={meta?.description || language.val('common_company')}
|
||||
/>
|
||||
<div className={styles.wrap}>
|
||||
{state === 'loading' && <p className={styles.tip}>加载中…</p>}
|
||||
|
||||
{state === 'badslug' && (
|
||||
<div className={styles.tip}>
|
||||
<p>这个地址不符合文章链接规则(只允许小写字母、数字和连字符)。</p>
|
||||
<Link to="/">回到首页</Link>
|
||||
</div>
|
||||
<div className={styles.layout}>
|
||||
{toc.length > 0 && (
|
||||
<nav className={styles.toc} aria-label="文章目录">
|
||||
<div className={styles.tocTitle}>目录</div>
|
||||
<ul className={styles.tocList}>
|
||||
{toc.map(t => (
|
||||
<li key={t.id} className={t.level === 3 ? styles.lvl3 : undefined}>
|
||||
<a
|
||||
href={'#' + t.id}
|
||||
className={active === t.id ? styles.active : undefined}
|
||||
onClick={e => goTo(e, t.id)}
|
||||
>
|
||||
{t.text}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</nav>
|
||||
)}
|
||||
|
||||
{state === 'notfound' && (
|
||||
<div className={styles.tip}>
|
||||
<p>没有找到这篇文章:{slug}</p>
|
||||
<Link to="/">回到首页</Link>
|
||||
</div>
|
||||
)}
|
||||
<div className={styles.main}>
|
||||
{state === 'loading' && <p className={styles.tip}>加载中…</p>}
|
||||
|
||||
{(state === 'ok' || (state === 'loading' && md)) && (
|
||||
<article className={styles.article}>
|
||||
{meta?.date && <p className={styles.meta}>更新于 {meta.date}</p>}
|
||||
<ReactMarkdown className={styles.md}>{md}</ReactMarkdown>
|
||||
</article>
|
||||
)}
|
||||
{state === 'badslug' && (
|
||||
<div className={styles.tip}>
|
||||
<p>这个地址不符合文章链接规则(只允许小写字母、数字和连字符)。</p>
|
||||
<Link to="/">回到首页</Link>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{state === 'notfound' && (
|
||||
<div className={styles.tip}>
|
||||
<p>没有找到这篇文章:{slug}</p>
|
||||
<Link to="/">回到首页</Link>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(state === 'ok' || (state === 'loading' && md)) && (
|
||||
<article className={styles.article} ref={articleRef}>
|
||||
{meta?.date && <p className={styles.meta}>更新于 {meta.date}</p>}
|
||||
<div className={styles.md}>
|
||||
<ReactMarkdown>{md}</ReactMarkdown>
|
||||
</div>
|
||||
</article>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{others.length > 0 && (
|
||||
<aside className={styles.related}>
|
||||
|
||||
@@ -5,12 +5,23 @@
|
||||
background: #f5f6fa;
|
||||
}
|
||||
|
||||
.wrap {
|
||||
// 三栏布局:左浮动目录 + 正文 + 右浮动「更多教程」
|
||||
.layout {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
max-width: 880px;
|
||||
max-width: none; // 自适应全屏,不再锁 1440
|
||||
margin: 0 auto;
|
||||
padding: 32px 20px 64px;
|
||||
padding: 92px 28px 72px; // 顶部让开 fixed 导航(60px)+ 间距
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
gap: 28px;
|
||||
}
|
||||
|
||||
.main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
max-width: none; // 主体自适应吃满剩余宽度,不再锁 940
|
||||
}
|
||||
|
||||
.tip {
|
||||
@@ -29,112 +40,92 @@
|
||||
}
|
||||
|
||||
.article {
|
||||
padding: 28px 32px;
|
||||
padding: 40px 48px 48px;
|
||||
background: #fff;
|
||||
border: 1px solid #e4e6eb;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #e8eaed;
|
||||
border-radius: 14px;
|
||||
box-shadow: 0 1px 3px rgba(16, 24, 40, 0.05);
|
||||
}
|
||||
|
||||
.meta {
|
||||
margin: 0 0 16px;
|
||||
margin: 0 0 6px;
|
||||
color: #9aa0a6;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.md {
|
||||
font-size: 15px;
|
||||
line-height: 1.9;
|
||||
color: #202124;
|
||||
word-break: break-word;
|
||||
// ---------- 左侧浮动目录 ----------
|
||||
.toc {
|
||||
position: sticky;
|
||||
top: 76px; // fixed 导航 60px + 16px 间距
|
||||
flex-shrink: 0;
|
||||
width: 224px;
|
||||
max-height: calc(100vh - 108px);
|
||||
overflow-y: auto;
|
||||
padding: 18px 16px 18px 0;
|
||||
}
|
||||
|
||||
:global {
|
||||
h1 {
|
||||
font-size: 26px;
|
||||
margin: 8px 0 18px;
|
||||
}
|
||||
.tocTitle {
|
||||
margin: 0 0 10px 14px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.12em;
|
||||
color: #9aa0a6;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 20px;
|
||||
margin: 28px 0 12px;
|
||||
padding-left: 10px;
|
||||
border-left: 4px solid #202124;
|
||||
}
|
||||
.tocList {
|
||||
margin: 0;
|
||||
padding: 0 0 0 2px;
|
||||
list-style: none;
|
||||
border-left: 2px solid #e8eaed;
|
||||
|
||||
h3 {
|
||||
font-size: 17px;
|
||||
margin: 22px 0 10px;
|
||||
}
|
||||
li a {
|
||||
display: block;
|
||||
padding: 7px 8px 7px 14px;
|
||||
margin-left: -2px;
|
||||
border-left: 2px solid transparent;
|
||||
color: #5f6368;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.55;
|
||||
text-decoration: none;
|
||||
border-radius: 0 8px 8px 0;
|
||||
transition: color 0.15s, border-color 0.15s, background 0.15s;
|
||||
|
||||
p,
|
||||
ul,
|
||||
ol {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
li {
|
||||
margin: 4px 0;
|
||||
}
|
||||
|
||||
code {
|
||||
background: #f1f3f4;
|
||||
border-radius: 4px;
|
||||
padding: 1px 6px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
pre {
|
||||
background: #f8f9fb;
|
||||
border: 1px solid #e4e6eb;
|
||||
border-radius: 8px;
|
||||
padding: 14px;
|
||||
overflow: auto;
|
||||
|
||||
code {
|
||||
background: none;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
blockquote {
|
||||
margin: 14px 0;
|
||||
padding: 8px 16px;
|
||||
border-left: 4px solid #dadce0;
|
||||
color: #5f6368;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
margin: 14px 0;
|
||||
|
||||
th,
|
||||
td {
|
||||
border: 1px solid #e4e6eb;
|
||||
padding: 8px 12px;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
a {
|
||||
&:hover {
|
||||
color: #1a73e8;
|
||||
background: #f0f6ff;
|
||||
}
|
||||
}
|
||||
|
||||
li.lvl3 a {
|
||||
padding-left: 30px;
|
||||
font-size: 13px;
|
||||
color: #80868b;
|
||||
}
|
||||
|
||||
li a.active {
|
||||
color: #1a73e8;
|
||||
font-weight: 600;
|
||||
border-left-color: #1a73e8;
|
||||
background: #f0f6ff;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 右侧浮动「更多教程」----------
|
||||
.related {
|
||||
margin-top: 24px;
|
||||
padding: 20px 24px;
|
||||
position: sticky;
|
||||
top: 76px;
|
||||
flex-shrink: 0;
|
||||
width: 256px;
|
||||
padding: 20px 20px 12px;
|
||||
background: #fff;
|
||||
border: 1px solid #e4e6eb;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #e8eaed;
|
||||
border-radius: 14px;
|
||||
box-shadow: 0 1px 3px rgba(16, 24, 40, 0.05);
|
||||
|
||||
h3 {
|
||||
margin: 0 0 12px;
|
||||
font-size: 16px;
|
||||
margin: 0 0 6px;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
ul {
|
||||
@@ -144,29 +135,273 @@
|
||||
}
|
||||
|
||||
li {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 10px;
|
||||
padding: 8px 0;
|
||||
border-top: 1px dashed #e4e6eb;
|
||||
display: block;
|
||||
padding: 11px 10px;
|
||||
margin: 0 -10px;
|
||||
border-top: 1px solid #f1f3f4;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
|
||||
&:first-child {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #f7f9fc;
|
||||
}
|
||||
|
||||
a {
|
||||
display: block;
|
||||
color: #202124;
|
||||
font-weight: 600;
|
||||
line-height: 1.5;
|
||||
text-decoration: none;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
|
||||
&:hover {
|
||||
color: #1a73e8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.desc {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
color: #9aa0a6;
|
||||
font-size: 13px;
|
||||
font-size: 12.5px;
|
||||
line-height: 1.6;
|
||||
margin-top: 3px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
// ---------- 正文排版 ----------
|
||||
.md {
|
||||
font-size: 16px;
|
||||
line-height: 2;
|
||||
color: #2b2d31;
|
||||
word-break: break-word;
|
||||
|
||||
:global {
|
||||
h1 {
|
||||
font-size: 30px;
|
||||
font-weight: 800;
|
||||
line-height: 1.4;
|
||||
letter-spacing: -0.01em;
|
||||
margin: 0 0 14px;
|
||||
color: #0f1419;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 23px;
|
||||
font-weight: 700;
|
||||
line-height: 1.45;
|
||||
margin: 52px 0 18px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 0;
|
||||
background: linear-gradient(90deg, #1a73e8, rgba(26, 115, 232, 0)) no-repeat left bottom / 100% 2px;
|
||||
color: #0f1419;
|
||||
scroll-margin-top: 84px; // 锚点跳转让开 fixed 导航
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 18.5px;
|
||||
font-weight: 700;
|
||||
line-height: 1.5;
|
||||
margin: 38px 0 14px;
|
||||
color: #1f2328;
|
||||
scroll-margin-top: 84px;
|
||||
}
|
||||
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
margin: 30px 0 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
ul,
|
||||
ol {
|
||||
margin: 18px 0;
|
||||
padding-left: 1.6em;
|
||||
}
|
||||
|
||||
li {
|
||||
margin: 10px 0;
|
||||
line-height: 1.95;
|
||||
|
||||
&::marker {
|
||||
color: #1a73e8;
|
||||
}
|
||||
}
|
||||
|
||||
li p {
|
||||
margin: 6px 0;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: 700;
|
||||
color: #0f1419;
|
||||
}
|
||||
|
||||
code {
|
||||
background: #f4f5f7;
|
||||
border: 1px solid #eceef1;
|
||||
border-radius: 6px;
|
||||
padding: 2px 7px;
|
||||
font-size: 14.5px;
|
||||
color: #c7254e;
|
||||
}
|
||||
|
||||
pre {
|
||||
background: #101828;
|
||||
border: 1px solid #1d2939;
|
||||
border-radius: 12px;
|
||||
padding: 20px 22px;
|
||||
overflow: auto;
|
||||
margin: 24px 0;
|
||||
line-height: 1.75;
|
||||
|
||||
code {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
color: #d0d5dd;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
blockquote {
|
||||
margin: 24px 0;
|
||||
padding: 14px 22px;
|
||||
background: #eef4fd;
|
||||
border-left: 4px solid #1a73e8;
|
||||
border-radius: 0 10px 10px 0;
|
||||
color: #3c4043;
|
||||
font-size: 15.5px;
|
||||
|
||||
p {
|
||||
margin: 8px 0;
|
||||
}
|
||||
|
||||
strong {
|
||||
color: #174ea6;
|
||||
}
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
margin: 26px 0;
|
||||
border: 1px solid #e8eaed;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
font-size: 15px;
|
||||
|
||||
th {
|
||||
background: #f6f8fa;
|
||||
font-weight: 700;
|
||||
color: #0f1419;
|
||||
padding: 11px 16px;
|
||||
border: 1px solid #e8eaed;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 11px 16px;
|
||||
border: 1px solid #e8eaed;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
tr:nth-child(even) td {
|
||||
background: #fafbfc;
|
||||
}
|
||||
}
|
||||
|
||||
hr {
|
||||
border: 0;
|
||||
border-top: 1px solid #e8eaed;
|
||||
margin: 48px 0;
|
||||
}
|
||||
|
||||
img {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
margin: 30px auto;
|
||||
border: 1px solid #e4e7ec;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 6px 22px rgba(15, 20, 25, 0.10);
|
||||
}
|
||||
|
||||
// 图片段落:整段居中,同段软换行的斜体作图注
|
||||
p:has(> img) {
|
||||
text-align: center;
|
||||
margin: 34px 0 6px;
|
||||
|
||||
em {
|
||||
display: block;
|
||||
margin-top: 12px;
|
||||
color: #9aa0a6;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.6;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
a {
|
||||
color: #1a73e8;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 窄屏:收起两侧浮动面板,恢复单栏 ----------
|
||||
@media (max-width: 1280px) {
|
||||
.layout {
|
||||
flex-wrap: wrap;
|
||||
padding: 84px 16px 56px;
|
||||
}
|
||||
|
||||
.toc {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.main {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.related {
|
||||
position: static;
|
||||
width: 100%;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.article {
|
||||
padding: 28px 22px 36px;
|
||||
}
|
||||
|
||||
.md {
|
||||
font-size: 15.5px;
|
||||
|
||||
:global {
|
||||
h1 {
|
||||
font-size: 25px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 21px;
|
||||
margin-top: 40px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import styles from './styles.module.less';
|
||||
import { Tag, TextArea, RadioGroup, Radio, Select, Image, Button, Slider, Toast } from '@douyinfe/semi-ui';
|
||||
import { observer } from 'mobx-react';
|
||||
import SourceList from './SourceList';
|
||||
import { getClosestVideoRatioEnhanced } from '@pages/editor/tools/tools';
|
||||
import { getImageToVideoParams } from './aiConfig';
|
||||
import { stores } from '@stores/index';
|
||||
// import { StarOne } from '@icon-park/react';
|
||||
|
||||
export interface IProps {}
|
||||
|
||||
function AiImage(props: IProps) {
|
||||
const { editor } = stores;
|
||||
const [aiAction, setAiAction] = useState('image-to-image');
|
||||
const [count, setCount] = useState(1);
|
||||
const [description, setDescription] = useState('');
|
||||
|
||||
// 获取视频比例
|
||||
// const { ratio } = getClosestVideoRatioEnhanced(editor.data.width, editor.data.height);
|
||||
const [size, setSize] = useState('1K');
|
||||
const sourceListRef = useRef<any>(null);
|
||||
|
||||
const Icon = (props: { size?: number }) => {
|
||||
return (
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width={props.size || 16}
|
||||
height={props.size || 16}
|
||||
focusable="false"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path
|
||||
d="M9.68 5.45c.22-1.1 1.8-1.1 2.02 0a8.79 8.79 0 0 0 6.85 6.85c1.1.22 1.1 1.8 0 2.02a8.79 8.79 0 0 0-6.85 6.85c-.22 1.1-1.8 1.1-2.02 0a8.79 8.79 0 0 0-6.85-6.85c-1.1-.22-1.1-1.8 0-2.02a8.79 8.79 0 0 0 6.85-6.85Zm8.48-3.85c.16-.8 1.31-.8 1.48 0a3.54 3.54 0 0 0 2.76 2.76c.8.17.8 1.32 0 1.48a3.54 3.54 0 0 0-2.76 2.76c-.17.8-1.32.8-1.48 0a3.54 3.54 0 0 0-2.76-2.76c-.8-.16-.8-1.31 0-1.48a3.54 3.54 0 0 0 2.76-2.76Z"
|
||||
fill="currentColor"
|
||||
></path>
|
||||
</svg>
|
||||
);
|
||||
};
|
||||
|
||||
// 处理表单提交
|
||||
const handleGenerate = async () => {
|
||||
// 获取参考元素数据
|
||||
const urls = sourceListRef.current?.getURLs() || [];
|
||||
|
||||
// 整合所有表单数据
|
||||
const formData = {
|
||||
aiAction,
|
||||
description,
|
||||
size,
|
||||
count,
|
||||
urls: urls.map(d => d.url),
|
||||
};
|
||||
|
||||
if (formData.urls.length === 0 && aiAction !== 'text-to-image') {
|
||||
Toast.error('图生图必须选择一个参考图');
|
||||
return;
|
||||
}
|
||||
|
||||
// 图生视频
|
||||
const params = await getImageToVideoParams(formData);
|
||||
if (!params) {
|
||||
return;
|
||||
}
|
||||
const [res, err] = await editor.apiServer.createAiTask(params);
|
||||
if (!err) {
|
||||
Toast.success('任务创建成功');
|
||||
} else {
|
||||
Toast.error(err);
|
||||
}
|
||||
console.log('表单数据:', formData);
|
||||
|
||||
// 这里可以添加后续的生成逻辑,比如调用API等
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.ai + ' scroll'}>
|
||||
<h1>参数设置</h1>
|
||||
<div className={styles.model}>
|
||||
<Select value={aiAction} style={{ width: '100%' }} onChange={setAiAction} placeholder="选择AI类型">
|
||||
<Select.Option value="text-to-image">文生图</Select.Option>
|
||||
<Select.Option value="image-to-image">图生图</Select.Option>
|
||||
<Select.Option value="images-to-image">多图融合</Select.Option>
|
||||
</Select>
|
||||
{/* <div className={styles.desc}>根据输入的文本内容进行</div> */}
|
||||
{aiAction !== 'text-to-image' && (
|
||||
<div className={styles.inner}>
|
||||
<h2>参考元素</h2>
|
||||
<SourceList action={aiAction} limitType="image" ref={sourceListRef} />
|
||||
</div>
|
||||
)}
|
||||
<div className={styles.inner}>
|
||||
<h2>描述信息</h2>
|
||||
<div className={styles.inner}>
|
||||
<TextArea
|
||||
style={{ width: '100%' }}
|
||||
rows={4}
|
||||
placeholder="请输入描述信息"
|
||||
value={description}
|
||||
onChange={setDescription}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.inner}>
|
||||
<h2>尺寸设置</h2>
|
||||
<Select value={size} style={{ width: '100%' }} onChange={setSize} placeholder="选择尺寸">
|
||||
<Select.Option value="1K">1K</Select.Option>
|
||||
<Select.Option value="2K">2K</Select.Option>
|
||||
<Select.Option value="3K">3K</Select.Option>
|
||||
<Select.Option value="4K">4K</Select.Option>
|
||||
{/* <Select.Option value="4:3">4:3</Select.Option> */}
|
||||
{/* <Select.Option value="3:4">3:4</Select.Option> */}
|
||||
{/* <Select.Option value="1:1">1:1</Select.Option> */}
|
||||
{/* <Select.Option value="21:9">21:9</Select.Option> */}
|
||||
{/* <Select.Option value="custom">自定义</Select.Option> */}
|
||||
</Select>
|
||||
</div>
|
||||
<div className={styles.inner}>
|
||||
<h2>生成数量: {count}</h2>
|
||||
{/*@ts-ignore*/}
|
||||
<Slider value={count} min={1} max={10} onChange={setCount}></Slider>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.model}>
|
||||
{/* <div className={styles.credit}>
|
||||
<span>
|
||||
预计消耗积分:<em>881</em>
|
||||
</span>
|
||||
<span>
|
||||
剩余:
|
||||
<i>
|
||||
<Icon size={12} />
|
||||
9881
|
||||
</i>
|
||||
</span>
|
||||
</div> */}
|
||||
<Button icon={<Icon />} block className={styles.btn} theme="solid" type="primary" onClick={handleGenerate}>
|
||||
开始生成
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default observer(AiImage);
|
||||
@@ -2,8 +2,6 @@ import React, { useState } from 'react';
|
||||
import styles from './styles.module.less';
|
||||
import { Tabs, TabPane, Empty, Button } from '@douyinfe/semi-ui';
|
||||
import QuickVideo from './QuickVideo';
|
||||
import AiVideo from './AiVideo';
|
||||
import AiImage from './AiImage';
|
||||
import Tasks from './Tasks';
|
||||
import { IllustrationNoAccess, IllustrationNoAccessDark } from '@douyinfe/semi-illustrations';
|
||||
import Login from '@components/login';
|
||||
@@ -44,6 +42,7 @@ export default function AiMain() {
|
||||
<i>字幕动效</i>
|
||||
<i>画面转场</i>
|
||||
</div>
|
||||
<div className={styles.qvHeroHint}>只需纯文本模型即可使用;模型支持多模态(视觉)就能自动生成出片</div>
|
||||
<div className={styles.qvCta}>立即生成 →</div>
|
||||
</div>
|
||||
|
||||
@@ -63,7 +62,7 @@ export default function AiMain() {
|
||||
<h2 className={styles.qvIntroTitle}>四步出一条视频</h2>
|
||||
<ol className={styles.qvSteps}>
|
||||
<li>添加几张图片,写一个标题</li>
|
||||
<li>AI 看懂图片,自动写出口播文案</li>
|
||||
<li>AI 自动写口播文案,每段配好对应画面</li>
|
||||
<li>挑人声、情绪、语速,试听满意再合成</li>
|
||||
<li>确认生成:图片排进时间轴,自动加字幕、配音、运镜和转场</li>
|
||||
</ol>
|
||||
@@ -73,12 +72,6 @@ export default function AiMain() {
|
||||
<div className={styles.qvHint}>生成前可先调好转场、图片动效和字幕样式,不满意随时回来重做。</div>
|
||||
</div>
|
||||
</TabPane>
|
||||
<TabPane tab={'Ai视频生成'} itemKey="1">
|
||||
<AiVideo />
|
||||
</TabPane>
|
||||
<TabPane tab={'Ai图片生成'} itemKey="2">
|
||||
<AiImage />
|
||||
</TabPane>
|
||||
<TabPane tab={'生成结果'} itemKey="3">
|
||||
<Tasks />
|
||||
</TabPane>
|
||||
|
||||
@@ -1,195 +0,0 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import styles from './styles.module.less';
|
||||
import { Tag, TextArea, RadioGroup, Radio, Select, Image, Button, Slider, Toast } from '@douyinfe/semi-ui';
|
||||
import { observer } from 'mobx-react';
|
||||
import SourceList from './SourceList';
|
||||
import { getClosestVideoRatioEnhanced } from '@pages/editor/tools/tools';
|
||||
import { getImageToVideoParams } from './aiConfig';
|
||||
import { stores } from '@stores/index';
|
||||
// import { StarOne } from '@icon-park/react';
|
||||
|
||||
/** cheaperinference 视频单价(USD/秒,来自其 /v1/models 的 resolution_prices,2026-10 实测) */
|
||||
const VIDEO_PRICE: Record<string, Record<string, number>> = {
|
||||
'grok-imagine-video': { '480p': 0.0325, '720p': 0.0455 },
|
||||
'veo-3.1-lite-generate-001': { '720p': 0.03, '1080p': 0.05 },
|
||||
'seedance-2.0-fast': { '480p': 0.034971, '720p': 0.078624 },
|
||||
};
|
||||
/** 与 localGenerateVideo 相同的降级顺序,取第一个支持该分辨率的模型价 */
|
||||
function videoPricePerSec(resolution: string) {
|
||||
const order = ['grok-imagine-video', 'veo-3.1-lite-generate-001', 'seedance-2.0-fast'];
|
||||
for (const m of order) {
|
||||
const v = VIDEO_PRICE[m]?.[resolution];
|
||||
if (v) return { price: v, model: m };
|
||||
}
|
||||
return { price: 0, model: '-' };
|
||||
}
|
||||
|
||||
export interface IProps {}
|
||||
|
||||
function AiVideo(props: IProps) {
|
||||
const { editor } = stores;
|
||||
const [aiAction, setAiAction] = useState('image-to-video');
|
||||
const [duration, setDuration] = useState(10);
|
||||
const [description, setDescription] = useState('');
|
||||
|
||||
const { ratio } = getClosestVideoRatioEnhanced(editor.data.width, editor.data.height);
|
||||
const [size, setSize] = useState(ratio);
|
||||
|
||||
const [clarity, setClarity] = useState('720p');
|
||||
const [count, setCount] = useState(1);
|
||||
const sourceListRef = useRef<any>(null);
|
||||
|
||||
const Icon = (props: { size?: number }) => {
|
||||
return (
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width={props.size || 16}
|
||||
height={props.size || 16}
|
||||
focusable="false"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path
|
||||
d="M9.68 5.45c.22-1.1 1.8-1.1 2.02 0a8.79 8.79 0 0 0 6.85 6.85c1.1.22 1.1 1.8 0 2.02a8.79 8.79 0 0 0-6.85 6.85c-.22 1.1-1.8 1.1-2.02 0a8.79 8.79 0 0 0-6.85-6.85c-1.1-.22-1.1-1.8 0-2.02a8.79 8.79 0 0 0 6.85-6.85Zm8.48-3.85c.16-.8 1.31-.8 1.48 0a3.54 3.54 0 0 0 2.76 2.76c.8.17.8 1.32 0 1.48a3.54 3.54 0 0 0-2.76 2.76c-.17.8-1.32.8-1.48 0a3.54 3.54 0 0 0-2.76-2.76c-.8-.16-.8-1.31 0-1.48a3.54 3.54 0 0 0 2.76-2.76Z"
|
||||
fill="currentColor"
|
||||
></path>
|
||||
</svg>
|
||||
);
|
||||
};
|
||||
|
||||
// 处理表单提交
|
||||
const handleGenerate = async () => {
|
||||
// 获取参考元素数据
|
||||
const urls = sourceListRef.current?.getURLs() || [];
|
||||
|
||||
// 整合所有表单数据
|
||||
const formData = {
|
||||
aiAction,
|
||||
description,
|
||||
size,
|
||||
clarity,
|
||||
duration,
|
||||
count,
|
||||
urls: urls.map(d => d.url),
|
||||
};
|
||||
console.log('表单数据:', formData);
|
||||
|
||||
// 图生视频
|
||||
const params = await getImageToVideoParams(formData);
|
||||
if (!params) {
|
||||
return;
|
||||
}
|
||||
const [res, err] = await editor.apiServer.createAiTask(params);
|
||||
if (!err) {
|
||||
Toast.success('任务创建成功');
|
||||
} else {
|
||||
Toast.error(err);
|
||||
}
|
||||
// 这里可以添加后续的生成逻辑,比如调用API等
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.ai + ' scroll'}>
|
||||
<h1>参数设置</h1>
|
||||
<div className={styles.model}>
|
||||
<Select value={aiAction} style={{ width: '100%' }} onChange={setAiAction} placeholder="选择AI类型">
|
||||
<Select.Option value="text-to-video">文生视频</Select.Option>
|
||||
<Select.Option value="image-to-video">图生视频</Select.Option>
|
||||
<Select.Option value="first-to-video">首帧生成视频</Select.Option>
|
||||
<Select.Option value="first-last-to-video">首尾帧过渡视频</Select.Option>
|
||||
<Select.Option value="action-to-video">动作模仿</Select.Option>
|
||||
</Select>
|
||||
{/* <div className={styles.desc}>根据输入的文本内容进行</div> */}
|
||||
{aiAction !== 'text-to-video' && (
|
||||
<div className={styles.inner}>
|
||||
<h2>参考元素</h2>
|
||||
<SourceList action={aiAction} ref={sourceListRef} />
|
||||
</div>
|
||||
)}
|
||||
<div className={styles.inner}>
|
||||
<h2>描述信息</h2>
|
||||
<div className={styles.inner}>
|
||||
<TextArea
|
||||
style={{ width: '100%' }}
|
||||
rows={4}
|
||||
placeholder="请输入描述信息"
|
||||
value={description}
|
||||
onChange={setDescription}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.inner}>
|
||||
<h2>尺寸设置</h2>
|
||||
<Select value={size} style={{ width: '100%' }} onChange={setSize} placeholder="选择尺寸">
|
||||
<Select.Option value="16:9">16:9</Select.Option>
|
||||
<Select.Option value="9:16">9:16</Select.Option>
|
||||
<Select.Option value="4:3">4:3</Select.Option>
|
||||
<Select.Option value="3:4">3:4</Select.Option>
|
||||
<Select.Option value="1:1">1:1</Select.Option>
|
||||
<Select.Option value="21:9">21:9</Select.Option>
|
||||
</Select>
|
||||
</div>
|
||||
<div className={styles.inner}>
|
||||
<h2>清晰度设置</h2>
|
||||
<RadioGroup
|
||||
value={clarity}
|
||||
style={{ width: '100%' }}
|
||||
type="button"
|
||||
buttonSize="middle"
|
||||
name="clarity"
|
||||
onChange={setClarity as any}
|
||||
>
|
||||
<Radio value={'480p'}>480p</Radio>
|
||||
<Radio value={'720p'}>720p</Radio>
|
||||
<Radio value={'1080p'}>1080p</Radio>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
<div className={styles.inner}>
|
||||
<h2>时长: {duration}s</h2>
|
||||
{/*@ts-ignore*/}
|
||||
<Slider value={duration} min={2} max={12} onChange={setDuration}></Slider>
|
||||
</div>
|
||||
<div className={styles.inner}>
|
||||
<h2>生成数量</h2>
|
||||
<RadioGroup
|
||||
value={count}
|
||||
style={{ width: '100%' }}
|
||||
type="button"
|
||||
buttonSize="middle"
|
||||
name="count"
|
||||
onChange={setCount as any}
|
||||
>
|
||||
<Radio value={1}>1</Radio>
|
||||
<Radio value={2}>2</Radio>
|
||||
<Radio value={3}>3</Radio>
|
||||
<Radio value={4}>4</Radio>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.model}>
|
||||
{/* <div className={styles.credit}>
|
||||
<span>
|
||||
预计消耗积分:<em>881</em>
|
||||
</span>
|
||||
<span>
|
||||
剩余:
|
||||
<i>
|
||||
<Icon size={12} />
|
||||
9881
|
||||
</i>
|
||||
</span>
|
||||
</div> */}
|
||||
<div className={styles.desc} style={{ marginBottom: 8, fontSize: 12 }}>
|
||||
预估费用 ≈ <b>${(videoPricePerSec(clarity).price * duration * count).toFixed(3)}</b>
|
||||
({videoPricePerSec(clarity).model} {clarity} ${videoPricePerSec(clarity).price}/秒 × {duration} 秒 × {count} 条,生成成功才计费)
|
||||
</div>
|
||||
<Button icon={<Icon />} block className={styles.btn} theme="solid" type="primary" onClick={handleGenerate}>
|
||||
开始生成
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default observer(AiVideo);
|
||||
@@ -1,5 +1,19 @@
|
||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Modal, Steps, Button, Input, TextArea, Select, Slider, Toast, Spin, Tag, Empty } from '@douyinfe/semi-ui';
|
||||
import {
|
||||
Modal,
|
||||
Steps,
|
||||
Button,
|
||||
Input,
|
||||
TextArea,
|
||||
Select,
|
||||
Slider,
|
||||
Toast,
|
||||
Spin,
|
||||
Tag,
|
||||
Empty,
|
||||
Radio,
|
||||
RadioGroup,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { VolumeNotice, Delete, Up, Down, Plus, Play, MusicOne } from '@icon-park/react';
|
||||
import styles from './quickvideo.module.less';
|
||||
import { addImageVideoAudioItem } from '../addItem';
|
||||
@@ -15,6 +29,7 @@ import {
|
||||
synthesizeSegment,
|
||||
decodeAudio,
|
||||
} from '@utils/aiQuickVideo';
|
||||
import { parseDocx, parsePdf, importFromUrl, makeTitleCover } from '@utils/sourceImport';
|
||||
|
||||
/** 界面上的文案段(带稳定 uid,便于配音结果对应) */
|
||||
type Seg = QvSegment & { uid: string };
|
||||
@@ -37,7 +52,20 @@ interface PickImage {
|
||||
h: number;
|
||||
}
|
||||
|
||||
const STEP_TITLES = ['图片与标题', '生成文案', '配置声音', '确认生成'];
|
||||
const STEP_TITLES = ['素材与标题', '生成文案', '配置声音', '确认生成'];
|
||||
|
||||
/** 素材来源:图片 / 文档 / 网址(第 1 步的输入方式) */
|
||||
type SrcMode = 'image' | 'doc' | 'url';
|
||||
const GEN_LABEL: Record<SrcMode, string> = {
|
||||
image: '① 识别图片 · 生成文案',
|
||||
doc: '① 读取文档 · 生成文案',
|
||||
url: '① 分析网页 · 生成文案',
|
||||
};
|
||||
const GEN_LOADING: Record<SrcMode, string> = {
|
||||
image: '正在识别图片写文案…',
|
||||
doc: '正在读取文档写文案…',
|
||||
url: '正在分析网页写文案…',
|
||||
};
|
||||
const MAX_IMAGES = 8;
|
||||
|
||||
const { Option } = Select;
|
||||
@@ -305,6 +333,12 @@ export default function QuickVideo({
|
||||
const [title, setTitle] = useState('');
|
||||
const [style, setStyle] = useState(COPY_STYLES[0].value);
|
||||
|
||||
/* 素材来源:图片 / Word·PDF 文档 / 网址(src 是最近一次成功导入的正文) */
|
||||
const [mode, setMode] = useState<SrcMode>('image');
|
||||
const [src, setSrc] = useState<{ mode: SrcMode; text: string; name: string } | null>(null);
|
||||
const [urlInput, setUrlInput] = useState('');
|
||||
const [importing, setImporting] = useState(false);
|
||||
|
||||
const [segs, setSegs] = useState<Seg[]>([]);
|
||||
const [genLoading, setGenLoading] = useState(false);
|
||||
|
||||
@@ -328,6 +362,7 @@ export default function QuickVideo({
|
||||
const [capEnter, setCapEnter] = useState('zoom');
|
||||
|
||||
const fileRef = useRef<HTMLInputElement>(null);
|
||||
const docRef = useRef<HTMLInputElement>(null);
|
||||
const playingRef = useRef<Audio | null>(null);
|
||||
|
||||
const newSeg = (text: string, image: number): Seg => ({
|
||||
@@ -381,6 +416,89 @@ export default function QuickVideo({
|
||||
});
|
||||
};
|
||||
|
||||
/** 把一批 dataURL 追加进素材池(量好宽高、按上限截断),返回实际加入数 */
|
||||
const addImageUrls = async (urls: string[], namePrefix: string): Promise<number> => {
|
||||
const measured = await Promise.all(
|
||||
urls.map(
|
||||
url =>
|
||||
new Promise<PickImage | null>(resolve => {
|
||||
const img = new Image();
|
||||
img.onload = () =>
|
||||
resolve({
|
||||
id: util.randomID(),
|
||||
url,
|
||||
name: namePrefix,
|
||||
w: img.naturalWidth,
|
||||
h: img.naturalHeight,
|
||||
});
|
||||
img.onerror = () => resolve(null);
|
||||
img.src = url;
|
||||
}),
|
||||
),
|
||||
);
|
||||
const room = MAX_IMAGES - images.length;
|
||||
const add = measured.filter(Boolean).slice(0, Math.max(0, room)) as PickImage[];
|
||||
if (add.length) setImages(prev => prev.concat(add).slice(0, MAX_IMAGES));
|
||||
return add.length;
|
||||
};
|
||||
|
||||
/* ---------- 文档上传(Word / PDF) ---------- */
|
||||
const onPickDoc = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
e.target.value = '';
|
||||
if (!file) return;
|
||||
const lower = file.name.toLowerCase();
|
||||
if (lower.endsWith('.doc')) {
|
||||
return Toast.warning('暂不支持旧版 .doc,请在 Word 里另存为 .docx 后再上传');
|
||||
}
|
||||
if (!lower.endsWith('.docx') && !lower.endsWith('.pdf')) {
|
||||
return Toast.warning('只支持 Word(.docx) 和 PDF 文件');
|
||||
}
|
||||
setImporting(true);
|
||||
try {
|
||||
const r = lower.endsWith('.pdf') ? await parsePdf(file) : await parseDocx(file);
|
||||
if (!r.text.trim() && !r.images.length) {
|
||||
Toast.error('没读到内容:文档可能是扫描件或受保护,请换一个文件');
|
||||
return;
|
||||
}
|
||||
setSrc({ mode: 'doc', text: r.text, name: file.name });
|
||||
const added = await addImageUrls(r.images, file.name.replace(/\.[^.]+$/, '').slice(0, 16));
|
||||
const bits: string[] = [];
|
||||
if (r.text.trim()) bits.push(`正文 ${r.text.length} 字`);
|
||||
if (r.images.length) bits.push(`提取配图 ${added} 张`);
|
||||
Toast.success(`已读取文档:${bits.join('、')}`);
|
||||
} catch (err: any) {
|
||||
Toast.error(err?.message || '文档解析失败');
|
||||
} finally {
|
||||
setImporting(false);
|
||||
}
|
||||
};
|
||||
|
||||
/* ---------- 网址抓取(正文 + 配图) ---------- */
|
||||
const onGrabUrl = async () => {
|
||||
const raw = urlInput.trim();
|
||||
if (!raw) return Toast.warning('请输入网址');
|
||||
setImporting(true);
|
||||
try {
|
||||
const r = await importFromUrl(raw);
|
||||
if (!r.text.trim() && !r.images.length) {
|
||||
Toast.error('这个页面没抓到文字和图片,换个网址试试');
|
||||
return;
|
||||
}
|
||||
setSrc({ mode: 'url', text: r.text, name: r.name });
|
||||
const added = await addImageUrls(r.images, (r.name || '网页配图').slice(0, 16));
|
||||
if (!title.trim() && r.name) setTitle(r.name.slice(0, 30));
|
||||
const bits: string[] = [];
|
||||
if (r.text.trim()) bits.push(`正文 ${r.text.length} 字`);
|
||||
if (r.images.length) bits.push(`图片 ${added} 张`);
|
||||
Toast.success(`已抓取:${bits.join('、')}`);
|
||||
} catch (err: any) {
|
||||
Toast.error(err?.message || '网址抓取失败');
|
||||
} finally {
|
||||
setImporting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const moveImage = (idx: number, dir: -1 | 1) => {
|
||||
setImages(prev => {
|
||||
const next = prev.slice();
|
||||
@@ -393,16 +511,27 @@ export default function QuickVideo({
|
||||
|
||||
/* ---------- 文案生成 ---------- */
|
||||
const genCopy = async () => {
|
||||
if (!images.length) return Toast.warning('请先添加图片');
|
||||
const bodyText = src?.text?.trim() || '';
|
||||
if (!images.length && !bodyText) {
|
||||
return Toast.warning(
|
||||
mode === 'doc' ? '请先上传 Word / PDF 文档' : mode === 'url' ? '请先抓取网址内容' : '请先添加图片',
|
||||
);
|
||||
}
|
||||
if (!title.trim()) return Toast.warning('请填写标题');
|
||||
setGenLoading(true);
|
||||
const [res, err] = await generateQuickVideoCopy({
|
||||
title: title.trim(),
|
||||
style,
|
||||
images: images.map(i => i.url),
|
||||
sourceText: bodyText || undefined,
|
||||
});
|
||||
setGenLoading(false);
|
||||
if (err || !res) return Toast.error(err || '文案生成失败');
|
||||
// 纯文档 / 纯文字素材没有配图时,自动生成一张标题封面,保证时间轴有画面可用
|
||||
if (!images.length) {
|
||||
const cover = makeTitleCover(title.trim());
|
||||
setImages([{ id: util.randomID(), url: cover.url, name: '标题封面', w: cover.w, h: cover.h }]);
|
||||
}
|
||||
const list = res.segments.map(s => newSeg(s.text, s.image));
|
||||
setSegs(list);
|
||||
setAudio({});
|
||||
@@ -596,6 +725,9 @@ export default function QuickVideo({
|
||||
|
||||
const resetAll = () => {
|
||||
setStep(0);
|
||||
setSrc(null);
|
||||
setUrlInput('');
|
||||
setMode('image');
|
||||
setSegs([]);
|
||||
setAudio({});
|
||||
setTitle('');
|
||||
@@ -609,7 +741,7 @@ export default function QuickVideo({
|
||||
if (step === 0) {
|
||||
return (
|
||||
<Button type="primary" loading={genLoading} onClick={genCopy}>
|
||||
{genLoading ? '正在识别图片写文案…' : '① 识别图片 · 生成文案'}
|
||||
{genLoading ? GEN_LOADING[mode] : GEN_LABEL[mode]}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -676,6 +808,7 @@ export default function QuickVideo({
|
||||
footer={null}
|
||||
centered
|
||||
maskClosable={false}
|
||||
className={styles.modal}
|
||||
bodyStyle={{ padding: '12px 24px 20px' }}
|
||||
>
|
||||
<Steps type="basic" size="small" current={step}>
|
||||
@@ -688,8 +821,67 @@ export default function QuickVideo({
|
||||
{step === 0 && (
|
||||
<>
|
||||
<div className={styles.desc}>
|
||||
添加几张图片 + 写一个标题,AI 会看懂图片内容,帮你写出口播文案、生成字幕和配音。
|
||||
素材三选一:上传图片,或上传 Word / PDF 文档,或输入网址自动抓取正文和配图 ——
|
||||
AI 看懂素材后写口播文案,再生成字幕和配音。
|
||||
</div>
|
||||
<div className={styles.modeRow}>
|
||||
<RadioGroup
|
||||
type="button"
|
||||
size="small"
|
||||
value={mode}
|
||||
onChange={e => setMode(e.target.value as SrcMode)}
|
||||
>
|
||||
<Radio value="image">图片</Radio>
|
||||
<Radio value="doc">Word / PDF</Radio>
|
||||
<Radio value="url">输入网址</Radio>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
{mode === 'doc' && (
|
||||
<>
|
||||
<div className={styles.srcBox} onClick={() => !importing && docRef.current?.click()}>
|
||||
{importing ? '正在读取文档…' : '点击选择 Word(.docx) / PDF 文件,自动提取正文和配图'}
|
||||
</div>
|
||||
<input
|
||||
ref={docRef}
|
||||
type="file"
|
||||
accept=".docx,.pdf"
|
||||
style={{ display: 'none' }}
|
||||
onChange={onPickDoc}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{mode === 'url' && (
|
||||
<div className={styles.urlRow}>
|
||||
<Input
|
||||
value={urlInput}
|
||||
onChange={setUrlInput}
|
||||
placeholder="粘贴网页地址(文章 / 博客 / 详情页链接均可)"
|
||||
style={{ flex: 1 }}
|
||||
showClear
|
||||
onPressEnter={onGrabUrl}
|
||||
/>
|
||||
<Button type="primary" loading={importing} onClick={onGrabUrl}>
|
||||
抓取内容和图片
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{src && src.mode === mode && (
|
||||
<div className={styles.srcCard}>
|
||||
<div className={styles.srcHead}>
|
||||
<Tag color={src.mode === 'doc' ? 'blue' : 'green'}>
|
||||
{src.mode === 'doc' ? '文档' : '网址'}
|
||||
</Tag>
|
||||
<span className={styles.srcName}>{src.name || '(未命名)'}</span>
|
||||
<span className={styles.total}>{src.text.length} 字</span>
|
||||
<span className={styles.srcDel} onClick={() => setSrc(null)}>
|
||||
移除
|
||||
</span>
|
||||
</div>
|
||||
{src.text && (
|
||||
<div className={styles.srcPreview}>{src.text.replace(/\s+/g, ' ').slice(0, 160)}</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<div className={styles.imgGrid}>
|
||||
{images.map((img, i) => (
|
||||
<div key={img.id} className={styles.imgItem}>
|
||||
@@ -1052,7 +1244,8 @@ export default function QuickVideo({
|
||||
|
||||
<div className={styles.footer}>
|
||||
<span className={styles.total}>
|
||||
{step === 0 && '共可添加 ' + MAX_IMAGES + ' 张图片'}
|
||||
{step === 0 &&
|
||||
`素材池 ${images.length}/${MAX_IMAGES} 张图片${src?.text ? ` · 正文 ${src.text.length} 字` : ''}`}
|
||||
{step === 1 && `${segs.length} 段文案`}
|
||||
{step === 2 && `已配音 ${freshCount}/${segs.length} 段`}
|
||||
{step === 3 && `总长约 ${totalDur.toFixed(1)} 秒`}
|
||||
@@ -1064,7 +1257,7 @@ export default function QuickVideo({
|
||||
</div>
|
||||
|
||||
{synthLoading && (
|
||||
<div style={{ marginTop: 8, fontSize: 12, color: '#8a9099' }}>
|
||||
<div style={{ marginTop: 8, fontSize: 12, color: '#fff' }}>
|
||||
<Spin size="small" /> 正在合成第 {synthIndex}/{segs.length} 段配音…
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
.desc {
|
||||
font-size: 12px;
|
||||
color: var(--h5ds-gray-1);
|
||||
color: #fff;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
height: 78px;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--h5ds-border, #e6e8eb);
|
||||
background: #f5f6f7;
|
||||
border: 1px solid #fff;
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
@@ -77,13 +77,13 @@
|
||||
.addBox {
|
||||
width: 104px;
|
||||
height: 78px;
|
||||
border: 1px dashed var(--h5ds-border, #d4d7dc);
|
||||
border: 1px dashed #fff;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--h5ds-gray-1, #8a9099);
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
|
||||
@@ -107,9 +107,9 @@
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
padding: 8px;
|
||||
border: 1px solid var(--h5ds-border, #e6e8eb);
|
||||
border: 1px solid #fff;
|
||||
border-radius: 6px;
|
||||
background: var(--h5ds-bg-1, #fafbfc);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
|
||||
.segIdx {
|
||||
flex: 0 0 auto;
|
||||
@@ -135,7 +135,7 @@
|
||||
gap: 8px;
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
color: var(--h5ds-gray-1, #8a9099);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.segAct {
|
||||
@@ -155,16 +155,16 @@
|
||||
|
||||
.label {
|
||||
font-size: 13px;
|
||||
color: var(--h5ds-gray-0, #1f2329);
|
||||
color: #fff;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
}
|
||||
|
||||
.summary {
|
||||
border: 1px solid var(--h5ds-border, #e6e8eb);
|
||||
border: 1px solid #fff;
|
||||
border-radius: 8px;
|
||||
padding: 12px 14px;
|
||||
background: var(--h5ds-bg-1, #fafbfc);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
font-size: 13px;
|
||||
line-height: 2;
|
||||
}
|
||||
@@ -178,22 +178,22 @@
|
||||
|
||||
.total {
|
||||
font-size: 13px;
|
||||
color: var(--h5ds-gray-1, #8a9099);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* 画面效果面板(一键出片 第 4 步) */
|
||||
.fxBox {
|
||||
border: 1px solid var(--h5ds-border, #e6e8eb);
|
||||
border: 1px solid #fff;
|
||||
border-radius: 8px;
|
||||
padding: 10px 14px 4px;
|
||||
margin-bottom: 12px;
|
||||
background: var(--h5ds-bg-1, #fafbfc);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
|
||||
.fxTitle {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--h5ds-gray-0, #1f2329);
|
||||
color: #fff;
|
||||
margin-bottom: 10px;
|
||||
|
||||
& + .fxTitle {
|
||||
@@ -210,14 +210,104 @@
|
||||
|
||||
.label {
|
||||
font-size: 13px;
|
||||
color: var(--h5ds-gray-0, #1f2329);
|
||||
color: #fff;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
}
|
||||
|
||||
.fxTip {
|
||||
font-size: 12px;
|
||||
color: var(--h5ds-gray-1, #8a9099);
|
||||
color: #fff;
|
||||
line-height: 1.7;
|
||||
margin: 2px 0 8px;
|
||||
}
|
||||
|
||||
/* 素材来源切换 + 文档 / 网址导入(AI 一键出片 第 1 步) */
|
||||
.modeRow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin: 10px 0 12px;
|
||||
}
|
||||
|
||||
.urlRow {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.srcBox {
|
||||
border: 1px dashed #fff;
|
||||
border-radius: 8px;
|
||||
padding: 16px 14px;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
margin-bottom: 12px;
|
||||
|
||||
&:hover {
|
||||
border-color: #4d7cfe;
|
||||
color: #4d7cfe;
|
||||
}
|
||||
}
|
||||
|
||||
.srcCard {
|
||||
border: 1px solid #fff;
|
||||
border-radius: 8px;
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
padding: 10px 12px;
|
||||
margin-bottom: 12px;
|
||||
|
||||
.srcHead {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.srcName {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-weight: 600;
|
||||
color: #fff;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.srcDel {
|
||||
flex: 0 0 auto;
|
||||
font-size: 12px;
|
||||
color: #d4380d;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.srcPreview {
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
color: #fff;
|
||||
line-height: 1.6;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ===== 作用域限定:仅本弹窗内的 Semi 输入框/下拉/单选 → 白色边框线条 ===== */
|
||||
.modal {
|
||||
:global(.semi-input-wrapper) {
|
||||
border-color: #fff !important;
|
||||
}
|
||||
|
||||
:global(.semi-select-rendered) {
|
||||
border-color: #fff !important;
|
||||
}
|
||||
|
||||
:global(.semi-radio .semi-radio-inner) {
|
||||
border-color: #fff;
|
||||
}
|
||||
}
|
||||
@@ -173,6 +173,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
.qvHeroHint {
|
||||
margin-top: 8px;
|
||||
font-size: 11.5px;
|
||||
line-height: 1.6;
|
||||
color: rgba(255, 255, 255, 0.68);
|
||||
}
|
||||
|
||||
.qvCta {
|
||||
margin-top: 11px;
|
||||
display: inline-block;
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
Pagination,
|
||||
Empty,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { Voice, Left, VoiceInput, Upload as UploadIcon, DeleteFive, Close, Refresh } from '@icon-park/react';
|
||||
import { Voice, Left, VoiceInput, Upload as UploadIcon, DeleteFive, Close, Refresh, Download } from '@icon-park/react';
|
||||
import { useCallback, useEffect, useReducer, useRef, useState } from 'react';
|
||||
import { getUploadBeforeData, isAPNG } from '@pages/editor/tools/uploadBeforeData';
|
||||
import { pubsub, util } from '@utils/index';
|
||||
@@ -497,6 +497,14 @@ export default function List(props: IProps) {
|
||||
setShowType('tts');
|
||||
},
|
||||
},
|
||||
{
|
||||
node: 'item',
|
||||
icon: <Download theme="outline" size="20" fill="var(--theme-icon)" />,
|
||||
name: language.val('my_download_more'),
|
||||
onClick: () => {
|
||||
window.open('https://doc.88531.cn/docs/mrfx/mrfx-1g99qum57n5qk', '_blank');
|
||||
},
|
||||
},
|
||||
]}
|
||||
trigger="click"
|
||||
position="bottomRight"
|
||||
|
||||
@@ -214,28 +214,6 @@ export default function Home() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Trust Bar */}
|
||||
<section className={styles.trustBar}>
|
||||
<p>受到众多大品牌信赖</p>
|
||||
<div className={styles.trustLogos}>
|
||||
{/* <span>
|
||||
<img src="/assets/images/zsyh.png" alt="" />
|
||||
</span> */}
|
||||
<span>
|
||||
<img src="/assets/images/kpy.png" alt="" />
|
||||
</span>
|
||||
<span>
|
||||
<img src="/assets/images/ytkd.png" alt="" />
|
||||
</span>
|
||||
<span>
|
||||
<img src="/assets/images/zgdx.png" alt="" />
|
||||
</span>
|
||||
<span>
|
||||
<img src="/assets/images/zgyd.png" alt="" />
|
||||
</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* AI Features */}
|
||||
<section className={styles.section}>
|
||||
<div className={styles.container}>
|
||||
|
||||
@@ -274,43 +274,6 @@
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
// ========== Trust Bar ==========
|
||||
.trustBar {
|
||||
padding: 50px 0;
|
||||
text-align: center;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 50px 24px;
|
||||
|
||||
p {
|
||||
font-size: 13px;
|
||||
color: #6b6880;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.trustLogos {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 40px;
|
||||
opacity: 0.3;
|
||||
flex-wrap: wrap;
|
||||
|
||||
span {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 2px;
|
||||
color: #a5a3b8;
|
||||
}
|
||||
img {
|
||||
// 添加滤镜,变成黑白图片
|
||||
filter: brightness(0) invert(1);
|
||||
// 反色
|
||||
height: 30px;
|
||||
}
|
||||
}
|
||||
|
||||
// ========== Sections ==========
|
||||
.section {
|
||||
padding: 90px 0;
|
||||
@@ -908,18 +871,6 @@ body[theme-mode='light'] {
|
||||
background: radial-gradient(ellipse, rgba(139, 92, 246, 0.08), transparent 70%);
|
||||
}
|
||||
|
||||
.trustBar p {
|
||||
color: #9089b8;
|
||||
}
|
||||
|
||||
.trustLogos {
|
||||
opacity: 0.2;
|
||||
|
||||
span {
|
||||
color: #4a4570;
|
||||
}
|
||||
}
|
||||
|
||||
.overline {
|
||||
color: #7c3aed;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { pubsub, util } from '@utils/index';
|
||||
import { useEffect, useReducer, useRef, useState } from 'react';
|
||||
import AudioItem from '@components/audio/AudioItem';
|
||||
import { language } from '@language/language';
|
||||
import { isFSApiSupported, getRootHandle } from '@services/localStorageService';
|
||||
// import { Play, PauseOne } from '@icon-park/react';
|
||||
// import { layout } from '@stores/layout';
|
||||
|
||||
@@ -19,6 +20,21 @@ export default function Material(props: IProps) {
|
||||
const [playItem, setPlayItem] = useState<any>(null);
|
||||
const [item0, setItem0] = useState(null);
|
||||
const [name, setName] = useState('');
|
||||
// 本地存储根目录名(浏览器安全限制只能拿到文件夹名,拿不到完整绝对路径)
|
||||
const [rootName, setRootName] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
if (isFSApiSupported()) {
|
||||
getRootHandle().then(h => setRootName(h?.name || ''));
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 素材实际存储路径:根目录名/materials/相对路径
|
||||
const realPath = (item: any) => {
|
||||
const rel = item.relativePath || item._localPath || '';
|
||||
if (!rel) return item.name;
|
||||
return rootName ? `${rootName}/${rel}` : rel;
|
||||
};
|
||||
|
||||
const itemFun = item => {
|
||||
return (
|
||||
@@ -66,7 +82,7 @@ export default function Material(props: IProps) {
|
||||
setItem0(item);
|
||||
setName(item.name);
|
||||
}}
|
||||
title={item.name}
|
||||
title={`${item.name}\n实际路径: ${realPath(item)}`}
|
||||
className={styles.name}
|
||||
data-itemid={item.id}
|
||||
>
|
||||
@@ -87,6 +103,14 @@ export default function Material(props: IProps) {
|
||||
categoryName={cname}
|
||||
itemWidth={160}
|
||||
item={itemFun}
|
||||
subTitle={
|
||||
rootName ? (
|
||||
<div className={styles.storagePath} title="素材实际保存位置(浏览器安全限制仅显示文件夹名)">
|
||||
📂 存储位置:<b>{rootName}/materials/</b>
|
||||
<span className={styles.storageHint}>文件夹为应用内分类,素材实际保存在上方目录;悬浮素材名可查看单个文件路径</span>
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
catesCallback={c => {
|
||||
console.log(c);
|
||||
}}
|
||||
|
||||
@@ -163,9 +163,21 @@ class Server extends BasicService {
|
||||
return this.get(`/common/config/value?key=${key}`);
|
||||
};
|
||||
|
||||
// 移动素材
|
||||
moveMaterial = params => {
|
||||
return this.post('/user/materials/move', params);
|
||||
// 移动素材:本地优先(本部署无 /user 后端),更新 IndexedDB 中的分类标记
|
||||
moveMaterial = async params => {
|
||||
try {
|
||||
const ids: string[] = params.ids || [];
|
||||
const tag = params.category_id || '';
|
||||
for (const id of ids) {
|
||||
const rec = await localDB.materials.get(id);
|
||||
if (rec) {
|
||||
await localDB.materials.update(id, { tag, updatedAt: Date.now() });
|
||||
}
|
||||
}
|
||||
return ['success', null];
|
||||
} catch (err: any) {
|
||||
return [null, err?.message || String(err)];
|
||||
}
|
||||
};
|
||||
|
||||
// 查询视频转码状态
|
||||
|
||||
@@ -100,3 +100,18 @@
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.storagePath {
|
||||
margin: 4px 0 10px;
|
||||
font-size: 13px;
|
||||
color: var(--theme-text, #333);
|
||||
b {
|
||||
color: var(--theme-icon, #1890ff);
|
||||
font-weight: 600;
|
||||
}
|
||||
.storageHint {
|
||||
margin-left: 10px;
|
||||
font-size: 12px;
|
||||
opacity: 0.55;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import { routes as homeRoutes } from '@pages/home';
|
||||
import { routes as aboutusRoutes } from '@pages/aboutus';
|
||||
import { routes as userRouter } from './pages/user';
|
||||
import { routes as workspaceRouter } from './pages/workspace';
|
||||
import { routes as agreementRouter } from './pages/agreement';
|
||||
@@ -62,8 +61,8 @@ const routes = [
|
||||
path: '/article',
|
||||
exact: false,
|
||||
component: IndexLayout,
|
||||
// 详情页优先:/article/about 走 aboutus,其余 /article/:slug 全部落到文章详情页
|
||||
routes: [...aboutusRoutes, ...articleRouter],
|
||||
// /article/about 也走文章详情页(AI 一键出片教程),全部 /article/:slug 统一渲染 markdown
|
||||
routes: [...articleRouter],
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
|
||||
@@ -748,6 +748,32 @@ export async function updateLocalCategory(id: string, data: { name?: string }):
|
||||
return [record, null];
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分类(文件夹):删除分类记录本身,并把其下素材/项目的分类标记清空。
|
||||
* 素材文件与记录保留在「全部」中,避免误删用户数据(素材可再单独勾选删除)。
|
||||
*/
|
||||
export async function deleteLocalCategory(type: 'project' | 'material', id: string): Promise<[any, string | null]> {
|
||||
try {
|
||||
const record = await localDB.categories.get(id);
|
||||
if (!record) return [null, '分类不存在'];
|
||||
await localDB.categories.delete(id);
|
||||
if (type === 'material') {
|
||||
const affected = await localDB.materials.filter(m => m.tag === id).toArray();
|
||||
for (const m of affected) {
|
||||
await localDB.materials.update(m.id, { tag: '', updatedAt: Date.now() });
|
||||
}
|
||||
return [{ cleared: affected.length }, null];
|
||||
}
|
||||
const affected = await localDB.projects.filter(p => String(p.categoryId) === id).toArray();
|
||||
for (const p of affected) {
|
||||
await localDB.projects.update(p.id, { categoryId: '0', updatedAt: Date.now() });
|
||||
}
|
||||
return [{ cleared: affected.length }, null];
|
||||
} catch (err: any) {
|
||||
return [null, err?.message || String(err)];
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取所有项目列表 */
|
||||
export async function getAllProjects(): Promise<{ id: string; updatedAt: number }[]> {
|
||||
return localDB.projects
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* - 文案:用户在「AI 设置」填的对话模型(带图时直接用该模型,需其支持图片输入)
|
||||
* - 配音:本机 unicut-tts(edge-tts),走同源 /localtts 反代,无需登录、无需密钥
|
||||
*/
|
||||
import { localChatCompletion } from '@utils/localAi';
|
||||
import { aiVisionAvailable, localChatCompletion } from '@utils/localAi';
|
||||
|
||||
/** 一段口播 = 一句文案 + 对应第几张图(1 基) */
|
||||
export interface QvSegment {
|
||||
@@ -125,27 +125,59 @@ export async function generateQuickVideoCopy(params: {
|
||||
title: string;
|
||||
style: string;
|
||||
images: string[];
|
||||
/** 文档 / 网页正文:有正文时以正文为内容依据,图片决定每段配什么画面 */
|
||||
sourceText?: string;
|
||||
}): Promise<[{ title: string; segments: QvSegment[] } | null, string | null]> {
|
||||
const images = params.images || [];
|
||||
if (images.length === 0) return [null, '请先添加至少 1 张图片'];
|
||||
const sourceText = (params.sourceText || '').trim();
|
||||
if (!images.length && !sourceText) return [null, '请先添加图片、文档或网址内容'];
|
||||
if (!params.title.trim()) return [null, '请填写标题'];
|
||||
|
||||
// 只有配了视觉(多模态)模型才压图发图:纯文本模型看不了图、也会被 image_url 顶回错误,
|
||||
// 走纯文本路径按编号顺序配画面,照样能出片
|
||||
const useVision = await aiVisionAvailable();
|
||||
const shrunk: string[] = [];
|
||||
for (const img of images) {
|
||||
shrunk.push(await shrinkImageForVision(img));
|
||||
if (useVision) {
|
||||
for (const img of images) {
|
||||
shrunk.push(await shrinkImageForVision(img));
|
||||
}
|
||||
}
|
||||
|
||||
const prompt = [
|
||||
`我在做一个短视频,标题是《${params.title}》。文案风格:${params.style}。`,
|
||||
`共有 ${images.length} 张图片,编号从 1 到 ${images.length}(顺序就是它们出现的顺序)。`,
|
||||
'请你逐张看图,理解每张图里展示的内容,然后写一段适合朗读的口播文案:',
|
||||
`1. 段落数 ${Math.min(images.length + 1, Math.max(3, images.length))} 段左右,每段 15~40 字,口语化、能直接读出来;`,
|
||||
'2. 每段给一个 image 字段,填这段对应第几张图(只填数字 1~' + images.length + ');',
|
||||
'3. 让整段文案围绕标题讲一个完整的小故事,第一段抓人,最后一段收尾;',
|
||||
'4. 不要出现“图片”“第一张”这种字眼,也不要加表情符号和换行。',
|
||||
'只输出 JSON,不要任何解释,格式:',
|
||||
'{"segments":[{"text":"...","image":1}]}',
|
||||
].join('\n');
|
||||
const lines: string[] = [`我在做一个短视频,标题是《${params.title}》。文案风格:${params.style}。`];
|
||||
if (sourceText) {
|
||||
const body = sourceText.slice(0, 6000);
|
||||
lines.push(
|
||||
`素材正文(来自用户上传的 Word / PDF 文档或网页,共 ${sourceText.length} 字,先看前 ${body.length} 字):`,
|
||||
'"""',
|
||||
body,
|
||||
'"""',
|
||||
'文案必须基于上面的素材正文改写,不要编造素材里没有的事实;素材里的关键信息、数字、结论要保留在文案里。',
|
||||
);
|
||||
}
|
||||
if (images.length) {
|
||||
lines.push(
|
||||
`共有 ${images.length} 张图片,编号从 1 到 ${images.length}(顺序就是它们出现的顺序)。`,
|
||||
!useVision
|
||||
? '你看不到图片本身,image 按顺序循环分配(第1段填1、第2段填2,排到最后一张回到1);'
|
||||
: sourceText
|
||||
? '素材正文决定每段说什么,图片决定每段配哪张画面(image 填最贴合的编号)。'
|
||||
: '请你逐张看图,理解每张图里展示的内容,然后写一段适合朗读的口播文案:',
|
||||
`1. 段落数 ${Math.min(images.length + 1, Math.max(3, images.length))} 段左右,每段 15~40 字,口语化、能直接读出来;`,
|
||||
'2. 每段给一个 image 字段,填这段对应第几张图(只填数字 1~' + images.length + ');',
|
||||
'3. 让整段文案围绕标题讲一个完整的小故事,第一段抓人,最后一段收尾;',
|
||||
'4. 不要出现“图片”“第一张”这种字眼,也不要加表情符号和换行。',
|
||||
);
|
||||
} else {
|
||||
lines.push(
|
||||
'素材只有文字,没有配图:',
|
||||
'1. 写 4~6 段、每段 15~40 字,口语化、能直接读出来;',
|
||||
'2. 每段 image 字段一律填 1;',
|
||||
'3. 让整段文案围绕标题讲一个完整的小故事,第一段抓人,最后一段收尾;',
|
||||
'4. 不要加表情符号和换行。',
|
||||
);
|
||||
}
|
||||
lines.push('只输出 JSON,不要任何解释,格式:', '{"segments":[{"text":"...","image":1}]}');
|
||||
const prompt = lines.join('\n');
|
||||
|
||||
const content: any[] = [{ type: 'text', text: prompt }];
|
||||
shrunk.forEach(url => {
|
||||
|
||||
@@ -119,6 +119,17 @@ const withAuth = (apiKey: string): Record<string, string> => {
|
||||
return h;
|
||||
};
|
||||
|
||||
/** 是否配置了视觉(多模态)模型:只有配了才会把图片真发给模型看,否则调用方走纯文本路径 */
|
||||
export async function aiVisionAvailable(): Promise<boolean> {
|
||||
if (!isAiConfigured()) return false;
|
||||
try {
|
||||
const cfg = await loadLocalAiConfig();
|
||||
return !!cfg.chat.visionModel;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** OpenAI 兼容对话(一次性返回),返回 [数据, 错误] */
|
||||
export async function localChatCompletion(params: {
|
||||
model?: string;
|
||||
@@ -133,6 +144,16 @@ export async function localChatCompletion(params: {
|
||||
});
|
||||
const primary = hasImage && cfg.chat.visionModel ? cfg.chat.visionModel : cfg.chat.model;
|
||||
const models = [primary, ...(cfg.chat.fallbackModels || [])].filter(Boolean);
|
||||
// 未配视觉模型时把图片块剥掉:纯文本主模型会被 image_url 内容块顶回错误,
|
||||
// 剥掉后纯文本模型照样能出文案(调用方按图片编号配画面)
|
||||
let messages = params.messages;
|
||||
if (hasImage && !cfg.chat.visionModel) {
|
||||
messages = (params.messages || []).map((m: any) => {
|
||||
if (!Array.isArray(m?.content)) return m;
|
||||
const parts = m.content.filter((c: any) => c?.type !== 'image_url' && c?.type !== 'image');
|
||||
return parts.length ? { ...m, content: parts } : m;
|
||||
});
|
||||
}
|
||||
let lastErr = '';
|
||||
|
||||
for (const model of models) {
|
||||
@@ -140,7 +161,7 @@ export async function localChatCompletion(params: {
|
||||
const res = await fetch(`${cfg.chat.baseUrl}/chat/completions`, {
|
||||
method: 'POST',
|
||||
headers: withAuth(cfg.chat.apiKey),
|
||||
body: JSON.stringify({ model, messages: params.messages, stream: false, max_tokens: 4096 }),
|
||||
body: JSON.stringify({ model, messages, stream: false, max_tokens: 4096 }),
|
||||
});
|
||||
const text = await res.text();
|
||||
let data: any = null;
|
||||
|
||||
@@ -0,0 +1,423 @@
|
||||
/**
|
||||
* AI 一键出片 · 素材导入(Word / PDF / 网址)
|
||||
*
|
||||
* - Word(.docx):jszip 解压读 word/document.xml 提取正文,顺带提取 word/media/ 内嵌配图
|
||||
* - PDF:pdfjs-dist 提取文字层,并渲染前几页当配图(扫描件没有文字层也能出画面)
|
||||
* - 网址:经同源 /grab/ 反代抓页面(nginx 动态反代,绕开浏览器跨域),解析正文与配图
|
||||
*
|
||||
* 全部在浏览器本地完成;除了用户自己输入的网址,不依赖任何外部服务。
|
||||
*/
|
||||
import JSZip from 'jszip';
|
||||
import * as pdfjs from 'pdfjs-dist';
|
||||
// @ts-ignore —— vite 把 worker 打进本地资源,离线可用(构建不跑 tsc)
|
||||
import PdfWorker from 'pdfjs-dist/build/pdf.worker.mjs?worker';
|
||||
|
||||
export interface ImportedSource {
|
||||
/** 提取到的正文(可能为空串) */
|
||||
text: string;
|
||||
/** 配图(dataURL,可直接给 <img> 和视觉模型用) */
|
||||
images: string[];
|
||||
/** 来源名:文件名或网页标题 */
|
||||
name: string;
|
||||
}
|
||||
|
||||
const DOCX_IMG_OK = /\.(png|jpe?g|gif|webp|bmp)$/i;
|
||||
const PDF_MAX_CHARS = 12000;
|
||||
const PDF_RENDER_PAGES = 4;
|
||||
const GRAB_TIMEOUT = 20000;
|
||||
const MAX_REDIRECTS = 5;
|
||||
/** 网页配图的最低尺寸:低于它的一般是图标 / logo / spacer */
|
||||
const IMG_MIN_W = 160;
|
||||
const IMG_MIN_H = 120;
|
||||
|
||||
/* ---------------- 通用小工具 ---------------- */
|
||||
|
||||
function guessMime(name: string): string {
|
||||
const ext = (name.split('.').pop() || '').toLowerCase();
|
||||
if (ext === 'png') return 'image/png';
|
||||
if (ext === 'jpg' || ext === 'jpeg') return 'image/jpeg';
|
||||
if (ext === 'gif') return 'image/gif';
|
||||
if (ext === 'webp') return 'image/webp';
|
||||
if (ext === 'bmp') return 'image/bmp';
|
||||
return 'application/octet-stream';
|
||||
}
|
||||
|
||||
function blobToDataUrl(blob: Blob): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const fr = new FileReader();
|
||||
fr.onload = () => resolve(String(fr.result || ''));
|
||||
fr.onerror = () => reject(new Error('读取文件失败'));
|
||||
fr.readAsDataURL(blob);
|
||||
});
|
||||
}
|
||||
|
||||
/** 探测图片真实宽高;坏图返回 null */
|
||||
function probeImage(url: string): Promise<{ w: number; h: number } | null> {
|
||||
return new Promise(resolve => {
|
||||
const img = new Image();
|
||||
img.onload = () => resolve({ w: img.naturalWidth, h: img.naturalHeight });
|
||||
img.onerror = () => resolve(null);
|
||||
img.src = url;
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------------- Word (.docx) ---------------- */
|
||||
|
||||
export async function parseDocx(file: File): Promise<ImportedSource> {
|
||||
const zip = await JSZip.loadAsync(file);
|
||||
const entry = zip.file('word/document.xml');
|
||||
if (!entry) {
|
||||
throw new Error('这不是有效的 Word 文档(缺少 word/document.xml),请在 Word 里另存为 .docx 再上传');
|
||||
}
|
||||
const xml = await entry.async('string');
|
||||
const doc = new DOMParser().parseFromString(xml, 'application/xml');
|
||||
|
||||
// 段落:只取最外层 w:p(表格 / 文本框里的嵌套段落不重复计)
|
||||
const isInsideP = (node: Node) => {
|
||||
let p = node.parentNode;
|
||||
while (p) {
|
||||
if (p.nodeName === 'w:p') return true;
|
||||
p = p.parentNode;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const lines: string[] = [];
|
||||
const ps = doc.getElementsByTagName('w:p');
|
||||
for (let i = 0; i < ps.length; i++) {
|
||||
const p = ps[i];
|
||||
if (isInsideP(p)) continue;
|
||||
let line = '';
|
||||
const els = p.getElementsByTagName('*');
|
||||
for (let j = 0; j < els.length; j++) {
|
||||
const el = els[j];
|
||||
if (el.nodeName === 'w:t') line += el.textContent || '';
|
||||
else if (el.nodeName === 'w:tab') line += ' ';
|
||||
else if (el.nodeName === 'w:br' || el.nodeName === 'w:cr') line += '\n';
|
||||
}
|
||||
lines.push(line);
|
||||
}
|
||||
const text = lines
|
||||
.join('\n')
|
||||
.replace(/[ \t]+\n/g, '\n')
|
||||
.replace(/\n{3,}/g, '\n\n')
|
||||
.trim();
|
||||
|
||||
// 内嵌配图:word/media/ 下的常见位图(emf/wmf 等浏览器画不出来的直接跳过)
|
||||
const media: { sortKey: string; f: { async: (t: 'blob') => Promise<Blob> } }[] = [];
|
||||
zip.forEach((path, f) => {
|
||||
if (!f.dir && /^word\/media\//.test(path) && DOCX_IMG_OK.test(path)) {
|
||||
media.push({ sortKey: path.replace(/^word\/media\//, ''), f });
|
||||
}
|
||||
});
|
||||
media.sort((a, b) => a.sortKey.localeCompare(b.sortKey, undefined, { numeric: true }));
|
||||
const images: string[] = [];
|
||||
for (const m of media.slice(0, 8)) {
|
||||
const raw = await m.f.async('blob');
|
||||
const type = (raw.type || '').split(';')[0] || guessMime(m.sortKey);
|
||||
images.push(await blobToDataUrl(new Blob([raw], { type })));
|
||||
}
|
||||
return { text, images, name: file.name };
|
||||
}
|
||||
|
||||
/* ---------------- PDF ---------------- */
|
||||
|
||||
let pdfWorker: Worker | null = null;
|
||||
|
||||
function ensurePdfWorker() {
|
||||
if (!pdfWorker) {
|
||||
pdfWorker = new PdfWorker();
|
||||
(pdfjs as any).GlobalWorkerOptions.workerPort = pdfWorker;
|
||||
}
|
||||
}
|
||||
|
||||
export async function parsePdf(file: File): Promise<ImportedSource> {
|
||||
ensurePdfWorker();
|
||||
const data = new Uint8Array(await file.arrayBuffer());
|
||||
let doc: any;
|
||||
try {
|
||||
doc = await (pdfjs as any).getDocument({ data, isEvalSupported: false }).promise;
|
||||
} catch (e: any) {
|
||||
const msg = `${e?.name || ''} ${e?.message || ''}`;
|
||||
if (/Password/i.test(msg)) throw new Error('PDF 设了密码,请先解除密码再上传');
|
||||
throw new Error('PDF 打不开:' + (e?.message || e));
|
||||
}
|
||||
try {
|
||||
// 文字层:逐页抽取,到上限为止
|
||||
const parts: string[] = [];
|
||||
let total = 0;
|
||||
for (let n = 1; n <= doc.numPages && total < PDF_MAX_CHARS; n++) {
|
||||
const page = await doc.getPage(n);
|
||||
const tc = await page.getTextContent();
|
||||
let buf = '';
|
||||
for (const it of tc.items as any[]) {
|
||||
if (typeof it.str !== 'string') continue;
|
||||
buf += it.str;
|
||||
if (it.hasEOL) buf += '\n';
|
||||
}
|
||||
if (buf.trim()) {
|
||||
parts.push(buf);
|
||||
total += buf.length;
|
||||
}
|
||||
page.cleanup();
|
||||
}
|
||||
const text = parts
|
||||
.join('\n\n')
|
||||
.replace(/\n{3,}/g, '\n\n')
|
||||
.trim();
|
||||
|
||||
// 前几页渲染成图:既是配图来源,也让扫描件(无文字层)可用
|
||||
const images: string[] = [];
|
||||
const renderN = Math.min(PDF_RENDER_PAGES, doc.numPages);
|
||||
for (let n = 1; n <= renderN; n++) {
|
||||
const page = await doc.getPage(n);
|
||||
const base = page.getViewport({ scale: 1 });
|
||||
const vp = page.getViewport({ scale: Math.min(2, 1280 / base.width) });
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = Math.max(1, Math.floor(vp.width));
|
||||
canvas.height = Math.max(1, Math.floor(vp.height));
|
||||
const ctx = canvas.getContext('2d');
|
||||
if (!ctx) break;
|
||||
ctx.fillStyle = '#fff';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
await page.render({ canvasContext: ctx, viewport: vp } as any).promise;
|
||||
images.push(canvas.toDataURL('image/jpeg', 0.85));
|
||||
page.cleanup();
|
||||
}
|
||||
if (!text && !images.length) throw new Error('PDF 里没读到文字和画面,文件可能已损坏');
|
||||
return { text, images, name: file.name };
|
||||
} finally {
|
||||
try {
|
||||
await doc.destroy();
|
||||
} catch (e) {
|
||||
/* 忽略销毁失败 */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------- 网址 ---------------- */
|
||||
|
||||
/** 和 nginx /grab/ 的规则保持一致:拒绝本机 / 内网 / 链路本地地址 */
|
||||
function assertFetchable(u: string) {
|
||||
let parsed: URL;
|
||||
try {
|
||||
parsed = new URL(u);
|
||||
} catch {
|
||||
throw new Error('网址格式不对,请输入完整地址(以 http 开头的完整链接)');
|
||||
}
|
||||
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
||||
throw new Error('只支持 http/https 网址');
|
||||
}
|
||||
const h = parsed.hostname.toLowerCase();
|
||||
if (
|
||||
h === 'localhost' ||
|
||||
h === '::1' ||
|
||||
h.endsWith('::1') ||
|
||||
/^(127\.|0\.0\.0\.0|10\.|192\.168\.|169\.254\.|172\.(1[6-9]|2[0-9]|3[01])\.)/.test(h)
|
||||
) {
|
||||
throw new Error('不能抓取本机 / 内网地址');
|
||||
}
|
||||
}
|
||||
|
||||
/** 经 /grab/ 抓取并手动跟随跳转(redirect:manual,跨域跳转也走同源反代) */
|
||||
async function grabRaw(rawUrl: string): Promise<{ res: Response; finalUrl: string }> {
|
||||
let cur = rawUrl;
|
||||
for (let i = 0; i <= MAX_REDIRECTS; i++) {
|
||||
assertFetchable(cur);
|
||||
// 规范化:裸域名自动补默认路径 /(否则反代会把原始请求路径透给上游)、非 ASCII 转百分号编码
|
||||
cur = new URL(cur).href;
|
||||
// 目标放请求头:nginx $arg_ 不解码 encodeURIComponent 的产物,query 传参会被误杀成 400
|
||||
const res = await fetch('/grab/', {
|
||||
headers: { 'X-Grab-Url': cur },
|
||||
redirect: 'manual',
|
||||
signal: AbortSignal.timeout(GRAB_TIMEOUT),
|
||||
});
|
||||
if (res.status >= 300 && res.status < 400) {
|
||||
const loc = res.headers.get('location');
|
||||
if (!loc) throw new Error(`抓取失败(HTTP ${res.status},跳转地址为空)`);
|
||||
cur = new URL(loc, cur).href;
|
||||
continue;
|
||||
}
|
||||
return { res, finalUrl: cur };
|
||||
}
|
||||
throw new Error('网址跳转次数过多');
|
||||
}
|
||||
|
||||
export async function importFromUrl(raw: string): Promise<ImportedSource> {
|
||||
let u = (raw || '').trim();
|
||||
if (!u) throw new Error('请输入网址');
|
||||
if (!/^https?:\/\//i.test(u)) u = 'https://' + u;
|
||||
|
||||
const { res, finalUrl } = await grabRaw(u);
|
||||
if (!res.ok) {
|
||||
const hint = res.status === 401 || res.status === 403 ? ',该站点拒绝了访问' : '';
|
||||
throw new Error(`抓取失败(HTTP ${res.status})${hint}`);
|
||||
}
|
||||
const ct = (res.headers.get('content-type') || '').toLowerCase();
|
||||
|
||||
// 直接就是一张图的地址
|
||||
if (ct.startsWith('image/')) {
|
||||
const blob = await res.blob();
|
||||
const dataUrl = await blobToDataUrl(blob);
|
||||
const dim = await probeImage(dataUrl);
|
||||
if (!dim || dim.w < IMG_MIN_W || dim.h < IMG_MIN_H) throw new Error('图片太小或无法识别');
|
||||
return { text: '', images: [dataUrl], name: new URL(finalUrl).hostname };
|
||||
}
|
||||
if (!/html|xml|text\/plain/.test(ct)) {
|
||||
throw new Error(`这个地址不是网页(返回类型 ${ct.split(';')[0] || '未知'})`);
|
||||
}
|
||||
const html = (await res.text()).slice(0, 3000000);
|
||||
const { title, text, images: candidates } = extractFromHtml(html, finalUrl);
|
||||
|
||||
// 抓配图:同样走 /grab/ 同源反代(图片站大多没有 CORS 头),最多 8 张、并发 4 路
|
||||
const picked: string[] = [];
|
||||
const queue = candidates.slice(0, 20);
|
||||
const grabOne = async () => {
|
||||
while (queue.length && picked.length < 8) {
|
||||
const imgUrl = queue.shift() as string;
|
||||
try {
|
||||
const r = await fetch('/grab/', {
|
||||
headers: { 'X-Grab-Url': new URL(imgUrl).href },
|
||||
signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
if (!r.ok) continue;
|
||||
const type = (r.headers.get('content-type') || '').toLowerCase();
|
||||
if (type && !type.startsWith('image/')) continue;
|
||||
const blob = await r.blob();
|
||||
if (!blob.size || blob.size > 10 * 1024 * 1024) continue;
|
||||
const dataUrl = await blobToDataUrl(blob);
|
||||
const dim = await probeImage(dataUrl);
|
||||
if (!dim || dim.w < IMG_MIN_W || dim.h < IMG_MIN_H) continue;
|
||||
picked.push(dataUrl);
|
||||
} catch {
|
||||
/* 单图失败不影响整体 */
|
||||
}
|
||||
}
|
||||
};
|
||||
await Promise.all([grabOne(), grabOne(), grabOne(), grabOne()]);
|
||||
|
||||
return { text, images: picked, name: title || new URL(finalUrl).hostname };
|
||||
}
|
||||
|
||||
/** 从 HTML 里取标题、正文、图片地址(相对地址转绝对) */
|
||||
export function extractFromHtml(
|
||||
html: string,
|
||||
baseUrl: string,
|
||||
): { title: string; text: string; images: string[] } {
|
||||
const dom = new DOMParser().parseFromString(html, 'text/html');
|
||||
const ogTitle = dom.querySelector('meta[property="og:title"]')?.getAttribute('content');
|
||||
const title = (ogTitle || dom.title || '').trim();
|
||||
|
||||
// 去掉不产生正文的节点
|
||||
dom
|
||||
.querySelectorAll('script,style,noscript,svg,iframe,canvas,form,nav,footer,header,aside,button')
|
||||
.forEach(el => el.remove());
|
||||
|
||||
const root =
|
||||
// 公众号文章正文在 #js_content(页面其余部分是账号栏/留言/分享等噪音),
|
||||
// 必须优先于 article/main 选择器——微信页两者都没有,否则会退化到整页 body
|
||||
dom.querySelector('#js_content') ||
|
||||
dom.querySelector('article') ||
|
||||
dom.querySelector('main') ||
|
||||
dom.querySelector('[role="main"]') ||
|
||||
dom.body;
|
||||
|
||||
// 图片:og:image 优先,其次 img 的常见懒加载属性
|
||||
const seen = new Set<string>();
|
||||
const images: string[] = [];
|
||||
const push = (v?: string | null) => {
|
||||
if (!v) return;
|
||||
const s = v.trim();
|
||||
if (!s || s.startsWith('data:') || /^blob:/i.test(s)) return;
|
||||
if (/\.svg(\?|#|$)/i.test(s)) return;
|
||||
let abs: string;
|
||||
try {
|
||||
abs = new URL(s, baseUrl).href;
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
if (!/^https?:/i.test(abs) || seen.has(abs)) return;
|
||||
seen.add(abs);
|
||||
images.push(abs);
|
||||
};
|
||||
push(dom.querySelector('meta[property="og:image"]')?.getAttribute('content'));
|
||||
root.querySelectorAll('img').forEach(img => {
|
||||
push(img.getAttribute('src'));
|
||||
push(img.getAttribute('data-src'));
|
||||
push(img.getAttribute('data-original'));
|
||||
push(img.getAttribute('data-lazy-src'));
|
||||
push(img.getAttribute('data-actualsrc'));
|
||||
});
|
||||
|
||||
// 正文:块级边界补换行后取 textContent,再压掉多余空白
|
||||
const clone = root.cloneNode(true) as HTMLElement;
|
||||
const nl = () => dom.createTextNode('\n');
|
||||
clone
|
||||
.querySelectorAll('p,h1,h2,h3,h4,h5,h6,li,blockquote,pre,td,th,figcaption,tr,div,br')
|
||||
.forEach(el => {
|
||||
el.insertBefore(nl(), el.firstChild);
|
||||
el.appendChild(nl());
|
||||
});
|
||||
const text = (clone.textContent || '')
|
||||
.replace(/\r/g, '')
|
||||
.replace(/[ \t ]+/g, ' ')
|
||||
.split('\n')
|
||||
.map(s => s.trim())
|
||||
.filter((s, i, arr) => s || (i > 0 && arr[i - 1]))
|
||||
.join('\n')
|
||||
.replace(/\n{3,}/g, '\n\n')
|
||||
.trim()
|
||||
.slice(0, 12000);
|
||||
|
||||
return { title, text, images };
|
||||
}
|
||||
|
||||
/* ---------------- 无图兜底:标题封面 ---------------- */
|
||||
|
||||
/** 纯文档 / 纯文字素材没有配图时,本地画一张标题封面,保证时间轴有画面可用 */
|
||||
export function makeTitleCover(title: string): { url: string; w: number; h: number } {
|
||||
const W = 1280;
|
||||
const H = 720;
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = W;
|
||||
canvas.height = H;
|
||||
const ctx = canvas.getContext('2d')!;
|
||||
const grad = ctx.createLinearGradient(0, 0, W, H);
|
||||
grad.addColorStop(0, '#1677ff');
|
||||
grad.addColorStop(0.55, '#597ef7');
|
||||
grad.addColorStop(1, '#722ed1');
|
||||
ctx.fillStyle = grad;
|
||||
ctx.fillRect(0, 0, W, H);
|
||||
ctx.fillStyle = 'rgba(255,255,255,0.08)';
|
||||
ctx.beginPath();
|
||||
ctx.arc(W - 150, 130, 230, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
ctx.beginPath();
|
||||
ctx.arc(110, H - 90, 190, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
|
||||
const raw = (title || 'AI 一键出片').trim().slice(0, 40);
|
||||
const fontSize = raw.length > 24 ? 48 : raw.length > 14 ? 58 : 68;
|
||||
ctx.font = `bold ${fontSize}px "PingFang SC", "Microsoft YaHei", sans-serif`;
|
||||
ctx.fillStyle = '#fff';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
// 中文没有空格,逐字按宽度断行,最多 3 行
|
||||
const maxW = W * 0.82;
|
||||
const lines: string[] = [];
|
||||
let cur = '';
|
||||
for (const ch of raw) {
|
||||
if (ctx.measureText(cur + ch).width > maxW) {
|
||||
lines.push(cur);
|
||||
cur = ch;
|
||||
} else {
|
||||
cur += ch;
|
||||
}
|
||||
}
|
||||
if (cur) lines.push(cur);
|
||||
const use = lines.slice(0, 3);
|
||||
if (lines.length > 3) use[2] = use[2].slice(0, -1) + '…';
|
||||
const lineH = fontSize * 1.35;
|
||||
const startY = H / 2 - ((use.length - 1) * lineH) / 2;
|
||||
use.forEach((ln, i) => ctx.fillText(ln, W / 2, startY + i * lineH));
|
||||
return { url: canvas.toDataURL('image/jpeg', 0.92), w: W, h: H };
|
||||
}
|
||||
@@ -4929,7 +4929,7 @@ var drawChart = (function (exports) {
|
||||
</script>
|
||||
<script>
|
||||
/*<!--*/
|
||||
const data = {"version":2,"tree":{"name":"root","children":[{"name":"homeAssets/js/opencv-ts-26caf77c.js","children":[{"uid":"21e0ef06-1","name":"\u0000commonjsHelpers.js"},{"uid":"21e0ef06-3","name":"__vite-browser-external"},{"uid":"21e0ef06-5","name":"\u0000__vite-browser-external?commonjs-proxy"},{"name":"\u0000C:/E/unicut/node_modules/opencv-ts/src/opencv.js?commonjs-module","uid":"21e0ef06-7"},{"name":"C:/E/unicut/node_modules/opencv-ts/src","children":[{"uid":"21e0ef06-9","name":"opencv.js"},{"uid":"21e0ef06-11","name":"opencv.js?commonjs-entry"}]}]},{"name":"homeAssets/js/main-c4b3b641.js","children":[{"name":"\u0000vite","children":[{"uid":"21e0ef06-13","name":"modulepreload-polyfill"},{"uid":"21e0ef06-2639","name":"preload-helper"}]},{"name":"\u0000C:/E/unicut/node_modules","children":[{"name":"react","children":[{"uid":"21e0ef06-15","name":"jsx-runtime.js?commonjs-module"},{"name":"cjs","children":[{"uid":"21e0ef06-17","name":"react-jsx-runtime.production.min.js?commonjs-exports"},{"uid":"21e0ef06-21","name":"react.production.min.js?commonjs-exports"}]},{"uid":"21e0ef06-19","name":"index.js?commonjs-module"}]},{"name":"react-dom","children":[{"uid":"21e0ef06-31","name":"index.js?commonjs-module"},{"name":"cjs/react-dom.production.min.js?commonjs-exports","uid":"21e0ef06-33"},{"uid":"21e0ef06-47","name":"client.js?commonjs-exports"}]},{"name":"scheduler","children":[{"uid":"21e0ef06-35","name":"index.js?commonjs-module"},{"name":"cjs/scheduler.production.min.js?commonjs-exports","uid":"21e0ef06-37"}]},{"name":"axios/lib/axios.js?commonjs-module","uid":"21e0ef06-57"},{"name":"pubsub-js/src/pubsub.js?commonjs-module","uid":"21e0ef06-123"},{"name":"dayjs/dayjs.min.js?commonjs-module","uid":"21e0ef06-127"},{"name":"simple-query-string/src/simplequerystring.js?commonjs-module","uid":"21e0ef06-131"},{"name":"dexie/dist/dexie.min.js?commonjs-module","uid":"21e0ef06-135"},{"name":"ignore/index.js?commonjs-module","uid":"21e0ef06-143"},{"name":"classnames/index.js?commonjs-module","uid":"21e0ef06-277"},{"name":"prop-types/index.js?commonjs-module","uid":"21e0ef06-281"},{"name":"lodash","children":[{"uid":"21e0ef06-325","name":"isBuffer.js?commonjs-module"},{"uid":"21e0ef06-339","name":"_nodeUtil.js?commonjs-module"},{"uid":"21e0ef06-369","name":"_cloneBuffer.js?commonjs-module"}]},{"name":"copy-text-to-clipboard/index.js?commonjs-module","uid":"21e0ef06-599"},{"name":"date-fns-tz","children":[{"name":"format","children":[{"uid":"21e0ef06-1309","name":"index.js?commonjs-module"},{"name":"formatters/index.js?commonjs-module","uid":"21e0ef06-1459"}]},{"name":"_lib","children":[{"name":"tzIntlTimeZoneName/index.js?commonjs-module","uid":"21e0ef06-1461"},{"name":"tzParseTimezone/index.js?commonjs-module","uid":"21e0ef06-1465"},{"name":"tzTokenizeDate/index.js?commonjs-module","uid":"21e0ef06-1467"},{"name":"newDateUTC/index.js?commonjs-module","uid":"21e0ef06-1471"},{"name":"tzPattern/index.js?commonjs-module","uid":"21e0ef06-1481"}]},{"name":"toDate/index.js?commonjs-module","uid":"21e0ef06-1479"},{"name":"formatInTimeZone/index.js?commonjs-module","uid":"21e0ef06-1489"},{"name":"utcToZonedTime/index.js?commonjs-module","uid":"21e0ef06-1499"},{"name":"getTimezoneOffset/index.js?commonjs-module","uid":"21e0ef06-1505"},{"name":"zonedTimeToUtc/index.js?commonjs-module","uid":"21e0ef06-1509"}]},{"name":"date-fns","children":[{"name":"format/index.js?commonjs-module","uid":"21e0ef06-1311"},{"name":"isValid/index.js?commonjs-module","uid":"21e0ef06-1317"},{"name":"isDate/index.js?commonjs-module","uid":"21e0ef06-1319"},{"name":"_lib","children":[{"name":"requiredArgs/index.js?commonjs-module","uid":"21e0ef06-1325"},{"name":"toInteger/index.js?commonjs-module","uid":"21e0ef06-1341"},{"name":"format","children":[{"name":"formatters/index.js?commonjs-module","uid":"21e0ef06-1349"},{"name":"lightFormatters/index.js?commonjs-module","uid":"21e0ef06-1395"},{"name":"longFormatters/index.js?commonjs-module","uid":"21e0ef06-1401"}]},{"name":"getUTCDayOfYear/index.js?commonjs-module","uid":"21e0ef06-1351"},{"name":"getUTCISOWeek/index.js?commonjs-module","uid":"21e0ef06-1355"},{"name":"startOfUTCISOWeek/index.js?commonjs-module","uid":"21e0ef06-1357"},{"name":"startOfUTCISOWeekYear/index.js?commonjs-module","uid":"21e0ef06-1361"},{"name":"getUTCISOWeekYear/index.js?commonjs-module","uid":"21e0ef06-1363"},{"name":"getUTCWeek/index.js?commonjs-module","uid":"21e0ef06-1371"},{"name":"startOfUTCWeek/index.js?commonjs-module","uid":"21e0ef06-1373"},{"name":"defaultOptions/index.js?commonjs-exports","uid":"21e0ef06-1375"},{"name":"startOfUTCWeekYear/index.js?commonjs-module","uid":"21e0ef06-1381"},{"name":"getUTCWeekYear/index.js?commonjs-module","uid":"21e0ef06-1383"},{"name":"addLeadingZeros/index.js?commonjs-module","uid":"21e0ef06-1391"},{"name":"getTimezoneOffsetInMilliseconds/index.js?commonjs-module","uid":"21e0ef06-1405"},{"name":"protectedTokens/index.js?commonjs-exports","uid":"21e0ef06-1409"},{"name":"defaultLocale/Line truncated
|
||||
const data = {"version":2,"tree":{"name":"root","children":[{"name":"homeAssets/js/opencv-ts-26caf77c.js","children":[{"uid":"ec5f2780-1","name":"\u0000commonjsHelpers.js"},{"uid":"ec5f2780-3","name":"__vite-browser-external"},{"uid":"ec5f2780-5","name":"\u0000__vite-browser-external?commonjs-proxy"},{"name":"\u0000/node_modules/opencv-ts/src/opencv.js?commonjs-module","uid":"ec5f2780-7"},{"name":"node_modules/opencv-ts/src","children":[{"uid":"ec5f2780-9","name":"opencv.js"},{"uid":"ec5f2780-11","name":"opencv.js?commonjs-entry"}]}]},{"name":"homeAssets/js/main-b9519a96.js","children":[{"name":"\u0000vite","children":[{"uid":"ec5f2780-13","name":"modulepreload-polyfill"},{"uid":"ec5f2780-2639","name":"preload-helper"}]},{"name":"\u0000/node_modules","children":[{"name":"react","children":[{"uid":"ec5f2780-15","name":"jsx-runtime.js?commonjs-module"},{"name":"cjs","children":[{"uid":"ec5f2780-17","name":"react-jsx-runtime.production.min.js?commonjs-exports"},{"uid":"ec5f2780-21","name":"react.production.min.js?commonjs-exports"}]},{"uid":"ec5f2780-19","name":"index.js?commonjs-module"}]},{"name":"react-dom","children":[{"uid":"ec5f2780-33","name":"index.js?commonjs-module"},{"name":"cjs/react-dom.production.min.js?commonjs-exports","uid":"ec5f2780-35"},{"uid":"ec5f2780-49","name":"client.js?commonjs-exports"}]},{"name":"scheduler","children":[{"uid":"ec5f2780-37","name":"index.js?commonjs-module"},{"name":"cjs/scheduler.production.min.js?commonjs-exports","uid":"ec5f2780-39"}]},{"name":"axios/lib/axios.js?commonjs-module","uid":"ec5f2780-59"},{"name":"pubsub-js/src/pubsub.js?commonjs-module","uid":"ec5f2780-125"},{"name":"dayjs/dayjs.min.js?commonjs-module","uid":"ec5f2780-129"},{"name":"simple-query-string/src/simplequerystring.js?commonjs-module","uid":"ec5f2780-133"},{"name":"dexie/dist/dexie.min.js?commonjs-module","uid":"ec5f2780-137"},{"name":"ignore/index.js?commonjs-module","uid":"ec5f2780-145"},{"name":"classnames/index.js?commonjs-module","uid":"ec5f2780-279"},{"name":"prop-types/index.js?commonjs-module","uid":"ec5f2780-283"},{"name":"lodash","children":[{"uid":"ec5f2780-327","name":"isBuffer.js?commonjs-module"},{"uid":"ec5f2780-341","name":"_nodeUtil.js?commonjs-module"},{"uid":"ec5f2780-371","name":"_cloneBuffer.js?commonjs-module"}]},{"name":"copy-text-to-clipboard/index.js?commonjs-module","uid":"ec5f2780-601"},{"name":"date-fns-tz","children":[{"name":"format","children":[{"uid":"ec5f2780-1311","name":"index.js?commonjs-module"},{"name":"formatters/index.js?commonjs-module","uid":"ec5f2780-1461"}]},{"name":"_lib","children":[{"name":"tzIntlTimeZoneName/index.js?commonjs-module","uid":"ec5f2780-1463"},{"name":"tzParseTimezone/index.js?commonjs-module","uid":"ec5f2780-1467"},{"name":"tzTokenizeDate/index.js?commonjs-module","uid":"ec5f2780-1469"},{"name":"newDateUTC/index.js?commonjs-module","uid":"ec5f2780-1473"},{"name":"tzPattern/index.js?commonjs-module","uid":"ec5f2780-1483"}]},{"name":"toDate/index.js?commonjs-module","uid":"ec5f2780-1481"},{"name":"formatInTimeZone/index.js?commonjs-module","uid":"ec5f2780-1491"},{"name":"utcToZonedTime/index.js?commonjs-module","uid":"ec5f2780-1501"},{"name":"getTimezoneOffset/index.js?commonjs-module","uid":"ec5f2780-1507"},{"name":"zonedTimeToUtc/index.js?commonjs-module","uid":"ec5f2780-1511"}]},{"name":"date-fns","children":[{"name":"format/index.js?commonjs-module","uid":"ec5f2780-1313"},{"name":"isValid/index.js?commonjs-module","uid":"ec5f2780-1319"},{"name":"isDate/index.js?commonjs-module","uid":"ec5f2780-1321"},{"name":"_lib","children":[{"name":"requiredArgs/index.js?commonjs-module","uid":"ec5f2780-1327"},{"name":"toInteger/index.js?commonjs-module","uid":"ec5f2780-1343"},{"name":"format","children":[{"name":"formatters/index.js?commonjs-module","uid":"ec5f2780-1351"},{"name":"lightFormatters/index.js?commonjs-module","uid":"ec5f2780-1397"},{"name":"longFormatters/index.js?commonjs-module","uid":"ec5f2780-1403"}]},{"name":"getUTCDayOfYear/index.js?commonjs-module","uid":"ec5f2780-1353"},{"name":"getUTCISOWeek/index.js?commonjs-module","uid":"ec5f2780-1357"},{"name":"startOfUTCISOWeek/index.js?commonjs-module","uid":"ec5f2780-1359"},{"name":"startOfUTCISOWeekYear/index.js?commonjs-module","uid":"ec5f2780-1363"},{"name":"getUTCISOWeekYear/index.js?commonjs-module","uid":"ec5f2780-1365"},{"name":"getUTCWeek/index.js?commonjs-module","uid":"ec5f2780-1373"},{"name":"startOfUTCWeek/index.js?commonjs-module","uid":"ec5f2780-1375"},{"name":"defaultOptions/index.js?commonjs-exports","uid":"ec5f2780-1377"},{"name":"startOfUTCWeekYear/index.js?commonjs-module","uid":"ec5f2780-1383"},{"name":"getUTCWeekYear/index.js?commonjs-module","uid":"ec5f2780-1385"},{"name":"addLeadingZeros/index.js?commonjs-module","uid":"ec5f2780-1393"},{"name":"getTimezoneOffsetInMilliseconds/index.js?commonjs-module","uid":"ec5f2780-1407"},{"name":"protectedTokens/index.js?commonjs-exports","uid":"ec5f2780-1411"},{"name":"defaultLocale/index.js?commonjs-module","uid":"eLine truncated
|
||||
|
||||
const run = () => {
|
||||
const width = window.innerWidth;
|
||||
|
||||
@@ -553,6 +553,18 @@
|
||||
resolved "https://registry.npmmirror.com/@icon-park/react/-/react-1.4.2.tgz#db761ebc0e685702b80c4aaf5b59af5ccda40ecc"
|
||||
integrity sha512-+MtQLjNiRuia3fC/NfpSCTIy5KH5b+NkMB9zYd7p3R4aAIK61AjK0OSraaICJdkKooU9jpzk8m0fY4g9A3JqhQ==
|
||||
|
||||
"@isaacs/cliui@^8.0.2":
|
||||
version "8.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550"
|
||||
integrity sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==
|
||||
dependencies:
|
||||
string-width "^5.1.2"
|
||||
string-width-cjs "npm:string-width@^4.2.0"
|
||||
strip-ansi "^7.0.1"
|
||||
strip-ansi-cjs "npm:strip-ansi@^6.0.1"
|
||||
wrap-ansi "^8.1.0"
|
||||
wrap-ansi-cjs "npm:wrap-ansi@^7.0.0"
|
||||
|
||||
"@jridgewell/gen-mapping@^0.3.12", "@jridgewell/gen-mapping@^0.3.5":
|
||||
version "0.3.13"
|
||||
resolved "https://registry.npmmirror.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz#6342a19f44347518c93e43b1ac69deb3c4656a1f"
|
||||
@@ -1050,6 +1062,78 @@
|
||||
resolved "https://registry.npmmirror.com/@mediapipe/tasks-vision/-/tasks-vision-0.10.35.tgz#ae1ff52d68550e0a4dd971ac6f67ef9aad7f946f"
|
||||
integrity sha512-HOvadwVRE6JC+45nyYhmnywnr5h/J8KZvOeUNVOG9q/0875pZgItznFB9bRTvLc264YSJqiZ1NsIpCStJw/egg==
|
||||
|
||||
"@napi-rs/canvas-android-arm64@0.1.100":
|
||||
version "0.1.100"
|
||||
resolved "https://registry.yarnpkg.com/@napi-rs/canvas-android-arm64/-/canvas-android-arm64-0.1.100.tgz#b7c68b91d57702a5fc523fa82de72ea741e6766e"
|
||||
integrity sha512-hjhCKhntPv9+t4ckHymdx0phYNcVW+GKQR6Lzw2zE+pOVjOplSmtx9nNNknTjbEDLcuLZqA1y8ufKg1XfgftzQ==
|
||||
|
||||
"@napi-rs/canvas-darwin-arm64@0.1.100":
|
||||
version "0.1.100"
|
||||
resolved "https://registry.yarnpkg.com/@napi-rs/canvas-darwin-arm64/-/canvas-darwin-arm64-0.1.100.tgz#d1686fa6ca699b07640efa5f45425db0a4e725e2"
|
||||
integrity sha512-2PcswRaC7Ly645DGt88///zuFDhJxJYdKAs1uU3mfk1atYkXufgcgLfBpk6Tm12nCQBaNt1wpybuPZ4qOhTo8A==
|
||||
|
||||
"@napi-rs/canvas-darwin-x64@0.1.100":
|
||||
version "0.1.100"
|
||||
resolved "https://registry.yarnpkg.com/@napi-rs/canvas-darwin-x64/-/canvas-darwin-x64-0.1.100.tgz#92978fd7eca21f7f1b59bd13ba3ce7c0e7c879a1"
|
||||
integrity sha512-ePNZtj7pNIva/siZMg+HmbeozkIjqUIYdoymH8HaA3qK7LfzFN4WMBM8G6HQ9ZC+H3+Dnn5pqtiXpgLykaPOhw==
|
||||
|
||||
"@napi-rs/canvas-linux-arm-gnueabihf@0.1.100":
|
||||
version "0.1.100"
|
||||
resolved "https://registry.yarnpkg.com/@napi-rs/canvas-linux-arm-gnueabihf/-/canvas-linux-arm-gnueabihf-0.1.100.tgz#95f9892e1d5a8274871d8ee406374e9ef692bd9f"
|
||||
integrity sha512-d5cDB48oWFGU8/XPhUOFAlySgb/VAu7D+s8fi55K1Pcfg8aPplHWqMgibhVLU8ky7Pyg/fuiVLz4Nf3JrSTuUA==
|
||||
|
||||
"@napi-rs/canvas-linux-arm64-gnu@0.1.100":
|
||||
version "0.1.100"
|
||||
resolved "https://registry.yarnpkg.com/@napi-rs/canvas-linux-arm64-gnu/-/canvas-linux-arm64-gnu-0.1.100.tgz#6b2b7c4bb016b8f5308115ac9ae909df4967a94b"
|
||||
integrity sha512-rDxgxRu69RvDlX/bh9o22DxLsGr8EqsNgotL9+RwQE1S0b0cqeatqsw6aW45mukm0B42DIAaAacKaYQ8cqS1nw==
|
||||
|
||||
"@napi-rs/canvas-linux-arm64-musl@0.1.100":
|
||||
version "0.1.100"
|
||||
resolved "https://registry.yarnpkg.com/@napi-rs/canvas-linux-arm64-musl/-/canvas-linux-arm64-musl-0.1.100.tgz#48cf6342543e4f87cf1f8e9b1aaa19ad85bcc178"
|
||||
integrity sha512-K3mDW66N+xT2/V439u1alFANiBUjdEx2gLiNYnCmUsva5jZMxWTjafBYwTzYK+EMFMHrUoabuU+T1BIP5CgbYQ==
|
||||
|
||||
"@napi-rs/canvas-linux-riscv64-gnu@0.1.100":
|
||||
version "0.1.100"
|
||||
resolved "https://registry.yarnpkg.com/@napi-rs/canvas-linux-riscv64-gnu/-/canvas-linux-riscv64-gnu-0.1.100.tgz#71b011007b03755c834a961735302c5837b041da"
|
||||
integrity sha512-mooqUBTIsccZpnoQC4NgrC1v6C1vof39etLNMnBwCY+p0gajWJvAHLGQ6g/gGyS5YrpDW+GefSN4+Cvcr08UWw==
|
||||
|
||||
"@napi-rs/canvas-linux-x64-gnu@0.1.100":
|
||||
version "0.1.100"
|
||||
resolved "https://registry.yarnpkg.com/@napi-rs/canvas-linux-x64-gnu/-/canvas-linux-x64-gnu-0.1.100.tgz#3f479d3b8b8c4658e5dec1b943ad7d2eefd2811f"
|
||||
integrity sha512-1eCvkDCazm7FFhsT7DfGOdSaHgZVK3bt/dSBl5EWHOWmnz+I7j8tPseJqqD81NF+MH21jKUK4wQSDjN0mdhnTg==
|
||||
|
||||
"@napi-rs/canvas-linux-x64-musl@0.1.100":
|
||||
version "0.1.100"
|
||||
resolved "https://registry.yarnpkg.com/@napi-rs/canvas-linux-x64-musl/-/canvas-linux-x64-musl-0.1.100.tgz#1beaca22c1fe97709a9c287115cb3c90194ddec6"
|
||||
integrity sha512-20arT6lnI19S68qNlii73TSEDbECNgzMz2EpldC1V3mZFuRkeujXkcebRk0LRJe9SEUAooYiLokfMViY8IX7yA==
|
||||
|
||||
"@napi-rs/canvas-win32-arm64-msvc@0.1.100":
|
||||
version "0.1.100"
|
||||
resolved "https://registry.yarnpkg.com/@napi-rs/canvas-win32-arm64-msvc/-/canvas-win32-arm64-msvc-0.1.100.tgz#8a1728b455dd17965f95c0bfdf6753be8c5851c0"
|
||||
integrity sha512-DZFFT1wIAg37LJw37yhMRFfjATd3vTQzjZ1Yki8u2vhO6Hi5VE6BVaGQ1aaDu7xb4iMErz+9EOwjpS7xcxFeBw==
|
||||
|
||||
"@napi-rs/canvas-win32-x64-msvc@0.1.100":
|
||||
version "0.1.100"
|
||||
resolved "https://registry.yarnpkg.com/@napi-rs/canvas-win32-x64-msvc/-/canvas-win32-x64-msvc-0.1.100.tgz#1e52883f8784ffdbe52dc2d47b05a0886aa6e9cf"
|
||||
integrity sha512-MyT1j3mHC2+Lu4pBi9mKyMJhtP6U7k7EldY7sj/uS5gJA65gTXt8MefJQXLJo5d/vZbuWmfxzkEUNc/urV3pHA==
|
||||
|
||||
"@napi-rs/canvas@^0.1.65":
|
||||
version "0.1.100"
|
||||
resolved "https://registry.yarnpkg.com/@napi-rs/canvas/-/canvas-0.1.100.tgz#2c89a15c28a62e1372be23fd474762ae1a8b16b7"
|
||||
integrity sha512-xglYA6q3XO5P3BNJYxVZ1IV7DLVjp1Py6nwag88YntrS+3vKHyYcMqXVS4ZztJmwz2uGvz1FWhI/4LgbR5uQDA==
|
||||
optionalDependencies:
|
||||
"@napi-rs/canvas-android-arm64" "0.1.100"
|
||||
"@napi-rs/canvas-darwin-arm64" "0.1.100"
|
||||
"@napi-rs/canvas-darwin-x64" "0.1.100"
|
||||
"@napi-rs/canvas-linux-arm-gnueabihf" "0.1.100"
|
||||
"@napi-rs/canvas-linux-arm64-gnu" "0.1.100"
|
||||
"@napi-rs/canvas-linux-arm64-musl" "0.1.100"
|
||||
"@napi-rs/canvas-linux-riscv64-gnu" "0.1.100"
|
||||
"@napi-rs/canvas-linux-x64-gnu" "0.1.100"
|
||||
"@napi-rs/canvas-linux-x64-musl" "0.1.100"
|
||||
"@napi-rs/canvas-win32-arm64-msvc" "0.1.100"
|
||||
"@napi-rs/canvas-win32-x64-msvc" "0.1.100"
|
||||
|
||||
"@pixi/accessibility@7.4.3":
|
||||
version "7.4.3"
|
||||
resolved "https://registry.npmmirror.com/@pixi/accessibility/-/accessibility-7.4.3.tgz#59d14a9886e853d4a469cf3d4256cb8e8ab9280d"
|
||||
@@ -1448,6 +1532,11 @@
|
||||
eventemitter3 "^4.0.0"
|
||||
url "^0.11.0"
|
||||
|
||||
"@pkgjs/parseargs@^0.11.0":
|
||||
version "0.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33"
|
||||
integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==
|
||||
|
||||
"@rolldown/pluginutils@1.0.0-beta.27":
|
||||
version "1.0.0-beta.27"
|
||||
resolved "https://registry.npmmirror.com/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.27.tgz#47d2bf4cef6d470b22f5831b420f8964e0bf755f"
|
||||
@@ -2278,7 +2367,7 @@ ansi-styles@^4.0.0, ansi-styles@^4.1.0:
|
||||
dependencies:
|
||||
color-convert "^2.0.1"
|
||||
|
||||
ansi-styles@^6.0.0:
|
||||
ansi-styles@^6.0.0, ansi-styles@^6.1.0:
|
||||
version "6.2.3"
|
||||
resolved "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-6.2.3.tgz#c044d5dcc521a076413472597a1acb1f103c4041"
|
||||
integrity sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==
|
||||
@@ -2377,6 +2466,13 @@ brace-expansion@^2.0.1:
|
||||
dependencies:
|
||||
balanced-match "^1.0.0"
|
||||
|
||||
brace-expansion@^2.0.2:
|
||||
version "2.1.7"
|
||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.1.7.tgz#14ea3836731823bb24740225ea43b941b436f9d1"
|
||||
integrity sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==
|
||||
dependencies:
|
||||
balanced-match "^1.0.0"
|
||||
|
||||
braces@^3.0.3:
|
||||
version "3.0.3"
|
||||
resolved "https://registry.npmmirror.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
|
||||
@@ -2634,7 +2730,7 @@ cropperjs@^1.5.13:
|
||||
resolved "https://registry.npmmirror.com/cropperjs/-/cropperjs-1.6.3.tgz#9556a39e3896f5dfa4b5b2649931454f631e9558"
|
||||
integrity sha512-BRb0PRIzjbfM5n+i6L2D85pSbXI/w6cnnwb9W9cRKgAmbiP+OjDeq+Irhd86IujZDXm/7JWECfscllFIdrlmfw==
|
||||
|
||||
cross-spawn@^7.0.3:
|
||||
cross-spawn@^7.0.3, cross-spawn@^7.0.6:
|
||||
version "7.0.6"
|
||||
resolved "https://registry.npmmirror.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f"
|
||||
integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==
|
||||
@@ -3063,6 +3159,14 @@ follow-redirects@^1.0.0, follow-redirects@^1.14.4:
|
||||
resolved "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.16.0.tgz#28474a159d3b9d11ef62050a14ed60e4df6d61bc"
|
||||
integrity sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==
|
||||
|
||||
foreground-child@^3.1.0:
|
||||
version "3.3.1"
|
||||
resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.3.1.tgz#32e8e9ed1b68a3497befb9ac2b6adf92a638576f"
|
||||
integrity sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==
|
||||
dependencies:
|
||||
cross-spawn "^7.0.6"
|
||||
signal-exit "^4.0.1"
|
||||
|
||||
form-data@^4.0.0:
|
||||
version "4.0.6"
|
||||
resolved "https://registry.npmmirror.com/form-data/-/form-data-4.0.6.tgz#28e864e1b786dbebb68db1f452f9635278665827"
|
||||
@@ -3158,6 +3262,18 @@ gl-transitions@^1.43.0:
|
||||
resolved "https://registry.npmmirror.com/gl-transitions/-/gl-transitions-1.71.0.tgz#f4454896100eadba6aadd9b73980d083e9aed93b"
|
||||
integrity sha512-fpCpeT5B0vQOAu1/XuTmOIWD3dJoMIuedmYdPqK/oGHMz8vexJzsCXVo8TQZVo7G2irAYhdhq+9wWtohj/IjZQ==
|
||||
|
||||
glob@^10.3.7:
|
||||
version "10.5.0"
|
||||
resolved "https://registry.yarnpkg.com/glob/-/glob-10.5.0.tgz#8ec0355919cd3338c28428a23d4f24ecc5fe738c"
|
||||
integrity sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==
|
||||
dependencies:
|
||||
foreground-child "^3.1.0"
|
||||
jackspeak "^3.1.2"
|
||||
minimatch "^9.0.4"
|
||||
minipass "^7.1.2"
|
||||
package-json-from-dist "^1.0.0"
|
||||
path-scurry "^1.11.1"
|
||||
|
||||
glob@^7.1.6:
|
||||
version "7.2.3"
|
||||
resolved "https://registry.npmmirror.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
|
||||
@@ -3496,6 +3612,15 @@ ismobilejs@^1.1.0:
|
||||
resolved "https://registry.npmmirror.com/ismobilejs/-/ismobilejs-1.1.1.tgz#c56ca0ae8e52b24ca0f22ba5ef3215a2ddbbaa0e"
|
||||
integrity sha512-VaFW53yt8QO61k2WJui0dHf4SlL8lxBofUuUmwBo0ljPk0Drz2TiuDW4jo3wDcv41qy/SxrJ+VAzJ/qYqsmzRw==
|
||||
|
||||
jackspeak@^3.1.2:
|
||||
version "3.4.3"
|
||||
resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-3.4.3.tgz#8833a9d89ab4acde6188942bd1c53b6390ed5a8a"
|
||||
integrity sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==
|
||||
dependencies:
|
||||
"@isaacs/cliui" "^8.0.2"
|
||||
optionalDependencies:
|
||||
"@pkgjs/parseargs" "^0.11.0"
|
||||
|
||||
jest-worker@^26.2.1:
|
||||
version "26.6.2"
|
||||
resolved "https://registry.npmmirror.com/jest-worker/-/jest-worker-26.6.2.tgz#7f72cbc4d643c365e27b9fd775f9d0eaa9c7a8ed"
|
||||
@@ -3772,6 +3897,11 @@ lower-case@^2.0.2:
|
||||
dependencies:
|
||||
tslib "^2.0.3"
|
||||
|
||||
lru-cache@^10.2.0:
|
||||
version "10.4.3"
|
||||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119"
|
||||
integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==
|
||||
|
||||
lru-cache@^5.1.1:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.npmmirror.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920"
|
||||
@@ -4426,6 +4556,18 @@ minimatch@^5.0.1:
|
||||
dependencies:
|
||||
brace-expansion "^2.0.1"
|
||||
|
||||
minimatch@^9.0.4:
|
||||
version "9.0.9"
|
||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.9.tgz#9b0cb9fcb78087f6fd7eababe2511c4d3d60574e"
|
||||
integrity sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==
|
||||
dependencies:
|
||||
brace-expansion "^2.0.2"
|
||||
|
||||
"minipass@^5.0.0 || ^6.0.2 || ^7.0.0", minipass@^7.1.2:
|
||||
version "7.1.3"
|
||||
resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.1.3.tgz#79389b4eb1bb2d003a9bba87d492f2bd37bdc65b"
|
||||
integrity sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==
|
||||
|
||||
mobx-react-lite@^2.2.0:
|
||||
version "2.2.2"
|
||||
resolved "https://registry.npmmirror.com/mobx-react-lite/-/mobx-react-lite-2.2.2.tgz#87c217dc72b4e47b22493daf155daf3759f868a6"
|
||||
@@ -4616,6 +4758,11 @@ p-try@^2.0.0:
|
||||
resolved "https://registry.npmmirror.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
|
||||
integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==
|
||||
|
||||
package-json-from-dist@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz#4f1471a010827a86f94cfd9b0727e36d267de505"
|
||||
integrity sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==
|
||||
|
||||
pako@~1.0.2:
|
||||
version "1.0.11"
|
||||
resolved "https://registry.npmmirror.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf"
|
||||
@@ -4677,6 +4824,14 @@ path-key@^3.0.0, path-key@^3.1.0:
|
||||
resolved "https://registry.npmmirror.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375"
|
||||
integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==
|
||||
|
||||
path-scurry@^1.11.1:
|
||||
version "1.11.1"
|
||||
resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.11.1.tgz#7960a668888594a0720b12a911d1a742ab9f11d2"
|
||||
integrity sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==
|
||||
dependencies:
|
||||
lru-cache "^10.2.0"
|
||||
minipass "^5.0.0 || ^6.0.2 || ^7.0.0"
|
||||
|
||||
path-to-regexp@^1.7.0:
|
||||
version "1.9.0"
|
||||
resolved "https://registry.npmmirror.com/path-to-regexp/-/path-to-regexp-1.9.0.tgz#5dc0753acbf8521ca2e0f137b4578b917b10cf24"
|
||||
@@ -4684,6 +4839,13 @@ path-to-regexp@^1.7.0:
|
||||
dependencies:
|
||||
isarray "0.0.1"
|
||||
|
||||
pdfjs-dist@^4.7.76:
|
||||
version "4.10.38"
|
||||
resolved "https://registry.yarnpkg.com/pdfjs-dist/-/pdfjs-dist-4.10.38.tgz#3ee698003790dc266cc8b55c0e662ccb9ae18f53"
|
||||
integrity sha512-/Y3fcFrXEAsMjJXeL9J8+ZG9U01LbuWaYypvDW2ycW1jL269L3js3DVBjDJ0Up9Np1uqDXsDrRihHANhZOlwdQ==
|
||||
optionalDependencies:
|
||||
"@napi-rs/canvas" "^0.1.65"
|
||||
|
||||
picocolors@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.npmmirror.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b"
|
||||
@@ -5341,6 +5503,13 @@ rfdc@^1.3.0:
|
||||
resolved "https://registry.npmmirror.com/rfdc/-/rfdc-1.4.1.tgz#778f76c4fb731d93414e8f925fbecf64cce7f6ca"
|
||||
integrity sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==
|
||||
|
||||
rimraf@^5.0.5:
|
||||
version "5.0.10"
|
||||
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-5.0.10.tgz#23b9843d3dc92db71f96e1a2ce92e39fd2a8221c"
|
||||
integrity sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ==
|
||||
dependencies:
|
||||
glob "^10.3.7"
|
||||
|
||||
rollup-plugin-node-externals@^6.1.1:
|
||||
version "6.1.2"
|
||||
resolved "https://registry.npmmirror.com/rollup-plugin-node-externals/-/rollup-plugin-node-externals-6.1.2.tgz#c328b86a00f3e0211a3bad2e0616e2ff1fa55b6c"
|
||||
@@ -5531,6 +5700,11 @@ signal-exit@^3.0.2, signal-exit@^3.0.3:
|
||||
resolved "https://registry.npmmirror.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"
|
||||
integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==
|
||||
|
||||
signal-exit@^4.0.1:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04"
|
||||
integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==
|
||||
|
||||
simple-query-string@^1.3.2:
|
||||
version "1.3.2"
|
||||
resolved "https://registry.npmmirror.com/simple-query-string/-/simple-query-string-1.3.2.tgz#3edc2c94280f7a878fa5a4de1898f8c9c0af39a7"
|
||||
@@ -5617,6 +5791,15 @@ string-argv@^0.3.1:
|
||||
resolved "https://registry.npmmirror.com/string-argv/-/string-argv-0.3.2.tgz#2b6d0ef24b656274d957d54e0a4bbf6153dc02b6"
|
||||
integrity sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==
|
||||
|
||||
"string-width-cjs@npm:string-width@^4.2.0":
|
||||
version "4.2.3"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||
dependencies:
|
||||
emoji-regex "^8.0.0"
|
||||
is-fullwidth-code-point "^3.0.0"
|
||||
strip-ansi "^6.0.1"
|
||||
|
||||
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
|
||||
version "4.2.3"
|
||||
resolved "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||
@@ -5626,7 +5809,7 @@ string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
|
||||
is-fullwidth-code-point "^3.0.0"
|
||||
strip-ansi "^6.0.1"
|
||||
|
||||
string-width@^5.0.0:
|
||||
string-width@^5.0.0, string-width@^5.0.1, string-width@^5.1.2:
|
||||
version "5.1.2"
|
||||
resolved "https://registry.npmmirror.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
|
||||
integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==
|
||||
@@ -5650,6 +5833,13 @@ stringify-entities@^4.0.0:
|
||||
character-entities-html4 "^2.0.0"
|
||||
character-entities-legacy "^3.0.0"
|
||||
|
||||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
||||
dependencies:
|
||||
ansi-regex "^5.0.1"
|
||||
|
||||
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
||||
version "6.0.1"
|
||||
resolved "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||
@@ -5717,7 +5907,7 @@ symbol-tree@^3.2.4:
|
||||
resolved "https://registry.npmmirror.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2"
|
||||
integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==
|
||||
|
||||
terser@^5.0.0:
|
||||
terser@^5.0.0, terser@^5.31.0:
|
||||
version "5.51.2"
|
||||
resolved "https://registry.npmmirror.com/terser/-/terser-5.51.2.tgz#555912425a7f2ff7737425c3718fa76c7069f6ef"
|
||||
integrity sha512-bWnjSNscmuI+GJze6ZupnHP8G/cTcsJF+bXCeQknk2SHQsgbNJnLrqiH9jZ2W4STPVXH2mDKKRX3iwPhc9Cn/Q==
|
||||
@@ -6052,6 +6242,15 @@ word@~0.3.0:
|
||||
resolved "https://registry.npmmirror.com/word/-/word-0.3.0.tgz#8542157e4f8e849f4a363a288992d47612db9961"
|
||||
integrity sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==
|
||||
|
||||
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
|
||||
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
|
||||
dependencies:
|
||||
ansi-styles "^4.0.0"
|
||||
string-width "^4.1.0"
|
||||
strip-ansi "^6.0.0"
|
||||
|
||||
wrap-ansi@^6.2.0:
|
||||
version "6.2.0"
|
||||
resolved "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53"
|
||||
@@ -6070,6 +6269,15 @@ wrap-ansi@^7.0.0:
|
||||
string-width "^4.1.0"
|
||||
strip-ansi "^6.0.0"
|
||||
|
||||
wrap-ansi@^8.1.0:
|
||||
version "8.1.0"
|
||||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
|
||||
integrity sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==
|
||||
dependencies:
|
||||
ansi-styles "^6.1.0"
|
||||
string-width "^5.0.1"
|
||||
strip-ansi "^7.0.1"
|
||||
|
||||
wrappy@1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.npmmirror.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
|
||||
|
||||