feat(web): 添加全局 Toast 通知系统和资产预览导航功能
- 新增 ToastProvider 和 useToast hook,支持全局成功/错误/信息提示 - 资产预览增加左右导航按钮、键盘快捷键(方向键)和计数器显示 - 资产库增加图片/视频类型筛选标签页及计数 - 对话列表增加最近对话展示、搜索优化和删除确认 - 消息增加删除确认对话框 - 优化聊天自动滚动行为,仅在用户未手动滚动时跟随新内容 - 新增删除消息 API 端点 - 优化消息历史清理逻辑,过滤错误消息和孤儿 tool 消息 - 添加自定义滚动条样式 - 优化账户参考图显示逻辑,支持本地文件显示 - 修复对话创建流程,直接导航到新创建的对话
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Router } from 'express';
|
||||
import fs from 'fs/promises';
|
||||
import fss from 'fs';
|
||||
import path from 'path';
|
||||
import multer from 'multer';
|
||||
|
||||
@@ -124,6 +125,16 @@ accountsRouter.post('/:id/references/upload', upload.single('file'), async (req,
|
||||
res.json({ ok: true, reference: refEntry });
|
||||
});
|
||||
|
||||
// Serve reference image file
|
||||
accountsRouter.get('/:id/references/:filename', (req, res) => {
|
||||
const id = req.params.id as string;
|
||||
const filename = req.params.filename as string;
|
||||
const fullPath = path.join(ACCOUNTS_DIR, id, 'references', filename);
|
||||
if (!fullPath.startsWith(ACCOUNTS_DIR)) return res.status(403).send('Forbidden');
|
||||
if (!fss.existsSync(fullPath)) return res.status(404).send('Not found');
|
||||
res.sendFile(fullPath);
|
||||
});
|
||||
|
||||
// Reference image delete
|
||||
accountsRouter.delete('/:id/references/:index', async (req, res) => {
|
||||
const id = req.params.id as string;
|
||||
|
||||
@@ -32,8 +32,15 @@ pipelineRouter.get('/conversations/:id/messages', (req, res) => {
|
||||
});
|
||||
|
||||
pipelineRouter.delete('/conversations/:id', (req, res) => {
|
||||
getDb().prepare('DELETE FROM messages WHERE conversation_id = ?').run(req.params.id);
|
||||
getDb().prepare('DELETE FROM conversations WHERE id = ?').run(req.params.id);
|
||||
res.status(204).send();
|
||||
res.json({ ok: true });
|
||||
});
|
||||
|
||||
// Delete a single message
|
||||
pipelineRouter.delete('/messages/:id', (req, res) => {
|
||||
getDb().prepare('DELETE FROM messages WHERE id = ?').run(req.params.id);
|
||||
res.json({ ok: true });
|
||||
});
|
||||
|
||||
// Update conversation (rename / toggle pin)
|
||||
|
||||
Reference in New Issue
Block a user