feat(web): 重构前端UI并支持OpenAI协议

- 添加账号管理详情页(基本信息、提示词、CapCut、参考图标签页)
- 重构资产页面,按项目组分开展示图片/视频
- 聊天界面支持深度思考内容折叠展示、复制、删除消息
- 设置页面支持Agent配置(Anthropic/OpenAI协议)和工具配置
- 后端支持OpenAI兼容协议流式输出和DeepSeek思考模式
- 添加对话置顶/删除功能、数据库迁移、资产清单API
- 添加账号参考图上传/删除、技能配置持久化、连接测试API
This commit is contained in:
2026-05-07 23:48:26 +08:00
parent 01963aac96
commit 088bdb9a8e
40 changed files with 2594 additions and 678 deletions

View File

@@ -4,8 +4,10 @@ class ChatSocket {
private ws: WebSocket | null = null;
private handlers: Map<string, MessageHandler[]> = new Map();
private reconnectTimer: ReturnType<typeof setTimeout> | null = null;
private intentionallyClosed = false;
connect() {
this.intentionallyClosed = false;
const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
const url = `${protocol}//${location.host}/ws`;
this.ws = new WebSocket(url);
@@ -13,7 +15,11 @@ class ChatSocket {
this.ws.onmessage = (event) => {
try { const { type, data } = JSON.parse(event.data); this.emit(type, data); } catch {}
};
this.ws.onclose = () => { this.reconnectTimer = setTimeout(() => this.connect(), 3000); };
this.ws.onclose = () => {
if (!this.intentionallyClosed) {
this.reconnectTimer = setTimeout(() => this.connect(), 3000);
}
};
}
on(type: string, handler: MessageHandler) {
@@ -23,7 +29,10 @@ class ChatSocket {
off(type: string, handler: MessageHandler) {
const list = this.handlers.get(type);
if (list) this.handlers.set(type, list.filter((h) => h !== handler));
if (list) {
const idx = list.indexOf(handler);
if (idx !== -1) list.splice(idx, 1);
}
}
send(type: string, data: Record<string, unknown> = {}) {
@@ -39,8 +48,11 @@ class ChatSocket {
}
disconnect() {
this.intentionallyClosed = true;
if (this.reconnectTimer) clearTimeout(this.reconnectTimer);
this.reconnectTimer = null;
this.ws?.close();
this.ws = null;
}
}