|
@@ -13,12 +13,29 @@ const RecordApp: React.FC = () => {
|
|
|
if (data.account && data.password) {
|
|
if (data.account && data.password) {
|
|
|
if (data.account === 'root' && password === 'root@2024') {
|
|
if (data.account === 'root' && password === 'root@2024') {
|
|
|
const res = await fetch('/api/bigModel');
|
|
const res = await fetch('/api/bigModel');
|
|
|
- const {data} = await res.json()
|
|
|
|
|
|
|
+ const body = await res.json();
|
|
|
|
|
+ const list: {
|
|
|
|
|
+ id: string;
|
|
|
|
|
+ type: "system" | "user" | "assistant";
|
|
|
|
|
+ create_time: string;
|
|
|
|
|
+ content: string;
|
|
|
|
|
+ }[] = body.data;
|
|
|
|
|
+ // 标题行
|
|
|
|
|
+ const headerRow = [
|
|
|
|
|
+ { id: 'ID', role: '角色', createTime: '创建时间', content: '内容' },
|
|
|
|
|
+ ];
|
|
|
|
|
+ // 导出数据
|
|
|
|
|
+ const sheetData = [...headerRow, ...list.map(item => ({
|
|
|
|
|
+ id: item.id,
|
|
|
|
|
+ role: item.type,
|
|
|
|
|
+ createTime: item.create_time,
|
|
|
|
|
+ content: item.content,
|
|
|
|
|
+ }))];
|
|
|
// 导出数据到Excel
|
|
// 导出数据到Excel
|
|
|
const option = {
|
|
const option = {
|
|
|
fileName: '聊天记录',
|
|
fileName: '聊天记录',
|
|
|
datas: [{
|
|
datas: [{
|
|
|
- sheetData: data,
|
|
|
|
|
|
|
+ sheetData: sheetData,
|
|
|
sheetName: '聊天记录',
|
|
sheetName: '聊天记录',
|
|
|
}],
|
|
}],
|
|
|
};
|
|
};
|