Files
syops/frontend/src/features/chat/components/ChatViewContent.vue
T

158 lines
6.7 KiB
Vue

/**
* features/chat/components/ChatViewContent.vue
* 对话页主区域:侧栏、消息列表、输入栏与内置浏览器。
*/
<script setup lang="ts">
import { Loader2 } from 'lucide-vue-next';
import ChatShell from '@/shared/layouts/ChatShell.vue';
import ChatSidebar from '@/features/chat/components/ChatSidebar.vue';
import ChatInputBar from '@/features/chat/components/ChatInputBar.vue';
import ChatMessageList from '@/features/chat/components/ChatMessageList.vue';
import ChatMobileHeader from '@/features/chat/components/ChatMobileHeader.vue';
import ChatBrowserPanel from '@/features/chat/components/ChatBrowserPanel.vue';
import { useChatPageContext } from '@/features/chat/composables/chat.context';
const page = useChatPageContext();
</script>
<template>
<ChatShell>
<template #overlay>
<div
v-if="page.isSidebarOpen && !page.isMobile"
class="fixed inset-0 z-40 bg-overlay backdrop-blur-sm transition-opacity md:hidden"
@click="page.isSidebarOpen = false"
/>
</template>
<template #sidebar>
<ChatSidebar
v-if="!page.isMobile"
v-model:collapsed="page.sidebarCollapsed"
v-model:agent-panel-open="page.showAgentPanel"
:is-open="page.isSidebarOpen"
:current-agent="page.currentAgent"
:agent-description="page.agentDescription"
:has-agent-guides="page.agentGuides.length > 0"
:display-history="page.displayHistory"
:active-history-key="page.activeHistoryKey"
:user-agents="page.userAgents"
:current-user="page.currentUser"
:applied-theme="page.appliedTheme"
@new-chat="page.handleSidebarNewChat"
@open-guide="page.openGuideModal"
@history-select="page.handleHistorySelect"
@clear-all-history="page.clearAllHistory"
@delete-history-item="page.deleteHistoryItem"
@switch-agent="page.switchToAgent"
@toggle-theme="page.toggleLightDark"
@open-feedback="page.showGeneralFeedbackDialog = true"
@go-workspace="page.goToWorkspace()"
@go-admin="page.goToAdmin"
@logout="page.handleLogout"
/>
</template>
<ChatMobileHeader
v-if="page.isMobile && page.currentAgent"
:agent-name="page.currentAgent?.name || 'AI'"
:has-agent-guides="page.agentGuides.length > 0"
:user-agents="page.userAgents"
@open-guide="page.openGuideModal"
@go-history="page.goToWorkspace('history')"
@open-agent-popover="page.loadUserAgents"
@switch-agent="page.switchToAgent"
/>
<div v-if="!page.currentAgent" class="flex flex-1 flex-col items-center justify-center space-y-4">
<Loader2 class="h-10 w-10 animate-spin text-brand-500" />
<p class="text-sm animate-pulse text-muted">{{ $t('chat.loadingAgent') }}</p>
</div>
<div v-else-if="page.currentAgent.type === 'iframe'" class="relative h-full w-full flex-1">
<iframe
:src="page.currentAgent.extra_config?.iframe_url"
class="h-full w-full border-0 bg-surface"
allow="microphone; camera; clipboard-read; clipboard-write"
/>
</div>
<template v-else>
<div class="flex min-h-0 flex-1">
<div class="flex min-h-0 flex-1 flex-col">
<ChatMessageList
:messages="page.messages"
:agent-name="page.currentAgent?.name || 'AI'"
:suggested-questions-style="page.suggestedQuestionsStyle"
:styled-sections="page.styledSuggestedQuestionSections"
:suggested-questions="page.agentSuggestedQuestions"
:show-thinking-bubble="page.shouldShowThinkingBubble"
:is-thinking="page.isThinking"
:show-chat-rating="page.showChatRating"
:copied-index="page.copiedIndex"
:is-shipping-notice-agent="page.isShippingNoticeAgent"
:handlers="page.messageBubbleHandlers"
:leave-handlers="page.leaveMessageHandlers"
:shipping-handlers="page.shippingMappingHandlers"
:should-render-message="page.shouldRenderMessage"
:should-show-tool-run-progress-after-message="page.shouldShowToolRunProgressAfterMessage"
:tool-run-progress="page.toolRunProgress"
:tool-run-progress-loading="page.toolRunProgressLoading"
:tool-run-progress-error="page.toolRunProgressError"
:tool-run-progress-title="page.toolRunProgressTitle"
:scroll-container-holder="page.scrollContainerHolder"
@copy="page.copyToClipboard($event.message, $event.index)"
@edit="page.input = $event"
@resend="page.handleSend($event)"
@regenerate="page.regenerate"
@open-feedback="page.handleOpenFeedback($event)"
@select-question="page.handleSend"
/>
<ChatInputBar
v-model="page.input"
v-model:selected-kb="page.selectedKb"
:attachments="page.attachments"
:attachment-policy="page.attachmentPolicy"
:available-kb-options="page.availableKbOptions"
:kb-dropdown-disabled="page.kbDropdownDisabled"
:is-thinking="page.isThinking"
:is-voice-recording="page.isVoiceRecording"
:is-voice-transcribing="page.isVoiceTranscribing"
:is-uploading-attachments="page.isUploadingAttachments"
:can-send-message="page.canSendMessage"
:is-shipping-notice-agent="page.isShippingNoticeAgent"
:shipping-suggested-prompt="page.shippingSuggestedPrompt"
:shipping-picker-ref-holder="page.shippingPickerRefHolder"
:get-kb-label="page.getKbLabel"
:browser-panel-open="page.browserPanelOpen"
@toggle-browser="page.toggleBrowserPanel"
@send="page.handleSend()"
@voice-click="page.handleVoiceFeatureClick"
@remove-attachment="page.removeAttachment"
@local-files-selected="page.handleLocalFilesSelected"
@add-remote-url="page.addRemoteUrlAttachment"
@shipping-inventory-selected="page.handleShippingInventorySelected"
@use-shipping-suggested-prompt="page.useShippingSuggestedPrompt"
/>
</div>
<ChatBrowserPanel
v-model:open="page.browserPanelOpen"
v-model:draft-url="page.browserDraftUrl"
:current-url="page.browserCurrentUrl"
:frame-key="page.browserFrameKey"
:panel-style="page.browserPanelStyle"
:is-resizing="page.isBrowserResizing"
@load="page.browser.loadPage"
@refresh="page.browser.refreshPage"
@open-new-tab="page.browser.openInNewTab"
@url-enter="page.browser.onUrlEnter"
@start-resize="page.browser.startResize"
@close="page.browser.close"
/>
</div>
</template>
</ChatShell>
</template>