-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecord.html
More file actions
104 lines (100 loc) · 4.13 KB
/
record.html
File metadata and controls
104 lines (100 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>后台管理系统</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
padding: 80px;
font-family: 'PingFang SC', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
font-weight: 600;
font-size: 20px;
}
#login {
display: block;
}
#content {
display: none;
}
</style>
</head>
<body>
<div class="container">
<div id="login">
<h2>请输入密码</h2>
<input type="password" id="password" class="form-control" placeholder="Password">
<button class="btn btn-primary mt-2" onclick="checkPassword()">登录</button>
</div>
<div id="content" class="row">
<div class="col-3">
<h3>用户列表</h3>
<ul id="userList" class="list-group"></ul>
</div>
<div class="col-9">
<h3>对话记录</h3>
<ul id="conversationList" class="list-group"></ul>
<div id="conversationContent" class="mt-4"></div>
</div>
</div>
</div>
<script>
const PASSWORD = 'a012.liaobai';
function checkPassword() {
const inputPassword = document.getElementById('password').value;
if (inputPassword === PASSWORD) {
document.getElementById('login').style.display = 'none';
document.getElementById('content').style.display = 'block';
fetchUsers();
} else {
alert('密码错误');
}
}
async function fetchUsers() {
try {
const response = await fetch('http://47.103.73.241/user/get-all-user');
const users = await response.json();
const userList = document.getElementById('userList');
userList.innerHTML = '';
users.forEach(user => {
const li = document.createElement('li');
li.className = 'list-group-item';
li.innerText = `用户ID: ${user.id}`;
li.onclick = () => fetchConversations(user.id);
userList.appendChild(li);
});
} catch (error) {
console.error('Error fetching users:', error);
}
}
async function fetchConversations(userId) {
try {
const response = await fetch(`http://47.103.73.241/conversation/get-user-conversation-record?userId=${userId}`);
const conversations = await response.json();
const conversationList = document.getElementById('conversationList');
conversationList.innerHTML = '';
conversations.forEach(conversation => {
const li = document.createElement('li');
li.className = 'list-group-item';
li.innerText = `对话ID: ${conversation.id} - AI回复次数: ${conversation.aiResponseCount}`;
li.onclick = () => fetchConversationContent(conversation.id);
conversationList.appendChild(li);
});
} catch (error) {
console.error('Error fetching conversations:', error);
}
}
async function fetchConversationContent(conversationId) {
try {
const response = await fetch(`http://47.103.73.241/conversation/get-conversation-content?id=${conversationId}`);
const content = await response.json();
const conversationContent = document.getElementById('conversationContent');
conversationContent.innerHTML = `<h4>对话内容</h4><pre>${JSON.stringify(content, null, 2)}</pre>`;
} catch (error) {
console.error('Error fetching conversation content:', error);
}
}
</script>
</body>
</html>