- 添加账号管理详情页(基本信息、提示词、CapCut、参考图标签页) - 重构资产页面,按项目组分开展示图片/视频 - 聊天界面支持深度思考内容折叠展示、复制、删除消息 - 设置页面支持Agent配置(Anthropic/OpenAI协议)和工具配置 - 后端支持OpenAI兼容协议流式输出和DeepSeek思考模式 - 添加对话置顶/删除功能、数据库迁移、资产清单API - 添加账号参考图上传/删除、技能配置持久化、连接测试API
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import { Router } from 'express';
|
|
import fs from 'fs/promises';
|
|
import path from 'path';
|
|
|
|
const PROJECT_ROOT = path.resolve(__dirname, '..', '..', '..');
|
|
|
|
export const promptsRouter = Router();
|
|
|
|
const PROMPT_FILES: Record<string, string> = {
|
|
storyboard: 'prompts/分镜.md',
|
|
image: 'prompts/图片提示词.md',
|
|
video: 'prompts/视频提示词.md',
|
|
};
|
|
|
|
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);
|
|
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', async (req, res) => {
|
|
const { accountId, type } = req.params;
|
|
const { content } = req.body;
|
|
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);
|
|
const dir = path.dirname(fullPath);
|
|
await fs.mkdir(dir, { recursive: true });
|
|
await fs.writeFile(fullPath, content, 'utf-8');
|
|
res.json({ ok: true });
|
|
});
|
|
|
|
promptsRouter.get('/:accountId', (req, res) => {
|
|
res.json(Object.keys(PROMPT_FILES).map((type) => ({
|
|
type,
|
|
path: PROMPT_FILES[type],
|
|
})));
|
|
});
|