Skip to content

Commit 0d6d1ed

Browse files
committed
feat: 红墨 v1.4.1 更新日志 2025-12-29
【本次更新摘要】 - 新增文案生成功能(标题、正文、标签) - 新增一键启动脚本(macOS/Linux/Windows) - 修复历史记录保存机制 - 更新品牌 Logo - 代码质量优化 一、新功能 ---------- 1. 文案生成功能 - 新增 /api/content 接口,自动生成小红书标题、正文和标签 - 新增 ContentDisplay 组件,支持一键复制 - 新增 content_prompt.txt 提示词模板 新增文件: - backend/routes/content_routes.py - backend/services/content.py - backend/prompts/content_prompt.txt - frontend/src/components/result/ContentDisplay.vue 2. 一键启动脚本 - 支持 macOS、Linux、Windows 三平台 - 自动检测并安装依赖(uv、pnpm) - 自动启动前后端服务 - 自动打开浏览器 新增文件: - start.sh (macOS/Linux 入口) - start.bat (Windows 入口) - scripts/start-macos.command - scripts/start-linux.sh - scripts/start-windows.bat 3. 品牌 Logo 更新 - 全新设计的红墨 Logo(红色圆形 R + Redink) - 带 Slogan 横幅版本 新增文件: - images/1.png (Logo 标准版) - images/2.png (Logo + Slogan 横幅) - images/3.png (Logo 大图版) - frontend/public/logo-banner.png 二、Bug 修复 ------------ 1. 历史记录保存机制修复 - 大纲生成后立即创建历史记录(HomeView.vue) - 编辑大纲时自动保存,300ms 防抖(OutlineView.vue) - 跳转前强制保存未保存的修改(OutlineView.vue) - 统一使用 setRecordId() 方法赋值(4个 Vue 文件) 2. 端口配置统一 - 启动脚本端口显示从 5001 修正为 12398 - 修复文件: scripts/*.sh, scripts/*.bat 3. CSS 变量修复 - 修复 --text-secondary 未定义问题,改为 --text-sub - 修复文件: frontend/src/components/result/ContentDisplay.vue 4. API 性能优化 - checkHistoryExists 改用专用 /exists 端点 - 修复文件: frontend/src/api/index.ts 三、代码优化 ------------ 1. 清理未使用的代码 - 删除 3 个生成器文件中未使用的 retry_on_error 装饰器 - 清理相关的 import(time, random, wraps) - 修复文件: - backend/generators/google_genai.py - backend/generators/image_api.py - backend/generators/openai_compatible.py 2. 前端状态管理增强 - 新增 outlineStatus、lastSavedAt 字段 - 新增 setRecordId()、markSaved()、hasUnsavedChanges() 方法 - 修复文件: frontend/src/stores/generator.ts 3. 后端历史服务增强 - 新增 RecordStatus 状态常量 - 新增 record_exists() 方法 - 新增 /api/history/<id>/exists 端点 - 修复文件: - backend/services/history.py - backend/routes/history_routes.py 四、UI 更新 ----------- 1. 侧边栏 Logo - 更换为带 Slogan 的横幅 Logo - 作者头像改为红色渐变圆形 + "墨"字 - 修复文件: - frontend/src/App.vue - frontend/src/assets/css/base.css 2. README 更新 - 使用新 Logo 横幅 - 新增一键启动脚本说明 - 新增 v1.4.1 更新日志 ================================================================================ 文件变更统计 ================================================================================ 修改文件 (19个): - README.md - backend/generators/google_genai.py - backend/generators/image_api.py - backend/generators/openai_compatible.py - backend/routes/__init__.py - backend/routes/history_routes.py - backend/services/history.py - backend/services/image.py - frontend/public/logo.png - frontend/src/App.vue - frontend/src/api/index.ts - frontend/src/assets/css/base.css - frontend/src/stores/generator.ts - frontend/src/views/GenerateView.vue - frontend/src/views/HistoryView.vue - frontend/src/views/HomeView.vue - frontend/src/views/OutlineView.vue - frontend/src/views/ResultView.vue - images/logo.png 新增文件 (11个): - backend/prompts/content_prompt.txt - backend/routes/content_routes.py - backend/services/content.py - frontend/public/logo-banner.png - frontend/src/components/result/ContentDisplay.vue - images/1.png - images/2.png - images/3.png - scripts/start-macos.command - scripts/start-linux.sh - scripts/start-windows.bat - start.bat - start.sh 代码变更: +1417 行, -447 行 ================================================================================ 建议的 Commit Message ================================================================================ feat: v1.4.1 新增文案生成、一键启动脚本、Logo更新 - 新增文案生成功能(标题、正文、标签自动生成) - 新增一键启动脚本,支持 macOS/Linux/Windows - 更新品牌 Logo,新增带 Slogan 横幅版本 - 修复历史记录保存机制,大纲生成后立即保存 - 修复端口配置统一为 12398 - 清理后端生成器未使用的重试装饰器代码 - 优化 checkHistoryExists 接口性能
1 parent 72540cc commit 0d6d1ed

33 files changed

Lines changed: 2821 additions & 447 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,4 @@ debug_*.py
7878
# Dev notes
7979
DEV_NOTES.md
8080
commit_message.txt
81+
git-changelog.txt

README.md

Lines changed: 34 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,21 @@
1-
## 红墨官方站点上线啦,注册即送100体验积分(每日签到也会随机有40-100积分哦)
2-
31
<div align="center">
42

5-
### ✨ 仅开放注册 1000 名 ✨
3+
<img src="images/2.png" alt="红墨 - 灵感一触即发 让创作从未如此简单" width="600"/>
64

7-
**无需部署,立即体验红墨的强大功能!**
5+
## 红墨官方站点上线啦,注册即送50体验积分!
86

9-
---
7+
> ✨ 邀请好友来一起玩吧,你和好友都会有50积分! ✨
108
9+
<div align="center">
1110
<a href="https://redink.top">
1211
<img src="images/redink.png" alt="红墨在线体验" width="500" style="border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);"/>
1312
</a>
1413

15-
### [点击访问在线体验站 → Redink.top](https://redink.top)
14+
#### [点击访问在线体验站 → Redink.top](https://redink.top)
1615

17-
<sub>💡 点击图片或链接即可访问 | 🎯 限量开放,先到先得</sub>
1816

1917
</div>
2018

21-
---
22-
23-
<div align="center">
24-
25-
# 🎨 红墨 - 小红书AI图文生成器
26-
27-
### 让传播不再需要门槛,让创作从未如此简单
28-
29-
![](images/index.gif)
30-
31-
<sub>*红墨首页 - 一句话开启创作之旅*</sub>
32-
33-
---
34-
3519
<img src="images/showcase-grid.png" alt="使用红墨生成的各类小红书封面" width="700" style="border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.12);"/>
3620

3721
<sub>*使用红墨生成的各类小红书封面 - AI驱动,风格统一,文字准确*</sub>
@@ -40,58 +24,12 @@
4024

4125
---
4226

43-
## 💭 写在前面
44-
45-
前段时间默子在 Linux.do 发了一个用 Nano banana Pro 做 PPT 的帖子,收获了 **600+ 点赞**。很多人用 🍌 Nano banana Pro 去做产品宣传图、直接生成漫画等等。我就在想:
46-
47-
> **为什么不拿 🍌2 来做点更功利、更刺激的事情?**
48-
49-
于是就有了这个项目:**一句话 + 一张图片 = 完整小红书图文**
50-
51-
---
52-
5327
## ✨ 效果展示
5428

55-
### 📝 输入一句话,生成完整图文
56-
57-
<table>
58-
<tr>
59-
<td width="50%">
60-
61-
#### 🎯 输入示例
62-
63-
**提示词**:秋季显白美甲(暗广一个:默子牌美甲)
64-
65-
**参考图片**:上传小红书主页截图
66-
- ✅ 包含头像、签名、背景、姓名
67-
- ✅ 自动学习个人风格
68-
69-
</td>
70-
<td width="50%">
71-
72-
#### ⚡ 生成流程
73-
74-
1. **智能大纲** (10-20秒)
75-
- 自动拆分 6-9 页内容
76-
- 可自定义每页描述
77-
78-
2. **封面生成** (即时)
79-
- 风格统一的封面设计
80-
81-
3. **批量生成** (并发)
82-
- 最多 15 张图同时生成
83-
- 支持单独重新生成
84-
85-
</td>
86-
</tr>
87-
</table>
88-
89-
---
90-
91-
### 🖼️ 生成步骤展示
29+
### 输入一句话,生成完整图文
9230

9331
<details open>
94-
<summary><b>📋 Step 1: 智能大纲生成</b></summary>
32+
<summary><b>Step 1: 智能大纲生成</b></summary>
9533

9634
<br>
9735

@@ -233,6 +171,18 @@ pnpm install
233171

234172
### 5. 启动服务
235173

174+
#### 一键启动(推荐)
175+
176+
双击运行启动脚本,自动安装依赖并启动前后端:
177+
178+
- **macOS**: `start.sh` 或双击 `scripts/start-macos.command`
179+
- **Linux**: `./start.sh`
180+
- **Windows**: 双击 `start.bat`
181+
182+
启动后自动打开浏览器访问 http://localhost:5173
183+
184+
#### 手动启动
185+
236186
**启动后端:**
237187
```bash
238188
uv run python -m backend.app
@@ -248,22 +198,6 @@ pnpm dev
248198

249199
---
250200

251-
## 🎮 使用指南
252-
253-
### 基础使用
254-
1. **输入主题**: 在首页输入想要创作的主题,如"如何在家做拿铁"
255-
2. **生成大纲**: AI 自动生成 6-9 页的内容大纲
256-
3. **编辑确认**: 可以编辑和调整每一页的描述
257-
4. **生成图片**: 点击生成,实时查看进度
258-
5. **下载使用**: 一键下载所有图片
259-
260-
### 进阶使用
261-
- **上传参考图片**: 适合品牌方,保持品牌视觉风格
262-
- **修改描述词**: 精确控制每一页的内容和构图
263-
- **重新生成**: 对不满意的页面单独重新生成
264-
265-
---
266-
267201
## 🔧 配置说明
268202

269203
### 配置方式
@@ -347,15 +281,22 @@ providers:
347281

348282
如果这个项目对你有帮助,欢迎给个 Star ⭐
349283

350-
### 未来计划
351-
- [ ] 支持更多图片格式,例如一句话生成一套PPT什么的
352-
- [x] 历史记录管理优化
353-
- [ ] 导出为各种格式(PDF、长图等)
354284

355285
---
356286

357287
## 更新日志
358288

289+
### v1.4.1 (2025-12-29)
290+
- ✨ 新增一键启动脚本,支持 macOS/Linux/Windows
291+
- ✨ 新增文案生成功能,自动生成标题、正文和标签
292+
- 🔧 修复历史记录保存机制:大纲生成后立即保存,编辑时自动保存(300ms防抖)
293+
- 🔧 优化跳转逻辑:点击"开始生成"前强制保存未保存的修改
294+
- 🔧 统一启动脚本端口显示为 12398
295+
- 🔧 清理后端生成器未使用的重试装饰器代码
296+
- 🔧 修复前端 CSS 变量引用问题
297+
- 🔧 优化 checkHistoryExists 接口性能,使用专用端点
298+
- 🔧 规范 recordId 赋值方式,统一使用 setRecordId() 方法
299+
359300
### v1.4.0 (2025-11-30)
360301
- 🏗️ 后端架构重构:拆分单体路由为模块化蓝图(history、images、generation、outline、config)
361302
- 🏗️ 前端组件重构:提取可复用组件(ImageGalleryModal、OutlineModal、ShowcaseBackground等)
@@ -463,19 +404,19 @@ providers:
463404

464405
## 👨‍💻 作者
465406

466-
**默子 (Histone)** - AI 创业者 | Python & 深度学习
407+
**默子 (Histone)** - AI 创业者
467408

468409
- 🏠 位置: 中国杭州
469410
- 🚀 状态: 创业中
470-
- 💡 专注: Transformers、GANs、多模态AI
471411
- 📧 Email: histonemax@gmail.com
472-
- 💬 微信: Histone2024
412+
- 💬 微信: Histone2024 (私人微信不解答任何技术问题)
473413
- 🐙 GitHub: [@HisMax](https://github.com/HisMax)
414+
-
474415

475416
*"让 AI 帮我们做更有创造力的事"*
476417

477418
---
478419

479420
**如果这个项目帮到了你,欢迎分享给更多人!** ⭐
480421

481-
有任何问题或建议,欢迎提 Issue 或者在 Linux.do 原帖讨论!
422+
有任何问题或建议,欢迎提 Issue !

backend/generators/google_genai.py

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
"""Google GenAI 图片生成器"""
22
import logging
3-
import time
4-
import random
53
import base64
6-
from functools import wraps
74
from typing import Dict, Any, Optional
85
from google import genai
96
from google.genai import types
@@ -279,58 +276,6 @@ def parse_genai_error(error: Exception) -> str:
279276
)
280277

281278

282-
def retry_on_error(max_retries=5, base_delay=3):
283-
"""智能重试装饰器,根据错误类型决定是否重试"""
284-
def decorator(func):
285-
@wraps(func)
286-
def wrapper(*args, **kwargs):
287-
last_error = None
288-
for attempt in range(max_retries):
289-
try:
290-
return func(*args, **kwargs)
291-
except Exception as e:
292-
last_error = e
293-
error_str = str(e).lower()
294-
295-
# 不可重试的错误类型
296-
non_retryable = [
297-
"401", "unauthenticated", # 认证错误
298-
"403", "permission_denied", "forbidden", # 权限错误
299-
"404", "not_found", # 资源不存在
300-
"invalid_argument", # 参数错误
301-
"safety", "blocked", "filter", # 安全过滤
302-
]
303-
304-
should_retry = True
305-
for keyword in non_retryable:
306-
if keyword in error_str:
307-
should_retry = False
308-
break
309-
310-
if not should_retry:
311-
# 直接抛出,不重试
312-
raise Exception(parse_genai_error(e))
313-
314-
# 可重试的错误
315-
if attempt < max_retries - 1:
316-
if "429" in error_str or "resource_exhausted" in error_str:
317-
wait_time = (base_delay ** attempt) + random.uniform(0, 1)
318-
logger.warning(f"⏳ 遇到速率限制,{wait_time:.1f}秒后重试 (尝试 {attempt + 2}/{max_retries})")
319-
else:
320-
wait_time = min(2 ** attempt, 10) + random.uniform(0, 1)
321-
logger.warning(f"⚠️ 请求失败,{wait_time:.1f}秒后重试 (尝试 {attempt + 2}/{max_retries})")
322-
time.sleep(wait_time)
323-
continue
324-
325-
# 重试次数耗尽
326-
raise Exception(parse_genai_error(e))
327-
328-
# 理论上不会到这里,但保险起见
329-
raise Exception(parse_genai_error(last_error))
330-
return wrapper
331-
return decorator
332-
333-
334279
class GoogleGenAIGenerator(ImageGeneratorBase):
335280
"""Google GenAI 图片生成器"""
336281

@@ -381,7 +326,6 @@ def validate_config(self) -> bool:
381326
"""验证配置"""
382327
return bool(self.api_key)
383328

384-
@retry_on_error(max_retries=5, base_delay=3)
385329
def generate_image(
386330
self,
387331
prompt: str,

backend/generators/image_api.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Image API 图片生成器"""
22
import logging
3-
import time
4-
import random
53
import base64
64
import requests
75
from typing import Dict, Any, Optional, List, Union
@@ -11,25 +9,6 @@
119
logger = logging.getLogger(__name__)
1210

1311

14-
def retry_on_error(max_retries: int = 3, base_delay: float = 2):
15-
"""错误重试装饰器"""
16-
def decorator(func):
17-
def wrapper(*args, **kwargs):
18-
last_error = None
19-
for attempt in range(max_retries):
20-
try:
21-
return func(*args, **kwargs)
22-
except Exception as e:
23-
last_error = e
24-
if attempt < max_retries - 1:
25-
delay = base_delay * (2 ** attempt) + random.uniform(0, 1)
26-
logger.warning(f"请求失败,{delay:.1f}秒后重试 (尝试 {attempt + 2}/{max_retries}): {str(e)[:100]}")
27-
time.sleep(delay)
28-
raise last_error
29-
return wrapper
30-
return decorator
31-
32-
3312
class ImageApiGenerator(ImageGeneratorBase):
3413
"""Image API 生成器"""
3514

@@ -73,7 +52,6 @@ def get_supported_aspect_ratios(self) -> List[str]:
7352
"""获取支持的宽高比"""
7453
return ["1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"]
7554

76-
@retry_on_error(max_retries=3, base_delay=2)
7755
def generate_image(
7856
self,
7957
prompt: str,

0 commit comments

Comments
 (0)