Upload 3 files
Browse files- static/index.html +57 -0
- static/script.js +241 -0
- static/style.css +218 -0
static/index.html
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="ja">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>AIチャットボット (最終版)</title>
|
| 7 |
+
|
| 8 |
+
<link rel="stylesheet" href="style.css">
|
| 9 |
+
<link rel="icon" href="https://www.google.com/s2/favicons?domain=deepmind.google" type="image/x-icon">
|
| 10 |
+
|
| 11 |
+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
| 12 |
+
<script src="https://cdn.jsdelivr.net/npm/dompurify/dist/purify.min.js"></script>
|
| 13 |
+
</head>
|
| 14 |
+
<body>
|
| 15 |
+
<div class="main-container">
|
| 16 |
+
|
| 17 |
+
<aside id="sidebar">
|
| 18 |
+
<button id="new-chat-button">+ 新規チャット</button>
|
| 19 |
+
<nav id="session-list"></nav>
|
| 20 |
+
</aside>
|
| 21 |
+
|
| 22 |
+
<main id="chat-container">
|
| 23 |
+
<header id="chat-header">
|
| 24 |
+
<button id="menu-button" title="会話履歴の表示/非表示">☰</button>
|
| 25 |
+
<h2 id="chat-title">AIチャットボット</h2>
|
| 26 |
+
<button id="toggle-settings-button" title="AIの設定">⚙️</button>
|
| 27 |
+
</header>
|
| 28 |
+
|
| 29 |
+
<section id="chat-window"></section>
|
| 30 |
+
|
| 31 |
+
<div id="file-preview-container" class="hidden">
|
| 32 |
+
<span id="file-name"></span>
|
| 33 |
+
<button id="remove-file-button" title="添付ファイルを削除">×</button>
|
| 34 |
+
</div>
|
| 35 |
+
|
| 36 |
+
<form id="chat-form">
|
| 37 |
+
<label for="file-input" class="file-input-label" title="ファイルを添付">📎</label>
|
| 38 |
+
<input type="file" id="file-input" accept="image/*" hidden>
|
| 39 |
+
|
| 40 |
+
<input type="text" id="message-input" placeholder="メッセージを入力、または画像をペースト..." autocomplete="off">
|
| 41 |
+
<button type="submit" id="send-button" title="送信">➤</button>
|
| 42 |
+
</form>
|
| 43 |
+
</main>
|
| 44 |
+
|
| 45 |
+
<aside id="settings-panel" class="hidden">
|
| 46 |
+
<h3>AIの設定</h3>
|
| 47 |
+
<div class="setting-item">
|
| 48 |
+
<label for="personality-input">人格 (システムプロンプト):</label>
|
| 49 |
+
<textarea id="personality-input" rows="8" placeholder="例: あなたは猫です。「〜にゃん」を付けて話してください。"></textarea>
|
| 50 |
+
<button id="save-personality-button">人格を保存</button>
|
| 51 |
+
</div>
|
| 52 |
+
</aside>
|
| 53 |
+
</div>
|
| 54 |
+
|
| 55 |
+
<script src="script.js"></script>
|
| 56 |
+
</body>
|
| 57 |
+
</html>
|
static/script.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @file Geminiチャットボットのフロントエンド用JavaScript
|
| 3 |
+
* @description UI操作、API通信、状態管理など、すべてのフロントエンドロジックを管理します。
|
| 4 |
+
* @version 4.1.0
|
| 5 |
+
*/
|
| 6 |
+
|
| 7 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 8 |
+
// --- 1. UI要素の取得 ---
|
| 9 |
+
const ui = {
|
| 10 |
+
sidebar: document.getElementById('sidebar'),
|
| 11 |
+
menuButton: document.getElementById('menu-button'),
|
| 12 |
+
chatWindow: document.getElementById('chat-window'),
|
| 13 |
+
chatForm: document.getElementById('chat-form'),
|
| 14 |
+
messageInput: document.getElementById('message-input'),
|
| 15 |
+
sendButton: document.getElementById('send-button'),
|
| 16 |
+
sessionList: document.getElementById('session-list'),
|
| 17 |
+
newChatButton: document.getElementById('new-chat-button'),
|
| 18 |
+
toggleSettingsButton: document.getElementById('toggle-settings-button'),
|
| 19 |
+
settingsPanel: document.getElementById('settings-panel'),
|
| 20 |
+
personalityInput: document.getElementById('personality-input'),
|
| 21 |
+
savePersonalityButton: document.getElementById('save-personality-button'),
|
| 22 |
+
fileInput: document.getElementById('file-input'),
|
| 23 |
+
filePreviewContainer: document.getElementById('file-preview-container'),
|
| 24 |
+
fileNameSpan: document.getElementById('file-name'),
|
| 25 |
+
removeFileButton: document.getElementById('remove-file-button'),
|
| 26 |
+
chatTitle: document.getElementById('chat-title'),
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
// --- 2. 状態管理変数 ---
|
| 30 |
+
let state = {
|
| 31 |
+
currentSessionId: localStorage.getItem('active_chat_session_id') || null,
|
| 32 |
+
attachedFile: null,
|
| 33 |
+
isLoading: false,
|
| 34 |
+
};
|
| 35 |
+
|
| 36 |
+
// --- 3. API通信モジュール ---
|
| 37 |
+
const api = {
|
| 38 |
+
getSessions: () => fetch('/api/sessions').then(res => res.json()),
|
| 39 |
+
getSession: (id) => fetch(`/api/session/${id}`).then(res => res.json()),
|
| 40 |
+
deleteSession: (id) => fetch(`/api/session/${id}`, { method: 'DELETE' }),
|
| 41 |
+
renameSession: (id, title) => fetch(`/api/session/${id}/rename`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title }) }),
|
| 42 |
+
pinSession: (id) => fetch(`/api/session/${id}/pin`, { method: 'POST' }),
|
| 43 |
+
setPersonality: (personality) => fetch('/api/set_personality', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ personality }) }),
|
| 44 |
+
postChat: (formData) => fetch('/api/chat', { method: 'POST', body: formData }).then(res => res.json()),
|
| 45 |
+
};
|
| 46 |
+
|
| 47 |
+
// --- 4. UI描画モジュール ---
|
| 48 |
+
const render = {
|
| 49 |
+
sessions: (sessions) => {
|
| 50 |
+
ui.sessionList.innerHTML = '';
|
| 51 |
+
sessions.forEach(session => {
|
| 52 |
+
const item = document.createElement('div');
|
| 53 |
+
item.className = 'session-item';
|
| 54 |
+
item.dataset.sessionId = session.id;
|
| 55 |
+
item.innerHTML = `
|
| 56 |
+
<span class="session-title">${session.title}</span>
|
| 57 |
+
<div class="session-actions">
|
| 58 |
+
<button class="session-action-button pin-button ${session.pinned ? 'pinned' : ''}" title="ピン留め">📌</button>
|
| 59 |
+
<button class="session-action-button rename-button" title="名前を変更">✏️</button>
|
| 60 |
+
<button class="session-action-button delete-button" title="削除">🗑️</button>
|
| 61 |
+
</div>`;
|
| 62 |
+
ui.sessionList.appendChild(item);
|
| 63 |
+
});
|
| 64 |
+
render.activeSessionHighlight();
|
| 65 |
+
},
|
| 66 |
+
chatHistory: (history) => {
|
| 67 |
+
ui.chatWindow.innerHTML = '';
|
| 68 |
+
history.forEach(msg => {
|
| 69 |
+
const content = {
|
| 70 |
+
text: msg.parts.filter(p => !p.startsWith('/uploads/')).join(' '),
|
| 71 |
+
imageUrl: msg.parts.find(p => p.startsWith('/uploads/'))
|
| 72 |
+
};
|
| 73 |
+
render.message({ sender: msg.role === 'user' ? 'user' : 'bot', ...content });
|
| 74 |
+
});
|
| 75 |
+
},
|
| 76 |
+
message: ({ sender, text, imageFile, imageUrl }) => {
|
| 77 |
+
const el = document.createElement('div');
|
| 78 |
+
el.className = `chat-message ${sender}-message`;
|
| 79 |
+
const imageSrc = imageUrl || (imageFile ? URL.createObjectURL(imageFile) : null);
|
| 80 |
+
if (imageSrc) {
|
| 81 |
+
const img = document.createElement('img');
|
| 82 |
+
img.src = imageSrc;
|
| 83 |
+
img.className = 'message-image';
|
| 84 |
+
el.prepend(img);
|
| 85 |
+
}
|
| 86 |
+
if (text) {
|
| 87 |
+
const textEl = document.createElement('div');
|
| 88 |
+
textEl.innerHTML = DOMPurify.sanitize(marked.parse(text));
|
| 89 |
+
el.appendChild(textEl);
|
| 90 |
+
}
|
| 91 |
+
ui.chatWindow.appendChild(el);
|
| 92 |
+
ui.chatWindow.scrollTop = ui.chatWindow.scrollHeight;
|
| 93 |
+
return el;
|
| 94 |
+
},
|
| 95 |
+
activeSessionHighlight: () => {
|
| 96 |
+
document.querySelectorAll('.session-item').forEach(item => {
|
| 97 |
+
item.classList.toggle('active', item.dataset.sessionId === state.currentSessionId);
|
| 98 |
+
});
|
| 99 |
+
},
|
| 100 |
+
filePreview: () => {
|
| 101 |
+
if (state.attachedFile) {
|
| 102 |
+
ui.fileNameSpan.textContent = state.attachedFile.name;
|
| 103 |
+
ui.filePreviewContainer.classList.remove('hidden');
|
| 104 |
+
} else {
|
| 105 |
+
ui.filePreviewContainer.classList.add('hidden');
|
| 106 |
+
ui.fileInput.value = '';
|
| 107 |
+
}
|
| 108 |
+
},
|
| 109 |
+
};
|
| 110 |
+
|
| 111 |
+
// --- 5. アプリケーションロジック ---
|
| 112 |
+
const actions = {
|
| 113 |
+
startNewChat: async () => {
|
| 114 |
+
state.currentSessionId = `session-${Date.now()}`;
|
| 115 |
+
localStorage.setItem('active_chat_session_id', state.currentSessionId);
|
| 116 |
+
ui.chatWindow.innerHTML = '';
|
| 117 |
+
ui.chatTitle.textContent = "新規チャット";
|
| 118 |
+
render.message({ sender: 'bot', text: 'こんにちは!新しい会話を始めましょう。' });
|
| 119 |
+
await actions.updateSessions();
|
| 120 |
+
},
|
| 121 |
+
loadSession: async (sessionId) => {
|
| 122 |
+
if (!sessionId) return;
|
| 123 |
+
ui.chatTitle.textContent = "読み込み中...";
|
| 124 |
+
const data = await api.getSession(sessionId);
|
| 125 |
+
if (data && data.history) {
|
| 126 |
+
ui.chatTitle.textContent = data.title || "新規チャット";
|
| 127 |
+
render.chatHistory(data.history);
|
| 128 |
+
} else { await actions.startNewChat(); }
|
| 129 |
+
},
|
| 130 |
+
updateSessions: async () => render.sessions(await api.getSessions()),
|
| 131 |
+
handleFile: (file) => {
|
| 132 |
+
if (file && file.type.startsWith('image/')) {
|
| 133 |
+
state.attachedFile = file;
|
| 134 |
+
render.filePreview();
|
| 135 |
+
} else { alert('画像ファイル(PNG, JPGなど)のみ添付できます。'); }
|
| 136 |
+
},
|
| 137 |
+
setFormEnabled: (enabled) => {
|
| 138 |
+
state.isLoading = !enabled;
|
| 139 |
+
ui.messageInput.disabled = !enabled;
|
| 140 |
+
ui.sendButton.disabled = !enabled;
|
| 141 |
+
}
|
| 142 |
+
};
|
| 143 |
+
|
| 144 |
+
// --- 6. イベントリスナー ---
|
| 145 |
+
ui.menuButton.addEventListener('click', () => ui.sidebar.classList.toggle('visible'));
|
| 146 |
+
ui.newChatButton.addEventListener('click', () => { actions.startNewChat(); ui.sidebar.classList.remove('visible'); });
|
| 147 |
+
ui.toggleSettingsButton.addEventListener('click', () => ui.settingsPanel.classList.toggle('hidden'));
|
| 148 |
+
ui.removeFileButton.addEventListener('click', () => { state.attachedFile = null; render.filePreview(); });
|
| 149 |
+
ui.fileInput.addEventListener('change', () => ui.fileInput.files.length > 0 && actions.handleFile(ui.fileInput.files[0]));
|
| 150 |
+
ui.savePersonalityButton.addEventListener('click', async () => {
|
| 151 |
+
await api.setPersonality(ui.personalityInput.value);
|
| 152 |
+
alert('人格を更新しました。');
|
| 153 |
+
ui.settingsPanel.classList.add('hidden');
|
| 154 |
+
});
|
| 155 |
+
|
| 156 |
+
ui.sessionList.addEventListener('click', async (e) => {
|
| 157 |
+
const item = e.target.closest('.session-item');
|
| 158 |
+
if (!item) return;
|
| 159 |
+
const sessionId = item.dataset.sessionId;
|
| 160 |
+
const action = e.target.closest('.session-action-button');
|
| 161 |
+
if (action) {
|
| 162 |
+
e.stopPropagation();
|
| 163 |
+
if (action.classList.contains('delete-button')) {
|
| 164 |
+
if (confirm(`「${item.querySelector('.session-title').textContent}」を削除しますか?`)) {
|
| 165 |
+
await api.deleteSession(sessionId);
|
| 166 |
+
if (state.currentSessionId === sessionId) {
|
| 167 |
+
state.currentSessionId = null; localStorage.removeItem('active_chat_session_id');
|
| 168 |
+
}
|
| 169 |
+
await actions.updateSessions();
|
| 170 |
+
if (!state.currentSessionId) await actions.startNewChat();
|
| 171 |
+
}
|
| 172 |
+
} else if (action.classList.contains('rename-button')) {
|
| 173 |
+
const newTitle = prompt("新しい名前:", item.querySelector('.session-title').textContent);
|
| 174 |
+
if (newTitle && newTitle.trim()) await api.renameSession(sessionId, newTitle.trim());
|
| 175 |
+
await actions.updateSessions();
|
| 176 |
+
} else if (action.classList.contains('pin-button')) {
|
| 177 |
+
await api.pinSession(sessionId); await actions.updateSessions();
|
| 178 |
+
}
|
| 179 |
+
} else {
|
| 180 |
+
state.currentSessionId = sessionId; localStorage.setItem('active_chat_session_id', state.currentSessionId);
|
| 181 |
+
await actions.loadSession(sessionId); render.activeSessionHighlight();
|
| 182 |
+
ui.sidebar.classList.remove('visible');
|
| 183 |
+
}
|
| 184 |
+
});
|
| 185 |
+
|
| 186 |
+
document.addEventListener('paste', e => {
|
| 187 |
+
const file = Array.from(e.clipboardData.items).find(item => item.type.startsWith('image/'))?.getAsFile();
|
| 188 |
+
if (file) { actions.handleFile(file); e.preventDefault(); }
|
| 189 |
+
});
|
| 190 |
+
|
| 191 |
+
ui.chatForm.addEventListener('submit', async (e) => {
|
| 192 |
+
e.preventDefault();
|
| 193 |
+
const userMessage = ui.messageInput.value.trim();
|
| 194 |
+
if ((!userMessage && !state.attachedFile) || !state.currentSessionId || state.isLoading) return;
|
| 195 |
+
actions.setFormEnabled(false);
|
| 196 |
+
render.message({ sender: 'user', text: userMessage, imageFile: state.attachedFile });
|
| 197 |
+
const formData = new FormData();
|
| 198 |
+
formData.append('session_id', state.currentSessionId);
|
| 199 |
+
formData.append('message', userMessage);
|
| 200 |
+
if (state.attachedFile) formData.append('file', state.attachedFile);
|
| 201 |
+
state.attachedFile = null; render.filePreview(); ui.messageInput.value = '';
|
| 202 |
+
const loadingMessage = render.message({ sender: 'bot', text: '考え中...' });
|
| 203 |
+
try {
|
| 204 |
+
const data = await api.postChat(formData);
|
| 205 |
+
ui.chatWindow.removeChild(loadingMessage);
|
| 206 |
+
render.message({ sender: 'bot', text: data.reply || data.error });
|
| 207 |
+
if (data.title) ui.chatTitle.textContent = data.title;
|
| 208 |
+
await actions.updateSessions();
|
| 209 |
+
} catch (error) {
|
| 210 |
+
loadingMessage.textContent = "エラー: メッセージの送信に失敗しました。";
|
| 211 |
+
} finally {
|
| 212 |
+
actions.setFormEnabled(true);
|
| 213 |
+
}
|
| 214 |
+
});
|
| 215 |
+
|
| 216 |
+
// --- 7. 初期化 ---
|
| 217 |
+
const initialize = async () => {
|
| 218 |
+
await actions.updateSessions();
|
| 219 |
+
const firstSession = ui.sessionList.querySelector('.session-item');
|
| 220 |
+
let sessionToLoad = state.currentSessionId;
|
| 221 |
+
|
| 222 |
+
if (sessionToLoad && !document.querySelector(`.session-item[data-session-id="${sessionToLoad}"]`)) {
|
| 223 |
+
sessionToLoad = null;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
if (!sessionToLoad && firstSession) {
|
| 227 |
+
sessionToLoad = firstSession.dataset.sessionId;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
if (sessionToLoad) {
|
| 231 |
+
state.currentSessionId = sessionToLoad;
|
| 232 |
+
localStorage.setItem('active_chat_session_id', state.currentSessionId);
|
| 233 |
+
await actions.loadSession(state.currentSessionId);
|
| 234 |
+
} else {
|
| 235 |
+
await actions.startNewChat();
|
| 236 |
+
}
|
| 237 |
+
ui.sidebar.classList.remove('visible');
|
| 238 |
+
};
|
| 239 |
+
|
| 240 |
+
initialize();
|
| 241 |
+
});
|
static/style.css
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* =================================
|
| 2 |
+
基本スタイルとレイアウト
|
| 3 |
+
================================= */
|
| 4 |
+
body {
|
| 5 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
|
| 6 |
+
background-color: #f0f2f5;
|
| 7 |
+
margin: 0;
|
| 8 |
+
color: #333;
|
| 9 |
+
overflow: hidden;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
.main-container {
|
| 13 |
+
display: flex;
|
| 14 |
+
position: relative;
|
| 15 |
+
height: 100vh;
|
| 16 |
+
width: 100vw;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
/* =================================
|
| 20 |
+
左サイドバー (会話履歴)
|
| 21 |
+
================================= */
|
| 22 |
+
#sidebar {
|
| 23 |
+
position: absolute;
|
| 24 |
+
left: 0;
|
| 25 |
+
top: 0;
|
| 26 |
+
height: 100vh;
|
| 27 |
+
width: 260px;
|
| 28 |
+
background-color: #202123;
|
| 29 |
+
color: white;
|
| 30 |
+
padding: 10px;
|
| 31 |
+
display: flex;
|
| 32 |
+
flex-direction: column;
|
| 33 |
+
gap: 10px;
|
| 34 |
+
z-index: 100;
|
| 35 |
+
transform: translateX(-100%);
|
| 36 |
+
transition: transform 0.3s ease-in-out;
|
| 37 |
+
box-shadow: 2px 0 5px rgba(0,0,0,0.5);
|
| 38 |
+
box-sizing: border-box;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
#sidebar.visible {
|
| 42 |
+
transform: translateX(0);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
#new-chat-button {
|
| 46 |
+
width: 100%;
|
| 47 |
+
padding: 10px;
|
| 48 |
+
border: 1px solid rgba(255, 255, 255, 0.5);
|
| 49 |
+
background-color: transparent;
|
| 50 |
+
color: white;
|
| 51 |
+
border-radius: 5px;
|
| 52 |
+
cursor: pointer;
|
| 53 |
+
text-align: left;
|
| 54 |
+
font-size: 0.9em;
|
| 55 |
+
transition: background-color 0.2s;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
#new-chat-button:hover {
|
| 59 |
+
background-color: #343541;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
#session-list {
|
| 63 |
+
flex-grow: 1;
|
| 64 |
+
overflow-y: auto;
|
| 65 |
+
display: flex;
|
| 66 |
+
flex-direction: column;
|
| 67 |
+
gap: 5px;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
.session-item {
|
| 71 |
+
display: flex;
|
| 72 |
+
align-items: center;
|
| 73 |
+
padding: 10px;
|
| 74 |
+
border-radius: 5px;
|
| 75 |
+
cursor: pointer;
|
| 76 |
+
font-size: 0.9em;
|
| 77 |
+
transition: background-color 0.2s;
|
| 78 |
+
position: relative;
|
| 79 |
+
}
|
| 80 |
+
.session-item:hover {
|
| 81 |
+
background-color: #343541;
|
| 82 |
+
}
|
| 83 |
+
.session-item.active {
|
| 84 |
+
background-color: #4A90E2;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
.session-title {
|
| 88 |
+
flex-grow: 1;
|
| 89 |
+
white-space: nowrap;
|
| 90 |
+
overflow: hidden;
|
| 91 |
+
text-overflow: ellipsis;
|
| 92 |
+
padding-right: 5px;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
.session-actions {
|
| 96 |
+
display: none;
|
| 97 |
+
align-items: center;
|
| 98 |
+
gap: 5px;
|
| 99 |
+
background-color: #343541;
|
| 100 |
+
padding: 3px 5px;
|
| 101 |
+
border-radius: 5px;
|
| 102 |
+
}
|
| 103 |
+
.session-item:hover .session-actions {
|
| 104 |
+
display: flex;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
.session-action-button {
|
| 108 |
+
background: none;
|
| 109 |
+
border: none;
|
| 110 |
+
color: #e0e0e0;
|
| 111 |
+
cursor: pointer;
|
| 112 |
+
font-size: 1.1em;
|
| 113 |
+
padding: 3px;
|
| 114 |
+
}
|
| 115 |
+
.session-action-button:hover {
|
| 116 |
+
color: #ffffff;
|
| 117 |
+
}
|
| 118 |
+
.session-action-button.pinned {
|
| 119 |
+
color: #4A90E2;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
/* =================================
|
| 123 |
+
中央チャットコンテナ
|
| 124 |
+
================================= */
|
| 125 |
+
main#chat-container {
|
| 126 |
+
width: 100%;
|
| 127 |
+
flex-grow: 1;
|
| 128 |
+
display: flex;
|
| 129 |
+
flex-direction: column;
|
| 130 |
+
background-color: #ffffff;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
header#chat-header {
|
| 134 |
+
display: flex;
|
| 135 |
+
align-items: center;
|
| 136 |
+
gap: 15px;
|
| 137 |
+
padding: 0 15px;
|
| 138 |
+
border-bottom: 1px solid #ddd;
|
| 139 |
+
flex-shrink: 0;
|
| 140 |
+
}
|
| 141 |
+
#chat-header h2 {
|
| 142 |
+
flex-grow: 1;
|
| 143 |
+
text-align: center;
|
| 144 |
+
font-size: 1.1em;
|
| 145 |
+
margin: 0;
|
| 146 |
+
white-space: nowrap;
|
| 147 |
+
overflow: hidden;
|
| 148 |
+
text-overflow: ellipsis;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
#menu-button, #toggle-settings-button {
|
| 152 |
+
background: none;
|
| 153 |
+
border: none;
|
| 154 |
+
font-size: 1.5em;
|
| 155 |
+
cursor: pointer;
|
| 156 |
+
padding: 10px;
|
| 157 |
+
color: #555;
|
| 158 |
+
transition: color 0.2s;
|
| 159 |
+
}
|
| 160 |
+
#menu-button:hover, #toggle-settings-button:hover {
|
| 161 |
+
color: #000;
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
section#chat-window {
|
| 165 |
+
flex-grow: 1;
|
| 166 |
+
padding: 20px;
|
| 167 |
+
overflow-y: auto;
|
| 168 |
+
display: flex;
|
| 169 |
+
flex-direction: column;
|
| 170 |
+
gap: 12px;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
.chat-message { padding: 10px 15px; border-radius: 18px; max-width: 80%; line-height: 1.5; word-wrap: break-word; display: flex; flex-direction: column; gap: 8px; }
|
| 174 |
+
.user-message { background-color: #4A90E2; color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
|
| 175 |
+
.bot-message { background-color: #e9e9eb; color: #333; align-self: flex-start; border-bottom-left-radius: 4px; }
|
| 176 |
+
.user-message .message-image, .bot-message .message-image { max-width: 100%; max-height: 300px; border-radius: 10px; object-fit: contain; }
|
| 177 |
+
.system-message { background-color: #fffbe5; color: #5c5224; align-self: center; font-size: 0.9em; font-style: italic; text-align: center; padding: 8px 12px; }
|
| 178 |
+
.bot-message.loading::after { content: '...'; display: inline-block; animation: loading-dots 1.4s infinite; }
|
| 179 |
+
@keyframes loading-dots { 0%, 20% { content: '.'; } 40% { content: '..'; } 60% { content: '...'; } }
|
| 180 |
+
|
| 181 |
+
/* Markdown表示用のスタイル */
|
| 182 |
+
.bot-message p { margin: 0 0 10px 0; }
|
| 183 |
+
.bot-message ul, .bot-message ol { padding-left: 20px; margin: 0 0 10px 0; }
|
| 184 |
+
.bot-message li { margin-bottom: 5px; }
|
| 185 |
+
.bot-message code { background-color: #e0e0e0; padding: 2px 4px; border-radius: 4px; font-family: monospace; }
|
| 186 |
+
.bot-message pre { background-color: #e0e0e0; padding: 10px; border-radius: 4px; white-space: pre-wrap; word-wrap: break-word; }
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
#file-preview-container { padding: 5px 15px; background-color: #f0f2f5; display: flex; justify-content: space-between; align-items: center; font-size: 0.9em; border-top: 1px solid #ddd; }
|
| 190 |
+
#file-preview-container.hidden { display: none; }
|
| 191 |
+
#remove-file-button { background: none; border: none; font-size: 1.2em; cursor: pointer; color: #888; }
|
| 192 |
+
|
| 193 |
+
form#chat-form { display: flex; align-items: center; border-top: 1px solid #ddd; padding: 10px 15px; gap: 10px; flex-shrink: 0; }
|
| 194 |
+
.file-input-label { font-size: 1.5em; cursor: pointer; padding: 5px; color: #555; }
|
| 195 |
+
#message-input { flex-grow: 1; border: 1px solid #ccc; border-radius: 20px; padding: 10px 15px; font-size: 1em; outline: none; transition: border-color 0.2s; }
|
| 196 |
+
#message-input:focus { border-color: #4A90E2; }
|
| 197 |
+
#send-button { background-color: #4A90E2; color: white; border: none; border-radius: 50%; width: 40px; height: 40px; font-size: 1.5em; cursor: pointer; transition: background-color 0.2s; flex-shrink: 0; }
|
| 198 |
+
#send-button:hover { background-color: #357ABD; }
|
| 199 |
+
|
| 200 |
+
/* =================================
|
| 201 |
+
右サイドバー (設定パネル)
|
| 202 |
+
================================= */
|
| 203 |
+
aside#settings-panel {
|
| 204 |
+
width: 300px;
|
| 205 |
+
background-color: #f9f9f9;
|
| 206 |
+
border-left: 1px solid #ddd;
|
| 207 |
+
padding: 20px;
|
| 208 |
+
transition: width 0.3s ease, padding 0.3s ease;
|
| 209 |
+
overflow: hidden;
|
| 210 |
+
box-sizing: border-box;
|
| 211 |
+
}
|
| 212 |
+
#settings-panel.hidden { width: 0; padding: 20px 0; border-left: none; }
|
| 213 |
+
#settings-panel h3 { margin-top: 0; text-align: center; border-bottom: 1px solid #eee; padding-bottom: 15px; }
|
| 214 |
+
.setting-item { display: flex; flex-direction: column; gap: 8px; }
|
| 215 |
+
.setting-item label { font-weight: bold; font-size: 0.9em; color: #555; }
|
| 216 |
+
.setting-item textarea { width: 100%; padding: 8px 12px; border: 1px solid #ccc; border-radius: 8px; font-size: 0.95em; box-sizing: border-box; font-family: inherit; resize: vertical; min-height: 100px; }
|
| 217 |
+
.setting-item button { background-color: #5cb85c; color: white; border: none; border-radius: 8px; padding: 10px; cursor: pointer; font-weight: bold; transition: background-color 0.2s; }
|
| 218 |
+
.setting-item button:hover { background-color: #4a934a; }
|