From 7f310340730018e1443d5aae9e6ff45ffd73c3e5 Mon Sep 17 00:00:00 2001 From: Metona Date: Sat, 4 Apr 2026 21:08:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=96=87=E6=9C=AC/=E4=BB=A3=E7=A0=81=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=BB=99=20Ollama=20=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - utils.js: 新增 fileToText() 读取文件文本、detectLanguage() 识别编程语言 - index.html: 新增文件上传按钮(📄)和文件预览容器 - input-area.js: 完整文件上传流程(校验/读取/预览/消息构造/发送) - style.css: 文件 chip 预览样式 支持 50+ 种文本/代码扩展名,文件内容以代码块格式嵌入消息。 单文件限制 500KB,支持多文件同时上传。 --- css/style.css | 64 ++++++++++++++ index.html | 13 ++- js/components/input-area.js | 163 ++++++++++++++++++++++++++++++------ js/utils.js | 41 +++++++++ 4 files changed, 255 insertions(+), 26 deletions(-) diff --git a/css/style.css b/css/style.css index 9425fea..e004ec2 100644 --- a/css/style.css +++ b/css/style.css @@ -806,6 +806,70 @@ body::before { justify-content: center; } +/* ── 文件预览区域 ── */ +.file-preview { + display: flex; + flex-wrap: wrap; + gap: 8px; + padding: 8px 0; +} + +.file-chip { + display: flex; + align-items: center; + gap: 6px; + padding: 5px 10px; + border-radius: 8px; + background: rgba(0, 245, 212, 0.06); + border: 1px solid rgba(0, 245, 212, 0.18); + font-size: 12px; + line-height: 1; + transition: var(--transition); + animation: fadeInUp 0.2s ease; +} + +.file-chip:hover { + border-color: rgba(0, 245, 212, 0.35); + background: rgba(0, 245, 212, 0.1); +} + +.file-icon { + font-size: 14px; + flex-shrink: 0; +} + +.file-name { + font-weight: 600; + color: var(--text-primary); + max-width: 160px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.file-size { + color: var(--text-muted); + flex-shrink: 0; +} + +.remove-file { + background: none; + border: none; + color: var(--text-muted); + cursor: pointer; + font-size: 15px; + line-height: 1; + padding: 0 2px; + border-radius: 4px; + transition: var(--transition); + flex-shrink: 0; +} + +.remove-file:hover { + color: var(--accent-red); + background: rgba(239, 68, 68, 0.1); +} + .input-row { display: flex; align-items: flex-end; diff --git a/index.html b/index.html index ac5c8e4..717b958 100644 --- a/index.html +++ b/index.html @@ -95,14 +95,25 @@
+
- + +