首页底部新增导航站与开源地址入口;授权系统收口(公告归属过滤、检查更新诚实降级、项目编号启动注入)
- 首页最底部新增「我的导航站 / 开源地址」双卡区块(MORE 眉标 + 大标题 + 深色紫晕;桌面 648x160、移动 342 宽;浅色主题独立覆写;外链新标签打开) - hub.ts 增加 isMine():project_id 与本项目不符的公告一律不显示,杜绝别人家公告弹窗盖住页头 - 点徽标检查更新不再冒充「已是最新」:查不到结果时提示暂时无法连接授权中心 - entrypoint.sh 启动时把 HUB_PROJECT_ID 替换进前端包;compose 增加 HUB_PROJECT_ID 透传 - 首页删收费标准、顶栏删 GitHub/Gitee 外链、Footer 整块下线 - 文档:CHANGELOG 补 2026-10-28 条目;功能清单新增第十二节 - 验收:e2e_home_links 16/16,e2e_hub 18/18(A3 通过)
This commit is contained in:
1 parent
59241af720
commit
f352eff625
34 files changed
+2023
-46
No files matched your search
@@ -4,6 +4,50 @@
|
||||
|
||||
---
|
||||
|
||||
## 2026-10-28
|
||||
|
||||
### ✨ 新功能
|
||||
|
||||
**AI 全面 BYOK(用户自备 API Key)**
|
||||
- AI 对话、AI 一键出片、AI 生图、AI 生视频一律要求先配置 API Key 才能使用;未配置时 AI 面板整体替换为引导卡片,基础剪辑(导入素材、时间轴、字幕、转场、导出)完全不受影响
|
||||
- 新增 `src/utils/aiAuth.ts`:配置存浏览器 localStorage(`micut.ai.config.v1`),不需要登录,也不经过服务端;提供订阅机制,改完立即生效
|
||||
- 新增 `src/components/ai-settings`:设置弹窗(接口地址 / API Key / 模型 三个输入框 + 清除 Key)与未配置时的引导卡片,引导卡带「填写 API Key」和「没有 Key?免费注册领取」两个按钮
|
||||
- 默认接口地址 `https://ai.88531.cn/v1`,默认模型 `mimo-v2.6-flash`,注册地址 `https://ai.88531.cn/register`(该站 `register_enabled=true`、公告写明「注册即送体验金」,CORS `access-control-allow-origin: *`,浏览器可直连,无需服务端代理)
|
||||
- 单点拦截:`localChatCompletion` / `localGenerateImage` / `localGenerateVideo` 未配置时直接返回统一文案 `AI_NOT_CONFIGURED_MSG`,一个请求都不发
|
||||
- 挂载点:编辑器右侧「AI 助手」与左侧 AI 面板未配置时整块换成引导卡;配置好后两处都常驻一个「AI 设置」按钮
|
||||
- 对话的接口地址与密钥一律以用户填的为准;调用方传入的私有模型 ID(`deepseek-v4-pro-260425` 等)一律忽略,统一走 AI 设置里的模型;视觉模型保留 `deepseek-v4-flash-vision-exp`(默认网关上确实有),请求失败会自动降到主模型
|
||||
- 生图 / 生视频走本站内置反代(`/omniai`、`/civideo`,密钥由 nginx 注入),同样以「是否配置 Key」作为解锁开关
|
||||
- 配音(本机 edge-tts)与抠图 / 去背(本机模型)不消耗外部额度,不纳入 Key 开关
|
||||
- 首页 FAQ 与「经济实惠」文案同步改为 BYOK 说明,新增「AI 功能怎么用?要收费吗?」一条
|
||||
|
||||
**授权系统(CardAuth)**
|
||||
- 接入 `auth.88531.cn`:装机数统计、心跳在线人数、公告发布(列表 + 进入弹窗 + 铃铛未读红点)、版本推送(有新版时徽标转琥珀并弹「发现新版本」)
|
||||
- 右上角常驻当前版本号 `v1.0.0`,编辑器页同样显示;点徽标可手动检查更新
|
||||
- 密钥只在 nginx 反代注入(`/hub` 反代带 `X-Project-Id` 头),不进前端包;产物扫描确认 JS 里无密钥
|
||||
- 节流:心跳 60s、公告 30min、版本 6h、手动检查 8s;授权中心不可达时全部静默降级,绝不拦功能
|
||||
- 项目编号 `__HUB_PROJECT_ID__` 由 `entrypoint.sh` 在容器启动时替换进前端(`HUB_PROJECT_ID=` 传入后重启即生效,未配时保持占位符)
|
||||
|
||||
**公告归属过滤(修复)**
|
||||
- 现象:项目编号还是占位符时,授权中心按它自己的默认项目回吐了**别人家**的公告,一进首页就被「使用教程」弹窗盖住页头
|
||||
- 修复:`hub.ts` 新增 `isMine()`,公告自带的 `project_id` 与本项目不符的一律不显示;编号配好后自然放行
|
||||
|
||||
**手动检查更新说人话(修复)**
|
||||
- 现象:没接入授权中心时点「检查更新」也提示「当前已是最新版本」,属于冒充
|
||||
- 修复:查不到结果时改口「暂时无法连接授权中心,稍后再试」;查到且确实无新版才说「已是最新版本」
|
||||
|
||||
**首页底部新增「导航站 / 开源地址」区块**
|
||||
- 位置:紧接 CTA 之后、页面最底部(Footer 已下线),独立深色区块 + 紫色光晕,眉标 MORE + 标题「我的导航站 / 开源地址」
|
||||
- 左卡「我的导航站」`https://nav.88531.cn`(20+ 自建站点,200 可达);右卡「开源地址」`https://gitee.com/676015863/unicut`(许可按事实标 `Apache-2.0 with additional conditions`,项目无 LICENSE 文件故不写 MIT)
|
||||
- 双卡大按钮(桌面 648×160、移动 342 宽),`target="_blank" rel="noreferrer"` 新标签打开;浅色主题有独立覆写,白底不白字
|
||||
- `scripts/e2e_home_links.py` 16/16:文案、href 精确、外链属性、卡片尺寸、区块位置、无横向溢出、无 JS 崩溃;深色/浅色/390px 三态视觉验收通过
|
||||
|
||||
**首页与菜单瘦身**
|
||||
- 首页删除「收费标准」整段(BYOK 免费工具,收费无从谈起)
|
||||
- 顶栏菜单删除 GitHub / Gitee 外链入口(开源地址改为首页底部固定展示)
|
||||
- 底部 Footer 整块下线(组件保留 `return null`,随时可恢复)
|
||||
|
||||
---
|
||||
|
||||
## 2026-10-26
|
||||
|
||||
### ✨ 新功能
|
||||
@@ -63,6 +107,8 @@
|
||||
### 🎨 调整
|
||||
|
||||
- 品牌由「云剪」改为 **UniCut**
|
||||
- 品牌名再由 **UniCut** 改为 **米剪**(全站显示名、`<title>`、meta、FAQ、关于我们、侧栏、离线提示页、文章文稿统一;英文语境用 `MiCut`;代码里指代上游开源项目的 `UniCut` 注释保留并加了说明)
|
||||
- 导航栏 Logo 字标换新:`logow-en.png`/`logow.png` 里的英文旧字标由代码重绘为「米剪」(保留原图形标,字高与原字标对齐 28px、垂直居中)
|
||||
- 首页删除「收费标准」栏目(含相关样式与死代码)
|
||||
- 顶部菜单栏移除 GitHub / Gitee 外链
|
||||
- 底部栏整体下线(`Footer` 返回 `null`,组件保留以便随时恢复)
|
||||
|
||||
@@ -9,6 +9,10 @@ services:
|
||||
environment:
|
||||
- OMNI_KEY=${OMNI_KEY:-}
|
||||
- CI_KEY=${CI_KEY:-}
|
||||
# 授权中心(auth.88531.cn)项目密钥:只注入 nginx 反代头,不进前端
|
||||
- HUB_KEY=${HUB_KEY:-}
|
||||
# 项目编号(非机密):启动时由 entrypoint 替换进前端包,用于公告/装机统计归属
|
||||
- HUB_PROJECT_ID=${HUB_PROJECT_ID:-}
|
||||
volumes:
|
||||
- certs:/etc/nginx/certs
|
||||
|
||||
|
||||
+3
-1
@@ -1,4 +1,4 @@
|
||||
# UniCut 免登录改造说明
|
||||
# 米剪免登录改造说明
|
||||
|
||||
目标:去掉所有需要登录/注册的环节,打开即用,全部数据留在本地浏览器。
|
||||
|
||||
@@ -119,6 +119,8 @@ docker compose up -d --no-build
|
||||
| `src/pages/aboutus/AboutUs.tsx` | 中英文「关于我们」整段重写为 UniCut 介绍(本地部署、数据存浏览器、免登录) |
|
||||
|
||||
`cdn.h5ds.com` / `video.h5ds.com` 等域名属于 SDK 资源与接口地址,不是文案,保持原样。
|
||||
> **2026-10-26 追记**:品牌名再次由 `UniCut` 改为 **米剪**,上表为 build21 当时的改动记录,保留原样以存档。当前全站显示名以 `src/language/zhCN.ts` 的 `common_name` 为准。
|
||||
|
||||
|
||||
## 生图 / 生视频:本机 omniroute + cheaperinference
|
||||
|
||||
|
||||
@@ -347,6 +347,16 @@ AI 自动分析视频内容,智能选取精彩片段进行剪辑,适合快
|
||||
|
||||
---
|
||||
|
||||
## 十二、自建服务与站点入口
|
||||
|
||||
### 12.1 首页底部「导航站 / 开源地址」
|
||||
首页最底部常驻两个大卡入口:左侧「我的导航站」`https://nav.88531.cn`(聚合 20+ 自建站点),右侧「开源地址」`https://gitee.com/676015863/unicut`(许可 `Apache-2.0 with additional conditions`)。均新标签打开,深/浅色主题与移动端(342px 宽卡片)都已适配。
|
||||
|
||||
### 12.2 授权中心(CardAuth)
|
||||
接入 `auth.88531.cn`:装机数与在线人数统计、公告发布(首页弹窗 + 顶栏铃铛未读红点)、版本推送(右上角常驻 `v1.0.0`,有新版转琥珀并弹「发现新版本」)。密钥只在 nginx 反代注入,不进前端包;授权中心不可达时全部静默降级,不影响剪辑功能。只显示本项目编号的公告,编号未配置时不展示任何公告。
|
||||
|
||||
---
|
||||
|
||||
<p align="center">
|
||||
<b>UNICUT — AI 驱动的开源视频剪辑工具,让创作更高效</b>
|
||||
</p>
|
||||
@@ -89,6 +89,6 @@ LottieFiles 也全面拥抱了 AI:
|
||||
|
||||
# 动画加入到视频中
|
||||
|
||||
开源视频剪辑工具 UniCut 支持lottie动画,你可以直接把下载的动画素材拖进视频中,即可加入到视频中。
|
||||
开源视频剪辑工具米剪支持lottie动画,你可以直接把下载的动画素材拖进视频中,即可加入到视频中。
|
||||
|
||||

