Files
flypic/frontend/src/components/SettingsModal.jsx
T
jinghui ecb28c3aa5 feat: 设置AI生图新增CF Workers AI免费额度与申请地址说明卡 (v1.4.12)
- 蓝色说明卡标注每日免费额度: 10000 neurons/天, 北京时间08:00重置, FLUX.1 schnell约10neurons/张≈每天约1000张免费文生图
- 两步申请地址: ① dash.cloudflare.com/sign-up 注册(免费无需信用卡) ② dash.cloudflare.com/profile/api-tokens 创建Token(Workers AI Run权限), 含Token创建提示
- 顶部简介同步补免费额度入口提示
- 浏览器实测信息卡/额度文案/两链接齐全, 截图核验布局无溢出截断
2026-11-19 22:38:57 +08:00

609 lines
31 KiB
React
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { useState, useEffect } from 'react';
import { X, ScanText, Info, Save, FlaskConical, Github, ExternalLink, Wand2, Film } from 'lucide-react';
import { settingsAPI, aigenAPI } from '../api';
const APP_VERSION = 'v1.4.12';
const REPO_URL = 'https://gitea.88531.cn/jinghui/flypic';
/**
* 设置弹窗:左侧菜单 + 右侧参数
* - OCR 识别:本地 tesseract / 线上接口切换、线上参数、测试
* - 关于:版本号 / 开源地址
*/
export default function SettingsModal({ open, onClose, versionLabel, initialTab }) {
const [active, setActive] = useState('ocr');
const [cfg, setCfg] = useState(null); // { provider, online:{url,model,apiKeyMasked} }
const [apiKeyInput, setApiKeyInput] = useState(''); // 新密钥(留空=保持原密钥)
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 }
useEffect(() => {
if (!open) return;
if (initialTab) setActive(initialTab);
setMsg(null);
setApiKeyInput('');
setIgNewKey('');
setIgCustomKey('');
setVaKey('');
settingsAPI.getSettings()
.then((d) => { setCfg({
provider: d?.provider || 'local',
online: {
url: d?.online?.url || 'https://ai.88531.cn/v1',
model: d?.online?.model || 'mimo-v2.6-flash',
apiKeyMasked: d?.online?.apiKeyMasked || ''
},
telemetry: d?.telemetry !== false
});
setIg({
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
},
custom: {
url: d?.imagegen?.custom?.url || '',
model: d?.imagegen?.custom?.model || '',
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;
const patch = (p) => setCfg((c) => ({ ...c, ...p, online: { ...c.online, ...(p.online || {}) } }));
const handleSave = async () => {
setSaving(true);
setMsg(null);
try {
const payload = {
ocr: {
provider: cfg.provider,
online: {
url: cfg.online.url,
model: cfg.online.model,
apiKey: apiKeyInput // 空字符串 = 保留原密钥
}
},
...(ig ? {
imagegen: {
provider: ig.provider,
newapi: {
url: ig.newapi.url,
model: ig.newapi.model || 'flux-schnell',
apiKey: igNewKey || '' // 空 = 保持原密钥
},
custom: {
url: ig.custom.url,
model: ig.custom.model,
apiKey: igCustomKey || ''
}
}
} : {}),
...(va ? {
videoai: {
provider: va.provider,
custom: {
url: va.custom.url,
model: va.custom.model,
apiKey: vaKey || ''
}
}
} : {})
};
const data = await settingsAPI.updateSettings(payload);
setCfg((c) => ({ ...(c || {}), ...data, online: { ...(c?.online || {}), ...(data?.online || {}) } }));
if (data?.imagegen) {
setIg({
provider: data.imagegen.provider || 'newapi',
newapi: {
url: data.imagegen.newapi?.url || '',
apiKeyMasked: data.imagegen.newapi?.apiKeyMasked || '',
hasKey: !!data.imagegen.newapi?.hasKey
},
custom: {
url: data.imagegen.custom?.url || '',
model: data.imagegen.custom?.model || '',
apiKeyMasked: data.imagegen.custom?.apiKeyMasked || ''
}
});
}
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) });
} finally {
setSaving(false);
}
};
const handleTest = async () => {
setTesting(true);
setMsg(null);
try {
// 若用户改了线上参数但没保存,测试时带上输入框内容
const apiKey = apiKeyInput || undefined;
const d = await settingsAPI.testOcr({
provider: cfg.provider,
url: cfg.online.url,
model: cfg.online.model,
...(cfg.provider === 'online' && apiKey ? { apiKey } : {})
});
if (d && typeof d.ms === 'number') {
setMsg({ type: 'ok', text: `识别成功(${d.ms}ms):${(d.text || '').slice(0, 80) || '(空)'}` });
} else {
setMsg({ type: 'error', text: (d && d.message) || '识别失败' });
}
} catch (e) {
setMsg({ type: 'error', text: '测试失败: ' + (e.data?.message || e.message) });
} finally {
setTesting(false);
}
};
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">
<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()}
>
{/* 左侧菜单 */}
<div className="w-44 flex-shrink-0 border-r border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50 p-3 flex flex-col">
<div className="text-sm font-semibold text-gray-900 dark:text-white px-2 py-2">设置</div>
{menus.map((m) => (
<button
key={m.key}
onClick={() => { setActive(m.key); setMsg(null); }}
className={`flex items-center gap-2 px-3 py-2.5 rounded-lg text-sm transition-colors ${
active === m.key
? 'bg-blue-50 dark:bg-blue-500/20 text-blue-700 dark:text-blue-300 font-medium'
: 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700'
}`}
>
<m.icon className="w-4 h-4" />
{m.label}
</button>
))}
</div>
{/* 右侧参数 */}
<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 === '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" />
</button>
</div>
{msg && (
<div className={`mb-4 px-3 py-2 rounded-lg text-sm ${
msg.type === 'ok' ? 'bg-green-50 text-green-700 dark:bg-green-500/15 dark:text-green-300'
: 'bg-red-50 text-red-700 dark:bg-red-500/15 dark:text-red-300'
}`}>{msg.text}</div>
)}
{active === 'ocr' && cfg && (
<div className="space-y-5">
<p className="text-sm text-gray-500 dark:text-gray-400">
OCR 用于「图内文字搜索」:识别图片中的文字并建立索引,扫描素材库时自动执行。
</p>
{/* 识别方式 */}
<div>
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">识别方式</label>
<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={cfg.provider === 'local'}
onChange={() => patch({ provider: 'local' })}
/>
<span>
<span className="block text-sm font-medium text-gray-900 dark:text-white">本地 OCR(tesseract)</span>
<span className="block text-xs text-gray-500 dark:text-gray-400 mt-0.5">免费离线,中英文识别,随容器内置,无需任何配置</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={cfg.provider === 'online'}
onChange={() => patch({ provider: 'online' })}
/>
<span>
<span className="block text-sm font-medium text-gray-900 dark:text-white">线上 OCR(视觉大模型)</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>
{/* 线上参数 */}
{cfg.provider === 'online' && (
<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">接口地址</label>
<input
type="text"
value={cfg.online.url}
onChange={(e) => patch({ online: { url: e.target.value } })}
placeholder="https://ai.88531.cn/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={cfg.online.model}
onChange={(e) => patch({ online: { model: e.target.value } })}
placeholder="mimo-v2.6-flash(默认)"
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={apiKeyInput}
onChange={(e) => setApiKeyInput(e.target.value)}
placeholder={cfg.online.apiKeyMasked ? `已配置(${cfg.online.apiKeyMasked}),留空保持不变` : 'sk-...'}
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>
<button
onClick={handleTest}
disabled={testing}
className="flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50"
>
<FlaskConical className="w-4 h-4" />
{testing ? '测试中...' : '测试识别'}
</button>
</div>
</div>
)}
{active === 'aigen' && cfg && ig && (
<div className="space-y-5">
<p className="text-xs text-gray-500 dark:text-gray-400">
AI 生图默认走内置 NewAPI(Pollinations + CF Workers AI 两个生图渠道,CF Workers AI 提供商可免费申请、每日有免费额度,见下方说明);也可以切换到自己的 OpenAI 兼容提供商。密钥只保存在本机,不出服务器。
</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={ig.provider === 'newapi'}
onChange={() => setIg((v) => ({ ...v, provider: 'newapi' }))}
/>
<span>
<span className="block text-sm font-medium text-gray-900 dark:text-white">内置 NewAPI(推荐)</span>
<span className="block text-xs text-gray-500 dark:text-gray-400 mt-0.5">
Pollinations / CF Workers AI 两大生图模型,开箱即用
{ig.newapi.hasKey ? ',Key 已配置' : ',未配置 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={ig.provider === 'custom'}
onChange={() => setIg((v) => ({ ...v, provider: 'custom' }))}
/>
<span>
<span className="block text-sm font-medium text-gray-900 dark:text-white">自定义提供商</span>
<span className="block text-xs text-gray-500 dark:text-gray-400 mt-0.5">任意 OpenAI 兼容 /v1/images/generations 接口(OpenAI、Stability、中转站等)</span>
</span>
</label>
</div>
</div>
{ig.provider === 'newapi' && (
<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">
{/* CF Workers AI 免费额度 + 申请地址 */}
<div className="p-3 rounded-lg bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800">
<div className="flex items-center gap-1.5 mb-1">
<span className="text-xs font-semibold text-blue-700 dark:text-blue-300">免费生图:Cloudflare Workers AI 提供商</span>
<span className="px-1.5 py-0.5 text-[10px] font-medium rounded bg-blue-600 text-white">每日免费额度</span>
</div>
<p className="text-[11px] leading-relaxed text-blue-600/90 dark:text-blue-300/85">
内置通道里的 CF Workers AI 提供商可自行免费申请:Workers 免费计划<strong className="font-medium">无需绑定信用卡</strong>,每天 10000 neurons 免费额度(北京时间每天 08:00 重置),FLUX.1 schnell 约 10 neurons/张,<strong className="font-medium">约合每天 1000 张免费文生图</strong>;DALL·E 3、FLUX 高质量等模型也走该额度。
</p>
<div className="mt-1.5 flex flex-wrap gap-x-4 gap-y-1 text-[11px]">
<a
href="https://dash.cloudflare.com/sign-up"
target="_blank"
rel="noreferrer"
className="text-blue-600 dark:text-blue-400 hover:underline font-medium"
>
① 注册 Cloudflare 账号(免费)→
</a>
<a
href="https://dash.cloudflare.com/profile/api-tokens"
target="_blank"
rel="noreferrer"
className="text-blue-600 dark:text-blue-400 hover:underline font-medium"
>
② 创建 API Token(Workers AI Run 权限)→
</a>
</div>
<p className="mt-1 text-[10px] text-blue-500/80 dark:text-blue-400/70">
Token 创建时直接选「Workers AI」预设模板即可,过期时间选 No expiration;申请到的 Token 填到下方 API Key 即可免费生图。
</p>
</div>
<div>
<label className="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1">接口地址</label>
<input
type="text"
value={ig.newapi.url}
onChange={(e) => setIg((v) => ({ ...v, newapi: { ...v.newapi, url: e.target.value } }))}
placeholder="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">API Key</label>
<input
type="password"
value={igNewKey}
onChange={(e) => setIgNewKey(e.target.value)}
placeholder={ig.newapi.apiKeyMasked ? `已配置(${ig.newapi.apiKeyMasked}),留空保持不变` : 'NewAPI 令牌(留空则用服务器环境变量)'}
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>
)}
{ig.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">接口地址</label>
<input
type="text"
value={ig.custom.url}
onChange={(e) => setIg((v) => ({ ...v, custom: { ...v.custom, url: e.target.value } }))}
placeholder="https://api.openai.com/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={ig.custom.model}
onChange={(e) => setIg((v) => ({ ...v, custom: { ...v.custom, model: e.target.value } }))}
placeholder="gpt-image-1 / flux-dev / stable-diffusion-xl ..."
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={igCustomKey}
onChange={(e) => setIgCustomKey(e.target.value)}
placeholder={ig.custom.apiKeyMasked ? `已配置(${ig.custom.apiKeyMasked}),留空保持不变` : 'sk-...'}
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 === '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">
<span className="text-gray-500 dark:text-gray-400">当前版本</span>
<span className="font-medium text-gray-900 dark:text-white">{versionLabel || APP_VERSION}</span>
</div>
<div className="flex items-center justify-between py-2 border-b border-gray-100 dark:border-gray-700">
<span className="text-gray-500 dark:text-gray-400">项目名称</span>
<span className="font-medium text-gray-900 dark:text-white">牛仔库</span>
</div>
<div className="flex items-center justify-between py-2">
<span className="text-gray-500 dark:text-gray-400">开源地址</span>
<a
href={REPO_URL}
target="_blank"
rel="noreferrer"
className="flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline"
>
<Github className="w-4 h-4" />
gitea.88531.cn/jinghui/flypic
<ExternalLink className="w-3 h-3" />
</a>
</div>
<p className="text-xs text-gray-400 dark:text-gray-500 pt-2">
牛仔库(FlyPic)基于 ZangXincz/FlyPic 二次开发,修复多项问题并新增 OCR 图内文字搜索、线上 OCR、授权系统接入等能力。
</p>
</div>
)}
</div>
</div>
</div>
);
}