-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
60 lines (58 loc) · 1.71 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<title>WebRTC OpenAI Demo</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
button {
padding: 10px 20px;
margin: 10px;
font-size: 16px;
}
#status {
margin: 20px 0;
padding: 10px;
border-radius: 5px;
}
#log {
background-color: #f5f5f5;
padding: 10px;
border-radius: 5px;
height: 200px;
overflow-y: auto;
margin-top: 20px;
}
</style>
</head>
<body>
<h1>WebRTC OpenAI Demo</h1>
<button id="connectButton" onclick="init()">开始连接</button>
<button id="disconnectButton" style="display: none;">断开连接</button>
<button id="sendButton" onclick="sendMessage()" disabled>发送测试消息</button>
<div id="status">状态:未连接</div>
<div id="log"></div>
<script>
// 重写console.log来显示在页面上
const oldLog = console.log;
console.log = function() {
const args = Array.from(arguments);
const message = args.map(arg =>
typeof arg === 'object' ? JSON.stringify(arg, null, 2) : arg
).join(' ');
const logDiv = document.getElementById('log');
if (logDiv) {
logDiv.innerHTML += message + '<br>';
logDiv.scrollTop = logDiv.scrollHeight;
}
oldLog.apply(console, arguments);
};
</script>
<script src="init.js"></script>
<script src="main.js"></script>
</body>
</html>