Quellcode durchsuchen

release: v0.0.9
- 改进工具栏布局和样式
- 优化快捷指令面板交互
- 修复消息显示溢出问题

alibct vor 7 Monaten
Ursprung
Commit
23a6e652b7
5 geänderte Dateien mit 197 neuen und 43 gelöschten Zeilen
  1. 17 0
      CHANGELOG.md
  2. 125 19
      css/chat.css
  3. 10 1
      js/chat-ui.js
  4. 1 1
      manifest.json
  5. 44 22
      sidebar.html

+ 17 - 0
CHANGELOG.md

@@ -1,5 +1,22 @@
 # 更新日志
 
+## [0.0.9] - 2024-03-xx
+
+### 优化
+
+- 改进工具栏布局
+  - 优化工具栏按钮样式
+  - 调整工具栏间距和对齐
+  - 改进按钮排列方式
+- 优化快捷指令面板
+  - 改进关闭按钮样式
+  - 优化菜单项文本格式
+  - 添加图标支持
+- 修复消息显示问题
+  - 解决长文本溢出问题
+  - 优化代码块换行
+  - 改进链接显示效果
+
 ## [0.0.8] - 2024-03-xx
 
 ### 新增

+ 125 - 19
css/chat.css

@@ -21,6 +21,7 @@
   align-items: flex-start;
   max-width: 85%;
   margin-bottom: 4px;
+  width: 100%; /* 添加宽度限制 */
 }
 
 .message.user {
@@ -34,6 +35,11 @@
   background: #fff;
   box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
   transition: all 0.3s ease;
+  max-width: 100%; /* 限制最大宽度 */
+  overflow-wrap: break-word; /* 确保长文本会换行 */
+  word-wrap: break-word; /* 兼容性支持 */
+  word-break: break-word; /* 允许在单词内换行 */
+  hyphens: auto; /* 添加连字符支持 */
 }
 
 .message.assistant .message-content {
@@ -71,6 +77,7 @@
   transition: all 0.3s ease-out !important;
   min-height: 40px !important; /* 设置固定的最小高度 */
   max-height: 120px !important;
+  margin-top: 8px;
 }
 
 .input-wrapper:focus-within {
@@ -145,20 +152,67 @@
   opacity: 0.1;
 }
 
-/* 快捷指令面板 */
+/* 工具栏 */
+.toolbar {
+  display: flex;
+  align-items: center;
+  justify-content: flex-end; /* 改为从右向左排列 */
+  background: #fff;
+  border-radius: 8px;
+}
+
+.toolbar-left,
+.toolbar-right {
+  display: flex;
+  align-items: center;
+  gap: 8px;
+  flex-direction: row-reverse; /* 按钮从右向左排列 */
+}
+
+/* 工具栏按钮 */
+.toolbar-button {
+  display: inline-flex;
+  align-items: center;
+  gap: 6px;
+  padding: 8px 12px; /* 只保留左内边距 */
+  border: none;
+  border-radius: 6px;
+  background: #f5f7fa;
+  color: #444;
+  font-size: 13px;
+  font-weight: 500;
+  cursor: pointer;
+  transition: all 0.2s ease;
+}
+
+.toolbar-button:hover {
+  background: #edf2fc;
+  color: #1a73e8;
+}
+
+.toolbar-button svg {
+  width: 16px;
+  height: 16px;
+}
+
+/* 快捷指令面板优化 */
 .prompt-panel {
   position: absolute;
-  bottom: 80px;
+  bottom: 100%;
   left: 16px;
   right: 16px;
+  margin-bottom: 8px;
   background: #fff;
   border-radius: 8px;
-  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
+  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
+  max-height: 400px;
   display: none;
+  overflow: hidden;
 }
 
 .prompt-panel.show {
-  display: block;
+  display: flex;
+  flex-direction: column;
   animation: slideUp 0.2s ease-out;
 }
 
