Geen omschrijving
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.html 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>OpenCode 交互界面</title>
  7. <style>
  8. * {
  9. margin: 0;
  10. padding: 0;
  11. box-sizing: border-box;
  12. }
  13. body {
  14. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  15. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  16. min-height: 100vh;
  17. padding: 20px;
  18. color: #333;
  19. }
  20. .container {
  21. max-width: 1200px;
  22. margin: 0 auto;
  23. background: white;
  24. border-radius: 12px;
  25. box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  26. overflow: hidden;
  27. min-height: 90vh;
  28. }
  29. header {
  30. background: linear-gradient(90deg, #4f46e5, #7c3aed);
  31. color: white;
  32. padding: 24px 32px;
  33. display: flex;
  34. justify-content: space-between;
  35. align-items: center;
  36. }
  37. .logo {
  38. display: flex;
  39. align-items: center;
  40. gap: 12px;
  41. }
  42. .logo h1 {
  43. font-size: 28px;
  44. font-weight: 700;
  45. }
  46. .logo-icon {
  47. font-size: 32px;
  48. }
  49. .status {
  50. background: rgba(255,255,255,0.2);
  51. padding: 8px 16px;
  52. border-radius: 20px;
  53. font-size: 14px;
  54. display: flex;
  55. align-items: center;
  56. gap: 8px;
  57. }
  58. .status-dot {
  59. width: 10px;
  60. height: 10px;
  61. border-radius: 50%;
  62. background: #10b981;
  63. }
  64. main {
  65. display: grid;
  66. grid-template-columns: 300px 1fr;
  67. height: calc(90vh - 100px);
  68. }
  69. .sidebar {
  70. background: #f8fafc;
  71. border-right: 1px solid #e2e8f0;
  72. padding: 24px;
  73. overflow-y: auto;
  74. }
  75. .section-title {
  76. font-size: 14px;
  77. font-weight: 600;
  78. color: #64748b;
  79. text-transform: uppercase;
  80. letter-spacing: 0.05em;
  81. margin-bottom: 16px;
  82. }
  83. .btn {
  84. background: #4f46e5;
  85. color: white;
  86. border: none;
  87. padding: 12px 20px;
  88. border-radius: 8px;
  89. cursor: pointer;
  90. font-weight: 500;
  91. transition: all 0.2s;
  92. width: 100%;
  93. margin-bottom: 12px;
  94. }
  95. .btn:hover {
  96. background: #4338ca;
  97. transform: translateY(-1px);
  98. }
  99. .btn-secondary {
  100. background: #64748b;
  101. }
  102. .btn-secondary:hover {
  103. background: #475569;
  104. }
  105. .session-list {
  106. list-style: none;
  107. margin-top: 20px;
  108. }
  109. .session-item {
  110. padding: 12px 16px;
  111. background: white;
  112. border: 1px solid #e2e8f0;
  113. border-radius: 8px;
  114. margin-bottom: 8px;
  115. cursor: pointer;
  116. transition: all 0.2s;
  117. }
  118. .session-item:hover {
  119. border-color: #4f46e5;
  120. background: #f1f5f9;
  121. }
  122. .session-item.active {
  123. border-color: #4f46e5;
  124. background: #eef2ff;
  125. }
  126. .session-title {
  127. font-weight: 500;
  128. color: #1e293b;
  129. }
  130. .session-id {
  131. font-size: 12px;
  132. color: #64748b;
  133. margin-top: 4px;
  134. }
  135. .chat-area {
  136. display: flex;
  137. flex-direction: column;
  138. height: 100%;
  139. }
  140. .chat-header {
  141. padding: 20px 24px;
  142. border-bottom: 1px solid #e2e8f0;
  143. display: flex;
  144. justify-content: space-between;
  145. align-items: center;
  146. }
  147. .chat-title {
  148. font-size: 18px;
  149. font-weight: 600;
  150. color: #1e293b;
  151. }
  152. .chat-messages {
  153. flex: 1;
  154. padding: 24px;
  155. overflow-y: auto;
  156. background: #f8fafc;
  157. }
  158. .message {
  159. margin-bottom: 20px;
  160. max-width: 80%;
  161. }
  162. .message.user {
  163. margin-left: auto;
  164. }
  165. .message-content {
  166. padding: 16px;
  167. border-radius: 18px;
  168. background: white;
  169. border: 1px solid #e2e8f0;
  170. box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  171. }
  172. .message.user .message-content {
  173. background: #4f46e5;
  174. color: white;
  175. border: none;
  176. }
  177. .message-header {
  178. display: flex;
  179. justify-content: space-between;
  180. margin-bottom: 8px;
  181. font-size: 12px;
  182. color: #64748b;
  183. }
  184. .message.user .message-header {
  185. color: #c7d2fe;
  186. }
  187. .input-area {
  188. padding: 20px 24px;
  189. border-top: 1px solid #e2e8f0;
  190. background: white;
  191. }
  192. .input-row {
  193. display: flex;
  194. gap: 12px;
  195. }
  196. .input-row textarea {
  197. flex: 1;
  198. padding: 16px;
  199. border: 2px solid #e2e8f0;
  200. border-radius: 12px;
  201. font-size: 16px;
  202. resize: none;
  203. font-family: inherit;
  204. transition: border-color 0.2s;
  205. min-height: 60px;
  206. max-height: 200px;
  207. }
  208. .input-row textarea:focus {
  209. outline: none;
  210. border-color: #4f46e5;
  211. }
  212. .input-row button {
  213. background: #4f46e5;
  214. color: white;
  215. border: none;
  216. width: 60px;
  217. border-radius: 12px;
  218. cursor: pointer;
  219. font-size: 20px;
  220. transition: background 0.2s;
  221. }
  222. .input-row button:hover {
  223. background: #4338ca;
  224. }
  225. .input-row button:disabled {
  226. background: #cbd5e1;
  227. cursor: not-allowed;
  228. }
  229. .controls {
  230. display: flex;
  231. gap: 8px;
  232. margin-top: 12px;
  233. }
  234. .control-btn {
  235. padding: 8px 16px;
  236. background: #f1f5f9;
  237. border: 1px solid #e2e8f0;
  238. border-radius: 6px;
  239. cursor: pointer;
  240. font-size: 14px;
  241. color: #475569;
  242. transition: all 0.2s;
  243. }
  244. .control-btn:hover {
  245. background: #e2e8f0;
  246. }
  247. .logs-panel {
  248. grid-column: 1 / -1;
  249. border-top: 1px solid #e2e8f0;
  250. max-height: 300px;
  251. overflow-y: auto;
  252. background: #0f172a;
  253. color: #e2e8f0;
  254. padding: 16px;
  255. font-family: 'Monaco', 'Menlo', monospace;
  256. font-size: 12px;
  257. }
  258. .log-entry {
  259. margin-bottom: 4px;
  260. padding: 4px 0;
  261. border-bottom: 1px solid #334155;
  262. }
  263. .log-time {
  264. color: #94a3b8;
  265. margin-right: 12px;
  266. }
  267. .log-source {
  268. color: #fbbf24;
  269. margin-right: 8px;
  270. }
  271. .log-message {
  272. color: #cbd5e1;
  273. }
  274. .hidden {
  275. display: none;
  276. }
  277. .streaming-indicator {
  278. display: inline-block;
  279. margin-left: 8px;
  280. color: #10b981;
  281. font-weight: 500;
  282. }
  283. .dot-flashing {
  284. position: relative;
  285. width: 10px;
  286. height: 10px;
  287. border-radius: 5px;
  288. background-color: #10b981;
  289. color: #10b981;
  290. animation: dot-flashing 1s infinite linear alternate;
  291. animation-delay: 0.5s;
  292. }
  293. .dot-flashing::before, .dot-flashing::after {
  294. content: '';
  295. display: inline-block;
  296. position: absolute;
  297. top: 0;
  298. }
  299. .dot-flashing::before {
  300. left: -15px;
  301. width: 10px;
  302. height: 10px;
  303. border-radius: 5px;
  304. background-color: #10b981;
  305. color: #10b981;
  306. animation: dot-flashing 1s infinite alternate;
  307. animation-delay: 0s;
  308. }
  309. .dot-flashing::after {
  310. left: 15px;
  311. width: 10px;
  312. height: 10px;
  313. border-radius: 5px;
  314. background-color: #10b981;
  315. color: #10b981;
  316. animation: dot-flashing 1s infinite alternate;
  317. animation-delay: 1s;
  318. }
  319. @keyframes dot-flashing {
  320. 0% {
  321. background-color: #10b981;
  322. }
  323. 50%, 100% {
  324. background-color: rgba(16, 185, 129, 0.2);
  325. }
  326. }
  327. </style>
  328. </head>
  329. <body>
  330. <div class="container">
  331. <header>
  332. <div class="logo">
  333. <div class="logo-icon">⚡</div>
  334. <h1>OpenCode 交互系统</h1>
  335. </div>
  336. <div class="status">
  337. <div class="status-dot"></div>
  338. <span id="statusText">连接正常</span>
  339. <span id="portInfo" style="margin-left: 12px;"></span>
  340. </div>
  341. </header>
  342. <main>
  343. <aside class="sidebar">
  344. <div class="section-title">会话管理</div>
  345. <button id="createSessionBtn" class="btn">新建会话</button>
  346. <button id="refreshSessionsBtn" class="btn btn-secondary">刷新会话列表</button>
  347. <div class="section-title" style="margin-top: 32px;">我的会话</div>
  348. <ul id="sessionList" class="session-list">
  349. <!-- 会话项将动态添加 -->
  350. </ul>
  351. <div class="section-title" style="margin-top: 32px;">系统日志</div>
  352. <button id="toggleLogsBtn" class="btn btn-secondary">显示/隐藏日志</button>
  353. </aside>
  354. <section class="chat-area">
  355. <div class="chat-header">
  356. <div class="chat-title" id="currentSessionTitle">请选择一个会话或创建新会话</div>
  357. <div class="controls">
  358. <button class="control-btn" id="clearChatBtn">清空对话</button>
  359. <button class="control-btn" id="exportChatBtn">导出对话</button>
  360. </div>
  361. </div>
  362. <div class="chat-messages" id="chatMessages">
  363. <!-- 消息将动态添加 -->
  364. <div class="welcome-message">
  365. <div class="message">
  366. <div class="message-content">
  367. <p>欢迎使用 OpenCode 交互系统!</p>
  368. <p>请先创建一个新会话,然后开始对话。</p>
  369. <p>支持流式响应和实时日志查看。</p>
  370. </div>
  371. </div>
  372. </div>
  373. </div>
  374. <div class="input-area">
  375. <div class="input-row">
  376. <textarea id="messageInput" placeholder="输入您的消息... (Shift+Enter 换行,Enter 发送)" rows="2"></textarea>
  377. <button id="sendMessageBtn" disabled>➤</button>
  378. </div>
  379. <div class="controls">
  380. <button class="control-btn" id="streamToggleBtn">流式模式: 开启</button>
  381. <button class="control-btn" id="attachFileBtn">附加文件</button>
  382. <button class="control-btn" id="settingsBtn">设置</button>
  383. </div>
  384. </div>
  385. </section>
  386. <div id="logsPanel" class="logs-panel hidden">
  387. <div class="section-title">OpenCode 进程日志</div>
  388. <div id="logEntries">
  389. <!-- 日志条目将动态添加 -->
  390. </div>
  391. </div>
  392. </main>
  393. </div>
  394. <script src="app.js"></script>
  395. </body>
  396. </html>