Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4dcc908eaa | ||
|
|
67f8a8f708 | ||
|
|
3c3d834806 | ||
|
|
fa989d0220 | ||
|
|
b6e0c475d3 | ||
|
|
76d9d45770 |
No files matched your search
@@ -1,5 +1,17 @@
|
||||
# 更新日志
|
||||
|
||||
## 2026-11-19 → v1.4.9
|
||||
|
||||
**AI 生图配置统一到设置 + 提示词全中文化**——模型与通道配置不再在弹窗里重复出现,提示词所见即中文:
|
||||
|
||||
- ✨ **配置去重**:AI 生图弹窗移除「模型提供商」「模型」两个下拉(与右上角设置重复);通道/模型统一在「设置 → AI 生图」配置,弹窗内只留一句「通道与模型在右上角设置里配置」+「去设置」直达按钮
|
||||
- ✨ **设置 → AI 生图新增「默认模型」下拉**(内置 NewAPI 通道):按分组列出 CF Workers AI / Pollinations 模型,与自定义提供商的模型名同在设置页;选参考图时后端自动切 FLUX.2 图生图模型,用户无需手动换模型
|
||||
- ✨ **提示词中文化**:热门提示词按钮显示中文名、点击替换(不追加)输入框;发送前提示词原样传给后端,由后端经聊天模型翻译成英文再发上游(多模型兜底,翻译失败回落原文)
|
||||
- 🐛 修复生图翻译调用早于 `effUrl/effKey` 声明导致的运行时引用错误(TDZ)
|
||||
- 🎨 AI 生图/AI 一键生成视频弹窗改为默认全屏显示
|
||||
- 🐛 所有弹窗仅通过关闭按钮关闭,点击遮罩不再关闭(防误触丢失提示词/参考图)
|
||||
- ✨ **提示词全面详细化**:40 条图片预设从短标签扩写为完整出图提示词(主体+场景+光线+构图+风格+质量,平均 200+ 字符);预设卡片直接显示详细描述(两行预览),点击填入完整提示词而非名称;6 条视频脚本提示词扩为含镜头语言与节奏的完整脚本框架
|
||||
|
||||
## 2026-11-18 → v1.4.8
|
||||
|
||||
**搜索结果批量改名 + 关键词替换**——搜索出一批文件后直接对命中结果批量改名,支持把文件名中的关键词替换掉:
|
||||
@@ -8,6 +20,7 @@
|
||||
- ✨ **新重命名模式「关键词替换」**:找什么→替换成(文件名中所有出现处全部替换);**替换成留空 = 删除该关键词**;不含关键词的文件自动跳过并在结果中报告;预览实时显示替换前后对照
|
||||
- ✨ 搜索范围与列表同款 `LIKE` 模糊匹配(多关键词 AND、filename+ocr_text),后端 `POST /api/batch/rename-preview` 与 `/start` 新增 `scope='search'` + `keywords` 参数(folder 可不传,传了则按文件夹递归限定范围)
|
||||
- ✨ 弹窗模式改 2×2 布局(4 种模式);关键词模式下隐藏「包含子目录」开关(搜索范围本身就含子目录);文件夹右键入口的原有三种模式行为不变
|
||||
- 🎨 顶栏副标题「轻量快速的图片素材库管理」→「轻量快速的素材库管理」(去「图片」二字,与全站文件类型通用化口径一致)
|
||||
- 🛡️ 关键词与替换文本同样走文件名非法字符 `\ / : * ? " < > |` 前后端校验;预览与执行共用同一计划(命中数、跳过原因一致)
|
||||
- 端到端实测:preview/scope=search 预览命中数、keyword 执行改名+DB path 同步、搜索态按钮与弹窗渲染
|
||||
|
||||
|
||||
+150
-15
@@ -7,7 +7,45 @@
|
||||
*/
|
||||
|
||||
const express = require('express');
|
||||
/** 文生图提示词翻译:含中文/非 ASCII 时先翻译成英文,失败则回落原文 */
|
||||
const TEXT_TRANSLATE_MODELS = (process.env.AIGEN_TRANSLATE_MODEL || 'glm-5.3-flash,deepseek-v4.1-flash,mimo-v2.6-flash').split(',').map(s=>s.trim()).filter(Boolean);
|
||||
async function translatePromptToEnglish(prompt, url, key) {
|
||||
const p = String(prompt || '').trim();
|
||||
if (!p || !/[\x80-\uFFFF]/.test(p)) return p; // 已是纯英文/ASCII,无需翻译
|
||||
for (const model of TEXT_TRANSLATE_MODELS) {
|
||||
try {
|
||||
const ctrl = new AbortController();
|
||||
const t = setTimeout(() => ctrl.abort(), 30000);
|
||||
const resp = await fetch(`${url}/chat/completions`, {
|
||||
method: 'POST',
|
||||
headers: { 'Authorization': `Bearer ${key}`, 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
model,
|
||||
messages: [
|
||||
{ role: 'system', content: 'You are a translator. Translate the user prompt into concise, vivid English suitable for an image generation model. Output ONLY the English prompt, no quotes, no explanation.' },
|
||||
{ role: 'user', content: p }
|
||||
],
|
||||
temperature: 0.2,
|
||||
max_tokens: 300
|
||||
}),
|
||||
signal: ctrl.signal
|
||||
});
|
||||
clearTimeout(t);
|
||||
if (!resp.ok) continue;
|
||||
const d = await resp.json();
|
||||
const out = (d && d.choices && d.choices[0] && d.choices[0].message && d.choices[0].message.content) || '';
|
||||
const clean = String(out).trim().replace(/^["'`]+|["'`]+$/g, '');
|
||||
if (clean) return clean;
|
||||
} catch (e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return p; // 全部失败回落原文
|
||||
}
|
||||
|
||||
const router = express.Router();
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { asyncHandler } = require('../middleware/errorHandler');
|
||||
const logger = require('../utils/logger');
|
||||
const { getSettings } = require('../../utils/settings');
|
||||
@@ -38,6 +76,61 @@ const BUILTIN_GROUPS = [
|
||||
|
||||
const ALLOWED_SIZES = ['1024x1024', '1280x720', '720x1280', '1536x1024', '1024x1536'];
|
||||
|
||||
// 以图生图(图片编辑)支持的模型:FLUX.2 系列走 /v1/images/edits 的 multipart 上传
|
||||
const EDIT_MODELS = [
|
||||
{ id: 'flux-2', name: 'FLUX.2 [dev](图生图)' },
|
||||
{ id: 'flux-2-klein', name: 'FLUX.2 Klein 9B(图生图·快)' },
|
||||
{ id: 'flux-2-klein-4b', name: 'FLUX.2 Klein 4B(图生图·最省)' }
|
||||
];
|
||||
|
||||
const REF_EXTS = new Set(['.jpg', '.jpeg', '.png', '.webp', '.bmp', '.avif', '.gif']);
|
||||
const MAX_REFS = 4;
|
||||
const MIME_BY_EXT = {
|
||||
'.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.png': 'image/png',
|
||||
'.webp': 'image/webp', '.bmp': 'image/bmp', '.avif': 'image/avif', '.gif': 'image/gif'
|
||||
};
|
||||
|
||||
/** 归一化基础地址 -> 完整 images/edits URL */
|
||||
function normalizeEditUrl(url) {
|
||||
let u = String(url || '').trim().replace(/\/+$/, '');
|
||||
if (/\/images\/edits$/.test(u)) return u;
|
||||
if (/\/images\/generations$/.test(u)) return u.replace(/\/images\/generations$/, '/images/edits');
|
||||
if (/\/v1$/.test(u)) return u + '/images/edits';
|
||||
if (/\/chat\/completions$/.test(u)) return u.replace(/\/chat\/completions$/, '/images/edits');
|
||||
return u + '/v1/images/edits';
|
||||
}
|
||||
|
||||
/**
|
||||
* 从素材库读取参考图(以图生图用)
|
||||
* refs 支持 ['a.jpg'] 或 [{ path|filename }]
|
||||
*/
|
||||
function loadRefImages(req, libraryId, refs) {
|
||||
const list = Array.isArray(refs) ? refs.filter(Boolean).slice(0, MAX_REFS) : [];
|
||||
if (list.length === 0) return [];
|
||||
const configManager = req.app.get('configManager');
|
||||
if (!configManager) throw new Error('服务未初始化');
|
||||
const config = configManager.load();
|
||||
const library = (config.libraries || []).find((l) => String(l.id) === String(libraryId));
|
||||
if (!library) throw new Error('素材库不存在,请重新选择参考图');
|
||||
|
||||
const out = [];
|
||||
for (const item of list) {
|
||||
const rel = typeof item === 'string' ? item : (item.path || item.filename);
|
||||
if (!rel) continue;
|
||||
const abs = path.resolve(path.join(library.path, rel));
|
||||
if (!abs.startsWith(path.resolve(library.path))) throw new Error('参考图路径非法');
|
||||
if (!fs.existsSync(abs)) throw new Error(`参考图不存在: ${rel}`);
|
||||
const ext = path.extname(abs).toLowerCase();
|
||||
if (!REF_EXTS.has(ext)) throw new Error(`不是图片文件: ${rel}(只能选图片做参考图)`);
|
||||
out.push({
|
||||
name: path.basename(abs),
|
||||
mime: MIME_BY_EXT[ext] || 'application/octet-stream',
|
||||
buf: fs.readFileSync(abs)
|
||||
});
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** 归一化基础地址 -> 完整 images/generations URL */
|
||||
function normalizeGenUrl(url) {
|
||||
let u = String(url || '').trim().replace(/\/+$/, '');
|
||||
@@ -70,7 +163,7 @@ function resolveProvider(settings) {
|
||||
url: (ig.newapi && ig.newapi.url) || 'http://192.168.68.19:3099/v1',
|
||||
// 内置 key 优先取设置里填的,其次取服务器环境变量
|
||||
apiKey: (ig.newapi && ig.newapi.apiKey) || process.env.NEWAPI_KEY || '',
|
||||
model: '',
|
||||
model: (ig.newapi && ig.newapi.model) || 'flux-schnell',
|
||||
label: 'NewAPI(Pollinations + CF Workers AI)'
|
||||
};
|
||||
}
|
||||
@@ -87,10 +180,12 @@ router.get('/models', asyncHandler(async (req, res) => {
|
||||
success: true,
|
||||
data: {
|
||||
groups: BUILTIN_GROUPS,
|
||||
editModels: EDIT_MODELS,
|
||||
sizes: ALLOWED_SIZES,
|
||||
provider: {
|
||||
type: cur.provider,
|
||||
label: cur.label,
|
||||
builtinModel: cur.model || 'flux-schnell',
|
||||
url: cur.url,
|
||||
apiKeyMasked: maskKey(cur.apiKey),
|
||||
hasKey: !!cur.apiKey,
|
||||
@@ -109,7 +204,12 @@ router.get('/models', asyncHandler(async (req, res) => {
|
||||
*/
|
||||
router.post('/generate', asyncHandler(async (req, res) => {
|
||||
const t0 = Date.now();
|
||||
const { prompt, model, size, provider } = req.body || {};
|
||||
const { prompt, model, size, provider, libraryId } = req.body || {};
|
||||
// 文生图:中文提示词先翻译成英文再发给上游(图生图同样翻译)
|
||||
const originalPrompt = String(prompt || '').trim();
|
||||
|
||||
// 参考图(以图生图):兼容 refImages / refs / refPaths 三种字段
|
||||
const rawRefs = (req.body && (req.body.refImages || req.body.refs || req.body.refPaths)) || [];
|
||||
|
||||
if (!prompt || !String(prompt).trim()) {
|
||||
return res.status(400).json({ success: false, error: '提示词不能为空' });
|
||||
@@ -136,30 +236,59 @@ router.post('/generate', asyncHandler(async (req, res) => {
|
||||
if (!effKey) {
|
||||
return res.status(400).json({ success: false, error: '未配置 NewAPI Key,请到设置 → AI 生图填写' });
|
||||
}
|
||||
if (!effModel) effModel = 'flux-schnell';
|
||||
effModel = effModel || cur.model || 'flux-schnell'; // 默认模型统一在设置 → AI 生图里配
|
||||
}
|
||||
|
||||
const effPrompt = await translatePromptToEnglish(originalPrompt, effUrl, effKey);
|
||||
const effSize = ALLOWED_SIZES.includes(size) ? size : '1024x1024';
|
||||
const genUrl = normalizeGenUrl(effUrl);
|
||||
|
||||
logger.info(`[aigen] generate model=${effModel} size=${effSize} provider=${useCustom ? 'custom' : 'builtin'} prompt=${String(prompt).slice(0, 60)}`);
|
||||
// 读取参考图(有参考图 = 以图生图,走图片编辑接口)
|
||||
let refs = [];
|
||||
if (rawRefs && (Array.isArray(rawRefs) ? rawRefs.length : true)) {
|
||||
try {
|
||||
refs = loadRefImages(req, libraryId, rawRefs);
|
||||
} catch (e) {
|
||||
return res.status(400).json({ success: false, error: e.message });
|
||||
}
|
||||
}
|
||||
const isEdit = refs.length > 0;
|
||||
// 前端不再选模型:有参考图且内置模型不支持编辑时,自动切到图生图模型
|
||||
if (isEdit && !useCustom && !['flux-2', 'flux-2-klein'].includes(effModel)) {
|
||||
effModel = 'flux-2';
|
||||
}
|
||||
const targetUrl = isEdit ? normalizeEditUrl(effUrl) : normalizeGenUrl(effUrl);
|
||||
|
||||
logger.info(`[aigen] ${isEdit ? 'edit' : 'generate'} model=${effModel} size=${effSize} refs=${refs.length} provider=${useCustom ? 'custom' : 'builtin'} prompt=${String(effPrompt).slice(0, 60)} (orig: ${String(originalPrompt).slice(0, 40)})`);
|
||||
|
||||
const ctrl = new AbortController();
|
||||
const timer = setTimeout(() => ctrl.abort(), 150000); // 生图最长 150s
|
||||
const timer = setTimeout(() => ctrl.abort(), isEdit ? 300000 : 150000); // 图生图更慢,最长 300s
|
||||
let result;
|
||||
try {
|
||||
const resp = await fetch(genUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${effKey}`,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
let body;
|
||||
let headers = { 'Authorization': `Bearer ${effKey}` };
|
||||
if (isEdit) {
|
||||
const form = new FormData();
|
||||
form.append('model', String(effModel || 'flux-2'));
|
||||
form.append('prompt', String(effPrompt));
|
||||
form.append('n', '1');
|
||||
form.append('size', effSize);
|
||||
refs.forEach((r, i) => {
|
||||
form.append(i === 0 ? 'image' : `image_${i}`, new Blob([r.buf], { type: r.mime }), r.name);
|
||||
});
|
||||
body = form;
|
||||
} else {
|
||||
headers['Content-Type'] = 'application/json';
|
||||
body = JSON.stringify({
|
||||
model: effModel,
|
||||
prompt: String(prompt),
|
||||
prompt: String(effPrompt),
|
||||
n: 1,
|
||||
size: effSize
|
||||
}),
|
||||
});
|
||||
}
|
||||
const resp = await fetch(targetUrl, {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body,
|
||||
signal: ctrl.signal
|
||||
});
|
||||
const text = await resp.text();
|
||||
@@ -171,6 +300,9 @@ router.post('/generate', asyncHandler(async (req, res) => {
|
||||
if (j.error && j.error.message) msg = j.error.message;
|
||||
else if (j.message) msg = j.message;
|
||||
} catch (e) { /* 保留默认信息 */ }
|
||||
if (isEdit && /not found|404|not support|unsupported|invalid model/i.test(msg + ' ' + resp.status)) {
|
||||
msg += '(当前模型可能不支持以图生图,请在设置里换成 flux-2 系列或支持图片编辑的模型)';
|
||||
}
|
||||
return res.status(502).json({ success: false, error: msg });
|
||||
}
|
||||
result = JSON.parse(text);
|
||||
@@ -227,6 +359,9 @@ router.post('/generate', asyncHandler(async (req, res) => {
|
||||
revisedPrompt: result.data && result.data[0] && result.data[0].revised_prompt,
|
||||
model: effModel,
|
||||
size: effSize,
|
||||
promptEn: effPrompt,
|
||||
edited: isEdit,
|
||||
refCount: refs.length,
|
||||
ms: Date.now() - t0
|
||||
}
|
||||
});
|
||||
|
||||
@@ -30,6 +30,7 @@ router.get('/', (req, res) => {
|
||||
provider: ig.provider === 'custom' ? 'custom' : 'newapi',
|
||||
newapi: {
|
||||
url: (ig.newapi && ig.newapi.url) || '',
|
||||
model: (ig.newapi && ig.newapi.model) || 'flux-schnell',
|
||||
apiKeyMasked: maskKey((ig.newapi && ig.newapi.apiKey) || ''),
|
||||
// 真正生效的 key:设置里的或环境变量兜底
|
||||
hasKey: !!((ig.newapi && ig.newapi.apiKey) || process.env.NEWAPI_KEY)
|
||||
@@ -40,6 +41,15 @@ router.get('/', (req, res) => {
|
||||
apiKeyMasked: maskKey((ig.custom && ig.custom.apiKey) || ''),
|
||||
configured: !!(ig.custom && ig.custom.url && ig.custom.apiKey)
|
||||
}
|
||||
},
|
||||
videoai: {
|
||||
provider: (s.videoai && s.videoai.provider) === 'custom' ? 'custom' : 'inherit',
|
||||
custom: {
|
||||
url: (s.videoai && s.videoai.custom && s.videoai.custom.url) || '',
|
||||
model: (s.videoai && s.videoai.custom && s.videoai.custom.model) || '',
|
||||
apiKeyMasked: maskKey((s.videoai && s.videoai.custom && s.videoai.custom.apiKey) || ''),
|
||||
configured: !!(s.videoai && s.videoai.custom && s.videoai.custom.url && s.videoai.custom.apiKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -64,6 +74,7 @@ router.put('/', (req, res) => {
|
||||
provider: ig.provider,
|
||||
newapi: {
|
||||
url: ig.newapi.url,
|
||||
model: ig.newapi.model || 'flux-schnell',
|
||||
apiKeyMasked: maskKey(ig.newapi.apiKey),
|
||||
hasKey: !!(ig.newapi.apiKey || process.env.NEWAPI_KEY)
|
||||
},
|
||||
@@ -73,6 +84,15 @@ router.put('/', (req, res) => {
|
||||
apiKeyMasked: maskKey(ig.custom.apiKey),
|
||||
configured: !!(ig.custom.url && ig.custom.apiKey)
|
||||
}
|
||||
},
|
||||
videoai: {
|
||||
provider: (saved.videoai && saved.videoai.provider) === 'custom' ? 'custom' : 'inherit',
|
||||
custom: {
|
||||
url: (saved.videoai && saved.videoai.custom && saved.videoai.custom.url) || '',
|
||||
model: (saved.videoai && saved.videoai.custom && saved.videoai.custom.model) || '',
|
||||
apiKeyMasked: maskKey((saved.videoai && saved.videoai.custom && saved.videoai.custom.apiKey) || ''),
|
||||
configured: !!(saved.videoai && saved.videoai.custom && saved.videoai.custom.url && saved.videoai.custom.apiKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+199
-11
@@ -14,9 +14,11 @@ const fs = require('fs');
|
||||
const os = require('os');
|
||||
const { asyncHandler, ValidationError, NotFoundError } = require('../middleware/errorHandler');
|
||||
const { processImage } = require('../../utils/scanner');
|
||||
const { getSettings } = require('../../utils/settings');
|
||||
const { getSettings, resolveVideoGen } = require('../../utils/settings');
|
||||
const logger = require('../utils/logger');
|
||||
const videotool = require('../../utils/videotool');
|
||||
const multer = require('multer');
|
||||
const upload = multer({ storage: multer.memoryStorage(), limits: { fileSize: 20 * 1024 * 1024 } });
|
||||
|
||||
const VIDEO_EXTS = new Set(['.mp4', '.mov', '.m4v', '.webm', '.mkv', '.avi', '.flv', '.wmv', '.mpg', '.mpeg', '.3gp', '.ts']);
|
||||
|
||||
@@ -133,7 +135,8 @@ router.post(
|
||||
model, // 模型名
|
||||
voice = 'zh-CN-XiaoxiaoNeural',
|
||||
resolution = '1920x1080',
|
||||
extraPrompt = ''
|
||||
extraPrompt = '',
|
||||
subtitleStyle = {}
|
||||
} = req.body || {};
|
||||
|
||||
if (!libraryId || !Array.isArray(images) || images.length < 2) {
|
||||
@@ -156,14 +159,13 @@ router.post(
|
||||
if (!library) throw new NotFoundError('Library', libraryId);
|
||||
|
||||
const settings = getSettings();
|
||||
const gen = (settings.imagegen && settings.imagegen.provider === 'custom')
|
||||
? settings.imagegen.custom
|
||||
: settings.imagegen.newapi;
|
||||
// 设置 - AI 视频(或复用 AI 生图)中的文本模型配置;请求参数可临时覆盖
|
||||
const gen = resolveVideoGen(settings);
|
||||
const url = (baseUrl || gen.url || '').replace(/\/+$/, '');
|
||||
const key = apiKey || gen.apiKey || process.env.NEWAPI_KEY || '';
|
||||
const mdl = model || gen.model || 'mimo-v2.6-flash';
|
||||
if (!url) throw new ValidationError('未配置模型接口地址(填 BASE URL 或在设置里配置)');
|
||||
if (!key) throw new ValidationError('请填写模型 KEY(或在设置-生图里配置)');
|
||||
if (!url) throw new ValidationError('未配置模型接口地址(请到右上角设置 → AI 视频里填写)');
|
||||
if (!key) throw new ValidationError('请先在右上角设置 → AI 视频里填写模型 KEY');
|
||||
|
||||
const id = `vt${++aiTaskSeq}_${Date.now()}`;
|
||||
const [w, h] = String(resolution).split('x').map((n) => parseInt(n, 10));
|
||||
@@ -185,7 +187,7 @@ router.post(
|
||||
runAiVideo({
|
||||
task, library, images, title: String(title).trim(), url, key, model: mdl,
|
||||
voice, width: Number.isFinite(w) ? w : 1920, height: Number.isFinite(h) ? h : 1080,
|
||||
extraPrompt: String(extraPrompt || ''),
|
||||
extraPrompt: String(extraPrompt || ''), subtitleStyle: subtitleStyle || {},
|
||||
req
|
||||
}).catch((err) => {
|
||||
task.status = 'error';
|
||||
@@ -200,7 +202,7 @@ router.post(
|
||||
router.get(
|
||||
'/task/:id',
|
||||
asyncHandler(async (req, res) => {
|
||||
const task = aiTasks.get(req.params.id);
|
||||
const task = aiTasks.get(req.params.id) || textTasks.get(req.params.id);
|
||||
if (!task) throw new NotFoundError('Task', req.params.id);
|
||||
res.json(task);
|
||||
})
|
||||
@@ -255,7 +257,7 @@ async function llmScript({ url, key, model, title, count, extraPrompt }) {
|
||||
}
|
||||
|
||||
async function runAiVideo(ctx) {
|
||||
const { task, library, images, title, url, key, model, voice, width, height, extraPrompt, req } = ctx;
|
||||
const { task, library, images, title, url, key, model, voice, width, height, extraPrompt, subtitleStyle, req } = ctx;
|
||||
|
||||
// 1) 校验图片文件
|
||||
const files = [];
|
||||
@@ -313,7 +315,7 @@ async function runAiVideo(ctx) {
|
||||
task.stepLabel = `正在合成画面 ${i + 1}/${segments.length}`;
|
||||
task.progress = 50 + Math.round((i / segments.length) * 45);
|
||||
const out = path.join(work, `seg${i}.mp4`);
|
||||
await videotool.buildSegment(segments[i], out, { width, height });
|
||||
await videotool.buildSegment(segments[i], out, { width, height, subtitleStyle: ctx.subtitleStyle });
|
||||
segFiles.push(out);
|
||||
}
|
||||
|
||||
@@ -348,4 +350,190 @@ async function runAiVideo(ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- URL 抓取:内容 + 图片 ----------
|
||||
router.post(
|
||||
'/extract-url',
|
||||
asyncHandler(async (req, res) => {
|
||||
const { url } = req.body || {};
|
||||
if (!url) throw new ValidationError('缺少 url');
|
||||
let html = '';
|
||||
try {
|
||||
const r = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' }, signal: AbortSignal.timeout(20000) });
|
||||
html = await r.text();
|
||||
} catch (e) { throw new ValidationError('抓取失败: ' + (e.message || e)); }
|
||||
const titleMatch = html.match(/<title[^>]*>([\s\S]*?)<\/title>/i);
|
||||
const title = titleMatch ? titleMatch[1].replace(/\s+/g, ' ').trim().slice(0, 80) : '';
|
||||
// images
|
||||
const imgs = [];
|
||||
const imgRe = /<img[^>]+src=["']([^"']+)["']/gi;
|
||||
let m;
|
||||
while ((m = imgRe.exec(html)) && imgs.length < 8) {
|
||||
let src = m[1];
|
||||
if (src.startsWith('//')) src = 'https:' + src;
|
||||
else if (src.startsWith('/')) { try { src = new URL(src, url).href; } catch (_) {} }
|
||||
else if (!/^https?:/i.test(src)) { try { src = new URL(src, url).href; } catch (_) {} }
|
||||
if (/^https?:/i.test(src) && !imgs.includes(src)) imgs.push(src);
|
||||
}
|
||||
// text: strip tags
|
||||
const text = html
|
||||
.replace(/<script[\s\S]*?<\/script>/gi, '')
|
||||
.replace(/<style[\s\S]*?<\/style>/gi, '')
|
||||
.replace(/<[^>]+>/g, ' ')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim()
|
||||
.slice(0, 4000);
|
||||
res.json({ success: true, title, text, images: imgs });
|
||||
})
|
||||
);
|
||||
|
||||
// ---------- 文档/PDF 提取 ----------
|
||||
router.post(
|
||||
'/extract-doc',
|
||||
upload.single('file'),
|
||||
asyncHandler(async (req, res) => {
|
||||
if (!req.file) throw new ValidationError('缺少文件');
|
||||
const name = req.file.originalname || 'doc';
|
||||
let text = '';
|
||||
const ext = path.extname(name).toLowerCase();
|
||||
if (ext === '.pdf') {
|
||||
const tmp = path.join(os.tmpdir(), `doc_${Date.now()}.pdf`);
|
||||
fs.writeFileSync(tmp, req.file.buffer);
|
||||
try {
|
||||
const { stdout } = await videotool.run('pdftotext', ['-layout', tmp, '-'], { timeoutMs: 60000 });
|
||||
text = stdout;
|
||||
} catch (e) {
|
||||
text = req.file.buffer.toString('utf8').replace(/[^\x20-\x7E\u4e00-\u9fa5]/g, ' ');
|
||||
} finally {
|
||||
try { fs.unlinkSync(tmp); } catch (_) {}
|
||||
}
|
||||
} else {
|
||||
text = req.file.buffer.toString('utf8');
|
||||
}
|
||||
text = String(text).replace(/\s+/g, ' ').trim().slice(0, 6000);
|
||||
res.json({ success: true, title: name.replace(/\.[^.]+$/, ''), text, images: [] });
|
||||
})
|
||||
);
|
||||
|
||||
// ---------- 文本源 AI 生成视频(提示词/URL/文档) ----------
|
||||
const textTasks = new Map();
|
||||
let textTaskSeq = 0;
|
||||
router.post(
|
||||
'/aigenerate-text',
|
||||
asyncHandler(async (req, res) => {
|
||||
const {
|
||||
libraryId, title, content, images = [],
|
||||
apiKey, baseUrl, model,
|
||||
voice = 'zh-CN-XiaoxiaoNeural',
|
||||
resolution = '1920x1080',
|
||||
extraPrompt = '',
|
||||
subtitleStyle = {}
|
||||
} = req.body || {};
|
||||
if (!libraryId) throw new ValidationError('缺少 libraryId');
|
||||
if (!title || !String(title).trim()) throw new ValidationError('请填写视频标题');
|
||||
const text = String(content || '').trim();
|
||||
if (!text && (!Array.isArray(images) || images.length === 0)) throw new ValidationError('缺少内容或图片');
|
||||
|
||||
const configManager = req.app.get('configManager');
|
||||
const config = configManager.load();
|
||||
const library = config.libraries.find((l) => String(l.id) === String(libraryId));
|
||||
if (!library) throw new NotFoundError('Library', libraryId);
|
||||
|
||||
const settings = getSettings();
|
||||
// 设置 - AI 视频(或复用 AI 生图)中的文本模型配置;请求参数可临时覆盖
|
||||
const gen = resolveVideoGen(settings);
|
||||
const url = (baseUrl || gen.url || '').replace(/\/+$/, '');
|
||||
const key = apiKey || gen.apiKey || process.env.NEWAPI_KEY || '';
|
||||
const mdl = model || gen.model || 'mimo-v2.6-flash';
|
||||
if (!url) throw new ValidationError('未配置模型接口地址(请到右上角设置 → AI 视频里填写)');
|
||||
if (!key) throw new ValidationError('请先在右上角设置 → AI 视频里填写模型 KEY');
|
||||
|
||||
const id = `vt${++textTaskSeq}_${Date.now()}`;
|
||||
const [w, h] = String(resolution).split('x').map((n) => parseInt(n, 10));
|
||||
const task = { id, status: 'running', step: 'script', stepLabel: '正在生成', progress: 0, error: '', resultPath: '', createdAt: Date.now() };
|
||||
textTasks.set(id, task);
|
||||
setTimeout(() => textTasks.delete(id), 30 * 60 * 1000);
|
||||
|
||||
runTextVideo({ task, library, title: String(title).trim(), content: text, images, url, key, model: mdl, voice, width: Number.isFinite(w)?w:1920, height: Number.isFinite(h)?h:1080, extraPrompt: String(extraPrompt||''), subtitleStyle: subtitleStyle||{}, req }).catch((err) => {
|
||||
task.status = 'error'; task.error = err.message || String(err);
|
||||
});
|
||||
res.json({ success: true, taskId: id });
|
||||
})
|
||||
);
|
||||
async function runTextVideo(ctx) {
|
||||
const { task, library, title, content, images, url, key, model, voice, width, height, extraPrompt, subtitleStyle, req } = ctx;
|
||||
const work = fs.mkdtempSync(path.join(os.tmpdir(), 'flypic-tv-'));
|
||||
try {
|
||||
// 生成背景图(若无图片)
|
||||
let bgPath = '';
|
||||
if (Array.isArray(images) && images.length) {
|
||||
// 用第一张图作为背景
|
||||
const rel = typeof images[0] === 'string' ? images[0] : images[0].path || images[0].url;
|
||||
if (rel && fs.existsSync(path.join(library.path, rel))) bgPath = path.join(library.path, rel);
|
||||
else if (rel && /^https?:/i.test(rel)) {
|
||||
// 下载
|
||||
try {
|
||||
const r = await fetch(rel); const buf = Buffer.from(await r.arrayBuffer());
|
||||
bgPath = path.join(work, 'bg.jpg'); fs.writeFileSync(bgPath, buf);
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
if (!bgPath) {
|
||||
bgPath = path.join(work, 'bg.png');
|
||||
await videotool.run('ffmpeg', ['-y', '-f', 'lavfi', '-i', `color=c=0x1a1a2e:s=${width}x${height}`, '-frames:v', '1', bgPath], { timeoutMs: 60000 });
|
||||
}
|
||||
|
||||
// LLM 生成分镜:基于内容切分
|
||||
task.step = 'script'; task.stepLabel = '正在生成脚本'; task.progress = 5;
|
||||
let script = [];
|
||||
if (content) {
|
||||
// 让模型按内容生成 N 段(N = min(8, 句子数))
|
||||
const sentences = content.split(/[。!?.!?]/).map(s=>s.trim()).filter(Boolean);
|
||||
const n = Math.min(8, Math.max(2, sentences.length));
|
||||
script = await llmScript({ url, key, model, title, count: n, extraPrompt: (extraPrompt + ' 内容:' + content.slice(0, 1500)).trim() });
|
||||
} else {
|
||||
script = [{ subtitle: title, tts: title }];
|
||||
}
|
||||
if (!Array.isArray(script) || !script.length) script = [{ subtitle: title, tts: title }];
|
||||
|
||||
// TTS + segments
|
||||
const segments = [];
|
||||
for (let i = 0; i < script.length; i++) {
|
||||
task.step = 'tts'; task.stepLabel = `正在朗读 ${i+1}/${script.length}`; task.progress = 10 + Math.round((i/script.length)*40);
|
||||
const seg = script[i];
|
||||
let ttsFile = ''; let dur = 0;
|
||||
if (seg.tts) {
|
||||
try {
|
||||
const t = await videotool.generateTts(seg.tts, { voice, outPath: path.join(work, `tts${i}.mp3`) });
|
||||
ttsFile = t.file; dur = t.seconds;
|
||||
} catch (e) { logger.warn('TTS fail: ' + e.message); }
|
||||
}
|
||||
segments.push({ imagePath: bgPath, subtitle: seg.subtitle || seg.tts || title, ttsFile, duration: Math.max(2.5, Math.min(12, dur || 4)) });
|
||||
}
|
||||
|
||||
// compose
|
||||
const segFiles = [];
|
||||
for (let i = 0; i < segments.length; i++) {
|
||||
task.step = 'compose'; task.stepLabel = `合成 ${i+1}/${segments.length}`; task.progress = 50 + Math.round((i/segments.length)*45);
|
||||
const out = path.join(work, `seg${i}.mp4`);
|
||||
await videotool.buildSegment(segments[i], out, { width, height, subtitleStyle });
|
||||
segFiles.push(out);
|
||||
}
|
||||
task.step = 'merge'; task.stepLabel = '合并'; task.progress = 96;
|
||||
const finalTmp = path.join(work, 'final.mp4');
|
||||
await videotool.concatSegments(segFiles, finalTmp);
|
||||
|
||||
const safeTitle = String(title).replace(/[\\/:*?"<>|]/g, '_').slice(0, 60) || 'AI视频';
|
||||
let target = path.join(library.path, `${safeTitle}.mp4`);
|
||||
let n = 1;
|
||||
while (fs.existsSync(target)) { target = path.join(library.path, `${safeTitle}_${n}.mp4`); n++; }
|
||||
fs.copyFileSync(finalTmp, target);
|
||||
await reindex(req, library.path, target);
|
||||
|
||||
task.status = 'done'; task.progress = 100; task.step = 'done'; task.stepLabel = '完成'; task.resultPath = path.relative(library.path, target);
|
||||
} finally {
|
||||
fs.rmSync(work, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
|
||||
// llmScript is defined later? it's a function declaration in same module scope (hoisted). ok.
|
||||
module.exports = router;
|
||||
@@ -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.8';
|
||||
const SITE_VERSION = process.env.SITE_VERSION || '1.4.9';
|
||||
const TIMEOUT_MS = 8000;
|
||||
|
||||
const state = {
|
||||
|
||||
@@ -23,13 +23,24 @@ const DEFAULTS = {
|
||||
provider: 'newapi', // 'newapi' | 'custom'
|
||||
newapi: {
|
||||
url: 'http://192.168.68.19:3099/v1',
|
||||
apiKey: '' // 留空则用服务器环境变量 NEWAPI_KEY
|
||||
apiKey: '', // 留空则用服务器环境变量 NEWAPI_KEY
|
||||
model: 'flux-schnell' // 默认生图模型(弹窗不再选模型,统一在设置里配)
|
||||
},
|
||||
custom: {
|
||||
url: '',
|
||||
apiKey: '',
|
||||
model: ''
|
||||
}
|
||||
},
|
||||
// AI 视频:一句话/文本/网页/文档 → 带字幕配音的成片
|
||||
// provider='inherit' 复用上面的 AI 生图配置;'custom' 用下面自定义的文本模型
|
||||
videoai: {
|
||||
provider: 'inherit',
|
||||
custom: {
|
||||
url: '',
|
||||
model: '',
|
||||
apiKey: ''
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,6 +68,7 @@ function getSettings() {
|
||||
provider: (data.imagegen && data.imagegen.provider) === 'custom' ? 'custom' : 'newapi',
|
||||
newapi: {
|
||||
url: (data.imagegen && data.imagegen.newapi && data.imagegen.newapi.url) || DEFAULTS.imagegen.newapi.url,
|
||||
model: (data.imagegen && data.imagegen.newapi && data.imagegen.newapi.model) || DEFAULTS.imagegen.newapi.model,
|
||||
apiKey: (data.imagegen && data.imagegen.newapi && data.imagegen.newapi.apiKey) || ''
|
||||
},
|
||||
custom: {
|
||||
@@ -64,6 +76,14 @@ function getSettings() {
|
||||
apiKey: (data.imagegen && data.imagegen.custom && data.imagegen.custom.apiKey) || '',
|
||||
model: (data.imagegen && data.imagegen.custom && data.imagegen.custom.model) || ''
|
||||
}
|
||||
},
|
||||
videoai: {
|
||||
provider: (data.videoai && data.videoai.provider) === 'custom' ? 'custom' : 'inherit',
|
||||
custom: {
|
||||
url: (data.videoai && data.videoai.custom && data.videoai.custom.url) || '',
|
||||
model: (data.videoai && data.videoai.custom && data.videoai.custom.model) || '',
|
||||
apiKey: (data.videoai && data.videoai.custom && data.videoai.custom.apiKey) || ''
|
||||
}
|
||||
}
|
||||
};
|
||||
} catch (e) {
|
||||
@@ -93,6 +113,7 @@ function saveSettings(settings) {
|
||||
if (ig.provider === 'custom' || ig.provider === 'newapi') merged.imagegen.provider = ig.provider;
|
||||
if (ig.newapi) {
|
||||
if (typeof ig.newapi.url === 'string') merged.imagegen.newapi.url = ig.newapi.url.trim();
|
||||
if (typeof ig.newapi.model === 'string') merged.imagegen.newapi.model = ig.newapi.model.trim() || 'flux-schnell';
|
||||
const k = ig.newapi.apiKey;
|
||||
// 空串/掩码 = 保持原值(与 OCR 行为一致)
|
||||
if (typeof k === 'string' && k.trim() && !k.includes('***')) {
|
||||
@@ -108,6 +129,19 @@ function saveSettings(settings) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (settings.videoai) {
|
||||
const va = settings.videoai;
|
||||
if (va.provider === 'custom' || va.provider === 'inherit') merged.videoai.provider = va.provider;
|
||||
if (va.custom) {
|
||||
if (typeof va.custom.url === 'string') merged.videoai.custom.url = va.custom.url.trim();
|
||||
if (typeof va.custom.model === 'string') merged.videoai.custom.model = va.custom.model.trim();
|
||||
const vk = va.custom.apiKey;
|
||||
// 空串/掩码 = 保持原密钥
|
||||
if (typeof vk === 'string' && vk.trim() && !vk.includes('***')) {
|
||||
merged.videoai.custom.apiKey = vk.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
fs.writeFileSync(p, JSON.stringify(merged, null, 2));
|
||||
return merged;
|
||||
}
|
||||
@@ -119,4 +153,36 @@ function maskKey(key) {
|
||||
return `${key.slice(0, 4)}***${key.slice(-4)}`;
|
||||
}
|
||||
|
||||
module.exports = { getSettings, saveSettings, maskKey, settingsPath };
|
||||
/**
|
||||
* 解析 AI 视频使用的文本大模型配置
|
||||
* - 设置-AI 视频里选了「自定义」且填了地址 → 用自定义
|
||||
* - 否则复用 AI 生图配置(内置 NewAPI / 自定义提供商)
|
||||
* 普通文本模型(chat/completions)即可,全流程由后端写分镜、TTS 配音、合成字幕。
|
||||
*/
|
||||
function resolveVideoGen(settings) {
|
||||
const s = settings || getSettings();
|
||||
const va = (s && s.videoai) || {};
|
||||
const ig = (s && s.imagegen) || {};
|
||||
const defModel = process.env.NEWAPI_TEXT_MODEL || 'mimo-v2.6-flash';
|
||||
if (va.provider === 'custom' && va.custom && va.custom.url) {
|
||||
return {
|
||||
url: String(va.custom.url).replace(/\/+$/, ''),
|
||||
model: va.custom.model || defModel,
|
||||
apiKey: va.custom.apiKey || process.env.NEWAPI_KEY || ''
|
||||
};
|
||||
}
|
||||
if (ig.provider === 'custom' && ig.custom) {
|
||||
return {
|
||||
url: String(ig.custom.url || '').replace(/\/+$/, ''),
|
||||
model: ig.custom.model || defModel,
|
||||
apiKey: ig.custom.apiKey || process.env.NEWAPI_KEY || ''
|
||||
};
|
||||
}
|
||||
return {
|
||||
url: String((ig.newapi && ig.newapi.url) || 'http://192.168.68.19:3099/v1').replace(/\/+$/, ''),
|
||||
model: defModel,
|
||||
apiKey: ((ig.newapi && ig.newapi.apiKey) || process.env.NEWAPI_KEY || '')
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { getSettings, saveSettings, maskKey, settingsPath, resolveVideoGen };
|
||||
@@ -365,17 +365,21 @@ async function stripSubtitleAudio(input, output, { removeAudio = true, removeSub
|
||||
* AI 生成视频素材装配(分段:图 + 该段字幕 + 该段配音)
|
||||
* @param {object} seg { imagePath, subtitle, ttsFile, duration } duration=该段秒数
|
||||
*/
|
||||
async function buildSegment(seg, outPath, { width = 1920, height = 1080, fontSizePct = 5 } = {}) {
|
||||
async function buildSegment(seg, outPath, { width = 1920, height = 1080, fontSizePct = 5, subtitleStyle = {} } = {}) {
|
||||
const dir = tmpDir();
|
||||
try {
|
||||
const tFile = path.join(dir, 'sub.txt');
|
||||
fs.writeFileSync(tFile, seg.subtitle || '', 'utf8');
|
||||
const textFile = tFile;
|
||||
const fontSize = Math.max(12, Math.round((height * fontSizePct) / 100));
|
||||
const fontSize = Math.max(12, Math.round((height * (subtitleStyle.fontSizePct || fontSizePct)) / 100));
|
||||
const color = subtitleStyle.color || 'white';
|
||||
const pos = subtitleStyle.position || 'bottom-center';
|
||||
const yExpr = pos.startsWith('top') ? 'h*0.07' : pos === 'center' ? '(h-text_h)/2' : 'h-text_h-h*0.07';
|
||||
const xExpr = pos.endsWith('left') ? 'w*0.05' : pos.endsWith('right') ? 'w-text_w-w*0.05' : '(w-text_w)/2';
|
||||
const vf = [
|
||||
`scale=${width}:${height}:force_original_aspect_ratio=decrease`,
|
||||
`pad=${width}:${height}:(ow-iw)/2:(oh-ih)/2:color=black`,
|
||||
`drawtext=fontfile=/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc:textfile=${textFile}:fontsize=${fontSize}:fontcolor=white@0.95:borderw=2:bordercolor=black@0.6:x=(w-text_w)/2:y=h-text_h-h*0.07:line_spacing=8`
|
||||
`drawtext=fontfile=/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc:textfile=${textFile}:fontsize=${fontSize}:fontcolor=${color}@0.95:borderw=2:bordercolor=black@0.6:x=${xExpr}:y=${yExpr}:line_spacing=8`
|
||||
].join(',');
|
||||
|
||||
const args = [
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ services:
|
||||
- HUB_API_KEY=${HUB_API_KEY:-}
|
||||
- NEWAPI_KEY=${NEWAPI_KEY:-}
|
||||
# 当前站点版本(与 frontend/package.json、CHANGELOG 保持一致,界面版本徽标来源)
|
||||
- SITE_VERSION=1.4.8
|
||||
- SITE_VERSION=1.4.9
|
||||
# 让容器经 host.docker.internal 访问宿主机的 AI 侧车
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import {
|
||||
X, Wand2, Loader2, Download, Save, RefreshCw, Sparkles,
|
||||
ChevronDown, FolderOpen, CheckCircle2, AlertTriangle
|
||||
ChevronDown, FolderOpen, CheckCircle2, AlertTriangle,
|
||||
Image as ImageIcon, Search, Plus, Trash2
|
||||
} from 'lucide-react';
|
||||
import { aigenAPI, fileAPI, imageAPI } from '../api';
|
||||
import { useLibraryStore } from '../stores/useLibraryStore';
|
||||
@@ -11,7 +12,7 @@ import { PROMPT_CATEGORIES } from '../constants/promptPresets';
|
||||
/**
|
||||
* AI 生图弹窗
|
||||
* - 热门提示词分类(点击填入/追加)
|
||||
* - 内置模型(NewAPI:CF Workers AI / Pollinations)+ 自定义提供商
|
||||
* - 通道与模型统一在「设置 → AI 生图」配置,弹窗不再重复选择
|
||||
* - 生成 → 预览 → 保存到素材库 / 下载 / 重新生成
|
||||
*/
|
||||
|
||||
@@ -34,12 +35,9 @@ export default function AIGenModal({ open, onClose, onSaved }) {
|
||||
|
||||
const [prompt, setPrompt] = useState('');
|
||||
const [cat, setCat] = useState('hot');
|
||||
const [groups, setGroups] = useState([]);
|
||||
const [sizes, setSizes] = useState([]);
|
||||
const [providerInfo, setProviderInfo] = useState(null);
|
||||
const [model, setModel] = useState('flux-schnell');
|
||||
const [size, setSize] = useState('1024x1024');
|
||||
const [useCustom, setUseCustom] = useState(false);
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState('');
|
||||
@@ -49,6 +47,13 @@ export default function AIGenModal({ open, onClose, onSaved }) {
|
||||
const [saved, setSaved] = useState(false);
|
||||
const [showFolderPick, setShowFolderPick] = useState(false);
|
||||
const [advanced, setAdvanced] = useState(false);
|
||||
|
||||
// 参考图(以图生图)
|
||||
const [refs, setRefs] = useState([]); // [{ path, filename, thumbnailPath }]
|
||||
const [showRefPicker, setShowRefPicker] = useState(false);
|
||||
const [refList, setRefList] = useState([]);
|
||||
const [refQuery, setRefQuery] = useState('');
|
||||
const [refLoading, setRefLoading] = useState(false);
|
||||
const imgRef = useRef(null);
|
||||
|
||||
// 打开时拉模型列表 + 当前配置
|
||||
@@ -57,19 +62,57 @@ export default function AIGenModal({ open, onClose, onSaved }) {
|
||||
setError('');
|
||||
setResult(null);
|
||||
setSaved(false);
|
||||
setRefs([]);
|
||||
setShowRefPicker(false);
|
||||
setRefQuery('');
|
||||
aigenAPI.getModels()
|
||||
.then((d) => {
|
||||
setGroups(d.groups || []);
|
||||
setSizes(d.sizes || []);
|
||||
setProviderInfo(d.provider || null);
|
||||
const first = (d.groups || [])[0];
|
||||
if (first && first.models && first.models[0]) setModel(first.models[0].id);
|
||||
if (d.provider && d.provider.type === 'custom') setUseCustom(true);
|
||||
})
|
||||
.catch((e) => setError('读取模型列表失败: ' + (e.data?.error || e.message)));
|
||||
}, [open]);
|
||||
|
||||
const currentModelId = useCustom ? (providerInfo?.customModel || '') : model;
|
||||
/** 素材库缩略图地址 */
|
||||
const thumbUrl = (img) => {
|
||||
if (!img || !currentLibraryId) return '';
|
||||
const raw = img.thumbnailPath || img.path || img.filename || '';
|
||||
const fn = String(raw).replace(/\\/g, '/').split('/').pop();
|
||||
return `/api/image/thumbnail/${currentLibraryId}/${encodeURIComponent(fn)}`;
|
||||
};
|
||||
|
||||
/** 打开素材库选图:读当前库的图片(只图片,不含视频) */
|
||||
const openRefPicker = async () => {
|
||||
setShowRefPicker(true);
|
||||
setRefLoading(true);
|
||||
setRefList([]);
|
||||
try {
|
||||
const resp = await imageAPI.search(currentLibraryId, { limit: 200, offset: 0, q: refQuery || undefined });
|
||||
const list = (resp.images || []).filter((it) => {
|
||||
const t = String(it.fileType || it.type || '').toLowerCase();
|
||||
if (t === 'video') return false;
|
||||
const ext = String(it.filename || it.path || '').split('.').pop().toLowerCase();
|
||||
return !['mp4', 'mov', 'mkv', 'webm', 'avi', 'm4v', 'ts', 'flv'].includes(ext);
|
||||
});
|
||||
setRefList(list);
|
||||
} catch (e) {
|
||||
setError('读取素材库图片失败: ' + (e.data?.error || e.message));
|
||||
} finally {
|
||||
setRefLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const isPickedRef = (img) => refs.some((r) => r.path === img.path);
|
||||
|
||||
const toggleRef = (img) => {
|
||||
setError('');
|
||||
if (isPickedRef(img)) {
|
||||
setRefs((prev) => prev.filter((r) => r.path !== img.path));
|
||||
return;
|
||||
}
|
||||
if (refs.length >= 4) { setError('最多选 4 张参考图'); return; }
|
||||
setRefs((prev) => [...prev, img]);
|
||||
};
|
||||
const handleGenerate = async () => {
|
||||
if (!prompt.trim()) { setError('请先输入提示词,或点一个热门提示词'); return; }
|
||||
setLoading(true);
|
||||
@@ -78,9 +121,9 @@ export default function AIGenModal({ open, onClose, onSaved }) {
|
||||
try {
|
||||
const d = await aigenAPI.generate({
|
||||
prompt: prompt.trim(),
|
||||
model: useCustom ? undefined : model,
|
||||
size,
|
||||
provider: useCustom ? 'custom' : 'builtin'
|
||||
libraryId: currentLibraryId,
|
||||
refImages: refs.map((r) => ({ path: r.path, filename: r.filename })),
|
||||
});
|
||||
const img = d.images && d.images[0];
|
||||
if (!img || !img.b64) throw new Error('未返回图片数据');
|
||||
@@ -138,19 +181,19 @@ export default function AIGenModal({ open, onClose, onSaved }) {
|
||||
};
|
||||
|
||||
const appendPrompt = (p) => {
|
||||
setPrompt((prev) => (prev.trim() ? prev.replace(/[,,、\s]+$/, '') + ',' + p : p));
|
||||
setPrompt(p);
|
||||
setError('');
|
||||
};
|
||||
|
||||
if (!open) return null;
|
||||
|
||||
const activeCat = PROMPT_CATEGORIES.find((c) => c.key === cat) || PROMPT_CATEGORIES[0];
|
||||
const noKey = providerInfo && !providerInfo.hasKey && !useCustom;
|
||||
const noKey = providerInfo && !providerInfo.hasKey && providerInfo.type !== 'custom';
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4" onClick={onClose}>
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4">
|
||||
<div
|
||||
className="bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-5xl max-h-[90vh] overflow-hidden flex flex-col"
|
||||
className="bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-[98vw] h-[98vh] max-w-none max-h-none overflow-hidden flex flex-col"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{/* 头部 */}
|
||||
@@ -217,7 +260,9 @@ export default function AIGenModal({ open, onClose, onSaved }) {
|
||||
<div className="text-xs font-medium text-gray-800 dark:text-gray-200 truncate group-hover:text-purple-700 dark:group-hover:text-purple-300">
|
||||
{p.name}
|
||||
</div>
|
||||
<div className="text-[10px] text-gray-400 dark:text-gray-500 truncate">{p.prompt}</div>
|
||||
<div className="mt-0.5 text-[10px] leading-4 text-gray-400 dark:text-gray-500 line-clamp-2 group-hover:text-gray-500 dark:group-hover:text-gray-400">
|
||||
{p.prompt}
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
@@ -226,61 +271,70 @@ export default function AIGenModal({ open, onClose, onSaved }) {
|
||||
|
||||
{/* 右:参数 + 生成 */}
|
||||
<div className="lg:col-span-2 space-y-3.5">
|
||||
{/* 提供商 */}
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1.5">模型提供商</label>
|
||||
<select
|
||||
value={useCustom ? 'custom' : 'builtin'}
|
||||
onChange={(e) => setUseCustom(e.target.value === 'custom')}
|
||||
className="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100"
|
||||
{/* 通道/模型已统一在设置里配置,此处不再重复选择 */}
|
||||
<div className="flex items-center justify-between px-3 py-2 rounded-lg bg-gray-50 dark:bg-gray-900/40 border border-gray-200 dark:border-gray-700">
|
||||
<span className="text-[11px] text-gray-500 dark:text-gray-400">
|
||||
通道与模型在右上角「设置 → AI 生图」配置
|
||||
</span>
|
||||
<button
|
||||
onClick={() => window.dispatchEvent(new CustomEvent('open:settings', { detail: { tab: 'aigen' } }))}
|
||||
className="text-[11px] text-purple-600 dark:text-purple-400 hover:underline flex-shrink-0 ml-2"
|
||||
>
|
||||
<option value="builtin">内置 NewAPI(Pollinations + CF Workers AI)</option>
|
||||
<option value="custom" disabled={!providerInfo?.customModel && !providerInfo?.customUrl}>
|
||||
自定义提供商{providerInfo?.customModel ? `(${providerInfo.customModel})` : '(未配置)'}
|
||||
</option>
|
||||
</select>
|
||||
{providerInfo && !providerInfo.hasKey && !useCustom && (
|
||||
<div className="mt-1.5 flex items-start gap-1.5 text-[11px] text-amber-600 dark:text-amber-400">
|
||||
<AlertTriangle className="w-3.5 h-3.5 flex-shrink-0 mt-px" />
|
||||
<span>
|
||||
未配置 API Key。到「设置 → AI 生图」填写,或由服务器环境变量注入。
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
去设置
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* 模型 */}
|
||||
{!useCustom && (
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1.5">模型</label>
|
||||
<select
|
||||
value={model}
|
||||
onChange={(e) => setModel(e.target.value)}
|
||||
className="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100"
|
||||
>
|
||||
{groups.map((g) => (
|
||||
<optgroup key={g.key} label={g.label}>
|
||||
{g.models.map((m) => (
|
||||
<option key={m.id} value={m.id}>{m.name}</option>
|
||||
))}
|
||||
</optgroup>
|
||||
))}
|
||||
</select>
|
||||
{noKey && (
|
||||
<div className="flex items-start gap-1.5 text-[11px] text-amber-600 dark:text-amber-400">
|
||||
<AlertTriangle className="w-3.5 h-3.5 flex-shrink-0 mt-px" />
|
||||
<span>未配置 API Key。到「设置 → AI 生图」填写,或由服务器环境变量注入。</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{useCustom && (
|
||||
<div className="p-3 bg-amber-50 dark:bg-amber-500/10 border border-amber-200 dark:border-amber-500/30 rounded-lg text-xs text-amber-700 dark:text-amber-300">
|
||||
使用设置中配置的自定义提供商({providerInfo?.customUrl || '未配置地址'})。
|
||||
模型:{providerInfo?.customModel || '(未配置)'}
|
||||
<button
|
||||
onClick={() => window.dispatchEvent(new CustomEvent('open:settings', { detail: { tab: 'aigen' } }))}
|
||||
className="ml-1 underline hover:text-amber-900 dark:hover:text-amber-100"
|
||||
>
|
||||
去配置
|
||||
</button>
|
||||
{/* 参考图:以图生图 */}
|
||||
<div>
|
||||
<div className="flex items-center justify-between mb-1.5">
|
||||
<label className="text-xs font-medium text-gray-500 dark:text-gray-400">
|
||||
参考图(以图生图){refs.length > 0 && <span className="text-purple-600 dark:text-purple-400">· 已选 {refs.length}/4</span>}
|
||||
</label>
|
||||
{refs.length > 0 && (
|
||||
<button
|
||||
onClick={() => setRefs([])}
|
||||
className="text-[11px] text-gray-400 hover:text-red-500 flex items-center gap-0.5"
|
||||
>
|
||||
<Trash2 className="w-3 h-3" />清空
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<div className="flex items-center gap-1.5 flex-wrap">
|
||||
{refs.map((r, i) => (
|
||||
<div key={r.path || i} className="relative w-14 h-14 rounded-lg overflow-hidden border border-gray-200 dark:border-gray-600">
|
||||
<img src={thumbUrl(r)} alt={r.filename || ''} className="w-full h-full object-cover" />
|
||||
<button
|
||||
onClick={() => toggleRef(r)}
|
||||
className="absolute top-0 right-0 p-0.5 bg-black/60 text-white rounded-bl"
|
||||
title="移除"
|
||||
>
|
||||
<X className="w-3 h-3" />
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
{refs.length < 4 && (
|
||||
<button
|
||||
onClick={openRefPicker}
|
||||
className="w-14 h-14 rounded-lg border-2 border-dashed border-gray-300 dark:border-gray-600 text-gray-400 hover:border-purple-400 hover:text-purple-500 flex flex-col items-center justify-center gap-0.5"
|
||||
title="从素材库选择参考图"
|
||||
>
|
||||
<Plus className="w-4 h-4" />
|
||||
<span className="text-[9px]">选图</span>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<p className="mt-1 text-[11px] text-gray-400 dark:text-gray-500">
|
||||
{refs.length > 0
|
||||
? '将按参考图生成(自动切到 FLUX.2 图生图模型),图片只在本机读取,不上传到第三方'
|
||||
: '选 1-4 张素材库图片做参考,即可换背景、改风格、保持人物一致'}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* 尺寸 */}
|
||||
<div>
|
||||
@@ -323,7 +377,8 @@ export default function AIGenModal({ open, onClose, onSaved }) {
|
||||
|
||||
{loading && (
|
||||
<div className="text-[11px] text-gray-400 dark:text-gray-500 text-center">
|
||||
正在调用 {useCustom ? '自定义提供商' : (model || '')},超时上限 150 秒
|
||||
正在调用生图服务
|
||||
{refs.length > 0 ? '(以图生图,约 20-60 秒)' : ',超时上限 150 秒'}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -390,7 +445,7 @@ export default function AIGenModal({ open, onClose, onSaved }) {
|
||||
</button>
|
||||
{showFolderPick && (
|
||||
<>
|
||||
<div className="fixed inset-0 z-10" onClick={() => setShowFolderPick(false)}></div>
|
||||
<div className="fixed inset-0 z-10"></div>
|
||||
<div className="absolute left-0 bottom-full mb-1 z-20 w-64 max-h-64 overflow-y-auto bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-xl p-1">
|
||||
{flattenFolders(folders).map((f) => (
|
||||
<button
|
||||
@@ -427,6 +482,93 @@ export default function AIGenModal({ open, onClose, onSaved }) {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 素材库选图(以图生图) */}
|
||||
{showRefPicker && (
|
||||
<div
|
||||
className="fixed inset-0 z-[60] flex items-center justify-center bg-black/60 p-4"
|
||||
onClick={() => setShowRefPicker(false)}
|
||||
>
|
||||
<div
|
||||
className="bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-3xl max-h-[85vh] flex flex-col overflow-hidden"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-gray-700">
|
||||
<div className="flex items-center gap-2">
|
||||
<ImageIcon className="w-4 h-4 text-purple-500" />
|
||||
<h3 className="text-sm font-semibold text-gray-900 dark:text-white">从素材库选择参考图</h3>
|
||||
<span className="text-[11px] text-gray-400">已选 {refs.length}/4</span>
|
||||
</div>
|
||||
<button onClick={() => setShowRefPicker(false)} className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700">
|
||||
<X className="w-4 h-4 text-gray-500" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="px-4 py-2.5 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2">
|
||||
<div className="relative flex-1">
|
||||
<Search className="w-3.5 h-3.5 text-gray-400 absolute left-2.5 top-1/2 -translate-y-1/2" />
|
||||
<input
|
||||
value={refQuery}
|
||||
onChange={(e) => setRefQuery(e.target.value)}
|
||||
onKeyDown={(e) => { if (e.key === 'Enter') openRefPicker(); }}
|
||||
placeholder="搜索文件名,回车查询"
|
||||
className="w-full pl-8 pr-3 py-1.5 text-xs border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
onClick={openRefPicker}
|
||||
className="px-3 py-1.5 text-xs rounded-lg bg-purple-600 text-white hover:bg-purple-700"
|
||||
>
|
||||
查询
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 overflow-y-auto p-3">
|
||||
{refLoading ? (
|
||||
<div className="flex items-center justify-center py-16 text-xs text-gray-400 gap-2">
|
||||
<Loader2 className="w-4 h-4 animate-spin" />读取图片中…
|
||||
</div>
|
||||
) : refList.length === 0 ? (
|
||||
<div className="py-16 text-center text-xs text-gray-400">这个素材库里没有可选图片</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-4 sm:grid-cols-5 md:grid-cols-6 gap-2">
|
||||
{refList.map((img) => {
|
||||
const picked = isPickedRef(img);
|
||||
const idx = refs.findIndex((r) => r.path === img.path);
|
||||
return (
|
||||
<button
|
||||
key={img.path || img.filename}
|
||||
onClick={() => toggleRef(img)}
|
||||
title={img.filename || img.path}
|
||||
className={`relative aspect-square rounded-lg overflow-hidden border-2 transition-all ${
|
||||
picked ? 'border-purple-500 ring-2 ring-purple-300' : 'border-transparent hover:border-gray-300'
|
||||
}`}
|
||||
>
|
||||
<img src={thumbUrl(img)} alt={img.filename || ''} className="w-full h-full object-cover" />
|
||||
{picked && (
|
||||
<span className="absolute top-1 left-1 w-5 h-5 rounded-full bg-purple-600 text-white text-[11px] flex items-center justify-center font-medium">
|
||||
{idx + 1}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between px-4 py-2.5 border-t border-gray-200 dark:border-gray-700">
|
||||
<span className="text-[11px] text-gray-400">点图多选,按点选顺序作为参考顺序</span>
|
||||
<button
|
||||
onClick={() => setShowRefPicker(false)}
|
||||
className="px-4 py-1.5 text-xs font-medium rounded-lg bg-purple-600 text-white hover:bg-purple-700"
|
||||
>
|
||||
完成
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ function AIVideoModal({ libraryId, images, onClose, onDone }) {
|
||||
const input = 'w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent';
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 bg-black bg-opacity-60 flex items-center justify-center p-4" onClick={(running || starting) ? undefined : onClose}>
|
||||
<div className="fixed inset-0 z-50 bg-black bg-opacity-60 flex items-center justify-center p-4">
|
||||
<div className="bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-lg max-h-[92vh] overflow-y-auto" onClick={(e) => e.stopPropagation()}>
|
||||
<div className="flex items-center justify-between px-5 py-4 border-b border-gray-200 dark:border-gray-700">
|
||||
<div className="flex items-center gap-2">
|
||||
|
||||
@@ -0,0 +1,391 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { X, Film, Loader2, CheckCircle2, AlertCircle, Link as LinkIcon, FileText, Image as ImageIcon, Sparkles, Search, Check, Settings } from 'lucide-react';
|
||||
import { getToken } from '../api/client';
|
||||
|
||||
const VOICES = [
|
||||
{ key: 'zh-CN-XiaoxiaoNeural', label: '晓晓(女声·自然)' },
|
||||
{ key: 'zh-CN-YunxiNeural', label: '云希(男声·温暖)' },
|
||||
{ key: 'zh-CN-YunjianNeural', label: '云健(男声·浑厚)' },
|
||||
{ key: 'zh-CN-XiaoyiNeural', label: '晓伊(女声·活泼)' },
|
||||
{ key: 'zh-CN-YunyangNeural', label: '云扬(男声·播音)' },
|
||||
];
|
||||
const RESOLUTIONS = [
|
||||
{ key: '1920x1080', label: '横屏 1920×1080' },
|
||||
{ key: '1080x1920', label: '竖屏 1080×1920' },
|
||||
];
|
||||
const SUBTITLE_STYLES = [
|
||||
{ key: 'bottom-center', label: '底部居中', position: 'bottom-center' },
|
||||
{ key: 'top-center', label: '顶部居中', position: 'top-center' },
|
||||
{ key: 'center', label: '画面中央', position: 'center' },
|
||||
];
|
||||
const SUBTITLE_COLORS = [
|
||||
{ key: 'white', label: '白色' },
|
||||
{ key: '#FFD700', label: '金色' },
|
||||
{ key: '#00FFCC', label: '青色' },
|
||||
];
|
||||
const POPULAR_PROMPTS = [
|
||||
'产品功能速览:开头 3 秒抛出用户痛点,逐条演示 3 个核心卖点与真实使用场景,配合界面录屏特写与前后对比,结尾出现品牌名与一句话 slogan,节奏明快,字幕醒目',
|
||||
'周末探店 vlog:从推门进店的第一视角开场,依次拍环境空镜、招牌菜特写、入口咀嚼的满足表情,穿插与店主的简短对话,轻快背景音乐,暖色调,结尾给出店名地址与推荐指数',
|
||||
'知识科普:先用一个反常识的问题抓住注意力,再分三步由浅入深讲解概念,每步配一个生活化类比和简单动画示意,最后用一句话总结并抛出延伸思考,语速适中,重点处放大字幕',
|
||||
'旅行日记:以清晨出发的车窗镜头开场,交替呈现沿途风景大远景、地标建筑仰拍、当地市集人文细节与个人打卡瞬间,配舒缓音乐和游记式旁白,结尾定格日落剪影并标注地点',
|
||||
'健身打卡:开场展示今日训练目标与身材对比,中间分组记录动作特写、重量数据和力竭瞬间,穿插教练指导与呼吸节奏提示,热血鼓点配乐,结尾打出训练总消耗与坚持天数',
|
||||
'美食制作:从食材摆盘的俯拍开场,按备料、烹饪、装盘三阶段推进,关键步骤给慢镜头特写(下锅滋响、拉丝、淋酱),配清晰步骤字幕,结尾成品 360 度展示与口感描述'
|
||||
];
|
||||
|
||||
function errText(e, fb) { if (!e) return fb; if (typeof e === 'string') return e; return e.message || JSON.stringify(e); }
|
||||
|
||||
function thumbUrl(libraryId, img) {
|
||||
const tp = img.thumbnailPath || '';
|
||||
const fn = tp ? tp.replace(/\\/g, '/').split('/').pop() : '';
|
||||
if (fn) return `/api/image/thumbnail/${libraryId}/${encodeURIComponent(fn)}${img.modifiedAt ? `?v=${img.modifiedAt}` : ''}`;
|
||||
return `/api/image/original/${libraryId}/${String(img.path || '').split('/').map(encodeURIComponent).join('/')}`;
|
||||
}
|
||||
|
||||
export default function AIVideoStudioModal({ libraryId, onClose, onDone }) {
|
||||
const [tab, setTab] = useState('prompt');
|
||||
const [title, setTitle] = useState('');
|
||||
const [content, setContent] = useState('');
|
||||
const [url, setUrl] = useState('');
|
||||
const [extracted, setExtracted] = useState(null);
|
||||
const [extracting, setExtracting] = useState(false);
|
||||
const [file, setFile] = useState(null);
|
||||
const [voice, setVoice] = useState(VOICES[0].key);
|
||||
const [resolution, setResolution] = useState('1920x1080');
|
||||
const [subtitlePos, setSubtitlePos] = useState('bottom-center');
|
||||
const [subtitleColor, setSubtitleColor] = useState('white');
|
||||
const [subtitleSize, setSubtitleSize] = useState(5);
|
||||
// 素材库图片选择(弹窗内直接挑选)
|
||||
const [libImgs, setLibImgs] = useState([]);
|
||||
const [libLoading, setLibLoading] = useState(false);
|
||||
const [keyword, setKeyword] = useState('');
|
||||
const [picked, setPicked] = useState([]);
|
||||
const [taskId, setTaskId] = useState('');
|
||||
const [task, setTask] = useState(null);
|
||||
const [error, setError] = useState('');
|
||||
const [starting, setStarting] = useState(false);
|
||||
const timerRef = { current: null };
|
||||
|
||||
const auth = { Authorization: `Bearer ${getToken()}` };
|
||||
|
||||
const loadImages = async (kw) => {
|
||||
setLibLoading(true);
|
||||
try {
|
||||
const q = new URLSearchParams({ libraryId: String(libraryId), offset: '0', limit: '120' });
|
||||
if (kw && kw.trim()) q.set('keywords', kw.trim());
|
||||
const r = await fetch(`/api/image?${q}`, { headers: auth });
|
||||
const d = await r.json();
|
||||
// 只允许图片做视频画面:视频文件当图传给 ffmpeg 会直接报 Option loop not found
|
||||
const VIDEO_EXT = ['mp4', 'mov', 'mkv', 'webm', 'avi', 'm4v', 'flv', 'wmv', 'ts'];
|
||||
setLibImgs(((d && d.data && d.data.images) || []).filter((i) => {
|
||||
if (!i || !i.path) return false;
|
||||
const t = String(i.fileType || i.type || '').toLowerCase();
|
||||
if (t === 'video') return false;
|
||||
const ext = String(i.filename || i.path).split('.').pop().toLowerCase();
|
||||
return !VIDEO_EXT.includes(ext);
|
||||
}));
|
||||
} catch (_) {
|
||||
setLibImgs([]);
|
||||
} finally {
|
||||
setLibLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => { if (libraryId) loadImages(''); }, [libraryId]);
|
||||
|
||||
const togglePick = (img) => {
|
||||
setPicked((list) => {
|
||||
const i = list.findIndex((x) => x.path === img.path);
|
||||
if (i >= 0) return list.filter((x) => x.path !== img.path);
|
||||
return [...list, img];
|
||||
});
|
||||
};
|
||||
|
||||
const poll = (id) => {
|
||||
const iv = setInterval(async () => {
|
||||
try {
|
||||
const r = await fetch(`/api/video/task/${id}`, { headers: { Authorization: `Bearer ${getToken()}` } });
|
||||
if (!r.ok) return;
|
||||
const d = await r.json();
|
||||
setTask(d);
|
||||
if (d.status === 'done' || d.status === 'error') {
|
||||
clearInterval(iv);
|
||||
if (d.status === 'done') setTimeout(() => { onDone && onDone(d.resultPath); onClose(); }, 1200);
|
||||
}
|
||||
} catch (_) {}
|
||||
}, 1500);
|
||||
timerRef.current = iv;
|
||||
};
|
||||
|
||||
const handleExtractUrl = async () => {
|
||||
setExtracting(true); setError('');
|
||||
try {
|
||||
const r = await fetch('/api/video/extract-url', { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${getToken()}` }, body: JSON.stringify({ url }) });
|
||||
const d = await r.json();
|
||||
if (!r.ok || d.error) throw new Error(errText(d.error, `失败 (${r.status})`));
|
||||
setExtracted(d);
|
||||
if (!title) setTitle(d.title || '');
|
||||
setContent(d.text || '');
|
||||
} catch (e) { setError(e.message); }
|
||||
finally { setExtracting(false); }
|
||||
};
|
||||
|
||||
const handleExtractDoc = async () => {
|
||||
if (!file) return;
|
||||
setExtracting(true); setError('');
|
||||
try {
|
||||
const fd = new FormData(); fd.append('file', file);
|
||||
const r = await fetch('/api/video/extract-doc', { method: 'POST', headers: { Authorization: `Bearer ${getToken()}` }, body: fd });
|
||||
const d = await r.json();
|
||||
if (!r.ok || d.error) throw new Error(errText(d.error, `失败 (${r.status})`));
|
||||
setExtracted(d);
|
||||
if (!title) setTitle(d.title || '');
|
||||
setContent(d.text || '');
|
||||
} catch (e) { setError(e.message); }
|
||||
finally { setExtracting(false); }
|
||||
};
|
||||
|
||||
const handleStart = async () => {
|
||||
setError('');
|
||||
if (!title.trim()) { setError('请填写视频标题'); return; }
|
||||
if (tab === 'images' && picked.length === 0) { setError('请先在「素材库图片」里选择至少 1 张'); return; }
|
||||
setStarting(true);
|
||||
try {
|
||||
const imgs = picked.length
|
||||
? picked.map((i) => ({ path: i.path, filename: i.filename, width: i.width, height: i.height }))
|
||||
: ((extracted && extracted.images) || []);
|
||||
const body = {
|
||||
libraryId, title: title.trim(),
|
||||
content: content.trim(),
|
||||
images: imgs,
|
||||
voice, resolution, extraPrompt: '',
|
||||
subtitleStyle: { position: subtitlePos, color: subtitleColor, fontSizePct: subtitleSize }
|
||||
};
|
||||
const r = await fetch('/api/video/aigenerate-text', { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${getToken()}` }, body: JSON.stringify(body) });
|
||||
const d = await r.json().catch(() => ({}));
|
||||
if (!r.ok || d.error) throw new Error(errText(d.error, `启动失败 (${r.status})`));
|
||||
setTaskId(d.taskId); poll(d.taskId);
|
||||
} catch (e) { setError(e.message || '启动失败'); }
|
||||
finally { setStarting(false); }
|
||||
};
|
||||
|
||||
const running = !!taskId && task && task.status === 'running';
|
||||
const failed = task && task.status === 'error';
|
||||
const done = task && task.status === 'done';
|
||||
|
||||
const input = 'w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent';
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 bg-black bg-opacity-60 flex items-center justify-center p-4">
|
||||
<div className="bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-[98vw] h-[98vh] max-w-none max-h-none overflow-y-auto" onClick={(e)=>e.stopPropagation()}>
|
||||
<div className="flex items-center justify-between px-5 py-4 border-b border-gray-200 dark:border-gray-700">
|
||||
<div className="flex items-center gap-2">
|
||||
<Film className="w-5 h-5 text-purple-500" />
|
||||
<h2 className="text-lg font-semibold text-gray-900 dark:text-gray-100">AI 一键生成视频</h2>
|
||||
</div>
|
||||
<button onClick={onClose} disabled={running||starting} className="p-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"><X className="w-5 h-5 text-gray-500" /></button>
|
||||
</div>
|
||||
<div className="p-5 space-y-4">
|
||||
{/* tabs */}
|
||||
<div className="flex gap-2 border-b border-gray-200 dark:border-gray-700 pb-2">
|
||||
{[
|
||||
{ k: 'prompt', l: '提示词', icon: Sparkles },
|
||||
{ k: 'url', l: '链接抓取', icon: LinkIcon },
|
||||
{ k: 'doc', l: '文档/PDF', icon: FileText },
|
||||
{ k: 'images', l: '素材库图片', icon: ImageIcon },
|
||||
].map(({ k, l, icon: Icon }) => (
|
||||
<button key={k} onClick={() => setTab(k)} className={`flex items-center gap-1 px-3 py-1.5 rounded-lg text-sm ${tab===k ? 'bg-purple-600 text-white' : 'bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300'}`}>
|
||||
<Icon className="w-4 h-4" /> {l}
|
||||
{k === 'images' && picked.length > 0 && <span className="ml-0.5 text-[10px] px-1 rounded bg-white/25">{picked.length}</span>}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{tab === 'prompt' && (
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">常用热门提示词</label>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{POPULAR_PROMPTS.map((p) => (
|
||||
<button key={p} onClick={() => { setContent(p); if (!title) setTitle(p.slice(0, 20)); }} className="px-3 py-1 text-xs rounded-full bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-purple-100 dark:hover:bg-purple-900/40">
|
||||
{p}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">提示词 / 内容</label>
|
||||
<textarea className={input} rows={4} value={content} onChange={(e) => setContent(e.target.value)} placeholder="描述你想要的视频内容…" />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{tab === 'url' && (
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">网页链接</label>
|
||||
<div className="flex gap-2">
|
||||
<input className={input} value={url} onChange={(e) => setUrl(e.target.value)} placeholder="https://..." />
|
||||
<button onClick={handleExtractUrl} disabled={extracting || !url} className="px-4 py-2 bg-blue-600 text-white rounded-lg text-sm disabled:opacity-50">
|
||||
{extracting ? '抓取中…' : '抓取'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{extracted && <p className="text-xs text-green-600">已抓取:{extracted.title}({extracted.images?.length || 0} 张图)</p>}
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">内容预览</label>
|
||||
<textarea className={input} rows={4} value={content} onChange={(e) => setContent(e.target.value)} />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{tab === 'doc' && (
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">上传 PDF / 文档</label>
|
||||
<input type="file" accept=".pdf,.txt,.md,.doc,.docx" onChange={(e) => setFile(e.target.files?.[0] || null)} />
|
||||
<button onClick={handleExtractDoc} disabled={extracting || !file} className="mt-2 px-4 py-2 bg-blue-600 text-white rounded-lg text-sm disabled:opacity-50">
|
||||
{extracting ? '识别中…' : 'AI 识别'}
|
||||
</button>
|
||||
</div>
|
||||
{extracted && <p className="text-xs text-green-600">已识别:{extracted.title}</p>}
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">内容预览</label>
|
||||
<textarea className={input} rows={4} value={content} onChange={(e) => setContent(e.target.value)} />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{tab === 'images' && (
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="relative flex-1">
|
||||
<Search className="w-4 h-4 text-gray-400 absolute left-2.5 top-1/2 -translate-y-1/2" />
|
||||
<input
|
||||
className={`${input} pl-8`}
|
||||
value={keyword}
|
||||
onChange={(e) => setKeyword(e.target.value)}
|
||||
onKeyDown={(e) => { if (e.key === 'Enter') loadImages(keyword); }}
|
||||
placeholder="搜索素材库图片(回车)"
|
||||
/>
|
||||
</div>
|
||||
<button onClick={() => loadImages(keyword)} className="px-3 py-2 text-sm rounded-lg border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">搜索</button>
|
||||
{picked.length > 0 && (
|
||||
<button onClick={() => setPicked([])} className="px-3 py-2 text-sm rounded-lg border border-gray-300 dark:border-gray-600 text-gray-500 hover:bg-gray-50 dark:hover:bg-gray-700">清空</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="max-h-64 overflow-y-auto rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/40 p-2">
|
||||
{libLoading && <div className="py-8 text-center text-sm text-gray-500"><Loader2 className="w-4 h-4 animate-spin inline mr-1" />加载图片…</div>}
|
||||
{!libLoading && libImgs.length === 0 && <div className="py-8 text-center text-sm text-gray-500">这个素材库还没有图片</div>}
|
||||
{!libLoading && libImgs.length > 0 && (
|
||||
<div className="grid grid-cols-4 sm:grid-cols-5 gap-2">
|
||||
{libImgs.map((img) => {
|
||||
const on = picked.some((x) => x.path === img.path);
|
||||
return (
|
||||
<button
|
||||
key={img.path}
|
||||
onClick={() => togglePick(img)}
|
||||
title={img.filename || img.path}
|
||||
className={`relative aspect-square rounded-lg overflow-hidden border-2 ${on ? 'border-purple-500 ring-2 ring-purple-300' : 'border-transparent hover:border-gray-300'}`}
|
||||
>
|
||||
<img src={thumbUrl(libraryId, img)} alt={img.filename || ''} className="w-full h-full object-cover" />
|
||||
{on && (
|
||||
<span className="absolute top-1 right-1 w-5 h-5 rounded-full bg-purple-600 text-white flex items-center justify-center">
|
||||
<Check className="w-3.5 h-3.5" />
|
||||
</span>
|
||||
)}
|
||||
{on && (
|
||||
<span className="absolute bottom-0 left-0 right-0 bg-purple-600/85 text-white text-[10px] py-0.5 truncate px-1">
|
||||
#{picked.findIndex((x) => x.path === img.path) + 1}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-xs text-gray-500 dark:text-gray-400">
|
||||
已选 {picked.length} 张(按点击顺序作为画面顺序);不选则按内容自动配图。
|
||||
</p>
|
||||
<textarea className={input} rows={2} value={content} onChange={(e) => setContent(e.target.value)} placeholder="补充说明(可选):想表达的主题、语气…" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">视频标题</label>
|
||||
<input className={input} value={title} onChange={(e) => setTitle(e.target.value)} placeholder="例如:产品速览 / 探店 vlog" maxLength={60} disabled={running||done} />
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">朗读音色</label>
|
||||
<select className={input} value={voice} onChange={(e) => setVoice(e.target.value)} disabled={running||done}>
|
||||
{VOICES.map((v) => <option key={v.key} value={v.key}>{v.label}</option>)}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">画幅</label>
|
||||
<select className={input} value={resolution} onChange={(e) => setResolution(e.target.value)} disabled={running||done}>
|
||||
{RESOLUTIONS.map((r) => <option key={r.key} value={r.key}>{r.label}</option>)}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-3 gap-3">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">字幕位置</label>
|
||||
<select className={input} value={subtitlePos} onChange={(e) => setSubtitlePos(e.target.value)} disabled={running||done}>
|
||||
{SUBTITLE_STYLES.map((s) => <option key={s.key} value={s.key}>{s.label}</option>)}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">字幕颜色</label>
|
||||
<select className={input} value={subtitleColor} onChange={(e) => setSubtitleColor(e.target.value)} disabled={running||done}>
|
||||
{SUBTITLE_COLORS.map((c) => <option key={c.key} value={c.key}>{c.label}</option>)}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">字幕字号</label>
|
||||
<input type="range" min={3} max={8} value={subtitleSize} onChange={(e) => setSubtitleSize(parseInt(e.target.value))} disabled={running||done} className="w-full" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-start gap-2 rounded-lg bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 px-3 py-2 text-xs text-gray-600 dark:text-gray-400">
|
||||
<Settings className="w-3.5 h-3.5 mt-0.5 flex-shrink-0" />
|
||||
<span>提供商 / 模型 / KEY 在右上角「设置 → AI 视频」里配置,普通文本模型即可;配音与字幕由本地合成。</span>
|
||||
</div>
|
||||
|
||||
{(running || done || failed) && (
|
||||
<div className={`rounded-lg border px-4 py-3 ${failed ? 'border-red-200 bg-red-50 dark:bg-red-900/20' : done ? 'border-green-200 bg-green-50 dark:bg-green-900/20' : 'border-blue-200 bg-blue-50 dark:bg-blue-900/20'}`}>
|
||||
<div className="flex items-center gap-2 text-sm">
|
||||
{failed ? <AlertCircle className="w-4 h-4 text-red-500" /> : done ? <CheckCircle2 className="w-4 h-4 text-green-500" /> : <Loader2 className="w-4 h-4 animate-spin text-blue-500" />}
|
||||
<span className={`font-medium ${failed ? 'text-red-700 dark:text-red-300' : done ? 'text-green-700 dark:text-green-300' : 'text-blue-700 dark:text-blue-300'}`}>
|
||||
{failed ? '生成失败' : done ? '生成完成' : (task?.stepLabel || '处理中')}
|
||||
</span>
|
||||
{running && <span className="ml-auto text-xs text-blue-600 dark:text-blue-300">{task?.progress || 0}%</span>}
|
||||
</div>
|
||||
{running && <div className="mt-2 h-1.5 bg-blue-100 dark:bg-blue-900/50 rounded-full overflow-hidden"><div className="h-full bg-blue-500 rounded-full transition-all" style={{ width: `${task?.progress || 0}%` }} /></div>}
|
||||
{failed && <p className="mt-1 text-xs text-red-600 dark:text-red-400">{task?.error}</p>}
|
||||
{done && task?.resultPath && <p className="mt-1 text-xs text-green-600 dark:text-green-400">已保存:{task.resultPath}</p>}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{error && <div className="text-sm text-red-600 bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-800 rounded-lg px-3 py-2">{error}</div>}
|
||||
|
||||
<div className="flex justify-end gap-3 pt-1">
|
||||
<button onClick={onClose} disabled={running||starting} className="px-4 py-2 text-sm rounded-lg border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50">
|
||||
{done ? '关闭' : '取消'}
|
||||
</button>
|
||||
{!running && !done && (
|
||||
<button onClick={handleStart} disabled={starting} className="px-5 py-2 text-sm rounded-lg bg-purple-600 hover:bg-purple-700 text-white font-medium disabled:opacity-50 flex items-center gap-2">
|
||||
{starting && <Loader2 className="w-4 h-4 animate-spin" />}
|
||||
{starting ? '启动中…' : '一键生成'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -169,7 +169,7 @@ function BatchRenameModal({ isOpen, folder, libraryId, scope, keywords, onClose,
|
||||
const modeInfo = MODES.find((m) => m.key === mode);
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4" onClick={handleClose}>
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4">
|
||||
<div
|
||||
className="bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-xl max-h-[90vh] overflow-hidden flex flex-col"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
|
||||
@@ -203,7 +203,7 @@ function BatchWatermarkModal({ isOpen, mode, folder, libraryId, onClose, onFinis
|
||||
: 0;
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4" onClick={handleClose}>
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4">
|
||||
<div
|
||||
className="bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect, useMemo, useRef } from 'react';
|
||||
import { Sun, Moon, Search, Filter, Sliders, RefreshCw, ScanLine, Star, Bell, Github, Settings, ExternalLink, Wand2 } from 'lucide-react';
|
||||
import { Sun, Moon, Search, Filter, Sliders, RefreshCw, ScanLine, Star, Bell, Github, Settings, ExternalLink, Wand2, Film } from 'lucide-react';
|
||||
import { useLibraryStore } from '../stores/useLibraryStore';
|
||||
import { useImageStore } from '../stores/useImageStore';
|
||||
import { useUIStore } from '../stores/useUIStore';
|
||||
@@ -9,6 +9,7 @@ import { useHub } from '../hooks/useHub';
|
||||
import { libraryAPI, scanAPI, watchAPI } from '../api';
|
||||
import SettingsModal from './SettingsModal';
|
||||
import AIGenModal from './AIGenModal';
|
||||
import AIVideoStudioModal from './AIVideoStudioModal';
|
||||
import { createLogger } from '../utils/logger';
|
||||
|
||||
const logger = createLogger('Header');
|
||||
@@ -33,12 +34,13 @@ function Header() {
|
||||
const [showSettings, setShowSettings] = useState(false);
|
||||
const [settingsTab, setSettingsTab] = useState('ocr');
|
||||
const [showAIGen, setShowAIGen] = useState(false);
|
||||
const [showAIVideo, setShowAIVideo] = useState(false);
|
||||
const searchDebounceRef = useRef(null);
|
||||
|
||||
// 授权系统 hub:版本 / 公告 / 在线人数
|
||||
const hub = useHub();
|
||||
const announcements = hub.announcements || [];
|
||||
const appVersion = hub.version ? `v${String(hub.version).replace(/^v/, '')}` : 'v1.4.8';
|
||||
const appVersion = hub.version ? `v${String(hub.version).replace(/^v/, '')}` : 'v1.4.9';
|
||||
|
||||
// 从全局 store 获取筛选状态
|
||||
const selectedFormats = filters.formats || [];
|
||||
@@ -410,6 +412,14 @@ function Header() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={() => setShowAIVideo(true)}
|
||||
title="AI 生成视频"
|
||||
className="p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors"
|
||||
>
|
||||
<Film className="w-5 h-5 text-purple-600 dark:text-purple-400" />
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => setShowAIGen(true)}
|
||||
title="AI 生图"
|
||||
@@ -432,6 +442,7 @@ function Header() {
|
||||
|
||||
<SettingsModal open={showSettings} onClose={() => setShowSettings(false)} versionLabel={appVersion} initialTab={settingsTab} />
|
||||
<AIGenModal open={showAIGen} onClose={() => setShowAIGen(false)} />
|
||||
{showAIVideo && <AIVideoStudioModal libraryId={currentLibraryId} onClose={() => setShowAIVideo(false)} onDone={() => { setShowAIVideo(false); window.location.reload(); }} />}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -671,7 +682,7 @@ function Header() {
|
||||
<div className="h-14 flex items-center justify-between px-6">
|
||||
<div className="flex-shrink-0">
|
||||
<h1 className="text-xl font-bold text-gray-900 dark:text-white">牛仔库</h1>
|
||||
<p className="text-xs text-gray-500 dark:text-gray-400">轻量快速的图片素材库管理</p>
|
||||
<p className="text-xs text-gray-500 dark:text-gray-400">轻量快速的素材库管理</p>
|
||||
</div>
|
||||
|
||||
{/* 搜索栏 */}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { X, ScanText, Info, Save, FlaskConical, Github, ExternalLink, Wand2 } from 'lucide-react';
|
||||
import { settingsAPI } from '../api';
|
||||
import { X, ScanText, Info, Save, FlaskConical, Github, ExternalLink, Wand2, Film } from 'lucide-react';
|
||||
import { settingsAPI, aigenAPI } from '../api';
|
||||
|
||||
const APP_VERSION = 'v1.4.8';
|
||||
const APP_VERSION = 'v1.4.9';
|
||||
const REPO_URL = 'https://gitea.88531.cn/jinghui/flypic';
|
||||
|
||||
/**
|
||||
@@ -17,6 +17,9 @@ export default function SettingsModal({ open, onClose, versionLabel, initialTab
|
||||
const [ig, setIg] = useState(null); // imagegen 配置
|
||||
const [igNewKey, setIgNewKey] = useState(''); // NewAPI 新密钥
|
||||
const [igCustomKey, setIgCustomKey] = useState(''); // 自定义提供商新密钥
|
||||
const [igGroups, setIgGroups] = useState([]); // 内置模型分组(默认模型下拉用)
|
||||
const [va, setVa] = useState(null); // AI 视频文本模型配置
|
||||
const [vaKey, setVaKey] = useState(''); // AI 视频新密钥
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [testing, setTesting] = useState(false);
|
||||
const [msg, setMsg] = useState(null); // { type, text }
|
||||
@@ -28,6 +31,7 @@ export default function SettingsModal({ open, onClose, versionLabel, initialTab
|
||||
setApiKeyInput('');
|
||||
setIgNewKey('');
|
||||
setIgCustomKey('');
|
||||
setVaKey('');
|
||||
settingsAPI.getSettings()
|
||||
.then((d) => { setCfg({
|
||||
provider: d?.provider || 'local',
|
||||
@@ -42,6 +46,7 @@ export default function SettingsModal({ open, onClose, versionLabel, initialTab
|
||||
provider: d?.imagegen?.provider || 'newapi',
|
||||
newapi: {
|
||||
url: d?.imagegen?.newapi?.url || 'http://192.168.68.19:3099/v1',
|
||||
model: d?.imagegen?.newapi?.model || 'flux-schnell',
|
||||
apiKeyMasked: d?.imagegen?.newapi?.apiKeyMasked || '',
|
||||
hasKey: !!d?.imagegen?.newapi?.hasKey
|
||||
},
|
||||
@@ -51,8 +56,20 @@ export default function SettingsModal({ open, onClose, versionLabel, initialTab
|
||||
apiKeyMasked: d?.imagegen?.custom?.apiKeyMasked || ''
|
||||
}
|
||||
});
|
||||
setVa({
|
||||
provider: d?.videoai?.provider === 'custom' ? 'custom' : 'inherit',
|
||||
custom: {
|
||||
url: d?.videoai?.custom?.url || '',
|
||||
model: d?.videoai?.custom?.model || '',
|
||||
apiKeyMasked: d?.videoai?.custom?.apiKeyMasked || '',
|
||||
configured: !!d?.videoai?.custom?.configured
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch((e) => setMsg({ type: 'error', text: '读取设置失败: ' + (e.data?.message || e.message) }));
|
||||
aigenAPI.getModels()
|
||||
.then((d) => setIgGroups(d.groups || []))
|
||||
.catch(() => setIgGroups([]));
|
||||
}, [open]);
|
||||
|
||||
if (!open) return null;
|
||||
@@ -77,6 +94,7 @@ export default function SettingsModal({ open, onClose, versionLabel, initialTab
|
||||
provider: ig.provider,
|
||||
newapi: {
|
||||
url: ig.newapi.url,
|
||||
model: ig.newapi.model || 'flux-schnell',
|
||||
apiKey: igNewKey || '' // 空 = 保持原密钥
|
||||
},
|
||||
custom: {
|
||||
@@ -85,6 +103,16 @@ export default function SettingsModal({ open, onClose, versionLabel, initialTab
|
||||
apiKey: igCustomKey || ''
|
||||
}
|
||||
}
|
||||
} : {}),
|
||||
...(va ? {
|
||||
videoai: {
|
||||
provider: va.provider,
|
||||
custom: {
|
||||
url: va.custom.url,
|
||||
model: va.custom.model,
|
||||
apiKey: vaKey || ''
|
||||
}
|
||||
}
|
||||
} : {})
|
||||
};
|
||||
const data = await settingsAPI.updateSettings(payload);
|
||||
@@ -105,8 +133,20 @@ export default function SettingsModal({ open, onClose, versionLabel, initialTab
|
||||
});
|
||||
}
|
||||
setApiKeyInput('');
|
||||
if (data?.videoai) {
|
||||
setVa({
|
||||
provider: data.videoai.provider === 'custom' ? 'custom' : 'inherit',
|
||||
custom: {
|
||||
url: data.videoai.custom?.url || '',
|
||||
model: data.videoai.custom?.model || '',
|
||||
apiKeyMasked: data.videoai.custom?.apiKeyMasked || '',
|
||||
configured: !!data.videoai.custom?.configured
|
||||
}
|
||||
});
|
||||
}
|
||||
setIgNewKey('');
|
||||
setIgCustomKey('');
|
||||
setVaKey('');
|
||||
setMsg({ type: 'ok', text: '已保存,新配置立即生效' });
|
||||
} catch (e) {
|
||||
setMsg({ type: 'error', text: '保存失败: ' + (e.data?.message || e.message) });
|
||||
@@ -142,11 +182,12 @@ export default function SettingsModal({ open, onClose, versionLabel, initialTab
|
||||
const menus = [
|
||||
{ key: 'ocr', label: 'OCR 识别', icon: ScanText },
|
||||
{ key: 'aigen', label: 'AI 生图', icon: Wand2 },
|
||||
{ key: 'videoai', label: 'AI 视频', icon: Film },
|
||||
{ key: 'about', label: '关于', icon: Info }
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4" onClick={onClose}>
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4">
|
||||
<div
|
||||
className="bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-3xl max-h-[85vh] overflow-hidden flex"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
@@ -174,7 +215,7 @@ export default function SettingsModal({ open, onClose, versionLabel, initialTab
|
||||
<div className="flex-1 p-6 overflow-y-auto">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<h2 className="text-lg font-semibold text-gray-900 dark:text-white">
|
||||
{active === 'ocr' ? 'OCR 识别设置' : active === 'aigen' ? 'AI 生图设置' : '关于'}
|
||||
{active === 'ocr' ? 'OCR 识别设置' : active === 'aigen' ? 'AI 生图设置' : active === 'videoai' ? 'AI 视频设置' : '关于'}
|
||||
</h2>
|
||||
<button onClick={onClose} className="p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700">
|
||||
<X className="w-5 h-5 text-gray-500" />
|
||||
@@ -343,6 +384,26 @@ export default function SettingsModal({ open, onClose, versionLabel, initialTab
|
||||
className="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1">默认模型</label>
|
||||
<select
|
||||
value={ig.newapi.model || 'flux-schnell'}
|
||||
onChange={(e) => setIg((v) => ({ ...v, newapi: { ...v.newapi, model: e.target.value } }))}
|
||||
className="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100"
|
||||
>
|
||||
{igGroups.map((g) => (
|
||||
<optgroup key={g.key} label={g.label}>
|
||||
{g.models.map((m) => (
|
||||
<option key={m.id} value={m.id}>{m.name}</option>
|
||||
))}
|
||||
</optgroup>
|
||||
))}
|
||||
{!igGroups.length && <option value="flux-schnell">FLUX.1 schnell(快速)</option>}
|
||||
</select>
|
||||
<p className="mt-1 text-[11px] text-gray-400 dark:text-gray-500">
|
||||
AI 生图弹窗使用此模型;选了参考图时后端自动切到 FLUX.2 图生图模型。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -395,6 +456,92 @@ export default function SettingsModal({ open, onClose, versionLabel, initialTab
|
||||
</div>
|
||||
)}
|
||||
|
||||
{active === 'videoai' && cfg && va && (
|
||||
<div className="space-y-5">
|
||||
<p className="text-xs text-gray-500 dark:text-gray-400">
|
||||
AI 视频用这个模型来写分镜脚本、把提示词/网页/文档内容组织成讲解稿(普通文本模型即可,无需多模态)。
|
||||
配音、字幕与成片合成由服务器本地完成。密钥只保存在本机,不出服务器。
|
||||
</p>
|
||||
|
||||
<div>
|
||||
<div className="text-xs font-medium text-gray-600 dark:text-gray-400 mb-2">文本模型来源</div>
|
||||
<div className="space-y-2">
|
||||
<label className="flex items-start gap-2.5 p-3 border border-gray-200 dark:border-gray-700 rounded-lg cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50">
|
||||
<input
|
||||
type="radio"
|
||||
className="mt-0.5"
|
||||
checked={va.provider === 'inherit'}
|
||||
onChange={() => setVa((v) => ({ ...v, provider: 'inherit' }))}
|
||||
/>
|
||||
<span>
|
||||
<span className="block text-sm font-medium text-gray-900 dark:text-white">复用「AI 生图」配置(推荐)</span>
|
||||
<span className="block text-xs text-gray-500 dark:text-gray-400 mt-0.5">用上面 AI 生图里的地址与 Key,无需重复填写</span>
|
||||
</span>
|
||||
</label>
|
||||
<label className="flex items-start gap-2.5 p-3 border border-gray-200 dark:border-gray-700 rounded-lg cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50">
|
||||
<input
|
||||
type="radio"
|
||||
className="mt-0.5"
|
||||
checked={va.provider === 'custom'}
|
||||
onChange={() => setVa((v) => ({ ...v, provider: 'custom' }))}
|
||||
/>
|
||||
<span>
|
||||
<span className="block text-sm font-medium text-gray-900 dark:text-white">单独配置提供商 / 模型 / Key</span>
|
||||
<span className="block text-xs text-gray-500 dark:text-gray-400 mt-0.5">任意 OpenAI 兼容 /v1/chat/completions 的文本模型</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{va.provider === 'custom' && (
|
||||
<div className="space-y-3 p-4 bg-gray-50 dark:bg-gray-900/50 rounded-lg border border-gray-200 dark:border-gray-700">
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1">接口地址(BASE URL)</label>
|
||||
<input
|
||||
type="text"
|
||||
value={va.custom.url}
|
||||
onChange={(e) => setVa((v) => ({ ...v, custom: { ...v.custom, url: e.target.value } }))}
|
||||
placeholder="https://api.openai.com/v1 或 http://192.168.68.19:3099/v1"
|
||||
className="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1">模型名称</label>
|
||||
<input
|
||||
type="text"
|
||||
value={va.custom.model}
|
||||
onChange={(e) => setVa((v) => ({ ...v, custom: { ...v.custom, model: e.target.value } }))}
|
||||
placeholder="mimo-v2.6-flash / gpt-4o-mini / qwen-plus ..."
|
||||
className="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1">API Key</label>
|
||||
<input
|
||||
type="password"
|
||||
value={vaKey}
|
||||
onChange={(e) => setVaKey(e.target.value)}
|
||||
placeholder={va.custom.apiKeyMasked ? `已配置(${va.custom.apiKeyMasked}),留空保持不变` : 'sk-... 或中转站 48 位令牌'}
|
||||
className="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex items-center gap-3">
|
||||
<button
|
||||
onClick={handleSave}
|
||||
disabled={saving}
|
||||
className="flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-lg disabled:opacity-50"
|
||||
>
|
||||
<Save className="w-4 h-4" />
|
||||
{saving ? '保存中...' : '保存'}
|
||||
</button>
|
||||
<span className="text-xs text-gray-400 dark:text-gray-500">保存后立即生效,无需重启</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{active === 'about' && (
|
||||
<div className="space-y-4 text-sm">
|
||||
<div className="flex items-center justify-between py-2 border-b border-gray-100 dark:border-gray-700">
|
||||
|
||||
@@ -138,7 +138,7 @@ function VideoEditModal({ file, libraryId, onClose, onDone }) {
|
||||
const input = 'w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent';
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 bg-black bg-opacity-60 flex items-center justify-center p-4" onClick={busy ? undefined : onClose}>
|
||||
<div className="fixed inset-0 z-50 bg-black bg-opacity-60 flex items-center justify-center p-4">
|
||||
<div className="bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-3xl max-h-[92vh] overflow-y-auto" onClick={(e) => e.stopPropagation()}>
|
||||
{/* 头部 */}
|
||||
<div className="flex items-center justify-between px-5 py-4 border-b border-gray-200 dark:border-gray-700 sticky top-0 bg-white dark:bg-gray-800 z-10">
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* AI 生图 · 常用热门提示词库
|
||||
* 分类 + 预设提示词(中英混合,flux 系模型对英文提示词效果更稳)
|
||||
* 点击条目 = 追加/替换输入框内容
|
||||
* 每条均为「主体 + 场景 + 光线 + 构图 + 风格 + 质量」的完整详细描述,点击即得可直接出图的提示词
|
||||
*/
|
||||
|
||||
export const PROMPT_CATEGORIES = [
|
||||
@@ -9,88 +10,88 @@ export const PROMPT_CATEGORIES = [
|
||||
key: 'hot',
|
||||
label: '🔥 热门',
|
||||
prompts: [
|
||||
{ name: '赛博朋克城市夜景', prompt: 'cyberpunk city at night, neon lights, rain reflections, flying cars, ultra detailed, cinematic lighting' },
|
||||
{ name: '治愈系猫咪', prompt: 'a fluffy cat sitting on windowsill, warm afternoon sunlight, soft focus, cozy atmosphere, photorealistic' },
|
||||
{ name: '水晶球微缩世界', prompt: 'miniature world inside a glass snow globe on wooden table, macro photography, dreamy bokeh, studio lighting' },
|
||||
{ name: '复古胶片人像', prompt: 'vintage film portrait, kodak portra 400, soft natural light, nostalgic mood, grain texture' },
|
||||
{ name: '极简几何壁纸', prompt: 'minimalist geometric wallpaper, pastel gradient colors, clean shapes, flat design, 4k' }
|
||||
{ name: '赛博朋克城市夜景', prompt: 'cyberpunk city street at night after rain, towering neon signs in chinese and japanese, colorful reflections on wet asphalt, flying cars leaving light trails in the sky, dense crowd with transparent umbrellas, volumetric fog, cinematic lighting, blade runner mood, ultra detailed, 8k, wide angle' },
|
||||
{ name: '治愈系猫咪', prompt: 'a fluffy orange cat curled up on a sunlit windowsill, warm golden hour afternoon light, dust particles floating in the air, sheer curtains gently blowing, potted plants nearby, soft focus background, cozy warm tones, photorealistic, 85mm lens, shallow depth of field, highly detailed fur' },
|
||||
{ name: '水晶球微缩世界', prompt: 'miniature snowy village inside a glass snow globe on a rustic wooden table, macro photography, tiny warm window lights glowing, dreamy bokeh, soft studio softbox lighting, sparkling snow dust, shallow depth of field, whimsical cozy atmosphere, ultra detailed, 8k' },
|
||||
{ name: '复古胶片人像', prompt: 'vintage film portrait of a young woman, kodak portra 400 film look, soft window light, nostalgic warm tones, subtle film grain, slightly faded colors, 1970s styling, gentle smile, shallow depth of field, 50mm lens, analog photography aesthetic' },
|
||||
{ name: '极简几何壁纸', prompt: 'minimalist geometric wallpaper with overlapping circles triangles and arches, pastel gradient of lavender peach and mint, clean flat design, subtle noise texture, balanced repeating composition, modern abstract background, no text, 4k' }
|
||||
]
|
||||
},
|
||||
{
|
||||
key: 'portrait',
|
||||
label: '👤 头像人像',
|
||||
prompts: [
|
||||
{ name: '动漫男头', prompt: 'anime boy avatar, short black hair, hoodie, city background at dusk, detailed illustration, vibrant colors' },
|
||||
{ name: '动漫女头', prompt: 'anime girl avatar, long silver hair, flower crown, soft pastel colors, clean lineart, studio ghibli style' },
|
||||
{ name: '3D 卡通头像', prompt: '3D cartoon avatar of a young man, Pixar style, round face, big eyes, soft studio lighting, plain background' },
|
||||
{ name: '写真级人像', prompt: 'professional headshot portrait, shallow depth of field, natural window light, high detail skin texture, 85mm lens' },
|
||||
{ name: '像素风头像', prompt: 'pixel art avatar, 64x64, retro game style, bold outlines, limited palette, cute expression' }
|
||||
{ name: '动漫男头', prompt: 'anime boy avatar, short messy black hair, oversized hoodie, city skyline at dusk in the background, detailed illustration, vibrant sunset colors, clean lineart, expressive eyes, upper body shot, japanese anime style, high quality' },
|
||||
{ name: '动漫女头', prompt: 'anime girl avatar, long silver hair, delicate flower crown, soft pastel colors, clean lineart, studio ghibli inspired style, gentle smile, dreamy floral background, detailed illustration, portrait framing, masterpiece quality' },
|
||||
{ name: '3D 卡通头像', prompt: '3D cartoon avatar of a young man, pixar style, round friendly face, big sparkling eyes, soft studio lighting, plain gradient background, smooth clay render, cute and approachable, octane render, high quality' },
|
||||
{ name: '写真级人像', prompt: 'professional headshot portrait, shallow depth of field, soft natural window light, high detail skin texture, 85mm f/1.8 lens, neutral clean background, sharp focus on eyes, commercial photography, subtle color grading' },
|
||||
{ name: '像素风头像', prompt: 'pixel art avatar, 64x64 grid, retro game style, bold clean outlines, limited 16 color palette, cute confident expression, symmetrical composition, nostalgic 8-bit vibe, crisp pixels, no anti-aliasing' }
|
||||
]
|
||||
},
|
||||
{
|
||||
key: 'wallpaper',
|
||||
label: '🖼 壁纸风景',
|
||||
prompts: [
|
||||
{ name: '雪山日出', prompt: 'snow mountain range at sunrise, golden alpenglow, crystal clear lake reflection, ultra wide angle, 8k landscape' },
|
||||
{ name: '海上星河', prompt: 'milky way over calm ocean, starry night, long exposure photography, deep blue tones, tranquil scene' },
|
||||
{ name: '梯田晨雾', prompt: 'terraced rice fields with morning mist, layered mountains, traditional chinese landscape painting mood, aerial view' },
|
||||
{ name: '梦幻森林', prompt: 'enchanted forest with glowing mushrooms and fireflies, volumetric light rays, fantasy atmosphere, highly detailed' },
|
||||
{ name: '沙漠驼队', prompt: 'camel caravan crossing golden sand dunes at sunset, long shadows, warm tones, national geographic style' }
|
||||
{ name: '雪山日出', prompt: 'snow mountain range at sunrise, golden alpenglow on the peaks, crystal clear alpine lake perfectly mirroring the mountains, wisps of mist, ultra wide angle, 8k landscape photography, cold blue shadows turning warm gold, dramatic sky' },
|
||||
{ name: '海上星河', prompt: 'milky way arching over a calm ocean at night, long exposure photography, thousands of stars, gentle glowing waves, deep blue tones, tranquil and vast scene, high detail astrophotography, horizon glow' },
|
||||
{ name: '梯田晨雾', prompt: 'terraced rice fields at dawn covered in morning mist, layered mountains fading into the distance, aerial drone view, traditional chinese landscape painting mood, soft light, serene atmosphere, green and grey tones, ultra detailed' },
|
||||
{ name: '梦幻森林', prompt: 'enchanted forest with glowing mushrooms and floating fireflies, volumetric light rays breaking through the canopy, moss covered ancient trees, fantasy atmosphere, magical blue and green glow, highly detailed digital art' },
|
||||
{ name: '沙漠驼队', prompt: 'camel caravan crossing golden sand dunes at sunset, long dramatic shadows, warm orange tones, national geographic style, vast desert horizon, rippled sand texture, wide cinematic shot, dusty air' }
|
||||
]
|
||||
},
|
||||
{
|
||||
key: 'anime',
|
||||
label: '✨ 动漫插画',
|
||||
prompts: [
|
||||
{ name: '樱花下的少女', prompt: 'anime girl under cherry blossom tree, petals falling, spring breeze, pastel colors, detailed anime illustration' },
|
||||
{ name: '机甲战士', prompt: 'giant mecha robot standing in ruined city, dramatic angle, sci-fi anime style, detailed mechanical parts, dynamic lighting' },
|
||||
{ name: '魔法使', prompt: 'young wizard casting spell, glowing runes, dark library background, fantasy anime illustration, vibrant magic effects' },
|
||||
{ name: '校园日常', prompt: 'anime scene of students walking home at sunset, warm orange sky, slice of life, clean lineart, makoto shinkai style' },
|
||||
{ name: '和风少女', prompt: 'girl in kimono holding wagashi, traditional japanese room, tatami, soft light, detailed anime art' }
|
||||
{ name: '樱花下的少女', prompt: 'anime girl standing under a cherry blossom tree, pink petals drifting in the spring breeze, soft pastel colors, backlit flowers, gentle smile, warm afternoon light, detailed anime illustration, masterpiece quality' },
|
||||
{ name: '机甲战士', prompt: 'giant mecha robot standing in a ruined city, dramatic low angle, sci-fi anime style, intricate mechanical parts, steam and sparks, dynamic lighting, floating dust, epic sense of scale, highly detailed' },
|
||||
{ name: '魔法使', prompt: 'young wizard casting a glowing spell, floating arcane runes, dark ancient library background, fantasy anime illustration, vibrant magic effects, rim lighting, sparkling light particles, dynamic pose' },
|
||||
{ name: '校园日常', prompt: 'anime scene of students walking home at sunset, warm orange sky with towering cumulus clouds, long shadows on the road, slice of life mood, clean lineart, makoto shinkai style, detailed background, nostalgic feeling' },
|
||||
{ name: '和风少女', prompt: 'girl in a colorful kimono holding japanese wagashi sweet, traditional tatami room with sliding shoji doors, soft diffused light, delicate fabric patterns, elegant and calm, detailed anime art' }
|
||||
]
|
||||
},
|
||||
{
|
||||
key: 'commerce',
|
||||
label: '🛍 电商海报',
|
||||
prompts: [
|
||||
{ name: '产品主图', prompt: 'product photography of a perfume bottle on marble pedestal, soft gradient background, studio lighting, luxury feel, high-end commercial shot' },
|
||||
{ name: '美食海报', prompt: 'gourmet burger with melted cheese, steam rising, dark moody background, commercial food photography, appetizing, sharp detail' },
|
||||
{ name: '双十一促销', prompt: 'e-commerce sale banner, red and gold color scheme, floating gift boxes and confetti, modern 3d render, festive atmosphere' },
|
||||
{ name: '化妆品展示', prompt: 'cosmetic serum bottle surrounded by fresh flowers and water drops, clean white background, fresh and natural, commercial photo' },
|
||||
{ name: '数码新品', prompt: 'smartphone floating above glowing platform, tech product render, blue and purple neon accents, futuristic commercial style' }
|
||||
{ name: '产品主图', prompt: 'product photography of a luxury perfume bottle on a white marble pedestal, soft gradient background, diffused studio lighting, subtle reflections, elegant high-end commercial shot, sharp detail, 8k, negative space for text' },
|
||||
{ name: '美食海报', prompt: 'gourmet burger with melted cheese and sesame bun, steam rising, dark moody background, dramatic side light, commercial food photography, fresh appetizing ingredients, sharp detail, shallow depth of field' },
|
||||
{ name: '双十一促销', prompt: 'e-commerce sale banner background, red and gold color scheme, floating gift boxes ribbons and confetti, modern 3d render, festive energetic atmosphere, glossy materials, studio lighting, empty center space for headline' },
|
||||
{ name: '化妆品展示', prompt: 'cosmetic serum bottle surrounded by fresh flowers and water droplets, clean white background, bright natural light, fresh and natural mood, commercial product photo, crisp detail, soft shadows' },
|
||||
{ name: '数码新品', prompt: 'smartphone floating above a glowing platform, tech product render, blue and purple neon accents, dark background with light streaks, futuristic commercial style, sharp reflections, high detail, 8k' }
|
||||
]
|
||||
},
|
||||
{
|
||||
key: 'icon3d',
|
||||
label: '🧊 图标3D',
|
||||
prompts: [
|
||||
{ name: '3D 立体图标', prompt: '3d icon of a treasure chest, glossy material, soft shadows, pastel gradient background, clay render style, cute and round' },
|
||||
{ name: '玻璃质感', prompt: 'glassmorphism 3d icon of cloud storage, translucent frosted glass, floating, soft studio light, clean background' },
|
||||
{ name: '卡通食物', prompt: 'cute 3d icon of a ramen bowl, kawaii style, thick outlines, vibrant colors, glossy plastic material' },
|
||||
{ name: '徽章印章', prompt: '3d golden badge icon with star, metallic material, embossed, dark blue background, premium look' },
|
||||
{ emoji: '🎮', name: '游戏手柄', prompt: '3d gamepad icon, retro controller, matte plastic material, playful colors, soft ambient occlusion, icon design' }
|
||||
{ name: '3D 立方图标', prompt: '3d icon of a treasure chest, glossy material, soft shadows, pastel gradient background, clay render style, cute rounded shapes, studio lighting, centered composition, app icon design, high quality' },
|
||||
{ name: '玻璃质感', prompt: 'glassmorphism 3d icon of cloud storage, translucent frosted glass, floating above a soft gradient, soft studio light, subtle refractions and highlights, clean minimal background, modern ui icon' },
|
||||
{ name: '卡通食物', prompt: 'cute 3d icon of a ramen bowl, kawaii style, thick outlines, vibrant colors, glossy plastic material, swirling steam on top, soft ambient occlusion, centered app icon' },
|
||||
{ name: '徽章印章', prompt: '3d golden badge icon with a star, metallic material, embossed details, dark blue background, premium look, soft rim light, centered composition, high quality render' },
|
||||
{ emoji: '🎮', name: '游戏手柄', prompt: '3d gamepad icon, retro controller, matte plastic material, playful colors, soft ambient occlusion, centered on pastel background, rounded cute style, icon design' }
|
||||
]
|
||||
},
|
||||
{
|
||||
key: 'art',
|
||||
label: '🎨 艺术风格',
|
||||
prompts: [
|
||||
{ name: '浮世绘海浪', prompt: 'great wave in ukiyo-e style, hokusai inspired, woodblock print texture, indigo blue palette, traditional japanese art' },
|
||||
{ name: '梵高星空', prompt: 'starry night style painting, swirling sky, thick brushstrokes, post-impressionism, oil painting texture' },
|
||||
{ name: '水彩花卉', prompt: 'delicate watercolor flowers, loose brushstrokes, soft edges, white background, botanical illustration style' },
|
||||
{ name: '低多边形', prompt: 'low poly landscape with pine forest and mountains, faceted geometry, vibrant sunset colors, digital art' },
|
||||
{ name: '水墨仙鹤', prompt: 'chinese ink wash painting of crane flying over lotus, minimal brush strokes, elegant, rice paper texture' }
|
||||
{ name: '浮世绘海浪', prompt: 'great wave cresting in ukiyo-e style, hokusai inspired, woodblock print texture, indigo blue palette, foamy claw-like spray, mount fuji in the distance, traditional japanese art, visible paper grain' },
|
||||
{ name: '梵高星空', prompt: 'starry night style painting, swirling turbulent sky, glowing yellow stars, dark cypress silhouette, thick impasto brushstrokes, post-impressionism, oil painting texture, vibrant blues and yellows' },
|
||||
{ name: '水彩花卉', prompt: 'delicate watercolor flowers, loose brushstrokes, soft bleeding edges, white background, botanical illustration style, pastel pink and green palette, airy composition, hand painted paper texture' },
|
||||
{ name: '低多边形', prompt: 'low poly landscape with pine forest and snow mountains, faceted geometry, vibrant sunset colors of orange and purple sky, clean triangles, stylized digital art' },
|
||||
{ name: '水墨仙鹤', prompt: 'chinese ink wash painting of a crane flying over a lotus pond, minimal confident brush strokes, elegant negative space, rice paper texture, subtle grey ink gradients, oriental aesthetic' }
|
||||
]
|
||||
},
|
||||
{
|
||||
key: 'scene',
|
||||
label: '🏠 室内场景',
|
||||
prompts: [
|
||||
{ name: '温馨书房', prompt: 'cozy home library with floor to ceiling bookshelves, leather armchair, warm lamp light, rainy window, photorealistic' },
|
||||
{ name: '北欧客厅', prompt: 'scandinavian living room, white walls, light wood furniture, large plants, natural daylight, interior design photo' },
|
||||
{ name: '咖啡角落', prompt: 'small cafe corner with espresso machine, pastries display, morning light through glass, hygge atmosphere' },
|
||||
{ name: '阁楼卧室', prompt: 'attic bedroom with slanted window, fairy lights, linen bedding, plants, soft morning light, aesthetic photo' },
|
||||
{ name: '赛博房间', prompt: 'futuristic bedroom with holographic screens, neon strip lights, minimalist furniture, cyberpunk interior' }
|
||||
{ name: '温馨书房', prompt: 'cozy home library with floor to ceiling bookshelves, leather armchair, warm lamp light, rainy window with droplets, photorealistic, warm amber tones, intimate atmosphere, detailed interior, 8k' },
|
||||
{ name: '北欧客厅', prompt: 'scandinavian living room, white walls, light oak furniture, large green plants, big windows with natural daylight, minimal decor, interior design photography, airy and clean, bright tones' },
|
||||
{ name: '咖啡角落', prompt: 'small cafe corner with an espresso machine and glass pastry display, morning sunlight streaming through the window, hygge atmosphere, warm wood tones, steam rising from a cup, photorealistic' },
|
||||
{ name: '阁楼卧室', prompt: 'attic bedroom with a slanted skylight window, fairy lights, linen bedding, potted plants, soft morning light, aesthetic cozy photo, muted tones, detailed textiles' },
|
||||
{ name: '赛博房间', prompt: 'futuristic bedroom with floating holographic screens, neon strip lights in cyan and magenta, minimalist furniture, cyberpunk interior, volumetric glow, detailed props, cinematic lighting' }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
Reference in new issue
Block a user