feat(web): 重构前端UI并支持OpenAI协议
- 添加账号管理详情页(基本信息、提示词、CapCut、参考图标签页) - 重构资产页面,按项目组分开展示图片/视频 - 聊天界面支持深度思考内容折叠展示、复制、删除消息 - 设置页面支持Agent配置(Anthropic/OpenAI协议)和工具配置 - 后端支持OpenAI兼容协议流式输出和DeepSeek思考模式 - 添加对话置顶/删除功能、数据库迁移、资产清单API - 添加账号参考图上传/删除、技能配置持久化、连接测试API
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Router } from 'express';
|
||||
import fs from 'fs';
|
||||
import fs from 'fs/promises';
|
||||
import path from 'path';
|
||||
|
||||
const PROJECT_ROOT = path.resolve(__dirname, '..', '..', '..');
|
||||
@@ -12,18 +12,21 @@ const PROMPT_FILES: Record<string, string> = {
|
||||
video: 'prompts/视频提示词.md',
|
||||
};
|
||||
|
||||
promptsRouter.get('/:accountId/:type', (req, res) => {
|
||||
promptsRouter.get('/:accountId/:type', async (req, res) => {
|
||||
const { accountId, type } = req.params;
|
||||
const relPath = PROMPT_FILES[type];
|
||||
if (!relPath) return res.status(400).json({ error: 'Unknown type: ' + type });
|
||||
|
||||
const fullPath = path.join(PROJECT_ROOT, 'accounts', accountId, relPath);
|
||||
if (!fs.existsSync(fullPath)) return res.status(404).json({ error: 'File not found' });
|
||||
|
||||
res.json({ path: relPath, content: fs.readFileSync(fullPath, 'utf-8') });
|
||||
try {
|
||||
const content = await fs.readFile(fullPath, 'utf-8');
|
||||
res.json({ path: relPath, content });
|
||||
} catch {
|
||||
res.status(404).json({ error: 'File not found' });
|
||||
}
|
||||
});
|
||||
|
||||
promptsRouter.put('/:accountId/:type', (req, res) => {
|
||||
promptsRouter.put('/:accountId/:type', async (req, res) => {
|
||||
const { accountId, type } = req.params;
|
||||
const { content } = req.body;
|
||||
const relPath = PROMPT_FILES[type];
|
||||
@@ -31,9 +34,8 @@ promptsRouter.put('/:accountId/:type', (req, res) => {
|
||||
|
||||
const fullPath = path.join(PROJECT_ROOT, 'accounts', accountId, relPath);
|
||||
const dir = path.dirname(fullPath);
|
||||
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
||||
|
||||
fs.writeFileSync(fullPath, content, 'utf-8');
|
||||
await fs.mkdir(dir, { recursive: true });
|
||||
await fs.writeFile(fullPath, content, 'utf-8');
|
||||
res.json({ ok: true });
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user