@@ -168,42 +222,47 @@
   align-items: center;
   padding: 12px 16px;
   border-bottom: 1px solid #eee;
+  background: #f8f9fa;
 }
 
 .prompt-header h3 {
   margin: 0;
-  font-size: 16px;
+  font-size: 14px;
   color: #333;
-}
-
-.close-prompt {
-  background: none;
-  border: none;
-  font-size: 20px;
-  color: #666;
-  cursor: pointer;
-  padding: 4px 8px;
+  font-weight: 500;
 }
 
 .prompt-list {
-  padding: 8px;
-  max-height: 300px;
+  flex: 1;
   overflow-y: auto;
+  padding: 8px;
 }
 
 .prompt-item {
+  display: flex;
+  align-items: center;
   width: 100%;
-  padding: 12px;
+  padding: 10px 12px;
   text-align: left;
   background: none;
   border: none;
   border-radius: 6px;
   cursor: pointer;
   transition: all 0.2s;
+  color: #333;
+  font-size: 13px;
+  line-height: 1.4;
 }
 
 .prompt-item:hover {
-  background: #f5f5f5;
+  background: #f0f4f8;
+}
+
+.prompt-item svg {
+  width: 16px;
+  height: 16px;
+  margin-right: 8px;
+  color: #666;
 }
 
 @keyframes slideUp {
@@ -382,10 +441,12 @@
 
 .message-content pre {
   background: #f6f8fa;
-  padding: 12px;
+  padding: 16px;
   border-radius: 6px;
   overflow-x: auto;
   margin: 8px 0;
+  max-width: 100%; /* 限制最大宽度 */
+  white-space: pre-wrap; /* 允许代码块换行 */
 }
 
 .message-content code {
@@ -399,11 +460,15 @@
 .message-content pre code {
   padding: 0;
   background: none;
+  font-size: 0.9em;
+  line-height: 1.5;
+  white-space: pre-wrap; /* 允许代码换行 */
 }
 
 .message-content a {
   color: #1a73e8;
   text-decoration: none;
+  word-break: break-all; /* 确保长链接可以换行 */
 }
 
 .message-content a:hover {
@@ -523,6 +588,8 @@
   border-radius: 6px;
   overflow-x: auto;
   margin: 8px 0;
+  max-width: 100%; /* 限制最大宽度 */
+  white-space: pre-wrap; /* 允许代码块换行 */
 }
 
 .message-content pre code {
@@ -530,6 +597,7 @@
   background: none;
   font-size: 0.9em;
   line-height: 1.5;
+  white-space: pre-wrap; /* 允许代码换行 */
 }
 
 /* 打断按钮样式 */
@@ -779,3 +847,41 @@
   overflow-y: auto !important;
   box-sizing: border-box !important; /* 添加盒模型设置 */
 }
+
+/* 快捷指令面板头部 */
+.prompt-header {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  padding: 12px 16px;
+  border-bottom: 1px solid #eee;
+  background: #f8f9fa;
+}
+
+/* 关闭按钮样式优化 */
+.close-prompt {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  width: 24px;
+  height: 24px;
+  padding: 0;
+  border: none;
+  border-radius: 4px;
+  background: transparent;
+  color: #666;
+  font-size: 18px;
+  cursor: pointer;
+  transition: all 0.2s ease;
+}
+
+.close-prompt:hover {
+  background: rgba(0, 0, 0, 0.05);
+  color: #333;
+}
+
+/* 使用SVG图标替代文字 */
+.close-prompt svg {
+  width: 16px;
+  height: 16px;
+}

+ 10 - 1
js/chat-ui.js

@@ -110,8 +110,17 @@ class ChatUI {
     // 点击快捷指令
     document.querySelectorAll(".prompt-item").forEach((item) => {
       item.addEventListener("click", () => {
-        this.input.value = item.textContent;
+        // 获取文本内容并处理格式
+        const text = item.textContent
+          .trim() // 移除首尾空白
+          .replace(/\s+/g, " ") // 将多个空白字符替换为单个空格
+          .replace(/[\n\r]+/g, ""); // 移除所有换行符
+
+        // 设置到输入框
+        this.input.value = text;
         this.promptPanel.classList.remove("show");
+
+        // 调整输入框高度并聚焦
         this.adjustInputHeight();
         this.input.focus();
       });

+ 1 - 1
manifest.json

@@ -1,7 +1,7 @@
 {
   "manifest_version": 3,
   "name": "派维斯智能体助手",
-  "version": "0.0.8",
+  "version": "0.0.9",
   "description": "一个辅助用户处理业务流程的智能体助手",
   "author": "Paiwise Team",
   "permissions": [

+ 44 - 22
sidebar.html

@@ -39,6 +39,50 @@
       </div>
 
       <div class="chat-input-container">
+        <!-- 工具栏 -->
+        <div class="toolbar">
+          <div class="toolbar-left">
+            <button class="toolbar-button" id="prompt-button">
+              <svg viewBox="0 0 24 24" fill="currentColor">
+                <path
+                  d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14z"
+                />
+                <path d="M7 12h2v5H7zm4-3h2v8h-2zm4-3h2v11h-2z" />
+              </svg>
+              快捷指令
+            </button>
+            <!-- 这里可以添加更多左侧工具按钮 -->
+          </div>
+          <div class="toolbar-right">
+            <!-- 这里可以添加右侧工具按钮 -->
+          </div>
+        </div>
+
+        <!-- 快捷指令面板 -->
+        <div class="prompt-panel" id="prompt-panel">
+          <div class="prompt-header">
+            <h3>快捷指令</h3>
+            <button class="close-prompt">
+              <svg viewBox="0 0 24 24" fill="currentColor">
+                <path
+                  d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
+                />
+              </svg>
+            </button>
+          </div>
+          <div class="prompt-list">
+            <button class="prompt-item">
+              <svg viewBox="0 0 24 24" fill="currentColor">
+                <path
+                  d="M3 17v2h6v-2H3zM3 5v2h10V5H3zm10 16v-2h8v-2h-8v-2h-2v6h2zM7 9v2H3v2h4v2h2V9H7zm14 4v-2H11v2h10zm-6-4h2V7h4V5h-4V3h-2v6z"
+                />
+              </svg>
+              分析当前页面的主要观点和论据
+            </button>
+            <!-- 添加更多快捷指令 -->
+          </div>
+        </div>
+
         <div class="input-wrapper">
           <textarea
             id="chat-input"
@@ -47,14 +91,6 @@
             autofocus
           ></textarea>
           <div class="input-buttons">
-            <button id="prompt-button" class="icon-button" title="快捷指令">
-              <svg viewBox="0 0 24 24" width="20" height="20">
-                <path
-                  fill="currentColor"
-                  d="M12 3L1 9l4 2.18v6L12 21l7-3.82v-6l2-1.09V17h2V9L12 3zm6.82 6L12 12.72 5.18 9 12 5.28 18.82 9zM17 15.99l-5 2.73-5-2.73v-3.72L12 15l5-2.73v3.72z"
-                />
-              </svg>
-            </button>
             <button id="send-button" class="icon-button" title="发送">
               <svg viewBox="0 0 24 24" width="20" height="20">
                 <path
@@ -66,20 +102,6 @@
           </div>
         </div>
       </div>
-
-      <!-- 快捷指令面板 -->
-      <div class="prompt-panel" id="prompt-panel">
-        <div class="prompt-header">
-          <h3>快捷指令</h3>
-          <button class="close-prompt">×</button>
-        </div>
-        <div class="prompt-list">
-          <button class="prompt-item">分析当前页面内容</button>
-          <button class="prompt-item">总结主要观点</button>
-          <button class="prompt-item">提取关键信息</button>
-          <button class="prompt-item">翻译选中内容</button>
-        </div>
-      </div>
     </div>
 
     <script src="js/config.js"></script>