2 Commits
Author SHA1 Message Date
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
jinghui c25f8b474c feat: AI生图弹窗新增生图模型点选 (v1.4.11)
- 弹窗按通道分组列出8个可选模型(CF Workers AI/Pollinations), 点击即选中高亮
- 所选模型存localStorage下次沿用; 自动初始化=设置默认模型
- generate带model参数(effModel=前端所选>设置默认), 后端加ALLOWED_MODELS白名单, 未知模型400
- 实测点选Pollinations动漫出图返回model=pollinations-flux-anime; 白名单拦截bogus-model
- 版本号4处升至1.4.11, CHANGELOG补条目
2026-11-19 14:38:18 +08:00
7 changed files with 121 additions and 17 deletions

No files matched your search

+11
View File
@@ -1,5 +1,16 @@
# 更新日志
## 2026-11-19 → v1.4.12
- ✨ **设置 → AI 生图新增「免费生图:Cloudflare Workers AI 提供商」说明卡**:标注每日免费额度(10000 neurons/天,北京时间 08:00 重置,FLUX.1 schnell 约 10 neurons/张 ≈ 每天约 1000 张),并给出两步申请地址——① 注册 Cloudflare 账号(免费、无需信用卡)② 创建 API Token(Workers AI Run 权限),含 Token 创建提示
- 顶部简介同步补充免费额度入口提示
## 2026-11-19 → v1.4.11
- ✨ **AI 生图弹窗新增「生图模型」点选**:按通道分组列出全部可选模型(CF Workers AI / Pollinations),点一下即选中并高亮,所选模型存 localStorage 下次沿用;自定义提供商则显示设置里配置的模型
- 生成时把所选模型带给后端(effModel = 前端所选 > 设置默认),后端加模型白名单校验,未知模型名直接 400
- 选了参考图时提示会自动切 FLUX.2 图生图模型;右上角保留「通道设置」入口
## 2026-11-19 → v1.4.10
- ✨ **提示词全中文化**:40 条图片预设新增中文详细提示词 promptCn(主体+场景+光线+构图+风格+质量),预设卡片、悬浮提示、点击填入全部显示中文;英文 prompt 字段保留作对照与翻译兜底
+9
View File
@@ -83,6 +83,12 @@ const EDIT_MODELS = [
{ id: 'flux-2-klein-4b', name: 'FLUX.2 Klein 4B(图生图·最省)' }
];
// 文生图允许的模型(内置分组 + 图生图专用),防止任意模型名打到上游
const ALLOWED_MODELS = new Set([
...BUILTIN_GROUPS.flatMap((g) => g.models.map((m) => m.id)),
...EDIT_MODELS.map((m) => m.id)
]);
const REF_EXTS = new Set(['.jpg', '.jpeg', '.png', '.webp', '.bmp', '.avif', '.gif']);
const MAX_REFS = 4;
const MIME_BY_EXT = {
@@ -236,6 +242,9 @@ router.post('/generate', asyncHandler(async (req, res) => {
if (!effKey) {
return res.status(400).json({ success: false, error: '未配置 NewAPI Key,请到设置 → AI 生图填写' });
}
if (effModel && !ALLOWED_MODELS.has(effModel)) {
return res.status(400).json({ success: false, error: `未知模型: ${effModel}` });
}
effModel = effModel || cur.model || 'flux-schnell'; // 默认模型统一在设置 → AI 生图里配
}
+1 -1
View File
@@ -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.10';
const SITE_VERSION = process.env.SITE_VERSION || '1.4.12';
const TIMEOUT_MS = 8000;
const state = {
+1 -1
View File
@@ -28,7 +28,7 @@ services:
- HUB_API_KEY=${HUB_API_KEY:-}
- NEWAPI_KEY=${NEWAPI_KEY:-}
# 当前站点版本(与 frontend/package.json、CHANGELOG 保持一致,界面版本徽标来源)
- SITE_VERSION=1.4.10
- SITE_VERSION=1.4.12
# 让容器经 host.docker.internal 访问宿主机的 AI 侧车
extra_hosts:
- "host.docker.internal:host-gateway"
+65 -12
View File
@@ -12,7 +12,7 @@ import { PROMPT_CATEGORIES } from '../constants/promptPresets';
/**
* AI 生图弹窗
* - 热门提示词分类(点击填入/追加)
* - 通道与模型统一在「设置 → AI 生图」配置,弹窗不再重复选择
* - 弹窗内点选生图模型(列表来自设置配置的模型分组),KEY/通道仍在「设置 → AI 生图」
* - 生成 → 预览 → 保存到素材库 / 下载 / 重新生成
*/
@@ -37,6 +37,8 @@ export default function AIGenModal({ open, onClose, onSaved }) {
const [cat, setCat] = useState('hot');
const [sizes, setSizes] = useState([]);
const [providerInfo, setProviderInfo] = useState(null);
const [modelGroups, setModelGroups] = useState([]); // 可选生图模型分组
const [selModel, setSelModel] = useState(''); // 用户点选的模型 id(空=设置默认)
const [size, setSize] = useState('1024x1024');
const [loading, setLoading] = useState(false);
@@ -69,6 +71,15 @@ export default function AIGenModal({ open, onClose, onSaved }) {
.then((d) => {
setSizes(d.sizes || []);
setProviderInfo(d.provider || null);
const groups = d.groups || [];
setModelGroups(groups);
const all = groups.flatMap((g) => (g.models || []).map((m) => m.id));
const p = d.provider || {};
// 自定义提供商:只有设置里填的那个模型可用
if (p.type === 'custom') { setSelModel(p.customModel || ''); return; }
const def = p.builtinModel || 'flux-schnell';
const saved = localStorage.getItem('flypic_aigen_model');
setSelModel(all.includes(saved) ? saved : (all.includes(def) ? def : (all[0] || def)));
})
.catch((e) => setError('读取模型列表失败: ' + (e.data?.error || e.message)));
}, [open]);
@@ -121,6 +132,7 @@ export default function AIGenModal({ open, onClose, onSaved }) {
try {
const d = await aigenAPI.generate({
prompt: prompt.trim(),
model: selModel || undefined,
size,
libraryId: currentLibraryId,
refImages: refs.map((r) => ({ path: r.path, filename: r.filename })),
@@ -271,17 +283,58 @@ export default function AIGenModal({ open, onClose, onSaved }) {
{/* 右:参数 + 生成 */}
<div className="lg:col-span-2 space-y-3.5">
{/* 通道/模型已统一在设置里配置,此处不再重复选择 */}
<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"
>
去设置
</button>
{/* 生图模型:列出可点选的模型 */}
<div className="px-3 py-2.5 rounded-lg bg-gray-50 dark:bg-gray-900/40 border border-gray-200 dark:border-gray-700">
<div className="flex items-center justify-between mb-2">
<span className="text-xs font-medium text-gray-500 dark:text-gray-400">生图模型</span>
<button
onClick={() => window.dispatchEvent(new CustomEvent('open:settings', { detail: { tab: 'aigen' } }))}
className="text-[11px] text-purple-600 dark:text-purple-400 hover:underline"
>
通道设置
</button>
</div>
{providerInfo && providerInfo.type === 'custom' ? (
<div className="flex flex-wrap gap-1.5">
<span className="px-2.5 py-1 rounded-full text-[11px] bg-purple-600 text-white border border-purple-600">
{providerInfo.customModel || '自定义模型'}
</span>
<span className="px-1 py-1 text-[11px] text-gray-400 dark:text-gray-500 self-center">
自定义提供商的模型在设置里配置
</span>
</div>
) : (
<div className="space-y-1.5">
{modelGroups.map((g) => (
<div key={g.key} className="flex items-start gap-2">
<span className="text-[10px] text-gray-400 dark:text-gray-500 w-[76px] flex-shrink-0 pt-1 leading-4">{g.label}</span>
<div className="flex flex-wrap gap-1.5">
{(g.models || []).map((m) => (
<button
key={m.id}
type="button"
title={m.id}
onClick={() => { setSelModel(m.id); localStorage.setItem('flypic_aigen_model', m.id); }}
className={`px-2.5 py-1 rounded-full text-[11px] border transition-colors ${selModel === m.id
? 'bg-purple-600 text-white border-purple-600'
: 'bg-white dark:bg-gray-800 text-gray-600 dark:text-gray-300 border-gray-200 dark:border-gray-600 hover:border-purple-400 hover:text-purple-600 dark:hover:text-purple-300'}`}
>
{m.name}
</button>
))}
</div>
</div>
))}
{!modelGroups.length && (
<span className="text-[11px] text-gray-400 dark:text-gray-500">读取模型列表中…</span>
)}
</div>
)}
{refs.length > 0 && (
<p className="mt-1.5 text-[11px] text-amber-600 dark:text-amber-400">
已选参考图:后端会自动切到 FLUX.2 图生图模型
</p>
)}
</div>
{noKey && (
<div className="flex items-start gap-1.5 text-[11px] text-amber-600 dark:text-amber-400">
+1 -1
View File
@@ -40,7 +40,7 @@ const [showAIVideo, setShowAIVideo] = useState(false);
// 授权系统 hub:版本 / 公告 / 在线人数
const hub = useHub();
const announcements = hub.announcements || [];
const appVersion = hub.version ? `v${String(hub.version).replace(/^v/, '')}` : 'v1.4.10';
const appVersion = hub.version ? `v${String(hub.version).replace(/^v/, '')}` : 'v1.4.12';
// 从全局 store 获取筛选状态
const selectedFormats = filters.formats || [];
+33 -2
View File
@@ -2,7 +2,7 @@ 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.10';
const APP_VERSION = 'v1.4.12';
const REPO_URL = 'https://gitea.88531.cn/jinghui/flypic';
/**
@@ -326,7 +326,7 @@ export default function SettingsModal({ open, onClose, versionLabel, initialTab
{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 两个生图渠道);也可以切换到自己的 OpenAI 兼容提供商。密钥只保存在本机,不出服务器。
AI 生图默认走内置 NewAPI(Pollinations + CF Workers AI 两个生图渠道,CF Workers AI 提供商可免费申请、每日有免费额度,见下方说明);也可以切换到自己的 OpenAI 兼容提供商。密钥只保存在本机,不出服务器。
</p>
<div>
@@ -364,6 +364,37 @@ export default function SettingsModal({ open, onClose, versionLabel, initialTab
{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