| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>OpenCode 交互界面</title>
- <style>
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- }
-
- body {
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- min-height: 100vh;
- padding: 20px;
- color: #333;
- }
-
- .container {
- max-width: 1200px;
- margin: 0 auto;
- background: white;
- border-radius: 12px;
- box-shadow: 0 20px 60px rgba(0,0,0,0.3);
- overflow: hidden;
- min-height: 90vh;
- }
-
- header {
- background: linear-gradient(90deg, #4f46e5, #7c3aed);
- color: white;
- padding: 24px 32px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
-
- .logo {
- display: flex;
- align-items: center;
- gap: 12px;
- }
-
- .logo h1 {
- font-size: 28px;
- font-weight: 700;
- }
-
- .logo-icon {
- font-size: 32px;
- }
-
- .status {
- background: rgba(255,255,255,0.2);
- padding: 8px 16px;
- border-radius: 20px;
- font-size: 14px;
- display: flex;
- align-items: center;
- gap: 8px;
- }
-
- .status-dot {
- width: 10px;
- height: 10px;
- border-radius: 50%;
- background: #10b981;
- }
-
- main {
- display: grid;
- grid-template-columns: 300px 1fr;
- height: calc(90vh - 100px);
- }
-
- .sidebar {
- background: #f8fafc;
- border-right: 1px solid #e2e8f0;
- padding: 24px;
- overflow-y: auto;
- }
-
- .section-title {
- font-size: 14px;
- font-weight: 600;
- color: #64748b;
- text-transform: uppercase;
- letter-spacing: 0.05em;
- margin-bottom: 16px;
- }
-
- .btn {
- background: #4f46e5;
- color: white;
- border: none;
- padding: 12px 20px;
- border-radius: 8px;
- cursor: pointer;
- font-weight: 500;
- transition: all 0.2s;
- width: 100%;
- margin-bottom: 12px;
- }
-
- .btn:hover {
- background: #4338ca;
- transform: translateY(-1px);
- }
-
- .btn-secondary {
- background: #64748b;
- }
-
- .btn-secondary:hover {
- background: #475569;
- }
-
- .session-list {
- list-style: none;
- margin-top: 20px;
- }
-
- .session-item {
- padding: 12px 16px;
- background: white;
- border: 1px solid #e2e8f0;
- border-radius: 8px;
- margin-bottom: 8px;
- cursor: pointer;
- transition: all 0.2s;
- }
-
- .session-item:hover {
- border-color: #4f46e5;
- background: #f1f5f9;
- }
-
- .session-item.active {
- border-color: #4f46e5;
- background: #eef2ff;
- }
-
- .session-title {
- font-weight: 500;
- color: #1e293b;
- }
-
- .session-id {
- font-size: 12px;
- color: #64748b;
- margin-top: 4px;
- }
-
- .chat-area {
- display: flex;
- flex-direction: column;
- height: 100%;
- }
-
- .chat-header {
- padding: 20px 24px;
- border-bottom: 1px solid #e2e8f0;
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
-
- .chat-title {
- font-size: 18px;
- font-weight: 600;
- color: #1e293b;
- }
-
- .chat-messages {
- flex: 1;
- padding: 24px;
- overflow-y: auto;
- background: #f8fafc;
- }
-
- .message {
- margin-bottom: 20px;
- max-width: 80%;
- }
-
- .message.user {
- margin-left: auto;
- }
-
- .message-content {
- padding: 16px;
- border-radius: 18px;
- background: white;
- border: 1px solid #e2e8f0;
- box-shadow: 0 2px 4px rgba(0,0,0,0.05);
- }
-
- .message.user .message-content {
- background: #4f46e5;
- color: white;
- border: none;
- }
-
- .message-header {
- display: flex;
- justify-content: space-between;
- margin-bottom: 8px;
- font-size: 12px;
- color: #64748b;
- }
-
- .message.user .message-header {
- color: #c7d2fe;
- }
-
- .input-area {
- padding: 20px 24px;
- border-top: 1px solid #e2e8f0;
- background: white;
- }
-
- .input-row {
- display: flex;
- gap: 12px;
- }
-
- .input-row textarea {
- flex: 1;
- padding: 16px;
- border: 2px solid #e2e8f0;
- border-radius: 12px;
- font-size: 16px;
- resize: none;
- font-family: inherit;
- transition: border-color 0.2s;
- min-height: 60px;
- max-height: 200px;
- }
-
- .input-row textarea:focus {
- outline: none;
- border-color: #4f46e5;
- }
-
- .input-row button {
- background: #4f46e5;
- color: white;
- border: none;
- width: 60px;
- border-radius: 12px;
- cursor: pointer;
- font-size: 20px;
- transition: background 0.2s;
- }
-
- .input-row button:hover {
- background: #4338ca;
- }
-
- .input-row button:disabled {
- background: #cbd5e1;
- cursor: not-allowed;
- }
-
- .controls {
- display: flex;
- gap: 8px;
- margin-top: 12px;
- }
-
- .control-btn {
- padding: 8px 16px;
- background: #f1f5f9;
- border: 1px solid #e2e8f0;
- border-radius: 6px;
- cursor: pointer;
- font-size: 14px;
- color: #475569;
- transition: all 0.2s;
- }
-
- .control-btn:hover {
- background: #e2e8f0;
- }
-
- .logs-panel {
- grid-column: 1 / -1;
- border-top: 1px solid #e2e8f0;
- max-height: 300px;
- overflow-y: auto;
- background: #0f172a;
- color: #e2e8f0;
- padding: 16px;
- font-family: 'Monaco', 'Menlo', monospace;
- font-size: 12px;
- }
-
- .log-entry {
- margin-bottom: 4px;
- padding: 4px 0;
- border-bottom: 1px solid #334155;
- }
-
- .log-time {
- color: #94a3b8;
- margin-right: 12px;
- }
-
- .log-source {
- color: #fbbf24;
- margin-right: 8px;
- }
-
- .log-message {
- color: #cbd5e1;
- }
-
- .hidden {
- display: none;
- }
-
- .streaming-indicator {
- display: inline-block;
- margin-left: 8px;
- color: #10b981;
- font-weight: 500;
- }
-
- .dot-flashing {
- position: relative;
- width: 10px;
- height: 10px;
- border-radius: 5px;
- background-color: #10b981;
- color: #10b981;
- animation: dot-flashing 1s infinite linear alternate;
- animation-delay: 0.5s;
- }
-
- .dot-flashing::before, .dot-flashing::after {
- content: '';
- display: inline-block;
- position: absolute;
- top: 0;
- }
-
- .dot-flashing::before {
- left: -15px;
- width: 10px;
- height: 10px;
- border-radius: 5px;
- background-color: #10b981;
- color: #10b981;
- animation: dot-flashing 1s infinite alternate;
- animation-delay: 0s;
- }
-
- .dot-flashing::after {
- left: 15px;
- width: 10px;
- height: 10px;
- border-radius: 5px;
- background-color: #10b981;
- color: #10b981;
- animation: dot-flashing 1s infinite alternate;
- animation-delay: 1s;
- }
-
- @keyframes dot-flashing {
- 0% {
- background-color: #10b981;
- }
- 50%, 100% {
- background-color: rgba(16, 185, 129, 0.2);
- }
- }
- </style>
- </head>
- <body>
- <div class="container">
- <header>
- <div class="logo">
- <div class="logo-icon">⚡</div>
- <h1>OpenCode 交互系统</h1>
- </div>
- <div class="status">
- <div class="status-dot"></div>
- <span id="statusText">连接正常</span>
- <span id="portInfo" style="margin-left: 12px;"></span>
- </div>
- </header>
-
- <main>
- <aside class="sidebar">
- <div class="section-title">会话管理</div>
- <button id="createSessionBtn" class="btn">新建会话</button>
- <button id="refreshSessionsBtn" class="btn btn-secondary">刷新会话列表</button>
-
- <div class="section-title" style="margin-top: 32px;">我的会话</div>
- <ul id="sessionList" class="session-list">
- <!-- 会话项将动态添加 -->
- </ul>
-
- <div class="section-title" style="margin-top: 32px;">系统日志</div>
- <button id="toggleLogsBtn" class="btn btn-secondary">显示/隐藏日志</button>
- </aside>
-
- <section class="chat-area">
- <div class="chat-header">
- <div class="chat-title" id="currentSessionTitle">请选择一个会话或创建新会话</div>
- <div class="controls">
- <button class="control-btn" id="clearChatBtn">清空对话</button>
- <button class="control-btn" id="exportChatBtn">导出对话</button>
- </div>
- </div>
-
- <div class="chat-messages" id="chatMessages">
- <!-- 消息将动态添加 -->
- <div class="welcome-message">
- <div class="message">
- <div class="message-content">
- <p>欢迎使用 OpenCode 交互系统!</p>
- <p>请先创建一个新会话,然后开始对话。</p>
- <p>支持流式响应和实时日志查看。</p>
- </div>
- </div>
- </div>
- </div>
-
- <div class="input-area">
- <div class="input-row">
- <textarea id="messageInput" placeholder="输入您的消息... (Shift+Enter 换行,Enter 发送)" rows="2"></textarea>
- <button id="sendMessageBtn" disabled>➤</button>
- </div>
- <div class="controls">
- <button class="control-btn" id="streamToggleBtn">流式模式: 开启</button>
- <button class="control-btn" id="attachFileBtn">附加文件</button>
- <button class="control-btn" id="settingsBtn">设置</button>
- </div>
- </div>
- </section>
-
- <div id="logsPanel" class="logs-panel hidden">
- <div class="section-title">OpenCode 进程日志</div>
- <div id="logEntries">
- <!-- 日志条目将动态添加 -->
- </div>
- </div>
- </main>
- </div>
-
- <script src="app.js"></script>
- </body>
- </html>
|