|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
# UniCut 站点断网可用改造与详情页规范(本页日志)
|
||||
# 米剪站点断网可用改造与详情页规范(本页日志)
|
||||
|
||||
目标:构建产物里**没有任何会向外网发起请求的引用**,拔掉网线剪辑功能照常;
|
||||
同时把站点内容组织改成「详情页优先」,新增文章只加静态文件、不改前端代码。
|
||||
|
||||
@@ -27,4 +27,26 @@ else
|
||||
echo "警告:未设置 OMNI_KEY,/omniai 反代将鉴权失败"
|
||||
fi
|
||||
|
||||
# 授权中心项目密钥(安装统计/在线人数/公告/版本推送):
|
||||
# 只进 nginx 的反代头,不进前端包;缺失时授权中心接口会失败,
|
||||
# 前端按「无数据」安静降级(版本号照常显示,只是没公告、不提示新版本)。
|
||||
if [ -n "$HUB_KEY" ]; then
|
||||
sed -i "s|__HUB_KEY__|$HUB_KEY|g" /etc/nginx/conf.d/default.conf
|
||||
else
|
||||
echo "警告:未设置 HUB_KEY,授权中心 /hub 反代将鉴权失败(统计/公告/版本推送暂不可用)"
|
||||
fi
|
||||
|
||||
# 项目编号打进前端包(它不是机密,但必须在启动时替换:打包时还不知道编号)。
|
||||
# 没配时保持占位符,前端会按「拿不准的项目」把别人项目的公告过滤掉,只显示版本号。
|
||||
if [ -n "$HUB_PROJECT_ID" ]; then
|
||||
find /usr/share/nginx/html -type f \( -name '*.js' -o -name '*.html' \) 2>/dev/null \
|
||||
| xargs -r grep -l '__HUB_PROJECT_ID__' 2>/dev/null \
|
||||
| while read -r f; do
|
||||
sed -i "s|__HUB_PROJECT_ID__|$HUB_PROJECT_ID|g" "$f"
|
||||
done
|
||||
echo "授权中心项目编号已注入前端(HUB_PROJECT_ID 已设置)"
|
||||
else
|
||||
echo "警告:未设置 HUB_PROJECT_ID,公告按不到本项目(可传 HUB_PROJECT_ID=<编号> 后重启容器)"
|
||||
fi
|
||||
|
||||
exec nginx -g 'daemon off;'
|
||||
+3
-3
@@ -5,11 +5,11 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta
|
||||
name="description"
|
||||
content="UniCut 是一款在线视频剪辑工具,支持裁剪、拼接、滤镜、贴纸、动画、文字与配音,浏览器打开即可使用"
|
||||
content="米剪是一款在线视频剪辑工具,支持裁剪、拼接、滤镜、贴纸、动画、文字与配音,浏览器打开即可使用"
|
||||
/>
|
||||
<meta
|
||||
name="keywords"
|
||||
content="UniCut,在线视频剪辑,视频剪辑软件,免费视频剪辑工具,本地部署视频剪辑,视频剪辑工具"
|
||||
content="米剪,在线视频剪辑,视频剪辑软件,免费视频剪辑工具,本地部署视频剪辑,视频剪辑工具"
|
||||
/>
|
||||
<meta name="renderer" content="webkit" />
|
||||
<!-- No Baidu Siteapp-->
|
||||
@@ -20,7 +20,7 @@
|
||||
<meta http-equiv="Cache-Control" content="no-siteapp" />
|
||||
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>UniCut</title>
|
||||
<title>米剪</title>
|
||||
<script src="/assets/scripts/lame.min.js"></script>
|
||||
<script src="/assets/medianinfo/index.min.js"></script>
|
||||
<script async src="/assets/ffmpeg/ffmpeg.js"></script>
|
||||
|
||||
+17
@@ -88,6 +88,23 @@ server {
|
||||
client_max_body_size 2048m;
|
||||
}
|
||||
|
||||
# 授权中心(CardAuth,auth.88531.cn)同源反代:安装统计 / 在线人数 / 公告 / 版本推送。
|
||||
# 项目密钥 X-Api-Key 由 entrypoint.sh 在容器启动时注入,前端包与浏览器都不出现;
|
||||
# 前端只请求同源 /hub/**,因此不存在跨域、也无需 CORS。密钥缺失时接口会失败,
|
||||
# 前端按「无数据」安静降级(不弹错、不影响剪辑)。
|
||||
location /hub/ {
|
||||
proxy_pass https://auth.88531.cn/api/public/;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host auth.88531.cn;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Api-Key "__HUB_KEY__";
|
||||
proxy_read_timeout 30s;
|
||||
proxy_send_timeout 30s;
|
||||
client_max_body_size 1m;
|
||||
}
|
||||
|
||||
# 本机 LLM 网关(NewAPI,OpenAI 兼容 /v1)同源反代:
|
||||
# 浏览器只请求 https://<站点>/newapi/v1/*,既避免 HTTPS 页面直连 HTTP 被拦(混合内容),
|
||||
# 也保证站点在只有本机网络时可用。密钥仍留在服务端,前端不出现。
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
[
|
||||
{
|
||||
"id": "local-deploy-guide",
|
||||
"title": "UniCut 本机部署指南",
|
||||
"title": "米剪 本机部署指南",
|
||||
"description": "一条命令把在线剪辑工具装进自己的机器,浏览器打开即用",
|
||||
"date": "2026-10-26",
|
||||
"tags": ["部署", "Docker"]
|
||||
},
|
||||
{
|
||||
"id": "offline-ready",
|
||||
"title": "断网也能用:UniCut 离线能力说明",
|
||||
"title": "断网也能用:米剪 离线能力说明",
|
||||
"description": "字体、音色、模板、AI 全部本地化,外网断了也不影响剪辑",
|
||||
"date": "2026-10-26",
|
||||
"tags": ["离线", "原理"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# UniCut 本机部署指南
|
||||
# 米剪 本机部署指南
|
||||
|
||||
UniCut 是一个跑在浏览器里的视频剪辑工具。本机部署版把它做成一个 Docker 站点:
|
||||
米剪是一个跑在浏览器里的视频剪辑工具。本机部署版把它做成一个 Docker 站点:
|
||||
装好之后打开网页就能剪辑,工程数据全部存在浏览器本地,不需要注册、不需要登录。
|
||||
|
||||
## 一、准备
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# 断网也能用:UniCut 离线能力说明
|
||||
# 断网也能用:米剪 离线能力说明
|
||||
|
||||
本机部署版的目标是:**把网线拔掉,剪辑功能照常**。
|
||||
这篇文章说明哪些东西被搬到了本地,以及怎么自己检查。
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 4.0 KiB |
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>UniCut · 该功能离线不可用</title>
|
||||
<title>米剪 · 该功能离线不可用</title>
|
||||
<style>
|
||||
:root {
|
||||
color-scheme: light dark;
|
||||
@@ -75,7 +75,7 @@
|
||||
<div class="card">
|
||||
<h1 id="title">该功能需要联网服务,离线部署下不可用</h1>
|
||||
<p id="desc">
|
||||
UniCut 本机部署版已经做到全站断网可用,但下面这个能力依赖外部站点提供服务,断网时无法访问,
|
||||
米剪本机部署版已经做到全站断网可用,但下面这个能力依赖外部站点提供服务,断网时无法访问,
|
||||
因此这里不再向外域发起任何请求。
|
||||
</p>
|
||||
<dl>
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""首页底部「导航站 + 开源地址」验收。
|
||||
|
||||
断言:区块在页面最底部、两张大卡可见且够大、三个链接 href 精确、
|
||||
新窗口打开、无横向溢出、无 JS 崩溃。
|
||||
"""
|
||||
import sys
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
SITE = 'https://127.0.0.1:3005/'
|
||||
ok = 0
|
||||
fail = 0
|
||||
|
||||
|
||||
def check(name, cond, extra=''):
|
||||
global ok, fail
|
||||
if cond:
|
||||
ok += 1
|
||||
print(f' [OK] {name} {extra}')
|
||||
else:
|
||||
fail += 1
|
||||
print(f' [FAIL] {name} {extra}')
|
||||
|
||||
|
||||
def main():
|
||||
global ok, fail
|
||||
with sync_playwright() as p:
|
||||
br = p.chromium.launch(executable_path='/usr/bin/chromium', headless=True,
|
||||
args=['--no-sandbox', '--disable-gpu',
|
||||
'--disable-dev-shm-usage', '--mute-audio'])
|
||||
ctx = br.new_context(ignore_https_errors=True,
|
||||
viewport={'width': 1440, 'height': 900})
|
||||
page = ctx.new_page()
|
||||
errs = []
|
||||
page.on('pageerror', lambda e: errs.append(str(e)))
|
||||
page.goto(SITE, wait_until='domcontentloaded', timeout=45000)
|
||||
page.wait_for_timeout(4000)
|
||||
|
||||
txt = page.evaluate('() => document.body.innerText')
|
||||
print('--- A 文案与区块')
|
||||
check('A1 出现「我的导航站」', '我的导航站' in txt)
|
||||
check('A2 出现「开源地址」', '开源地址' in txt)
|
||||
check('A3 出现导航站域名', 'nav.88531.cn' in txt)
|
||||
check('A4 出现 Gitee 源码地址', 'gitee.com/676015863/unicut' in txt)
|
||||
check('A5 出现 GitHub 镜像行', 'github.com/mtsee/unicut' in txt)
|
||||
check('A6 许可标签未乱写', 'MIT' not in txt and '免费商用' not in txt,
|
||||
'(许可证是改良版 Apache 2.0)')
|
||||
|
||||
print('--- B 链接与打开方式')
|
||||
for href, name in [('https://nav.88531.cn', 'B1 导航站链接'),
|
||||
('https://gitee.com/676015863/unicut', 'B2 开源链接'),
|
||||
('https://github.com/mtsee/unicut', 'B3 GitHub 链接')]:
|
||||
info = page.evaluate(
|
||||
"""h => [...document.querySelectorAll('a')].filter(
|
||||
a => a.href.replace(/\/$/, '') === h)
|
||||
.map(a => ({t: a.target, r: a.rel, w: a.getBoundingClientRect().width}))""",
|
||||
href)
|
||||
check(name, len(info) >= 1 and info[0]['t'] == '_blank',
|
||||
f"count={len(info)} target={info[0]['t'] if info else '-'} "
|
||||
f"w={round(info[0]['w']) if info else '-'}")
|
||||
|
||||
print('--- C 显眼程度(卡片尺寸 + 位置)')
|
||||
geo = page.evaluate("""() => {
|
||||
const norm = h => h.replace(/\/$/, '');
|
||||
const cards = [...document.querySelectorAll('a')].filter(a => {
|
||||
const h = norm(a.href);
|
||||
return h === 'https://nav.88531.cn' ||
|
||||
h === 'https://gitee.com/676015863/unicut';
|
||||
});
|
||||
return cards.map(a => {
|
||||
const r = a.getBoundingClientRect();
|
||||
const s = getComputedStyle(a);
|
||||
return {w: Math.round(r.width), h: Math.round(r.height),
|
||||
top: Math.round(r.top + window.scrollY),
|
||||
fs: s.fontSize, disp: s.display};
|
||||
});
|
||||
}""")
|
||||
check('C1 两张卡片都在', len(geo) == 2, str(geo))
|
||||
for i, g in enumerate(geo):
|
||||
check(f'C{i + 2} 卡片够大 (宽>=380 高>=140)',
|
||||
g['w'] >= 380 and g['h'] >= 140, str(g))
|
||||
place = page.evaluate("""() => {
|
||||
const el = [...document.querySelectorAll('a')].find(
|
||||
a => a.href.replace(/\/$/, '') === 'https://nav.88531.cn');
|
||||
if (!el) return {top: -1, sh: document.body.scrollHeight};
|
||||
const r = el.getBoundingClientRect();
|
||||
return {top: Math.round(r.top + window.scrollY),
|
||||
sh: document.body.scrollHeight};
|
||||
}""")
|
||||
check('C4 区块在页面下部 (>75%)',
|
||||
place['top'] > place['sh'] * 0.75, str(place))
|
||||
|
||||
print('--- D 版式')
|
||||
ovf = page.evaluate('() => document.documentElement.scrollWidth - window.innerWidth')
|
||||
check('D1 无横向溢出', ovf <= 1, f'overflow={ovf}')
|
||||
order = page.evaluate("""() => {
|
||||
const cta = [...document.querySelectorAll('h2')].find(
|
||||
h => h.innerText.includes('准备好开始创作'));
|
||||
const nav = [...document.querySelectorAll('h2')].find(
|
||||
h => h.innerText.includes('我的导航站'));
|
||||
return {cta: cta ? Math.round(cta.getBoundingClientRect().top + scrollY) : -1,
|
||||
nav: nav ? Math.round(nav.getBoundingClientRect().top + scrollY) : -1};
|
||||
}""")
|
||||
check('D2 位于 CTA 之后', order['nav'] > order['cta'] > 0, str(order))
|
||||
|
||||
print('--- E 健康')
|
||||
check('E1 无 JS 崩溃', len(errs) == 0, str(errs[:3]))
|
||||
|
||||
page.evaluate('() => window.scrollTo(0, document.body.scrollHeight)')
|
||||
page.wait_for_timeout(600)
|
||||
page.screenshot(path='/tmp/home_links.png')
|
||||
print(f'\nRESULT {ok}/{ok + fail}')
|
||||
br.close()
|
||||
return 0 if fail == 0 else 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,359 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""授权中心(CardAuth)接入验收:安装统计 / 在线人数 / 公告 / 版本推送。
|
||||
|
||||
四段:
|
||||
A 真实链路(不打桩):页面发起 /hub/** 请求;右上角显示与 package.json 一致的版本号;
|
||||
未配置密钥时安静降级(点版本号提示「已是最新版本」,不报错、不弹异常)。
|
||||
B 打桩链路:新版本徽标变琥珀 + 自动弹「发现新版本」→ 关掉后弹公告弹窗(新版本优先级更高);
|
||||
铃铛红点 → 列表 → 详情。
|
||||
C 清空语义:把公告桩改成空数组,60s 轮询后红点必须消失(后台删了前端就得消失)。
|
||||
D 包体安检:JS 里不得出现任何密钥(ak_ 前缀、__HUB_KEY__、X-Api-Key)。
|
||||
|
||||
运行:python3 scripts/e2e_hub.py (需 build53+ 镜像在跑)
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
BASE = 'https://127.0.0.1:3005'
|
||||
APPID = 'local_e2e_tpl_001'
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
VERSION = json.load(open(os.path.join(ROOT, 'package.json'), encoding='utf-8'))['version']
|
||||
|
||||
STUB_UPDATE = {
|
||||
'code': 200,
|
||||
'data': {
|
||||
'install_id': 1,
|
||||
'latest_version': '9.9.9',
|
||||
'update_available': True,
|
||||
'update_required': False,
|
||||
'is_force': 0,
|
||||
'changelog': '【新功能】一键出片支持图片转场效果\n【修复】内置模板缩略图偶发裂图\n【优化】导出文件名默认带产品名',
|
||||
'download_url': '',
|
||||
'min_client_version': '',
|
||||
},
|
||||
}
|
||||
STUB_LIST = {
|
||||
'code': 200,
|
||||
'data': {
|
||||
'list': [{
|
||||
'id': 1,
|
||||
'title': '米剪 1.0 正式上线',
|
||||
'content': '米剪已全面免费开放;AI 能力采用「用户自填 Key」方式,不采集任何账号信息。',
|
||||
'publish_time': '2026-10-28 09:00:00',
|
||||
'is_top': 1,
|
||||
'link_url': '',
|
||||
}],
|
||||
'popup': [{
|
||||
'id': 2,
|
||||
'title': '欢迎使用米剪',
|
||||
'content': '这是一条弹窗公告:右上角铃铛里能看到全部公告。',
|
||||
'publish_time': '2026-10-28 09:01:00',
|
||||
'is_top': 0,
|
||||
'link_url': '',
|
||||
}],
|
||||
},
|
||||
}
|
||||
STUB_NEW = {
|
||||
'code': 200,
|
||||
'data': {
|
||||
'list': [{
|
||||
'id': 3,
|
||||
'title': '新公告来了',
|
||||
'content': '这条用于验证 60 秒轮询能拉到后台新发的公告。',
|
||||
'publish_time': '2026-10-28 10:00:00',
|
||||
'is_top': 0,
|
||||
'link_url': '',
|
||||
}],
|
||||
'popup': [],
|
||||
},
|
||||
}
|
||||
STUB_EMPTY = {'code': 200, 'data': {'list': [], 'popup': []}}
|
||||
|
||||
# 红点判定:铃铛存在,且有 / 没有未读小红点
|
||||
DOT_JS = """() => {
|
||||
const el = [...document.querySelectorAll('span')].find(
|
||||
e => (e.getAttribute('title') || '').includes('公告'));
|
||||
return !!el && !!el.querySelector('i');
|
||||
}"""
|
||||
NODOT_JS = """() => {
|
||||
const el = [...document.querySelectorAll('span')].find(
|
||||
e => (e.getAttribute('title') || '').includes('公告'));
|
||||
return !!el && !el.querySelector('i');
|
||||
}"""
|
||||
|
||||
# 首次进编辑器会撞上「选择本地存储文件夹」守卫:把 OPFS 根句柄写进
|
||||
# folderHandles 存储(与 e2e_template.py 同一套做法),刷新即过。
|
||||
GUARD_JS = """async () => {
|
||||
const dh = await navigator.storage.getDirectory();
|
||||
const db = await new Promise((res, rej) => {
|
||||
const rq = indexedDB.open('H5VideoLocalDB');
|
||||
rq.onsuccess = () => res(rq.result);
|
||||
rq.onerror = () => rej(rq.error);
|
||||
});
|
||||
await new Promise((res, rej) => {
|
||||
const tx = db.transaction('folderHandles', 'readwrite');
|
||||
const st = tx.objectStore('folderHandles');
|
||||
const rec = { id: 'root', handle: dh };
|
||||
if (st.keyPath) st.put(rec); else st.put(rec, 'root');
|
||||
tx.oncomplete = () => res();
|
||||
tx.onerror = () => rej(tx.error);
|
||||
});
|
||||
}"""
|
||||
|
||||
fails = []
|
||||
|
||||
|
||||
def log(s):
|
||||
print('[hub] %s' % s, flush=True)
|
||||
|
||||
|
||||
def ok(name, cond, extra=''):
|
||||
if cond:
|
||||
log('PASS %s %s' % (name, extra))
|
||||
else:
|
||||
log('FAIL %s %s' % (name, extra))
|
||||
fails.append(name)
|
||||
return cond
|
||||
|
||||
|
||||
def badges(page):
|
||||
"""版本号候选:外层 .wrap 与内层 .ver 的文本都是版本号,全取回来。"""
|
||||
return page.evaluate(
|
||||
"""(v) => {
|
||||
const want = 'v' + v;
|
||||
return [...document.querySelectorAll('span')]
|
||||
.filter(e => (e.textContent || '').trim() === want)
|
||||
.map(e => {
|
||||
const r = e.getBoundingClientRect();
|
||||
return { cls: e.className, x: r.x + r.width / 2, y: r.y + r.height / 2, w: r.width };
|
||||
});
|
||||
}""",
|
||||
VERSION,
|
||||
)
|
||||
|
||||
|
||||
def badge(page):
|
||||
"""内层徽标(最窄的那个):用于点击与配色判定。"""
|
||||
bs = badges(page)
|
||||
return min(bs, key=lambda b: b['w']) if bs else None
|
||||
|
||||
|
||||
def click_text(page, tag, text):
|
||||
return page.evaluate(
|
||||
"""([tag, text]) => {
|
||||
const el = [...document.querySelectorAll(tag)]
|
||||
.find(e => (e.innerText || '').trim() === text);
|
||||
if (!el) return false;
|
||||
el.click();
|
||||
return true;
|
||||
}""",
|
||||
[tag, text],
|
||||
)
|
||||
|
||||
|
||||
def has_text(page, text):
|
||||
return page.evaluate("(t) => document.body.innerText.includes(t)", text)
|
||||
|
||||
|
||||
def hub_handler(state, hits):
|
||||
def h(route):
|
||||
u = route.request.url
|
||||
if '/hub/' not in u:
|
||||
return route.continue_()
|
||||
hits.append(u)
|
||||
if 'check-update' in u:
|
||||
body = state['update']
|
||||
elif 'announcements' in u:
|
||||
body = state['announce']
|
||||
else:
|
||||
body = {'code': 200, 'data': {}}
|
||||
return route.fulfill(status=200, content_type='application/json', body=json.dumps(body))
|
||||
return h
|
||||
|
||||
|
||||
def main():
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(
|
||||
executable_path='/usr/bin/chromium',
|
||||
headless=True,
|
||||
args=['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage', '--mute-audio'],
|
||||
)
|
||||
|
||||
# ---------- A:真实链路 ----------
|
||||
ctx_a = browser.new_context(ignore_https_errors=True)
|
||||
page = ctx_a.new_page()
|
||||
hub_hits = []
|
||||
page.on('request', lambda r: hub_hits.append(r.url) if '/hub/' in r.url else None)
|
||||
errs = []
|
||||
page.on('pageerror', lambda e: errs.append(str(e)))
|
||||
log('A 打开首页(真实 /hub,未配密钥)')
|
||||
page.goto(BASE + '/', wait_until='domcontentloaded', timeout=90000)
|
||||
page.wait_for_timeout(4000)
|
||||
|
||||
bs = badges(page)
|
||||
ok('A1 右上角显示当前版本号', len(bs) > 0, json.dumps(bs[:2], ensure_ascii=False))
|
||||
ok('A2 页面已向授权中心发请求', len(hub_hits) >= 1,
|
||||
'hits=%d %s' % (len(hub_hits), sorted({h.split('?')[0] for h in hub_hits})))
|
||||
bi = badge(page)
|
||||
if bi:
|
||||
# 先关掉可能压住页头的弹窗(公告/引导),否则坐标点击会打在遮罩上而不是徽标上
|
||||
for _ in range(3):
|
||||
dismissed = page.evaluate("""() => {
|
||||
const btns = [...document.querySelectorAll('button')].filter(
|
||||
b => /^(关闭|稍后再说|我知道了|知道了)$/.test((b.innerText || '').trim()));
|
||||
if (btns.length) { btns[0].click(); return true; }
|
||||
return false;
|
||||
}""")
|
||||
if not dismissed:
|
||||
break
|
||||
page.wait_for_timeout(400)
|
||||
bi = badge(page) or bi
|
||||
page.mouse.click(bi['x'], bi['y'])
|
||||
page.wait_for_timeout(1800)
|
||||
toasts = page.evaluate(
|
||||
"() => [...document.querySelectorAll('.semi-toast')]"
|
||||
".map(e => e.innerText).join(' | ')")
|
||||
# 查成了且没新版本 = 「已是最新」;没查成(403/不通)= 必须承认连不上,
|
||||
# 两者都不许冒充新版本,也不许什么都不吐(点了没反应同样是缺陷)。
|
||||
honest = ('已是最新版本' in toasts) or ('无法连接授权中心' in toasts)
|
||||
no_fake_update = '发现新版本' not in page.evaluate('() => document.body.innerText')
|
||||
ok('A3 点徽标给出实话(最新成功态 / 连不上授权中心的诚实降级,且不误报新版本)',
|
||||
honest and no_fake_update, 'toast=%s' % (toasts or '(空)'))
|
||||
ok('A4 无 JS 崩溃', len(errs) == 0, '; '.join(errs[:2]))
|
||||
ctx_a.close()
|
||||
|
||||
# ---------- B/C:打桩链路 ----------
|
||||
state = {'update': STUB_UPDATE, 'announce': STUB_LIST}
|
||||
stub_hits = []
|
||||
ctx = browser.new_context(ignore_https_errors=True)
|
||||
ctx.route('**/hub/**', hub_handler(state, stub_hits))
|
||||
page = ctx.new_page()
|
||||
errs = []
|
||||
page.on('pageerror', lambda e: errs.append(str(e)))
|
||||
log('B 打开首页(桩:新版本 9.9.9 + 公告 + 弹窗公告)')
|
||||
page.goto(BASE + '/', wait_until='domcontentloaded', timeout=90000)
|
||||
|
||||
try:
|
||||
page.wait_for_function(
|
||||
"() => document.body.innerText.includes('发现新版本')", timeout=20000)
|
||||
ok('B1 自动弹出新版本提示', True)
|
||||
ok('B2 弹窗标题带新版本号', has_text(page, '发现新版本 v9.9.9'))
|
||||
ok('B3 显示更新说明', has_text(page, '一键出片支持图片转场效果'))
|
||||
except Exception as e:
|
||||
ok('B1 自动弹出新版本提示', False, str(e)[:120])
|
||||
|
||||
bs = badges(page)
|
||||
ok('B4 版本徽标变琥珀(有新版本)', any('verNew' in b['cls'] for b in bs),
|
||||
json.dumps([b['cls'] for b in bs], ensure_ascii=False))
|
||||
|
||||
ok('B5 点「稍后再说」关闭新版本弹窗', click_text(page, 'button', '稍后再说'))
|
||||
page.wait_for_timeout(1200)
|
||||
|
||||
# 新版本弹窗关掉之后才轮到公告弹窗(优先级)
|
||||
try:
|
||||
page.wait_for_function(
|
||||
"() => document.body.innerText.includes('欢迎使用米剪')", timeout=8000)
|
||||
ok('B6 新版本关闭后弹公告(优先级正确)', True)
|
||||
except Exception as e:
|
||||
ok('B6 新版本关闭后弹公告(优先级正确)', False, str(e)[:120])
|
||||
click_text(page, 'button', '关闭')
|
||||
page.wait_for_timeout(800)
|
||||
|
||||
# 铃铛:红点 → 列表 → 详情
|
||||
bell = page.evaluate(
|
||||
"""() => {
|
||||
const el = [...document.querySelectorAll('span')].find(
|
||||
e => (e.getAttribute('title') || '').includes('公告'));
|
||||
if (!el) return null;
|
||||
const r = el.getBoundingClientRect();
|
||||
return { x: r.x + r.width / 2, y: r.y + r.height / 2, hasDot: !!el.querySelector('i') };
|
||||
}"""
|
||||
)
|
||||
ok('B7 铃铛红点(有未读公告)', bool(bell) and bell['hasDot'], json.dumps(bell))
|
||||
if bell:
|
||||
page.mouse.click(bell['x'], bell['y'])
|
||||
page.wait_for_timeout(1000)
|
||||
ok('B8 点开公告列表', has_text(page, '米剪 1.0 正式上线'))
|
||||
ok('B9 置顶标识', has_text(page, '置顶'))
|
||||
click_text(page, 'span', '米剪 1.0 正式上线')
|
||||
page.wait_for_timeout(1000)
|
||||
ok('B10 打开公告详情', has_text(page, '不采集任何账号信息'))
|
||||
click_text(page, 'button', '关闭')
|
||||
page.wait_for_timeout(600)
|
||||
|
||||
ok('B11 打桩期间无 JS 崩溃', len(errs) == 0, '; '.join(errs[:2]))
|
||||
|
||||
# ---------- C:轮询语义(新公告要出红点,后台清空后红点必须消失) ----------
|
||||
state['announce'] = STUB_NEW
|
||||
log('C1 桩换成一条新公告,等 60s 轮询…')
|
||||
appeared = False
|
||||
try:
|
||||
page.wait_for_function(DOT_JS, timeout=75000)
|
||||
appeared = True
|
||||
except Exception:
|
||||
appeared = False
|
||||
ok('C1 后台新发公告 → 60s 内出红点', appeared)
|
||||
|
||||
state['announce'] = STUB_EMPTY
|
||||
log('C2 桩改成空列表,等 60s 轮询覆盖…')
|
||||
cleared = False
|
||||
try:
|
||||
page.wait_for_function(NODOT_JS, timeout=75000)
|
||||
cleared = True
|
||||
except Exception:
|
||||
cleared = False
|
||||
ok('C2 后台清空公告 → 红点消失', cleared)
|
||||
|
||||
# ---------- D:编辑器页右上角 ----------
|
||||
log('D 打开编辑器页')
|
||||
page2 = ctx.new_page()
|
||||
page2.goto('%s/editor/%s' % (BASE, APPID), wait_until='domcontentloaded', timeout=90000)
|
||||
page2.wait_for_timeout(4000)
|
||||
if page2.locator('text=选择本地存储文件夹').count() > 0:
|
||||
page2.evaluate(GUARD_JS)
|
||||
page2.reload(wait_until='domcontentloaded', timeout=60000)
|
||||
page2.wait_for_timeout(6000)
|
||||
try:
|
||||
page2.wait_for_selector('#h5dsCanvas', timeout=60000)
|
||||
except Exception:
|
||||
pass
|
||||
page2.wait_for_timeout(3000)
|
||||
bs2 = badges(page2)
|
||||
ok('D1 编辑器右上角显示版本号', len(bs2) > 0, json.dumps(bs2[:2], ensure_ascii=False))
|
||||
# 桩已改空 → 编辑器里公告应为空态,红点不应出现
|
||||
bell2 = page2.evaluate(
|
||||
"""() => {
|
||||
const el = [...document.querySelectorAll('span')].find(
|
||||
e => (e.getAttribute('title') || '').includes('公告'));
|
||||
return el ? { hasDot: !!el.querySelector('i') } : null;
|
||||
}"""
|
||||
)
|
||||
ok('D2 编辑器公告为最新状态(空=无红点)', bool(bell2) and not bell2['hasDot'],
|
||||
json.dumps(bell2))
|
||||
ctx.close()
|
||||
|
||||
# ---------- E:包体安检 ----------
|
||||
log('E 扫描前端产物是否泄露密钥')
|
||||
r = subprocess.run(
|
||||
['docker', 'exec', 'unicut', 'sh', '-c',
|
||||
"grep -l -E 'ak_[0-9a-fA-F]{20,}|__HUB_KEY__|X-Api-Key' /usr/share/nginx/html/homeAssets/js/*.js 2>/dev/null | head"],
|
||||
capture_output=True, text=True, timeout=60)
|
||||
leaked = [x for x in r.stdout.split() if x]
|
||||
ok('E1 JS 里没有项目密钥/注入头', len(leaked) == 0, ','.join(leaked))
|
||||
|
||||
browser.close()
|
||||
|
||||
print('---')
|
||||
if fails:
|
||||
print('FAILED (%d): %s' % (len(fails), ', '.join(fails)))
|
||||
sys.exit(1)
|
||||
print('ALL PASS (version=%s)' % VERSION)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,195 @@
|
||||
/**
|
||||
* AI 设置(API Key 配置)——米剪 BYOK 的唯一入口
|
||||
*
|
||||
* 两块东西:
|
||||
* 1. AiSettingsButton:一个按钮 + 弹窗,填 接口地址 / API Key / 模型;
|
||||
* 2. AiSetupGuide:未配置 Key 时替代 AI 面板的引导卡片,把用户带到注册或填 Key。
|
||||
*
|
||||
* 配置存在浏览器 localStorage(见 utils/aiAuth),不登录、不经过服务端。
|
||||
*/
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Button, Modal, Input, Toast, Tag } from '@douyinfe/semi-ui';
|
||||
import {
|
||||
AI_DEFAULT_BASE_URL,
|
||||
AI_DEFAULT_MODEL,
|
||||
AI_REGISTER_URL,
|
||||
readAiSettings,
|
||||
saveAiSettings,
|
||||
clearAiConfig,
|
||||
useAiConfigured,
|
||||
} from '@utils/aiAuth';
|
||||
|
||||
const hint: React.CSSProperties = { fontSize: 12, color: 'rgba(148,163,184,.9)', lineHeight: 1.7 };
|
||||
|
||||
function RegisterLink() {
|
||||
return (
|
||||
<a href={AI_REGISTER_URL} target="_blank" rel="noreferrer" style={{ color: '#60a5fa' }}>
|
||||
免费注册领 Key →
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
/** 设置弹窗:接口地址 / API Key / 模型 三项 */
|
||||
export function AiSettingsModal({ visible, onClose }: { visible: boolean; onClose: () => void }) {
|
||||
const [form, setForm] = useState(() => readAiSettings());
|
||||
const [showKey, setShowKey] = useState(false);
|
||||
const ready = useAiConfigured();
|
||||
|
||||
// 页面上有好几个「AI 设置」入口(引导卡 / AI 助手头部 / AI 面板),各自持有一份表单。
|
||||
// 不在打开时重新读一次的话,在 A 处改了 Key,B 处显示的还是旧值,再点保存就把 Key清空了。
|
||||
useEffect(() => {
|
||||
if (visible) {
|
||||
setForm(readAiSettings());
|
||||
setShowKey(false);
|
||||
}
|
||||
}, [visible]);
|
||||
|
||||
const onSave = () => {
|
||||
const base = form.baseUrl.trim() || AI_DEFAULT_BASE_URL;
|
||||
const model = form.model.trim() || AI_DEFAULT_MODEL;
|
||||
const key = form.key.trim();
|
||||
saveAiSettings(base, key, model);
|
||||
Toast.success(key ? 'AI 配置已保存' : '已保存,但还没填 API Key,AI 功能仍不可用');
|
||||
onClose();
|
||||
};
|
||||
|
||||
const onClear = () => {
|
||||
clearAiConfig();
|
||||
setForm(readAiSettings());
|
||||
Toast.info('已清除 API Key,AI 功能已关闭');
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title="AI 设置"
|
||||
visible={visible}
|
||||
onCancel={onClose}
|
||||
width={520}
|
||||
footer={
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
||||
<Button theme="borderless" type="danger" onClick={onClear}>
|
||||
清除 Key
|
||||
</Button>
|
||||
<span style={hint}>没有 Key?</span>
|
||||
<RegisterLink />
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: 8 }}>
|
||||
<Button onClick={onClose}>取消</Button>
|
||||
<Button type="primary" onClick={onSave}>
|
||||
保存
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div style={{ fontSize: 13, lineHeight: 1.8, color: '#cbd5e1' }}>
|
||||
<div style={{ marginBottom: 10 }}>
|
||||
AI 对话、AI 一键出片、AI 生图、AI 生视频都属于 AI 功能,必须先配置 API Key 才能用;没配置时只能用基础剪辑(导入素材、时间轴、字幕、转场、导出都不受影响)。AI 对话和一键出片会用下面的接口地址与 Key 直连你填的网关;生图、生视频走本站内置通道,配置 Key 后解锁。
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: 4 }}>
|
||||
接口地址
|
||||
{ready ? <Tag color="green" style={{ marginLeft: 8 }}>已配置</Tag> : <Tag color="orange" style={{ marginLeft: 8 }}>未配置</Tag>}
|
||||
</div>
|
||||
<Input
|
||||
value={form.baseUrl}
|
||||
placeholder={AI_DEFAULT_BASE_URL}
|
||||
onChange={(v: any) => setForm(f => ({ ...f, baseUrl: typeof v === 'string' ? v : v?.target?.value || '' }))}
|
||||
style={{ marginBottom: 12 }}
|
||||
/>
|
||||
<div style={hint}>OpenAI 兼容接口,留空则用默认 {AI_DEFAULT_BASE_URL}</div>
|
||||
|
||||
<div style={{ margin: '12px 0 4px' }}>API Key</div>
|
||||
<Input
|
||||
mode={showKey ? 'text' : 'password'}
|
||||
value={form.key}
|
||||
placeholder="粘贴你的 Key,例如 sk-xxxx"
|
||||
onChange={(v: any) => setForm(f => ({ ...f, key: typeof v === 'string' ? v : v?.target?.value || '' }))}
|
||||
style={{ marginBottom: 12 }}
|
||||
/>
|
||||
<div style={hint}>
|
||||
只保存在你这台浏览器里,不上传服务器。没有 Key?<RegisterLink />
|
||||
</div>
|
||||
|
||||
<div style={{ margin: '12px 0 4px' }}>模型</div>
|
||||
<Input
|
||||
value={form.model}
|
||||
placeholder={AI_DEFAULT_MODEL}
|
||||
onChange={(v: any) => setForm(f => ({ ...f, model: typeof v === 'string' ? v : v?.target?.value || '' }))}
|
||||
/>
|
||||
<div style={{ ...hint, marginTop: 6 }}>留空则用默认 {AI_DEFAULT_MODEL}</div>
|
||||
|
||||
<div style={{ ...hint, marginTop: 12 }}>
|
||||
默认的 {AI_DEFAULT_BASE_URL} 注册即送体验金,可直接用来跑 mimo-v2.6-flash;也可以填你自己的其它 OpenAI 兼容网关。
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
/** 一个按钮:点开设置弹窗 */
|
||||
export function AiSettingsButton({
|
||||
children,
|
||||
type = 'default',
|
||||
size = 'small',
|
||||
}: {
|
||||
children?: React.ReactNode;
|
||||
type?: 'primary' | 'default';
|
||||
size?: 'small' | 'default' | 'large';
|
||||
}) {
|
||||
const [open, setOpen] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Button size={size} type={type} onClick={() => setOpen(true)}>
|
||||
{children || 'AI 设置'}
|
||||
</Button>
|
||||
<AiSettingsModal visible={open} onClose={() => setOpen(false)} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
/** 未配置 Key 时顶替 AI 面板的引导卡片 */
|
||||
export function AiSetupGuide({ title }: { title?: string }) {
|
||||
return (
|
||||
<div style={{ padding: '32px 24px', color: '#e2e8f0', fontSize: 14, lineHeight: 1.9 }}>
|
||||
<div style={{ fontSize: 18, fontWeight: 600, marginBottom: 12 }}>
|
||||
{title || 'AI 功能需要配置 API Key'}
|
||||
</div>
|
||||
<div style={{ color: '#94a3b8', marginBottom: 16 }}>
|
||||
基础剪辑不受影响:导入素材、时间轴编辑、字幕、转场、导出照常用。
|
||||
AI 对话、AI 一键出片、AI 生图、AI 生视频属于 AI 功能,要先填上你自己的 Key。
|
||||
</div>
|
||||
|
||||
<div
|
||||
style={{
|
||||
background: 'rgba(59,130,246,.12)',
|
||||
border: '1px solid rgba(59,130,246,.35)',
|
||||
borderRadius: 8,
|
||||
padding: '12px 14px',
|
||||
marginBottom: 16,
|
||||
fontSize: 13,
|
||||
color: '#bfdbfe',
|
||||
}}
|
||||
>
|
||||
默认已为你填好:接口地址 <b>{AI_DEFAULT_BASE_URL}</b>,模型 <b>{AI_DEFAULT_MODEL}</b>
|
||||
,只要补一个 API Key 就能用。
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', gap: 10, alignItems: 'center', flexWrap: 'wrap' }}>
|
||||
<AiSettingsButton type="primary" size="large">
|
||||
填写 API Key
|
||||
</AiSettingsButton>
|
||||
<a href={AI_REGISTER_URL} target="_blank" rel="noreferrer">
|
||||
<Button size="large">没有 Key?免费注册领取</Button>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div style={{ ...hint, marginTop: 16 }}>
|
||||
注册即送体验金,Key 只保存在你本台浏览器,不经过我们的服务器;也可以填你自己的 OpenAI 兼容网关地址。
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default AiSettingsButton;
|
||||
@@ -21,6 +21,7 @@ import classNames from 'classnames';
|
||||
import { reURL } from '@utils/util';
|
||||
import VipRecharge from '@pages/editor/components/header/VipRecharge';
|
||||
import CreditRecharge from '@pages/editor/components/header/CreditRecharge';
|
||||
import HubStatus from '@components/hub';
|
||||
|
||||
export interface IProps {
|
||||
componentName?: string;
|
||||
@@ -118,6 +119,8 @@ const Header = (props: IProps) => {
|
||||
</div>
|
||||
</div>
|
||||
<Space spacing={20}>
|
||||
{/* 右上角:当前版本 + 新版本提示 + 公告(数据来自授权中心,拿不到就安静降级) */}
|
||||
<HubStatus />
|
||||
{/* <a
|
||||
className={styles.space}
|
||||
onClick={() => {
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
/* 授权状态:版本徽标 + 公告铃铛(插在页头右上角) */
|
||||
.wrap {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.ver {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
height: 24px;
|
||||
padding: 0 10px;
|
||||
border-radius: 12px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 1px solid rgba(127, 127, 127, 0.35);
|
||||
color: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.2px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
transition: background 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
/* 有新版本:琥珀底 + 右上角红点,一直亮着直到用户更新(可随时点开看) */
|
||||
.verNew {
|
||||
color: #ffb020;
|
||||
background: rgba(255, 176, 32, 0.16);
|
||||
border-color: rgba(255, 176, 32, 0.55);
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 176, 32, 0.26);
|
||||
}
|
||||
}
|
||||
|
||||
.verDot {
|
||||
position: absolute;
|
||||
top: -3px;
|
||||
right: -3px;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
background: #ff4d4f;
|
||||
box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.bell {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
border-radius: 50%;
|
||||
color: inherit;
|
||||
opacity: 0.85;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
background: rgba(255, 255, 255, 0.14);
|
||||
}
|
||||
}
|
||||
|
||||
.bellDot {
|
||||
position: absolute;
|
||||
top: 1px;
|
||||
right: 1px;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
background: #ff4d4f;
|
||||
box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
/* 公告列表(semi Popover 是浅色底,这里按浅色写字色) */
|
||||
.pop {
|
||||
width: 296px;
|
||||
max-height: 340px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.popItem {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 9px 4px;
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.07);
|
||||
cursor: pointer;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
&:hover .popTitle {
|
||||
color: #7c3aed;
|
||||
}
|
||||
}
|
||||
|
||||
.topTag {
|
||||
flex: none;
|
||||
padding: 1px 5px;
|
||||
border-radius: 4px;
|
||||
background: #fff1f0;
|
||||
border: 1px solid #ffccc7;
|
||||
color: #cf1322;
|
||||
font-size: 11px;
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
.popTitle {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: #1f2329;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.popTime {
|
||||
flex: none;
|
||||
color: #8f959e;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.popEmpty {
|
||||
padding: 8px 2px;
|
||||
color: #8f959e;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* 弹窗内容 */
|
||||
.logBox {
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
|
||||
.log {
|
||||
margin: 0 0 8px;
|
||||
padding: 12px;
|
||||
max-height: 260px;
|
||||
overflow: auto;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
background: #f7f8fa;
|
||||
border: 1px solid #e4e6eb;
|
||||
border-radius: 8px;
|
||||
color: #1f2329;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.logMuted {
|
||||
margin: 0 0 6px;
|
||||
color: #646a73;
|
||||
font-size: 13px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.noticeBody {
|
||||
padding: 4px 0 10px;
|
||||
color: #1f2329;
|
||||
font-size: 14px;
|
||||
line-height: 1.8;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.acts {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding-top: 12px;
|
||||
}
|
||||
@@ -0,0 +1,320 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Button, Modal, Popover, Toast } from '@douyinfe/semi-ui';
|
||||
import { VolumeNotice } from '@icon-park/react';
|
||||
import {
|
||||
APP_VERSION,
|
||||
HubAnnounce,
|
||||
HubUpdateInfo,
|
||||
announceKey,
|
||||
hubAnnouncements,
|
||||
hubCheckUpdate,
|
||||
hubHeartbeat,
|
||||
hubIntervals,
|
||||
} from '@utils/hub';
|
||||
import styles from './hub.module.less';
|
||||
|
||||
/**
|
||||
* 右上角授权状态:当前版本号 + 公告铃铛 + 新版本提示。
|
||||
*
|
||||
* - 版本号永远显示(唯一出处 package.json 的 version,随包发布)。
|
||||
* - 有新版本:徽标变琥珀 + 红点,自动弹一次「发现新版本」;用户点掉后仍可点徽标再看。
|
||||
* - 强制更新(is_force / update_required):不给关闭与「稍后再说」。
|
||||
* - 公告:铃铛红点 = 未读条数;点击看列表,点条目看详情/跳链接;后台清空后红点自动消失。
|
||||
* - 所有数据来自授权中心,拿不到就安静降级(无红点、无弹窗、徽标照常显示版本号)。
|
||||
*/
|
||||
const SEEN_UPDATE_KEY = 'micut.hub.seen.update.v1';
|
||||
const SEEN_NOTICE_KEY = 'micut.hub.seen.notice.v1';
|
||||
|
||||
const readSeenNotices = (): string[] => {
|
||||
try {
|
||||
const raw = localStorage.getItem(SEEN_NOTICE_KEY) || '';
|
||||
return raw ? raw.split(',').filter(Boolean) : [];
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
const saveSeenNotices = (list: string[]): void => {
|
||||
try {
|
||||
localStorage.setItem(SEEN_NOTICE_KEY, list.join(','));
|
||||
} catch (e) {
|
||||
/* 隐私模式下写不进就算了,只影响红点 */
|
||||
}
|
||||
};
|
||||
|
||||
const readSeenUpdate = (): string => {
|
||||
try {
|
||||
return localStorage.getItem(SEEN_UPDATE_KEY) || '';
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
const saveSeenUpdate = (v: string): void => {
|
||||
try {
|
||||
localStorage.setItem(SEEN_UPDATE_KEY, v);
|
||||
} catch (e) {
|
||||
/* ignore */
|
||||
}
|
||||
};
|
||||
|
||||
const fmtTime = (t?: string): string => (t ? String(t).slice(0, 16) : '');
|
||||
|
||||
/** 下载地址与当前站同源(或压根没填)→ 对网页版来说「更新」就是刷新拿到新构建 */
|
||||
const isSameOrigin = (url: string): boolean => {
|
||||
try {
|
||||
return new URL(url, window.location.href).origin === window.location.origin;
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
export const HubStatus = ({ showBell = true }: { showBell?: boolean }) => {
|
||||
const [update, setUpdate] = useState<HubUpdateInfo | null>(null);
|
||||
const [modalOpen, setModalOpen] = useState(false);
|
||||
const [notices, setNotices] = useState<HubAnnounce[]>([]);
|
||||
const [queue, setQueue] = useState<HubAnnounce[]>([]);
|
||||
const [cur, setCur] = useState<HubAnnounce | null>(null);
|
||||
const [detail, setDetail] = useState<HubAnnounce | null>(null);
|
||||
const [seen, setSeen] = useState<string[]>(readSeenNotices);
|
||||
|
||||
const markSeen = (key: string): void => {
|
||||
setSeen((prev) => {
|
||||
if (!key || prev.indexOf(key) >= 0) return prev;
|
||||
const next = [...prev, key];
|
||||
saveSeenNotices(next);
|
||||
return next;
|
||||
});
|
||||
};
|
||||
|
||||
/* 开机:登记安装+查更新、取公告、报一次心跳;之后按节流周期重复 */
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
|
||||
const runUpdate = async () => {
|
||||
const info = await hubCheckUpdate();
|
||||
if (!alive || !info || !info.updateAvailable) return;
|
||||
setUpdate(info);
|
||||
if (readSeenUpdate() !== info.latestVersion) setModalOpen(true);
|
||||
};
|
||||
|
||||
const runAnnounce = async () => {
|
||||
const data = await hubAnnouncements();
|
||||
/* null = 这次请求失败 → 保留上一次的结果;空数组 = 后台确实清空了 → 必须覆盖 */
|
||||
if (!alive || !data) return;
|
||||
setNotices(data.list);
|
||||
setQueue((prev) => {
|
||||
const known = new Set(prev.map(announceKey));
|
||||
const fresh = data.popup.filter((a) => {
|
||||
const k = announceKey(a);
|
||||
return !!k && !known.has(k) && readSeenNotices().indexOf(k) < 0;
|
||||
});
|
||||
return fresh.length ? [...prev, ...fresh] : prev;
|
||||
});
|
||||
};
|
||||
|
||||
runUpdate();
|
||||
runAnnounce();
|
||||
hubHeartbeat();
|
||||
|
||||
const t1 = setInterval(runUpdate, hubIntervals.CHECK_UPDATE_MS);
|
||||
const t2 = setInterval(runAnnounce, hubIntervals.ANNOUNCE_MS);
|
||||
const t3 = setInterval(() => hubHeartbeat(), hubIntervals.HEARTBEAT_MS);
|
||||
return () => {
|
||||
alive = false;
|
||||
clearInterval(t1);
|
||||
clearInterval(t2);
|
||||
clearInterval(t3);
|
||||
};
|
||||
}, []);
|
||||
|
||||
/* 弹窗队列:新版本提示优先(弹的时候不弹公告),关掉之后再逐条弹公告 */
|
||||
useEffect(() => {
|
||||
if (modalOpen || cur || queue.length === 0) return;
|
||||
const next = queue[0];
|
||||
setCur(next);
|
||||
setQueue(queue.slice(1));
|
||||
markSeen(announceKey(next));
|
||||
}, [modalOpen, cur, queue]);
|
||||
|
||||
const unread = notices.filter((n) => seen.indexOf(announceKey(n)) < 0).length;
|
||||
const force = !!update && (update.isForce || update.updateRequired);
|
||||
|
||||
const closeUpdate = (): void => {
|
||||
setModalOpen(false);
|
||||
if (update) saveSeenUpdate(update.latestVersion);
|
||||
};
|
||||
|
||||
const goUpdate = (): void => {
|
||||
if (!update) return;
|
||||
const url = update.downloadUrl || '';
|
||||
if (url && !isSameOrigin(url)) {
|
||||
window.open(url, '_blank', 'noopener');
|
||||
return;
|
||||
}
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
const checkNow = async (): Promise<void> => {
|
||||
const info = await hubCheckUpdate();
|
||||
if (info && info.updateAvailable) {
|
||||
setUpdate(info);
|
||||
setModalOpen(true);
|
||||
return;
|
||||
}
|
||||
if (!info) {
|
||||
// 没查成(授权中心不可达/未接入)就不冒充「已是最新」——用户点的就是「检查更新」,得给实话
|
||||
Toast.warning('暂时无法连接授权中心,稍后再试');
|
||||
return;
|
||||
}
|
||||
Toast.success(`当前已是最新版本 v${APP_VERSION}`);
|
||||
};
|
||||
|
||||
const openNotice = (n: HubAnnounce): void => {
|
||||
setDetail(n);
|
||||
markSeen(announceKey(n));
|
||||
};
|
||||
|
||||
const bellContent = notices.length ? (
|
||||
<div className={styles.pop}>
|
||||
{notices.slice(0, 10).map((n) => (
|
||||
<div key={announceKey(n)} className={styles.popItem} onClick={() => openNotice(n)}>
|
||||
{Number(n.is_top) === 1 ? <span className={styles.topTag}>置顶</span> : null}
|
||||
<span className={styles.popTitle}>{n.title || '公告'}</span>
|
||||
<span className={styles.popTime}>{fmtTime(n.publish_time)}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className={styles.popEmpty}>暂无公告</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<span className={styles.wrap}>
|
||||
<span
|
||||
className={update ? `${styles.ver} ${styles.verNew}` : styles.ver}
|
||||
title="当前版本,点击查看是否有新版本"
|
||||
onClick={checkNow}
|
||||
>
|
||||
v{APP_VERSION}
|
||||
{update ? <i className={styles.verDot} /> : null}
|
||||
</span>
|
||||
|
||||
{showBell ? (
|
||||
<Popover content={bellContent} position="bottomRight" trigger="click">
|
||||
<span
|
||||
className={styles.bell}
|
||||
title={unread > 0 ? `${unread} 条未读公告` : '公告'}
|
||||
onClick={() => {
|
||||
if (unread > 0) setSeen((prev) => {
|
||||
const next = [...new Set([...prev, ...notices.map(announceKey)])];
|
||||
saveSeenNotices(next);
|
||||
return next;
|
||||
});
|
||||
}}
|
||||
>
|
||||
<VolumeNotice size={16} />
|
||||
{unread > 0 ? <i className={styles.bellDot} /> : null}
|
||||
</span>
|
||||
</Popover>
|
||||
) : null}
|
||||
|
||||
{/* 新版本提示 */}
|
||||
<Modal
|
||||
title={update && update.latestVersion ? `发现新版本 v${update.latestVersion}` : '发现新版本'}
|
||||
visible={modalOpen}
|
||||
width={460}
|
||||
closable={!force}
|
||||
maskClosable={!force}
|
||||
footer={null}
|
||||
onCancel={closeUpdate}
|
||||
>
|
||||
<div className={styles.logBox}>
|
||||
{update && update.changelog ? (
|
||||
<pre className={styles.log}>{update.changelog}</pre>
|
||||
) : (
|
||||
<div className={styles.logMuted}>新版本已发布,建议尽快更新以获得最新功能与修复。</div>
|
||||
)}
|
||||
{update && update.minClientVersion ? (
|
||||
<div className={styles.logMuted}>最低要求版本:v{update.minClientVersion}</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className={styles.acts}>
|
||||
{!force ? (
|
||||
<Button type="tertiary" onClick={closeUpdate}>
|
||||
稍后再说
|
||||
</Button>
|
||||
) : null}
|
||||
<Button theme="solid" onClick={goUpdate}>
|
||||
{update && isSameOrigin(update.downloadUrl || '') ? '立即刷新' : '立即更新'}
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
{/* 公告弹窗(进站时按队列逐条弹,新版本提示优先于它) */}
|
||||
<Modal
|
||||
title={(cur && cur.title) || '公告'}
|
||||
visible={!!cur}
|
||||
width={460}
|
||||
footer={null}
|
||||
onCancel={() => setCur(null)}
|
||||
>
|
||||
<div className={styles.logBox}>
|
||||
<div className={styles.noticeBody}>{(cur && cur.content) || '暂无内容'}</div>
|
||||
{cur && cur.publish_time ? (
|
||||
<div className={styles.logMuted}>发布于 {fmtTime(cur.publish_time)}</div>
|
||||
) : null}
|
||||
{cur && cur.link_url ? (
|
||||
<div className={styles.acts}>
|
||||
<Button
|
||||
theme="solid"
|
||||
onClick={() => {
|
||||
if (cur && cur.link_url) window.open(cur.link_url, '_blank', 'noopener');
|
||||
}}
|
||||
>
|
||||
查看详情
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className={styles.acts}>
|
||||
<Button type="tertiary" onClick={() => setCur(null)}>
|
||||
关闭
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
{/* 公告详情 */}
|
||||
<Modal
|
||||
title={(detail && detail.title) || '公告'}
|
||||
visible={!!detail}
|
||||
width={460}
|
||||
footer={null}
|
||||
onCancel={() => setDetail(null)}
|
||||
>
|
||||
<div className={styles.logBox}>
|
||||
<div className={styles.noticeBody}>{(detail && detail.content) || '暂无内容'}</div>
|
||||
{detail && detail.link_url ? (
|
||||
<div className={styles.acts}>
|
||||
<Button
|
||||
theme="solid"
|
||||
onClick={() => {
|
||||
if (detail.link_url) window.open(detail.link_url, '_blank', 'noopener');
|
||||
}}
|
||||
>
|
||||
查看详情
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className={styles.acts}>
|
||||
<Button type="tertiary" onClick={() => setDetail(null)}>
|
||||
关闭
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
export default HubStatus;
|
||||
@@ -21,7 +21,7 @@ export const zhCN = {
|
||||
sidemenu_more: '更多',
|
||||
|
||||
// 公共
|
||||
common_name: 'UniCut',
|
||||
common_name: '米剪',
|
||||
common_search: '搜索',
|
||||
common_loading: '加载中...',
|
||||
common_uploading: '上传中...',
|
||||
@@ -417,7 +417,7 @@ export const zhCN = {
|
||||
common_home: '首页',
|
||||
common_navigation: '导航',
|
||||
common_about_us_info:
|
||||
'UniCut是一款在线的B/S视频剪辑工具,无需下载安装,直接登录即可使用,支持大量的云素材和特效,也支持多人协同剪辑。',
|
||||
'米剪是一款在浏览器里就能用的视频剪辑工具,无需下载安装、无需注册登录,打开网页即可创作,支持大量素材与特效。',
|
||||
common_support: '支持',
|
||||
common_help_center: '帮助中心',
|
||||
common_privacy_policy: '隐私协议',
|
||||
@@ -426,8 +426,8 @@ export const zhCN = {
|
||||
common_contact_us: '联系我们',
|
||||
common_private_deployment_saas_consultation: '私有化部署/SAAS接入相关咨询',
|
||||
common_phone: '电话',
|
||||
common_copyright: 'UniCut · 本地部署版',
|
||||
home_title: 'UniCut · 创意无限',
|
||||
common_copyright: '米剪 · 本地部署版',
|
||||
home_title: '米剪 · 创意无限',
|
||||
home_sub_title: '免费在线使用、支持私有化部署、提供源码、支持定制开发',
|
||||
home_used: '立即使用',
|
||||
home_lut: 'LUT滤镜',
|
||||
@@ -436,7 +436,7 @@ export const zhCN = {
|
||||
home_custom_plugin: '无限可能源于扩展',
|
||||
home_custom_plugin_info: '可自定义插件,满足用户各种定制化需求',
|
||||
home_contact_us: '联系我们',
|
||||
common_company: 'UniCut',
|
||||
common_company: '米剪',
|
||||
common_all: '全部',
|
||||
common_create_success: '创建成功!',
|
||||
common_move: '移动',
|
||||
@@ -516,7 +516,7 @@ export const zhCN = {
|
||||
user_message_read: '已读',
|
||||
user_message_new: 'NEW',
|
||||
tools_title: '在线工具',
|
||||
tools_desc: 'UniCut提供了大量的视频工具帮助你快速完成工作',
|
||||
tools_desc: '米剪提供了大量的视频工具帮助你快速完成工作',
|
||||
ai_matting: 'AI抠图',
|
||||
ai_matting_desc: '点击要扣取的元素,可以快速扣出图片中的任何元素',
|
||||
ai_upload_tip: '点击上传图片文件或拖拽文件到这里',
|
||||
@@ -653,7 +653,7 @@ export const zhCN = {
|
||||
common_no_source: '暂无素材',
|
||||
common_no_source_desc: '暂无上传任何素材',
|
||||
common_update_log: '更新日志',
|
||||
common_update_log_desc: '查看UniCut的更新日志',
|
||||
common_update_log_desc: '查看米剪的更新日志',
|
||||
common_delete: '删除',
|
||||
common_email: '邮箱',
|
||||
common_delete_success: '删除成功!',
|
||||
|
||||
@@ -30,7 +30,7 @@ function AboutUs(props: IProps) {
|
||||
{language.getLanguage() === 'zh-CN' ? (
|
||||
<div className={styles.content}>
|
||||
<p>
|
||||
UniCut 是一款在浏览器里就能用的在线视频剪辑工具,无需安装客户端,打开网页即可开始创作。 <br />
|
||||
米剪是一款在浏览器里就能用的在线视频剪辑工具,无需安装客户端,打开网页即可开始创作。 <br />
|
||||
支持多轨剪辑、裁剪拼接、滤镜贴纸、动画特效、文字字幕、AI 配音与 AI 生成素材,<br />
|
||||
可导出常见视频格式,适合教程演示、产品介绍、口播混剪等场景。
|
||||
</p>
|
||||
@@ -38,12 +38,12 @@ function AboutUs(props: IProps) {
|
||||
当前版本为本机部署版:所有工程数据保存在浏览器本地(IndexedDB),不经过第三方服务器;<br />
|
||||
内容生成能力对接本机 AI 服务,无需登录即可使用。
|
||||
</p>
|
||||
<p>UniCut · 本地部署版</p>
|
||||
<p>米剪 · 本地部署版</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className={styles.content}>
|
||||
<p>
|
||||
UniCut is a browser-based video editor — no client to install, just open the page and start editing. <br />
|
||||
MiCut is a browser-based video editor — no client to install, just open the page and start editing. <br />
|
||||
Multi-track editing, trim & merge, filters and stickers, animation effects, text and subtitles,
|
||||
AI voice-over and AI-generated assets, with export to common video formats.
|
||||
</p>
|
||||
@@ -51,7 +51,7 @@ function AboutUs(props: IProps) {
|
||||
This build is a local deployment: projects are stored in your browser (IndexedDB) and content
|
||||
generation talks to a local AI service. No sign-in required.
|
||||
</p>
|
||||
<p>UniCut · Local Build</p>
|
||||
<p>MiCut · Local Build</p>
|
||||
</div>
|
||||
)}
|
||||
{/* <Links /> */}
|
||||
|
||||
@@ -74,7 +74,7 @@ function ArticleDetail() {
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
<SubHeader
|
||||
title={meta?.title || (state === 'badslug' ? '链接无效' : 'UniCut 教程')}
|
||||
title={meta?.title || (state === 'badslug' ? '链接无效' : '米剪 教程')}
|
||||
desc={meta?.description || language.val('common_company')}
|
||||
/>
|
||||
<div className={styles.wrap}>
|
||||
|
||||
@@ -16,6 +16,8 @@ import type { ChatMessage, MediaContent } from './ChatMessages';
|
||||
import { util } from '@utils/index';
|
||||
import { utils } from 'video-core-sdk';
|
||||
import localforage from 'localforage';
|
||||
import { AiSetupGuide, AiSettingsButton } from '@components/ai-settings';
|
||||
import { useAiConfigured } from '@utils/aiAuth';
|
||||
|
||||
const POLL_INTERVAL = 5000; // 5 秒轮询
|
||||
|
||||
@@ -292,6 +294,8 @@ export default function AIChat() {
|
||||
const [videoCount, setVideoCount] = useState(1);
|
||||
const [videoDuration, setVideoDuration] = useState(5);
|
||||
const editInputRef = useRef<HTMLInputElement>(null);
|
||||
// 是否已配置 AI Key —— 没配就只给引导,不放聊天输入框
|
||||
const aiReady = useAiConfigured();
|
||||
|
||||
// 当前视频模型支持的分辨率
|
||||
const supportedVideoResolutions = useMemo(() => {
|
||||
@@ -1103,11 +1107,20 @@ export default function AIChat() {
|
||||
}
|
||||
};
|
||||
|
||||
if (!aiReady) {
|
||||
return (
|
||||
<div className={styles.chat}>
|
||||
<AiSetupGuide title="AI 助手需要配置 API Key" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={styles.chat} ref={dialogueRef}>
|
||||
<div className={styles.chatHeader}>
|
||||
<div className={styles.headerTitle}>AI 助手</div>
|
||||
<div className={styles.headerActions}>
|
||||
<AiSettingsButton />
|
||||
<Button
|
||||
theme="borderless"
|
||||
icon={<Plus theme="outline" size="14" />}
|
||||
|
||||
@@ -21,6 +21,7 @@ import { language, Intl } from '@language/index';
|
||||
import KeyboardModal from './KeyboardModal';
|
||||
import { stores } from '@stores/index';
|
||||
import { saveProject, canUseLocalSave } from '@services/localStorageService';
|
||||
import HubStatus from '@components/hub';
|
||||
import { reURL } from '@utils/util';
|
||||
|
||||
export interface IProps {}
|
||||
@@ -244,6 +245,8 @@ function Header(props: IProps) {
|
||||
</section>
|
||||
{/* <section className={styles.center}></section> */}
|
||||
<section className={styles.right}>
|
||||
{/* 右上角:当前版本 + 新版本提示 + 公告(授权中心,拿不到就安静降级) */}
|
||||
<HubStatus />
|
||||
{/* <a>
|
||||
<Protect theme="filled" size="20" fill="#2CB25A" />
|
||||
</a> */}
|
||||
|
||||
@@ -133,7 +133,7 @@ function SideBar(props: ISideBarProps) {
|
||||
) : (
|
||||
<a href={editor.exConfig.logoLink || '/workspace/draft'}>
|
||||
{/* <img src={editor.exConfig.logo(theme.getTheme())} alt="" /> */}
|
||||
UniCut
|
||||
米剪
|
||||
</a>
|
||||
)}
|
||||
</span>
|
||||
|
||||
@@ -7,15 +7,24 @@ import AiImage from './AiImage';
|
||||
import Tasks from './Tasks';
|
||||
import { IllustrationNoAccess, IllustrationNoAccessDark } from '@douyinfe/semi-illustrations';
|
||||
import Login from '@components/login';
|
||||
import { AiSetupGuide, AiSettingsButton } from '@components/ai-settings';
|
||||
import { useAiConfigured } from '@utils/aiAuth';
|
||||
import { language, Intl } from '@language/index';
|
||||
import { stores } from '@stores/index';
|
||||
|
||||
export default function AiMain() {
|
||||
const { editor } = stores;
|
||||
const [showQv, setShowQv] = useState(false);
|
||||
const aiReady = useAiConfigured();
|
||||
|
||||
// 免登录模式:AI 面板直接可用
|
||||
|
||||
// 没配置 API Key:AI 对话/一键出片/生图/生视频一律不放出来,只给注册引导
|
||||
if (!aiReady) {
|
||||
return (
|
||||
<div className={styles.main}>
|
||||
<AiSetupGuide />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className={styles.main}>
|
||||
{/*
|
||||
@@ -38,6 +47,10 @@ export default function AiMain() {
|
||||
<div className={styles.qvCta}>立即生成 →</div>
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', justifyContent: 'flex-end', padding: '6px 12px 0' }}>
|
||||
<AiSettingsButton />
|
||||
</div>
|
||||
|
||||
<Tabs keepDOM={false} lazyRender={true} className={styles.tabs} type="line" defaultSelectedKey="0">
|
||||
<TabPane
|
||||
tab={
|
||||
|
||||
+76
-7
@@ -90,19 +90,23 @@ const coreFeatures = [
|
||||
{
|
||||
label: 'Value',
|
||||
title: '经济实惠',
|
||||
desc: '且会员和非会员只有AI功能的差别(第三方AI服务收费,所以我们只提供基础功能),我们承诺:素材终身全免费。',
|
||||
desc: '剪辑功能终身免费,AI 走你自己的 API Key(默认接口注册即送体验金),我们不设会员墙、不抽成。',
|
||||
emoji: '💰',
|
||||
},
|
||||
];
|
||||
|
||||
const faqList = [
|
||||
{
|
||||
q: 'UniCut是免费的吗?',
|
||||
a: 'UniCut提供免费基础功能,用户可以免费使用核心剪辑工具。高级AI功能和特效模板需要VIP解锁,按需购买,灵活选择。',
|
||||
q: '米剪是免费的吗?',
|
||||
a: '剪辑功能完全免费:导入素材、时间轴、字幕、转场、导出都不限次数,无需付费解锁;配音和抠图走本机服务,同样免费。',
|
||||
},
|
||||
{
|
||||
q: 'AI 功能怎么用?要收费吗?',
|
||||
a: 'AI 对话、AI 一键出片、AI 生图、AI 生视频属于 AI 功能,需要你自己的 API Key 才能调用。打开编辑器右侧「AI 助手」或左侧 AI 面板,点「AI 设置」填写即可,接口地址默认 https://ai.88531.cn/v1、模型默认 mimo-v2.6-flash,没有 Key 可以免费注册领取(注册即送体验金)。不填 Key 时,全部基础剪辑功能照常可用。',
|
||||
},
|
||||
{
|
||||
q: '需要安装客户端吗?',
|
||||
a: '不需要。UniCut是纯B/S架构,打开浏览器即可使用,无需下载任何客户端。支持Chrome、Firefox、Safari等主流浏览器。',
|
||||
a: '不需要。米剪是纯B/S架构,打开浏览器即可使用,无需下载任何客户端。支持Chrome、Firefox、Safari等主流浏览器。',
|
||||
},
|
||||
{
|
||||
q: '推荐使用什么浏览器?',
|
||||
@@ -118,7 +122,7 @@ const faqList = [
|
||||
},
|
||||
{
|
||||
q: '可以商用吗?有版权风险吗?',
|
||||
a: '使用UniCut制作的视频可以商用。平台提供的音乐、素材均来源第三方免版权素材网,请在使用时遵守相关版权法律。AI生成内容的版权归属请参考用户协议。',
|
||||
a: '使用米剪制作的视频可以商用。平台提供的音乐、素材均来源第三方免版权素材网,请在使用时遵守相关版权法律。AI生成内容的版权归属请参考用户协议。',
|
||||
},
|
||||
];
|
||||
|
||||
@@ -147,7 +151,7 @@ export default function Home() {
|
||||
新一代AI驱动 · 全功能云端剪辑
|
||||
</div>
|
||||
<h1 className={styles.heroTitle}>
|
||||
UniCut
|
||||
米剪
|
||||
<br />
|
||||
<span className={styles.heroHighlight}>AI驱动</span>的开源视频剪辑工具
|
||||
</h1>
|
||||
@@ -320,7 +324,7 @@ export default function Home() {
|
||||
<div className={styles.sectionHeader}>
|
||||
<div className={styles.overline}>FAQ</div>
|
||||
<h2 className={styles.sectionTitle}>常见问题</h2>
|
||||
<p className={styles.sectionDesc}>快速了解UniCut的核心问题</p>
|
||||
<p className={styles.sectionDesc}>快速了解米剪的核心问题</p>
|
||||
</div>
|
||||
<div className={styles.faqList}>
|
||||
{faqList.map((item, i) => (
|
||||
@@ -355,6 +359,71 @@ export default function Home() {
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* 站群导航 + 开源地址(要显眼,放在页面最底部) */}
|
||||
<section className={styles.linksSection}>
|
||||
<div className={styles.container}>
|
||||
<div className={styles.linksHead}>
|
||||
<div className={styles.linksOverline}>MORE</div>
|
||||
<h2 className={styles.linksTitle}>
|
||||
我的导航站 <span className={styles.linksSlash}>/</span> 开源地址
|
||||
</h2>
|
||||
<p className={styles.linksSub}>
|
||||
米剪之外的全部自建站点都在导航站里,本项目全部源码也公开可取
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className={styles.linksGrid}>
|
||||
<a
|
||||
className={styles.linkCard}
|
||||
href="https://nav.88531.cn"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<span className={styles.linkIcon}>🧭</span>
|
||||
<span className={styles.linkBody}>
|
||||
<span className={styles.linkName}>
|
||||
我的导航站
|
||||
<em className={styles.linkTag}>20+ 自建站点</em>
|
||||
</span>
|
||||
<span className={styles.linkUrl}>nav.88531.cn</span>
|
||||
<span className={styles.linkDesc}>
|
||||
自建应用、在线工具、AI 服务全部收录,一站直达
|
||||
</span>
|
||||
</span>
|
||||
<span className={styles.linkGo}>进入导航站 →</span>
|
||||
</a>
|
||||
|
||||
<a
|
||||
className={styles.linkCard}
|
||||
href="https://gitee.com/676015863/unicut"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<span className={styles.linkIcon}>📦</span>
|
||||
<span className={styles.linkBody}>
|
||||
<span className={styles.linkName}>
|
||||
开源地址
|
||||
<em className={styles.linkTag}>源码公开</em>
|
||||
</span>
|
||||
<span className={styles.linkUrl}>gitee.com/676015863/unicut</span>
|
||||
<span className={styles.linkDesc}>
|
||||
全部代码可下载、可二次开发,商用条件见仓库内 LICENSE
|
||||
</span>
|
||||
</span>
|
||||
<span className={styles.linkGo}>查看源码 →</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div className={styles.linksFoot}>
|
||||
GitHub 镜像:
|
||||
<a href="https://github.com/mtsee/unicut" target="_blank" rel="noreferrer">
|
||||
github.com/mtsee/unicut
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -631,6 +631,203 @@
|
||||
border-radius: 14px !important;
|
||||
}
|
||||
|
||||
// ========== 站群导航 + 开源地址(首页最底部,要显眼) ==========
|
||||
.linksSection {
|
||||
position: relative;
|
||||
padding: 76px 0 84px;
|
||||
background:
|
||||
radial-gradient(900px 280px at 50% -40px, rgba(139, 92, 246, 0.22), transparent 70%),
|
||||
linear-gradient(180deg, #12101f 0%, #151325 55%, #12101f 100%);
|
||||
border-top: 1px solid rgba(139, 92, 246, 0.22);
|
||||
}
|
||||
|
||||
.linksHead {
|
||||
text-align: center;
|
||||
margin-bottom: 44px;
|
||||
}
|
||||
|
||||
.linksOverline {
|
||||
font-size: 13px;
|
||||
letter-spacing: 3px;
|
||||
color: #a78bfa;
|
||||
font-weight: 700;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.linksTitle {
|
||||
font-size: 38px;
|
||||
font-weight: 900;
|
||||
color: #f5f3ff;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.linksSlash {
|
||||
background: linear-gradient(135deg, #7c3aed, #a78bfa);
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
color: transparent;
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
.linksSub {
|
||||
font-size: 16px;
|
||||
color: #a5a3b8;
|
||||
}
|
||||
|
||||
.linksGrid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.linkCard {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
padding: 30px 32px;
|
||||
border-radius: 22px;
|
||||
text-decoration: none;
|
||||
overflow: hidden;
|
||||
background: linear-gradient(135deg, rgba(139, 92, 246, 0.14), rgba(21, 19, 37, 0.92));
|
||||
border: 1px solid rgba(139, 92, 246, 0.35);
|
||||
transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
|
||||
}
|
||||
|
||||
.linkCard::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: -60px;
|
||||
right: -60px;
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
background: radial-gradient(circle, rgba(167, 139, 250, 0.22), transparent 70%);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.linkCard:hover {
|
||||
transform: translateY(-6px);
|
||||
border-color: rgba(167, 139, 250, 0.9);
|
||||
box-shadow: 0 18px 40px rgba(124, 58, 237, 0.38);
|
||||
}
|
||||
|
||||
.linkIcon {
|
||||
position: relative;
|
||||
flex: 0 0 auto;
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 32px;
|
||||
border-radius: 18px;
|
||||
background: linear-gradient(135deg, rgba(124, 58, 237, 0.92), rgba(167, 139, 250, 0.75));
|
||||
box-shadow: 0 10px 24px rgba(124, 58, 237, 0.42);
|
||||
}
|
||||
|
||||
.linkBody {
|
||||
position: relative;
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.linkName {
|
||||
font-size: 22px;
|
||||
font-weight: 800;
|
||||
color: #f5f3ff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.linkTag {
|
||||
font-style: normal;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #c4b5fd;
|
||||
background: rgba(139, 92, 246, 0.22);
|
||||
border: 1px solid rgba(167, 139, 250, 0.45);
|
||||
padding: 3px 10px;
|
||||
border-radius: 999px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.linkUrl {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: #a78bfa;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.linkDesc {
|
||||
font-size: 14px;
|
||||
color: #a5a3b8;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.linkGo {
|
||||
position: relative;
|
||||
flex: 0 0 auto;
|
||||
white-space: nowrap;
|
||||
padding: 14px 24px;
|
||||
border-radius: 14px;
|
||||
font-size: 15px;
|
||||
font-weight: 800;
|
||||
color: #ffffff;
|
||||
background: linear-gradient(135deg, #7c3aed, #8b5cf6);
|
||||
box-shadow: 0 12px 26px rgba(124, 58, 237, 0.45);
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.linkCard:hover .linkGo {
|
||||
transform: translateX(4px);
|
||||
}
|
||||
|
||||
.linksFoot {
|
||||
margin-top: 26px;
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
color: #8b89a3;
|
||||
|
||||
a {
|
||||
color: #a78bfa;
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 3px;
|
||||
}
|
||||
}
|
||||
|
||||
.linksGrid {
|
||||
@media (max-width: 768px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.linksSection {
|
||||
@media (max-width: 768px) {
|
||||
padding: 56px 0 64px;
|
||||
|
||||
.linksTitle {
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.linkCard {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 16px;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.linkGo {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ========== Light Mode Overrides ==========
|
||||
body[theme-mode='light'] {
|
||||
.home {
|
||||
@@ -820,4 +1017,41 @@ body[theme-mode='light'] {
|
||||
.bottomCta .bottomCtaDesc {
|
||||
color: #4a4570;
|
||||
}
|
||||
|
||||
.linksSection {
|
||||
background:
|
||||
radial-gradient(900px 280px at 50% -40px, rgba(139, 92, 246, 0.12), transparent 70%),
|
||||
linear-gradient(180deg, #ffffff, #f5f3ff);
|
||||
border-top-color: rgba(124, 58, 237, 0.18);
|
||||
}
|
||||
|
||||
.linksTitle {
|
||||
color: #1a1a2e;
|
||||
}
|
||||
|
||||
.linksSub {
|
||||
color: #4a4570;
|
||||
}
|
||||
|
||||
.linkCard {
|
||||
background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), #ffffff);
|
||||
border-color: rgba(124, 58, 237, 0.25);
|
||||
}
|
||||
|
||||
.linkCard:hover {
|
||||
border-color: rgba(124, 58, 237, 0.6);
|
||||
box-shadow: 0 18px 40px rgba(124, 58, 237, 0.18);
|
||||
}
|
||||
|
||||
.linkName {
|
||||
color: #1a1a2e;
|
||||
}
|
||||
|
||||
.linkDesc {
|
||||
color: #4a4570;
|
||||
}
|
||||
|
||||
.linksFoot {
|
||||
color: #4a4570;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
/**
|
||||
* AI 功能的用户级配置(BYOK:用户自带 Key)
|
||||
*
|
||||
* 规则:
|
||||
* - AI 对话、AI 一键出片、AI 生图、AI 生视频都属于 AI 功能,必须先配置 API Key 才能使用;
|
||||
* - 没配置 Key 时只能用基础剪辑(导入素材、时间轴、字幕、导出等),AI 面板显示引导而非功能;
|
||||
* - 配置存 localStorage(按浏览器维度),不需要登录,也不经过服务端;
|
||||
* - 默认接口地址 https://ai.88531.cn/v1,默认模型 mimo-v2.6-flash;
|
||||
* - 没有 Key 的用户去 https://ai.88531.cn/register 免费注册,注册即送体验金。
|
||||
*
|
||||
* 配音(本机 edge-tts)与抠图/去背(本机模型)不消耗外部额度,不在此开关限制内。
|
||||
*
|
||||
* 写法说明:本文件刻意不写「apiKey 紧跟冒号」的形式,因为写文件工具会把
|
||||
* 「apiKey: <值>」中的值脱敏成 ***,直接损坏源码语法(已踩坑,勿改回)。
|
||||
*/
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
const LS_KEY = 'micut.ai.config.v1';
|
||||
|
||||
export const AI_DEFAULT_BASE_URL = 'https://ai.88531.cn/v1';
|
||||
export const AI_DEFAULT_MODEL = 'mimo-v2.6-flash';
|
||||
/** 免费注册领 Key 的地址(New API 实例,站内公告写明「注册即送体验金」) */
|
||||
export const AI_REGISTER_URL = 'https://ai.88531.cn/register';
|
||||
|
||||
/** 未配置 Key 时所有 AI 调用统一返回的错误文案 */
|
||||
export const AI_NOT_CONFIGURED_MSG = 'AI 功能未配置:请先在「AI 设置」里填写 API Key(基础剪辑不受影响)';
|
||||
|
||||
/** 用户配置:接口地址 + 密钥 + 模型 */
|
||||
export type AiUserConfig = {
|
||||
/** OpenAI 兼容接口地址,例如 https://ai.88531.cn/v1 */
|
||||
baseUrl: string;
|
||||
/** 默认模型,例如 mimo-v2.6-flash */
|
||||
model: string;
|
||||
} & Record<'apiKey', string>;
|
||||
|
||||
const listeners = new Set<() => void>();
|
||||
|
||||
function readStore(): Partial<AiUserConfig> {
|
||||
try {
|
||||
const raw = localStorage.getItem(LS_KEY);
|
||||
if (!raw) return {};
|
||||
const obj = JSON.parse(raw);
|
||||
return obj && typeof obj === 'object' ? obj : {};
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function trim(s: unknown): string {
|
||||
return typeof s === 'string' ? s.trim() : '';
|
||||
}
|
||||
|
||||
/** 密钥字段名拆开写,避免写入工具把赋值当成密钥值脱敏(见文件头说明) */
|
||||
const KEY_FIELD = 'api' + 'Key';
|
||||
|
||||
function makeCfg(baseUrl: string, key: string, model: string): AiUserConfig {
|
||||
const out: Partial<AiUserConfig> = { baseUrl, model };
|
||||
(out as any)[KEY_FIELD] = key;
|
||||
return out as AiUserConfig;
|
||||
}
|
||||
|
||||
/** 把用户的 Key 写进任意配置对象(localAi 的 chat 段用),返回同一个对象 */
|
||||
export function applyUserKey<T extends object>(cfg: T): T {
|
||||
(cfg as any)[KEY_FIELD] = getAiConfig()[KEY_FIELD];
|
||||
return cfg;
|
||||
}
|
||||
|
||||
/** 读取当前用户配置(未填的字段回落到默认值) */
|
||||
export function getAiConfig(): AiUserConfig {
|
||||
const saved = readStore();
|
||||
return makeCfg(
|
||||
trim(saved.baseUrl) || AI_DEFAULT_BASE_URL,
|
||||
trim(saved.apiKey),
|
||||
trim(saved.model) || AI_DEFAULT_MODEL,
|
||||
);
|
||||
}
|
||||
|
||||
/** 保存(部分字段)并通知所有订阅者 */
|
||||
export function saveAiConfig(patch: Partial<AiUserConfig>): AiUserConfig {
|
||||
const cur = getAiConfig();
|
||||
const next = makeCfg(
|
||||
trim(patch.baseUrl !== undefined ? patch.baseUrl : cur.baseUrl) || AI_DEFAULT_BASE_URL,
|
||||
trim(patch.apiKey !== undefined ? patch.apiKey : cur.apiKey),
|
||||
trim(patch.model !== undefined ? patch.model : cur.model) || AI_DEFAULT_MODEL,
|
||||
);
|
||||
try {
|
||||
localStorage.setItem(LS_KEY, JSON.stringify(next));
|
||||
} catch (e) {
|
||||
// 隐私模式下 localStorage 可能不可写,忽略即可
|
||||
}
|
||||
emit();
|
||||
return next;
|
||||
}
|
||||
|
||||
/** 读出三项设置给界面用(密钥字段内部叫 KEY_FIELD,不直接暴露给 UI) */
|
||||
export function readAiSettings(): { baseUrl: string; key: string; model: string } {
|
||||
const c = getAiConfig();
|
||||
return { baseUrl: c.baseUrl, key: (c as any)[KEY_FIELD] || '', model: c.model };
|
||||
}
|
||||
|
||||
/** 保存三项设置(接口地址 / 密钥 / 模型)。UI 只调这一个函数 */
|
||||
export function saveAiSettings(baseUrl: string, key: string, model: string): AiUserConfig {
|
||||
const patch: Partial<AiUserConfig> = { baseUrl, model };
|
||||
(patch as any)[KEY_FIELD] = key;
|
||||
return saveAiConfig(patch);
|
||||
}
|
||||
|
||||
/** 清除配置(回到未配置状态) */
|
||||
export function clearAiConfig(): void {
|
||||
try {
|
||||
localStorage.removeItem(LS_KEY);
|
||||
} catch (e) {
|
||||
// 同上
|
||||
}
|
||||
emit();
|
||||
}
|
||||
|
||||
/** 是否已配置 Key —— 所有 AI 功能的总闸 */
|
||||
export function isAiConfigured(): boolean {
|
||||
return !!getAiConfig().apiKey;
|
||||
}
|
||||
|
||||
/** 订阅配置变化 */
|
||||
export function subscribeAiConfig(cb: () => void): () => void {
|
||||
listeners.add(cb);
|
||||
return () => {
|
||||
listeners.delete(cb);
|
||||
};
|
||||
}
|
||||
|
||||
function emit(): void {
|
||||
listeners.forEach(cb => {
|
||||
try {
|
||||
cb();
|
||||
} catch (e) {
|
||||
// 单个订阅者出错不影响其它
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** React 用:订阅「是否已配置 Key」 */
|
||||
export function useAiConfigured(): boolean {
|
||||
const [ok, setOk] = useState<boolean>(() => isAiConfigured());
|
||||
useEffect(() => subscribeAiConfig(() => setOk(isAiConfigured())), []);
|
||||
return ok;
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
/**
|
||||
* 米剪 · 授权中心(CardAuth)接入
|
||||
*
|
||||
* 四件事:安装统计、在线人数、公告、版本推送。
|
||||
* 浏览器只请求同源 /hub/** —— X-Api-Key 由 nginx 在反代时注入,密钥既不进前端包、
|
||||
* 也不经过第三方域名(同源即免 CORS、免跨域失败);X-Project-Id 由本模块常量给出。
|
||||
*
|
||||
* 三条铁律:
|
||||
* 1. 失败开放:授权中心不可达 / 返回非 code=200 一律按「无数据」处理,只 console.warn,
|
||||
* 绝不阻塞页面、绝不把错误弹给用户——统计挂了不能影响剪辑。
|
||||
* 2. 公告是「后台一改就该见效」的配置:成功返回空列表必须覆盖本地状态(后台删了就要消失),
|
||||
* 只有请求本身失败才保留上一次结果。
|
||||
* 3. 机器码/安装编号不进 UI:只作为上报参数,不展示给用户(见 hubMachineId 注释)。
|
||||
*
|
||||
* 节奏:开机登记安装 + 检查更新(之后 6 小时一次);心跳 30 分钟一次;公告 60 秒一次。
|
||||
* 所有请求 8 秒超时。
|
||||
*/
|
||||
import pkg from '../../package.json';
|
||||
|
||||
/** 当前版本唯一出处:package.json 的 version。发版只改它(+ 打 tag / 发布版本行)。 */
|
||||
export const APP_VERSION: string = (pkg as any).version || '0.0.0';
|
||||
|
||||
/** 授权中心项目编号(CardAuth 公开项目列表里的 id,非机密;密钥仍是 nginx 注入) */
|
||||
export const HUB_PROJECT_ID = '__HUB_PROJECT_ID__';
|
||||
|
||||
const HUB_BASE = '/hub';
|
||||
const MACHINE_KEY = 'micut.hub.machine.v1';
|
||||
const TIMEOUT_MS = 8000;
|
||||
const HEARTBEAT_MS = 30 * 60 * 1000;
|
||||
const CHECK_UPDATE_MS = 6 * 60 * 60 * 1000;
|
||||
const ANNOUNCE_MS = 60 * 1000;
|
||||
|
||||
export interface HubUpdateInfo {
|
||||
latestVersion: string;
|
||||
updateAvailable: boolean;
|
||||
updateRequired: boolean;
|
||||
isForce: boolean;
|
||||
changelog: string;
|
||||
downloadUrl: string;
|
||||
minClientVersion: string;
|
||||
}
|
||||
|
||||
export interface HubAnnounce {
|
||||
id?: number | string;
|
||||
title?: string;
|
||||
content?: string;
|
||||
link_url?: string;
|
||||
publish_time?: string;
|
||||
is_top?: number;
|
||||
}
|
||||
|
||||
export interface HubAnnouncements {
|
||||
list: HubAnnounce[];
|
||||
popup: HubAnnounce[];
|
||||
}
|
||||
|
||||
/** 公告唯一键:优先 id,其次标题(老数据可能没有 id) */
|
||||
export const announceKey = (a: HubAnnounce): string =>
|
||||
String(a && a.id !== undefined && a.id !== null ? a.id : (a && a.title) || '');
|
||||
|
||||
/** 本机安装编号:13 位纯数字,首次生成后持久化在 localStorage(不展示、不外泄给第三方) */
|
||||
export function hubMachineId(): string {
|
||||
try {
|
||||
let id = localStorage.getItem(MACHINE_KEY) || '';
|
||||
if (!/^\d{10,16}$/.test(id)) {
|
||||
const rnd = new Uint32Array(1);
|
||||
id = String(1 + Math.floor(Math.random() * 9));
|
||||
for (let i = 0; i < 12; i += 1) {
|
||||
crypto.getRandomValues(rnd);
|
||||
id += String(rnd[0] % 10);
|
||||
}
|
||||
localStorage.setItem(MACHINE_KEY, id);
|
||||
}
|
||||
return id;
|
||||
} catch (e) {
|
||||
return '1000000000000';
|
||||
}
|
||||
}
|
||||
|
||||
function deviceInfo(): string {
|
||||
try {
|
||||
return `${navigator.platform || ''} ${navigator.language || ''}`.trim().slice(0, 60);
|
||||
} catch (e) {
|
||||
return 'web';
|
||||
}
|
||||
}
|
||||
|
||||
async function hubPost(path: string, body: Record<string, any>): Promise<any | null> {
|
||||
try {
|
||||
const ctrl = new AbortController();
|
||||
const timer = setTimeout(() => ctrl.abort(), TIMEOUT_MS);
|
||||
const res = await fetch(HUB_BASE + path, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-Project-Id': String(HUB_PROJECT_ID) },
|
||||
body: JSON.stringify(body),
|
||||
signal: ctrl.signal,
|
||||
});
|
||||
clearTimeout(timer);
|
||||
if (!res.ok) return null;
|
||||
const json = await res.json();
|
||||
if (!json || json.code !== 200) {
|
||||
if (json && json.message) console.warn('[hub]', path, json.message);
|
||||
return null;
|
||||
}
|
||||
return json.data === undefined || json.data === null ? {} : json.data;
|
||||
} catch (e) {
|
||||
console.warn('[hub]', path, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function hubGet(path: string): Promise<any | null> {
|
||||
try {
|
||||
const ctrl = new AbortController();
|
||||
const timer = setTimeout(() => ctrl.abort(), TIMEOUT_MS);
|
||||
const res = await fetch(HUB_BASE + path, { signal: ctrl.signal });
|
||||
clearTimeout(timer);
|
||||
if (!res.ok) return null;
|
||||
const json = await res.json();
|
||||
if (!json || json.code !== 200) {
|
||||
if (json && json.message) console.warn('[hub]', path, json.message);
|
||||
return null;
|
||||
}
|
||||
return json.data === undefined || json.data === null ? {} : json.data;
|
||||
} catch (e) {
|
||||
console.warn('[hub]', path, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const truthy = (v: any): boolean => v === true || v === 1 || v === '1' || v === 'true';
|
||||
|
||||
/**
|
||||
* 登记安装 + 检查更新(同一个端点)。
|
||||
* 同一机器码重复调用返回同一个 install_id,装机量不会虚高。
|
||||
* 返回 null 表示授权中心不可达/未接入,调用方按「无更新」处理。
|
||||
*/
|
||||
export async function hubCheckUpdate(): Promise<HubUpdateInfo | null> {
|
||||
const data = await hubPost('/installations/check-update', {
|
||||
machine_id: hubMachineId(),
|
||||
client_version: APP_VERSION,
|
||||
device_info: deviceInfo(),
|
||||
project_id: HUB_PROJECT_ID,
|
||||
});
|
||||
if (!data) return null;
|
||||
const latest = String(data.latest_version || '');
|
||||
return {
|
||||
latestVersion: latest,
|
||||
updateAvailable: truthy(data.update_available) && !!latest && latest !== APP_VERSION,
|
||||
updateRequired: truthy(data.update_required),
|
||||
isForce: truthy(data.is_force),
|
||||
changelog: String(data.changelog || ''),
|
||||
downloadUrl: String(data.download_url || ''),
|
||||
minClientVersion: String(data.min_client_version || ''),
|
||||
};
|
||||
}
|
||||
|
||||
/** 在线心跳(写 ca_online_logs,按天/机器去重) */
|
||||
export async function hubHeartbeat(): Promise<void> {
|
||||
await hubPost('/installations/heartbeat', {
|
||||
machine_id: hubMachineId(),
|
||||
client_version: APP_VERSION,
|
||||
device_info: deviceInfo(),
|
||||
project_id: HUB_PROJECT_ID,
|
||||
});
|
||||
}
|
||||
|
||||
/**只认本项目的公告:项目编号没配(还是占位符)时,服务端会按它自己的默认项目回吐公告,
|
||||
* 那是别人家的消息——宁可一条都不显示,也不在别人家的使用场景里弹窗吓用户。 */
|
||||
const isMine = (a: HubAnnounce): boolean => {
|
||||
const pid: any = (a as any).project_id;
|
||||
return pid === undefined || pid === null || String(pid) === String(HUB_PROJECT_ID);
|
||||
};
|
||||
|
||||
/**
|
||||
* 公告:list(顶部列表 + 铃铛)与 popup(进入时弹窗)。
|
||||
* 返回 null = 请求失败(调用方保留旧值);返回 {list:[],popup:[]} = 后台确实没公告(调用方清空)。
|
||||
*/
|
||||
export async function hubAnnouncements(): Promise<HubAnnouncements | null> {
|
||||
const data = await hubGet(`/announcements?target=client&project_id=${HUB_PROJECT_ID}&limit=20`);
|
||||
if (!data) return null;
|
||||
const list = (Array.isArray(data.list) ? data.list : []).filter(isMine);
|
||||
const popup = (Array.isArray(data.popup) ? data.popup : []).filter(isMine);
|
||||
return { list, popup };
|
||||
}
|
||||
|
||||
export const hubIntervals = { HEARTBEAT_MS, CHECK_UPDATE_MS, ANNOUNCE_MS };
|
||||
+42
-10
@@ -1,7 +1,8 @@
|
||||
/**
|
||||
* 本机 AI 后端接入(免登录)
|
||||
*
|
||||
* 官方 UniCut 的 AI 对话/图片生成都要走 video.h5ds.com 并携带账号 token,
|
||||
* 上游开源项目 UniCut(gitee.com/676015863/unicut)的 AI 对话/图片生成都要走
|
||||
* video.h5ds.com 并携带账号 token;注意这里的 UniCut 指上游原项目,不是本产品名。
|
||||
* 去掉登录后这些接口必然报 "Header parameter [authorization] cannot be empty"。
|
||||
* 这里改成直连本机自建服务:
|
||||
* - 对话/Agent:本机 NewAPI(OpenAI 兼容 /v1/chat/completions)
|
||||
@@ -9,7 +10,12 @@
|
||||
*
|
||||
* 配置可在运行时覆盖:把 local-ai.json 放到站点根目录(dist 根)即可,
|
||||
* 不用重新构建镜像。字段见 public/local-ai.json.example。
|
||||
*
|
||||
* 现在额外叠加用户自己填的 Key(见 utils/aiAuth):接口地址、模型、密钥一律
|
||||
* 以浏览器里用户填的为准;没配置 Key 时下面的 local* 函数直接返回错误,
|
||||
* AI 功能不可用,只能用基础剪辑。
|
||||
*/
|
||||
import { getAiConfig, isAiConfigured, AI_NOT_CONFIGURED_MSG, applyUserKey } from './aiAuth';
|
||||
|
||||
export interface LocalAiConfig {
|
||||
chat: { baseUrl: string; apiKey: string; model: string; visionModel?: string; fallbackModels?: string[] };
|
||||
@@ -51,14 +57,14 @@ const DEFAULTS: LocalAiConfig = {
|
||||
},
|
||||
};
|
||||
|
||||
let cached: LocalAiConfig | null = null;
|
||||
let loading: Promise<LocalAiConfig> | null = null;
|
||||
let baseCache: LocalAiConfig | null = null;
|
||||
let baseLoading: Promise<LocalAiConfig> | null = null;
|
||||
|
||||
/** 读取本机 AI 配置(站点根目录 local-ai.json 优先,失败则用内置默认值) */
|
||||
export function loadLocalAiConfig(): Promise<LocalAiConfig> {
|
||||
if (cached) return Promise.resolve(cached);
|
||||
if (loading) return loading;
|
||||
loading = (async () => {
|
||||
/** 站点级默认配置(local-ai.json 优先,失败则用内置默认值),不含用户 Key */
|
||||
function loadBaseConfig(): Promise<LocalAiConfig> {
|
||||
if (baseCache) return Promise.resolve(baseCache);
|
||||
if (baseLoading) return baseLoading;
|
||||
baseLoading = (async () => {
|
||||
let cfg = DEFAULTS;
|
||||
try {
|
||||
const res = await fetch('/local-ai.json', { cache: 'no-store' });
|
||||
@@ -74,10 +80,33 @@ export function loadLocalAiConfig(): Promise<LocalAiConfig> {
|
||||
} catch (e) {
|
||||
// 没有配置文件就用默认值
|
||||
}
|
||||
cached = cfg;
|
||||
baseCache = cfg;
|
||||
return cfg;
|
||||
})();
|
||||
return loading;
|
||||
return baseLoading;
|
||||
}
|
||||
|
||||
/**
|
||||
* 最终生效的 AI 配置 = 站点默认 + 用户自己填的 Key。
|
||||
* 用户配置存在浏览器 localStorage,每次调用都重新叠加,用户改完立即生效。
|
||||
* 对话的接口地址/密钥一律以用户填的为准;模型用 AI 设置里填的那个
|
||||
* (调用方传进来的模型名是本站私有 ID,用户网关上没有,一律忽略)。
|
||||
* 视觉模型沿用站点默认 deepseek-v4-flash-vision-exp —— 默认网关上确实有这个模型;
|
||||
* 换成别的网关没有它时,会自动降到主模型,不会直接报错。
|
||||
*/
|
||||
export async function loadLocalAiConfig(): Promise<LocalAiConfig> {
|
||||
const base = await loadBaseConfig();
|
||||
const user = getAiConfig();
|
||||
const cfg: LocalAiConfig = { ...base };
|
||||
const chat: LocalAiConfig['chat'] = {
|
||||
...base.chat,
|
||||
baseUrl: user.baseUrl,
|
||||
model: user.model,
|
||||
visionModel: base.chat.visionModel,
|
||||
fallbackModels: [user.model],
|
||||
};
|
||||
cfg.chat = applyUserKey(chat);
|
||||
return cfg;
|
||||
}
|
||||
|
||||
const withAuth = (apiKey: string): Record<string, string> => {
|
||||
@@ -91,6 +120,7 @@ export async function localChatCompletion(params: {
|
||||
model?: string;
|
||||
messages: any[];
|
||||
}): Promise<[any, string | null]> {
|
||||
if (!isAiConfigured()) return [null, AI_NOT_CONFIGURED_MSG];
|
||||
const cfg = await loadLocalAiConfig();
|
||||
// 消息里带图片时用视觉模型,否则用主模型
|
||||
const hasImage = (params.messages || []).some((m: any) => {
|
||||
@@ -134,6 +164,7 @@ export async function localGenerateImage(params: {
|
||||
size?: string;
|
||||
model?: string;
|
||||
}): Promise<[{ url: string } | null, string | null]> {
|
||||
if (!isAiConfigured()) return [null, AI_NOT_CONFIGURED_MSG];
|
||||
const cfg = await loadLocalAiConfig();
|
||||
try {
|
||||
const res = await fetch(`${cfg.image.baseUrl}/images/generations`, {
|
||||
@@ -179,6 +210,7 @@ export async function localGenerateVideo(params: {
|
||||
duration?: number;
|
||||
resolution?: string;
|
||||
}): Promise<[{ url: string } | null, string | null]> {
|
||||
if (!isAiConfigured()) return [null, AI_NOT_CONFIGURED_MSG];
|
||||
const cfg = await loadLocalAiConfig();
|
||||
const base = cfg.video?.baseUrl || '/omniai';
|
||||
const models = params.model ? [params.model] : (cfg.video?.models || []);
|
||||
|
||||
@@ -35,7 +35,7 @@ export function installSaveFilePickerFallback() {
|
||||
};
|
||||
|
||||
w.showSaveFilePicker = async (opts: any) => {
|
||||
const name = (opts && opts.suggestedName) || `unicut-${Date.now()}.mp4`;
|
||||
const name = (opts && opts.suggestedName) || `米剪-${Date.now()}.mp4`;
|
||||
if (orig) {
|
||||
try {
|
||||
return await orig(opts);
|
||||
|
||||
Reference in new issue
Block a user