|
@@ -402,6 +402,7 @@
|
|
class="message-input"
|
|
class="message-input"
|
|
v-model="inputContent"
|
|
v-model="inputContent"
|
|
@keyup.enter="sendMessage"
|
|
@keyup.enter="sendMessage"
|
|
|
|
+ @input="handleInputChange"
|
|
placeholder="Type a message..."
|
|
placeholder="Type a message..."
|
|
/>
|
|
/>
|
|
<button
|
|
<button
|
|
@@ -415,7 +416,7 @@
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- <div class="right_menu" :class="{ collapsed: isRightMenuCollapsed }" :style="{ width: rightMenuWidth + 'px' }">
|
|
|
|
|
|
+ <div class="right_menu" :class="{ collapsed: isRightMenuCollapsed || !enableWebSearch }" :style="{ width: rightMenuWidth + 'px' }">
|
|
<!-- 添加拖动条 -->
|
|
<!-- 添加拖动条 -->
|
|
<div
|
|
<div
|
|
class="resize-handle"
|
|
class="resize-handle"
|
|
@@ -437,10 +438,29 @@
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div class="right-menu-content">
|
|
<div class="right-menu-content">
|
|
|
|
+ <div class="search-header">
|
|
|
|
+ <span>搜索结果</span>
|
|
|
|
+ <div class="web-search-toggle">
|
|
|
|
+ <input
|
|
|
|
+ type="checkbox"
|
|
|
|
+ id="searchToggle"
|
|
|
|
+ v-model="enableWebSearch"
|
|
|
|
+ class="toggle-input"
|
|
|
|
+ @change="handleSearchToggle"
|
|
|
|
+ />
|
|
|
|
+ <label for="searchToggle" class="toggle-label">
|
|
|
|
+ {{ enableWebSearch ? '搜索已开启' : '搜索已关闭' }}
|
|
|
|
+ </label>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
<SearchResults
|
|
<SearchResults
|
|
|
|
+ v-if="enableWebSearch"
|
|
:searchResults="searchResults"
|
|
:searchResults="searchResults"
|
|
:loading="isSearchLoading"
|
|
:loading="isSearchLoading"
|
|
:total="searchTotal"
|
|
:total="searchTotal"
|
|
|
|
+ :enableWebSearch="enableWebSearch"
|
|
|
|
+ :message="currentSearchQuery"
|
|
|
|
+ @update:enableWebSearch="handleSearchToggle"
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -464,6 +484,7 @@ import {
|
|
FileOutlined,
|
|
FileOutlined,
|
|
ArrowUpOutlined,
|
|
ArrowUpOutlined,
|
|
UploadOutlined,
|
|
UploadOutlined,
|
|
|
|
+ FileSearchOutlined,
|
|
} from "@ant-design/icons-vue";
|
|
} from "@ant-design/icons-vue";
|
|
import leftIcon from "../assets/svg/left.svg";
|
|
import leftIcon from "../assets/svg/left.svg";
|
|
import rightIcon from "../assets/svg/right.svg";
|
|
import rightIcon from "../assets/svg/right.svg";
|
|
@@ -485,6 +506,7 @@ import SearchResults from "../components/SearchResults/index.vue";
|
|
import VoiceConfig from "../components/VoiceConfig/index.vue";
|
|
import VoiceConfig from "../components/VoiceConfig/index.vue";
|
|
import KnowledgeConfig from "../components/KnowledgeConfig/index.vue";
|
|
import KnowledgeConfig from "../components/KnowledgeConfig/index.vue";
|
|
import ExportButton from "../components/ExportButton/index.vue";
|
|
import ExportButton from "../components/ExportButton/index.vue";
|
|
|
|
+import dayjs from 'dayjs';
|
|
|
|
|
|
// 初始化 markdown-it
|
|
// 初始化 markdown-it
|
|
const md = new MarkdownIt({
|
|
const md = new MarkdownIt({
|
|
@@ -871,6 +893,11 @@ const sendMessage = async () => {
|
|
)
|
|
)
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
+ // 如果启用了网络搜索,更新搜索查询
|
|
|
|
+ if (enableWebSearch.value) {
|
|
|
|
+ currentSearchQuery.value = inputContent.value;
|
|
|
|
+ }
|
|
|
|
+
|
|
// 构建消息内容,包含文件信息
|
|
// 构建消息内容,包含文件信息
|
|
let messageContent = inputContent.value.trim();
|
|
let messageContent = inputContent.value.trim();
|
|
|
|
|
|
@@ -1230,6 +1257,66 @@ const startResize = (e) => {
|
|
document.addEventListener('touchend', handleEnd);
|
|
document.addEventListener('touchend', handleEnd);
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+// 添加搜索开关状态
|
|
|
|
+const isSearchEnabled = ref(true);
|
|
|
|
+
|
|
|
|
+// 添加切换搜索方法
|
|
|
|
+const toggleSearch = () => {
|
|
|
|
+ isSearchEnabled.value = !isSearchEnabled.value;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// 修改 toggleWebSearch 方法
|
|
|
|
+const toggleWebSearch = () => {
|
|
|
|
+ enableWebSearch.value = !enableWebSearch.value;
|
|
|
|
+ isSearchEnabled.value = enableWebSearch.value;
|
|
|
|
+
|
|
|
|
+ // 当关闭搜索时,自动折叠右侧菜单
|
|
|
|
+ if (!enableWebSearch.value) {
|
|
|
|
+ isRightMenuCollapsed.value = true;
|
|
|
|
+ currentSearchQuery.value = '';
|
|
|
|
+ if (document.querySelector('.chat')) {
|
|
|
|
+ document.querySelector('.chat').style.right = '0';
|
|
|
|
+ }
|
|
|
|
+ } else if (inputContent.value.trim()) {
|
|
|
|
+ isRightMenuCollapsed.value = false;
|
|
|
|
+ currentSearchQuery.value = inputContent.value;
|
|
|
|
+ if (document.querySelector('.chat')) {
|
|
|
|
+ document.querySelector('.chat').style.right = `${rightMenuWidth.value}px`;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// 添加新的响应式变量
|
|
|
|
+const currentSearchQuery = ref('');
|
|
|
|
+
|
|
|
|
+// 添加输入变化处理方法
|
|
|
|
+const handleInputChange = () => {
|
|
|
|
+ if (enableWebSearch.value && inputContent.value.trim()) {
|
|
|
|
+ currentSearchQuery.value = inputContent.value;
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// 添加处理搜索开关的方法
|
|
|
|
+const handleSearchToggle = (value) => {
|
|
|
|
+ enableWebSearch.value = value;
|
|
|
|
+ isSearchEnabled.value = value;
|
|
|
|
+
|
|
|
|
+ // 当关闭搜索时,自动折叠右侧菜单
|
|
|
|
+ if (!value) {
|
|
|
|
+ isRightMenuCollapsed.value = true;
|
|
|
|
+ // 更新聊天区域的样式
|
|
|
|
+ if (document.querySelector('.chat')) {
|
|
|
|
+ document.querySelector('.chat').style.right = '0';
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ isRightMenuCollapsed.value = false;
|
|
|
|
+ // 展开时更新聊天区域的样式
|
|
|
|
+ if (document.querySelector('.chat')) {
|
|
|
|
+ document.querySelector('.chat').style.right = `${rightMenuWidth.value}px`;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
<style scoped>
|
|
@@ -1963,13 +2050,13 @@ const startResize = (e) => {
|
|
background: #f7f7f8;
|
|
background: #f7f7f8;
|
|
border-left: 1px solid rgba(0, 0, 0, 0.06);
|
|
border-left: 1px solid rgba(0, 0, 0, 0.06);
|
|
transform: translateX(0);
|
|
transform: translateX(0);
|
|
- transition: transform 0.3s ease;
|
|
|
|
|
|
+ transition: transform 0.3s ease, width 0.3s ease;
|
|
z-index: 2;
|
|
z-index: 2;
|
|
}
|
|
}
|
|
|
|
|
|
.right_menu.collapsed {
|
|
.right_menu.collapsed {
|
|
- transform: translateX(100%); /* 使用 transform 代替 width */
|
|
|
|
- width: 600px; /* 保持固定宽度 */
|
|
|
|
|
|
+ transform: translateX(100%);
|
|
|
|
+ width: 0;
|
|
}
|
|
}
|
|
|
|
|
|
/* 当右侧菜单展开时,给聊天区域添加右边距 */
|
|
/* 当右侧菜单展开时,给聊天区域添加右边距 */
|
|
@@ -2843,6 +2930,63 @@ button,
|
|
width: 100% !important;
|
|
width: 100% !important;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+.search-header {
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: space-between;
|
|
|
|
+ align-items: center;
|
|
|
|
+ padding: 16px;
|
|
|
|
+ border-bottom: 1px solid #f0f0f0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.search-header span {
|
|
|
|
+ font-size: 16px;
|
|
|
|
+ font-weight: bold;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* 添加开关样式 */
|
|
|
|
+.web-search-toggle {
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.toggle-input {
|
|
|
|
+ position: relative;
|
|
|
|
+ width: 36px;
|
|
|
|
+ height: 20px;
|
|
|
|
+ margin-right: 8px;
|
|
|
|
+ appearance: none;
|
|
|
|
+ background: #ccc;
|
|
|
|
+ border-radius: 10px;
|
|
|
|
+ cursor: pointer;
|
|
|
|
+ transition: background 0.3s;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.toggle-input:checked {
|
|
|
|
+ background: #1677ff;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.toggle-input::before {
|
|
|
|
+ content: "";
|
|
|
|
+ position: absolute;
|
|
|
|
+ top: 2px;
|
|
|
|
+ left: 2px;
|
|
|
|
+ width: 16px;
|
|
|
|
+ height: 16px;
|
|
|
|
+ background: white;
|
|
|
|
+ border-radius: 50%;
|
|
|
|
+ transition: transform 0.3s;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.toggle-input:checked::before {
|
|
|
|
+ transform: translateX(16px);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.toggle-label {
|
|
|
|
+ font-size: 14px;
|
|
|
|
+ color: rgba(0, 0, 0, 0.88);
|
|
|
|
+ cursor: pointer;
|
|
|
|
+}
|
|
</style>
|
|
</style>
|
|
<style lang="less" scoped>
|
|
<style lang="less" scoped>
|
|
::v-deep .message-content {
|
|
::v-deep .message-content {
|