From e17b78cd19c31f02cb5d3ed277a93fba3ad4925b Mon Sep 17 00:00:00 2001 From: jinghui Date: Wed, 18 Nov 2026 17:37:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(v1.4.3):=20=E8=A7=86=E9=A2=91=E7=BC=96?= =?UTF-8?q?=E8=BE=91/AI=E8=A7=86=E9=A2=91=E8=A1=A5=E9=89=B4=E6=9D=83?= =?UTF-8?q?=E5=A4=B4=E4=BF=AE=E5=A4=8D[object=20Object]=20+=20=E4=BE=A7?= =?UTF-8?q?=E6=A0=8F=E3=80=8C=E5=85=A8=E9=83=A8=E5=9B=BE=E7=89=87=E3=80=8D?= =?UTF-8?q?=E6=94=B9=E3=80=8C=E5=85=A8=E9=83=A8=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - VideoEditModal /api/video/edit、AIVideoModal /api/video/aigenerate+task轮询均裸fetch未带Authorization,后端/api全组401 → 补token头 - 错误信息经errText()解析(对象取message兜底状态码),不再显示[object Object] - MergeCollage拼图找相似接口同样缺token,一并修复 - Sidebar首项文案「全部图片」→「全部」 - 版本4处升v1.4.3 --- CHANGELOG.md | 6 ++++++ backend/utils/hub.js | 2 +- docker-compose.yml | 2 +- frontend/src/components/AIVideoModal.jsx | 19 ++++++++++++++++--- frontend/src/components/Header.jsx | 2 +- frontend/src/components/MergeCollage.jsx | 2 +- frontend/src/components/SettingsModal.jsx | 2 +- frontend/src/components/Sidebar.jsx | 2 +- frontend/src/components/VideoEditModal.jsx | 15 +++++++++++++-- 9 files changed, 41 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b67d9c8..1ece663 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # 更新日志 +## 2026-11-18 → v1.4.3 + +**优化**:侧栏首项文案「全部图片」改为「全部」(`Sidebar.jsx`)。 + +**修复:视频编辑/AI 生成视频点「开始处理」报 `[object Object]`、功能完全不可用**——根因是两处裸 `fetch` 调用没带登录态:`VideoEditModal.jsx`(`/api/video/edit`)与 `AIVideoModal.jsx`(`/api/video/aigenerate`、`/api/video/task/:id`)均未附 `Authorization` 头,而后端 `/api` 全组走认证中间件,一律 401 拒绝;前端又把 `{code, message}` 错误对象直接 `new Error()`,对象转字符串就成了 `[object Object]`。修复:三处请求补 `Authorization: `Bearer ${getToken()}`(与图片编辑器等既有调用一致),错误信息统一经 `errText()` 解析(对象取 `message`,再兜底状态码),不再出现 `[object Object]`。另修复 `MergeCollage.jsx` 拼图找相似接口同样的缺 token 问题(历史遗留)。 + ## 2026-11-18 → v1.4.2 **修复:添加素材库报 `Path does not exist`(视频目录)**——根因是该目录未挂载进容器(容器里看不到宿主机目录)。`docker-compose.yml` 已补挂载 `/vol2/1000/HD2/发布到平台的图片和视频`,README 使用注意新增排查方法(volumes 加一行同路径挂载后 `docker compose up -d`)。后端报错同步中文化:`素材库路径不存在: <路径>(如为宿主机目录,需先在 docker-compose.yml 的 volumes 里挂载进容器再重试)`(创建与更新两处)。 diff --git a/backend/utils/hub.js b/backend/utils/hub.js index bbf4ea3..75b5911 100644 --- a/backend/utils/hub.js +++ b/backend/utils/hub.js @@ -16,7 +16,7 @@ const { getSettings } = require('./settings'); const HUB_URL = (process.env.HUB_URL || 'https://auth.88531.cn/api').replace(/\/+$/, ''); const HUB_PROJECT_ID = process.env.HUB_PROJECT_ID || ''; const HUB_API_KEY = process.env.HUB_API_KEY || ''; -const SITE_VERSION = process.env.SITE_VERSION || '1.4.2'; +const SITE_VERSION = process.env.SITE_VERSION || '1.4.3'; const TIMEOUT_MS = 8000; const state = { diff --git a/docker-compose.yml b/docker-compose.yml index 71cdcc3..0cdc2e5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,7 +28,7 @@ services: - HUB_API_KEY=${HUB_API_KEY:-} - NEWAPI_KEY=${NEWAPI_KEY:-} # 当前站点版本(与 frontend/package.json、CHANGELOG 保持一致,界面版本徽标来源) - - SITE_VERSION=1.4.2 + - SITE_VERSION=1.4.3 # 让容器经 host.docker.internal 访问宿主机的 AI 侧车 extra_hosts: - "host.docker.internal:host-gateway" diff --git a/frontend/src/components/AIVideoModal.jsx b/frontend/src/components/AIVideoModal.jsx index fec6389..0cce5fe 100644 --- a/frontend/src/components/AIVideoModal.jsx +++ b/frontend/src/components/AIVideoModal.jsx @@ -6,6 +6,14 @@ import { useEffect, useRef, useState } from 'react'; import { X, Loader2, Film, CheckCircle2, AlertCircle, KeyRound } from 'lucide-react'; import { imageAPI } from '../api'; +import { getToken } from '../api/client'; + +// 后端错误可能为字符串或 {code,message} 对象,统一取可读文本 +const errText = (e, fallback) => { + if (!e) return fallback; + if (typeof e === 'string') return e; + return e.message || JSON.stringify(e); +}; const VOICES = [ { key: 'zh-CN-XiaoxiaoNeural', label: '晓晓(女声·自然)' }, @@ -51,7 +59,9 @@ function AIVideoModal({ libraryId, images, onClose, onDone }) { if (!taskId) return; timerRef.current = setInterval(async () => { try { - const res = await fetch(`/api/video/task/${taskId}`); + const res = await fetch(`/api/video/task/${taskId}`, { + headers: { Authorization: `Bearer ${getToken()}` } + }); if (!res.ok) return; const data = await res.json(); setTask(data); @@ -74,7 +84,10 @@ function AIVideoModal({ libraryId, images, onClose, onDone }) { try { const res = await fetch('/api/video/aigenerate', { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${getToken()}` + }, body: JSON.stringify({ libraryId, images: list.map((img) => ({ path: img.path })), @@ -86,7 +99,7 @@ function AIVideoModal({ libraryId, images, onClose, onDone }) { }) }); const data = await res.json().catch(() => ({})); - if (!res.ok || data.error) throw new Error(data.error || `启动失败 (${res.status})`); + if (!res.ok || data.error) throw new Error(errText(data.error, `启动失败 (${res.status})`)); setTaskId(data.taskId); } catch (e) { setError(e.message || '启动失败'); diff --git a/frontend/src/components/Header.jsx b/frontend/src/components/Header.jsx index 49f9563..53c793d 100644 --- a/frontend/src/components/Header.jsx +++ b/frontend/src/components/Header.jsx @@ -38,7 +38,7 @@ function Header() { // 授权系统 hub:版本 / 公告 / 在线人数 const hub = useHub(); const announcements = hub.announcements || []; - const appVersion = hub.version ? `v${String(hub.version).replace(/^v/, '')}` : 'v1.4.2'; + const appVersion = hub.version ? `v${String(hub.version).replace(/^v/, '')}` : 'v1.4.3'; // 从全局 store 获取筛选状态 const selectedFormats = filters.formats || []; diff --git a/frontend/src/components/MergeCollage.jsx b/frontend/src/components/MergeCollage.jsx index 07b2459..b3034ea 100644 --- a/frontend/src/components/MergeCollage.jsx +++ b/frontend/src/components/MergeCollage.jsx @@ -221,7 +221,7 @@ export default function MergeCollage({ image, libraryId, onMerge, setStatus, set method: 'POST', headers: { 'Content-Type': 'application/json', - Authorization: `*** ${getToken()}` + Authorization: `Bearer ${getToken()}` }, body: JSON.stringify({ libraryId, diff --git a/frontend/src/components/SettingsModal.jsx b/frontend/src/components/SettingsModal.jsx index c122000..ae3635b 100644 --- a/frontend/src/components/SettingsModal.jsx +++ b/frontend/src/components/SettingsModal.jsx @@ -2,7 +2,7 @@ import { useState, useEffect } from 'react'; import { X, ScanText, Info, Save, FlaskConical, Github, ExternalLink, Wand2 } from 'lucide-react'; import { settingsAPI } from '../api'; -const APP_VERSION = 'v1.4.2'; +const APP_VERSION = 'v1.4.3'; const REPO_URL = 'https://gitea.88531.cn/jinghui/flypic'; /** diff --git a/frontend/src/components/Sidebar.jsx b/frontend/src/components/Sidebar.jsx index da75a25..05fdc45 100644 --- a/frontend/src/components/Sidebar.jsx +++ b/frontend/src/components/Sidebar.jsx @@ -1718,7 +1718,7 @@ function Sidebar() {
- 全部图片 + 全部 {totalImageCount} diff --git a/frontend/src/components/VideoEditModal.jsx b/frontend/src/components/VideoEditModal.jsx index f6112b6..338b36d 100644 --- a/frontend/src/components/VideoEditModal.jsx +++ b/frontend/src/components/VideoEditModal.jsx @@ -6,6 +6,14 @@ import { useState } from 'react'; import { X, Droplets, Eraser, Type, Scissors, Loader2 } from 'lucide-react'; import { imageAPI } from '../api'; +import { getToken } from '../api/client'; + +// 后端错误可能为字符串或 {code,message} 对象,统一取可读文本 +const errText = (e, fallback) => { + if (!e) return fallback; + if (typeof e === 'string') return e; + return e.message || JSON.stringify(e); +}; const ACTIONS = [ { key: 'watermark-add', label: '加水印', icon: Droplets }, @@ -109,11 +117,14 @@ function VideoEditModal({ file, libraryId, onClose, onDone }) { try { const res = await fetch('/api/video/edit', { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${getToken()}` + }, body: JSON.stringify({ libraryId, path: file.path, action, options, output: outputMode }) }); const data = await res.json().catch(() => ({})); - if (!res.ok || data.error) throw new Error(data.error || `处理失败 (${res.status})`); + if (!res.ok || data.error) throw new Error(errText(data.error, `处理失败 (${res.status})`)); onDone && onDone(data.path); onClose(); } catch (e) {