- 添加账号管理详情页(基本信息、提示词、CapCut、参考图标签页) - 重构资产页面,按项目组分开展示图片/视频 - 聊天界面支持深度思考内容折叠展示、复制、删除消息 - 设置页面支持Agent配置(Anthropic/OpenAI协议)和工具配置 - 后端支持OpenAI兼容协议流式输出和DeepSeek思考模式 - 添加对话置顶/删除功能、数据库迁移、资产清单API - 添加账号参考图上传/删除、技能配置持久化、连接测试API
25 lines
823 B
TypeScript
25 lines
823 B
TypeScript
import { useState, useEffect, useCallback } from 'react';
|
|
import { api } from '@/lib/api';
|
|
import type { Account } from '@/types';
|
|
|
|
export function useAccounts() {
|
|
const [accounts, setAccounts] = useState<Account[]>([]);
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
const refresh = useCallback(() => {
|
|
api.listAccounts().then(setAccounts).finally(() => setLoading(false));
|
|
}, []);
|
|
|
|
useEffect(() => { refresh(); }, [refresh]);
|
|
|
|
const create = async (data: Partial<Account>) => {
|
|
const acc = await api.createAccount(data);
|
|
await refresh();
|
|
return acc;
|
|
};
|
|
const update = (id: string, data: Partial<Account>) => api.updateAccount(id, data).then(refresh);
|
|
const remove = (id: string) => api.deleteAccount(id).then(refresh);
|
|
|
|
return { accounts, loading, refresh, create, update, remove };
|
|
}
|