+
+
+
diff --git a/ui/src/conversation-panel/right-sidebar/index.ts b/ui/src/conversation-panel/right-sidebar/index.ts
index e86829bd383..488543980f6 100644
--- a/ui/src/conversation-panel/right-sidebar/index.ts
+++ b/ui/src/conversation-panel/right-sidebar/index.ts
@@ -1,8 +1,8 @@
-import { inject, ref } from 'vue'
+import { computed, inject, ref, toValue, watch } from 'vue'
import type { ChatRecordMeta } from '../core/types'
import type { PreviewFile } from './file-preview/index'
import type { ChatParagraphSource } from '@/api/types'
-import type { InjectionKey } from 'vue'
+import type { InjectionKey, MaybeRefOrGetter, Ref } from 'vue'
import { createExecutionDetailStore } from './execution-detail/index'
import { createFilePreviewStore } from './file-preview/index'
import { createKnowledgeSourceStore } from './knowledge-source/index'
@@ -16,6 +16,35 @@ export const RIGHT_SIDEBAR_PANEL = {
export type RightSidebarPanel = (typeof RIGHT_SIDEBAR_PANEL)[keyof typeof RIGHT_SIDEBAR_PANEL]
+/**
+ * 右侧栏宽度:执行详情、知识来源固定 420px;文件预览默认取对话区一半(420px–960px),可拖动调整并记住。
+ * 拖动后的宽度至少 420px,并为对话区保留至少 360px;窗口变窄时按当前上限显示,不改写记住的宽度。cqw 以对话布局宽度为基准。
+ */
+const RIGHT_SIDEBAR_WIDTH = 420
+const FILE_PREVIEW_DEFAULT_WIDTH = 'clamp(420px, 50cqw, 960px)'
+const FILE_PREVIEW_MIN_WIDTH = 420
+const CONVERSATION_MIN_WIDTH = 360
+const FILE_PREVIEW_WIDTH_STORAGE_KEY = 'conversation-file-preview-width'
+
+// 读取记住的文件预览宽度;嵌入页禁用存储等读取失败时按未调整处理
+function readFilePreviewWidth(): number | null {
+ try {
+ const width = Number(localStorage.getItem(FILE_PREVIEW_WIDTH_STORAGE_KEY))
+ return width >= FILE_PREVIEW_MIN_WIDTH ? width : null
+ } catch {
+ return null
+ }
+}
+
+function writeFilePreviewWidth(width: number | null) {
+ try {
+ if (width == null) localStorage.removeItem(FILE_PREVIEW_WIDTH_STORAGE_KEY)
+ else localStorage.setItem(FILE_PREVIEW_WIDTH_STORAGE_KEY, String(width))
+ } catch {
+ // 存储不可用时只在本次页面内生效
+ }
+}
+
/**
* 右侧栏 store:当前面板与右侧开合,组合各面板自己的 store。
* 由 view 创建并 provide;消息底部点击「执行详情」「知识来源」、回答中点击可预览文件时写入对应面板数据并打开右侧。
@@ -26,6 +55,28 @@ export function createRightSidebarStore() {
const executionDetail = createExecutionDetailStore()
const knowledgeSource = createKnowledgeSourceStore()
const filePreview = createFilePreviewStore()
+ const filePreviewWidth = ref(readFilePreviewWidth())
+ /** 只有文件预览可拖动调整宽度 */
+ const rightResizable = computed(() => panel.value === RIGHT_SIDEBAR_PANEL.FILE_PREVIEW)
+ const rightWidth = computed(() => {
+ if (!rightResizable.value) return RIGHT_SIDEBAR_WIDTH
+ if (filePreviewWidth.value == null) return FILE_PREVIEW_DEFAULT_WIDTH
+ return `clamp(${FILE_PREVIEW_MIN_WIDTH}px, ${filePreviewWidth.value}px, calc(100cqw - ${CONVERSATION_MIN_WIDTH}px))`
+ })
+
+ // 拖动调整文件预览宽度,按当前布局宽度限定范围后记住
+ const resizeRight = (width: number, layoutWidth: number) => {
+ if (!rightResizable.value) return
+ const maxWidth = Math.max(FILE_PREVIEW_MIN_WIDTH, layoutWidth - CONVERSATION_MIN_WIDTH)
+ filePreviewWidth.value = Math.round(Math.min(Math.max(width, FILE_PREVIEW_MIN_WIDTH), maxWidth))
+ writeFilePreviewWidth(filePreviewWidth.value)
+ }
+
+ // 恢复文件预览默认宽度
+ const resetRightWidth = () => {
+ filePreviewWidth.value = null
+ writeFilePreviewWidth(null)
+ }
const openPanel = (target: RightSidebarPanel) => {
panel.value = target
@@ -53,6 +104,10 @@ export function createRightSidebarStore() {
return {
panel,
rightSideOpen,
+ rightWidth,
+ rightResizable,
+ resizeRight,
+ resetRightWidth,
executionDetail,
knowledgeSource,
filePreview,
@@ -65,6 +120,35 @@ export function createRightSidebarStore() {
export type RightSidebarStore = ReturnType
+/**
+ * 挤压态下文件预览与左侧栏互相让位,避免对话区被两侧挤窄:
+ * 打开文件预览时收起左侧栏,预览关闭或切到其他面板后恢复由预览收起的左侧栏;预览中展开左侧栏则关闭预览。
+ * 抽屉态两侧都覆盖在对话区上,不处理。
+ */
+export function bindFilePreviewLeftSide(rightSidebar: RightSidebarStore, leftSideOpen: Ref, pushMode: MaybeRefOrGetter) {
+ const previewOpen = computed(() => rightSidebar.rightSideOpen.value && rightSidebar.panel.value === RIGHT_SIDEBAR_PANEL.FILE_PREVIEW)
+ let collapsedByPreview = false
+
+ watch(previewOpen, (open) => {
+ if (!toValue(pushMode)) {
+ collapsedByPreview = false
+ return
+ }
+ if (open && leftSideOpen.value) {
+ collapsedByPreview = true
+ leftSideOpen.value = false
+ } else if (!open && collapsedByPreview) {
+ collapsedByPreview = false
+ leftSideOpen.value = true
+ }
+ })
+ watch(leftSideOpen, (open) => {
+ if (!open || !previewOpen.value || !toValue(pushMode)) return
+ collapsedByPreview = false
+ rightSidebar.closeRightSide()
+ })
+}
+
export const RIGHT_SIDEBAR_KEY: InjectionKey = Symbol('right-sidebar')
export function useRightSidebarStore(): RightSidebarStore {
diff --git a/ui/src/conversation-panel/view/chat/index.vue b/ui/src/conversation-panel/view/chat/index.vue
index 98592feae41..439eaac2e78 100644
--- a/ui/src/conversation-panel/view/chat/index.vue
+++ b/ui/src/conversation-panel/view/chat/index.vue
@@ -10,7 +10,7 @@ import ConversationLayout from '../../core/layout/index.vue'
import { CONVERSATION_LIST_KEY } from '../../left-sidebar/conversation-list/index'
import ConversationList from '../../left-sidebar/conversation-list/index.vue'
import ChatPanel from '../../main/chat-panel/index.vue'
-import { RIGHT_SIDEBAR_KEY } from '../../right-sidebar/index'
+import { RIGHT_SIDEBAR_KEY, bindFilePreviewLeftSide } from '../../right-sidebar/index'
import RightSidebar from '../../right-sidebar/index.vue'
import { CHAT_USER_PROFILE_KEY, DEVICE_KEY, SHOW_SHARE_KEY, VIEW_KEY, VIEW_TYPE, createDeviceType } from '../index.ts'
import { createChatConversation, createChatUserProfileGetter } from './index'
@@ -55,6 +55,8 @@ bundle.list.bindLeftSideMode(leftMode)
const rightMode = computed(() => (isMobile.value ? 'drawer' : 'push'))
// 左栏为抽屉即手机端
provide(DEVICE_KEY, createDeviceType(leftMode))
+// 挤压态下文件预览与左侧栏互相让位
+bindFilePreviewLeftSide(bundle.rightSidebar, bundle.list.leftSideOpen, () => leftMode.value === 'push')
const closeDrawers = () => {
if (leftMode.value === 'drawer') bundle.list.leftSideOpen.value = false
@@ -83,9 +85,13 @@ watch([() => bundle.list.currentChatId.value, () => bundle.list.composerResetSig
diff --git a/ui/src/conversation-panel/view/debug/index.vue b/ui/src/conversation-panel/view/debug/index.vue
index 001a443512c..80b2b97d888 100644
--- a/ui/src/conversation-panel/view/debug/index.vue
+++ b/ui/src/conversation-panel/view/debug/index.vue
@@ -12,7 +12,7 @@ import ConversationLayout from '../../core/layout/index.vue'
import { CONVERSATION_LIST_KEY } from '../../left-sidebar/conversation-list/index'
import ConversationList from '../../left-sidebar/conversation-list/index.vue'
import ChatPanel from '../../main/chat-panel/index.vue'
-import { RIGHT_SIDEBAR_KEY } from '../../right-sidebar/index'
+import { RIGHT_SIDEBAR_KEY, bindFilePreviewLeftSide } from '../../right-sidebar/index'
import RightSidebar from '../../right-sidebar/index.vue'
import { DEVICE_KEY, VIEW_KEY, VIEW_TYPE, createDeviceType } from '../index.ts'
import { createDebugConversation } from './index'
@@ -56,6 +56,8 @@ const leftMode = computed(() => (debug.expanded.value ? 'push' : 'drawer'))
const rightMode = computed(() => (debug.expanded.value ? 'push' : 'drawer'))
// 左栏为抽屉即手机端
provide(DEVICE_KEY, createDeviceType(leftMode))
+// 挤压态下文件预览与左侧栏互相让位
+bindFilePreviewLeftSide(bundle.rightSidebar, bundle.list.leftSideOpen, () => leftMode.value === 'push')
// 抽屉态:遮罩点击 / 切换会话 → 收起
const closeDrawers = () => {
@@ -85,9 +87,13 @@ watch([() => bundle.list.currentChatId.value, () => bundle.list.composerResetSig
diff --git a/ui/src/conversation-panel/view/embed/index.vue b/ui/src/conversation-panel/view/embed/index.vue
index 4c57a1d8d77..171abcc8a9d 100644
--- a/ui/src/conversation-panel/view/embed/index.vue
+++ b/ui/src/conversation-panel/view/embed/index.vue
@@ -11,7 +11,7 @@ import ConversationLayout from '../../core/layout/index.vue'
import { CONVERSATION_LIST_KEY } from '../../left-sidebar/conversation-list/index'
import ConversationList from '../../left-sidebar/conversation-list/index.vue'
import ChatPanel from '../../main/chat-panel/index.vue'
-import { RIGHT_SIDEBAR_KEY } from '../../right-sidebar/index'
+import { RIGHT_SIDEBAR_KEY, bindFilePreviewLeftSide } from '../../right-sidebar/index'
import RightSidebar from '../../right-sidebar/index.vue'
import { createChatUserProfileGetter } from '../chat/index'
import { CHAT_USER_PROFILE_KEY, DEVICE_KEY, SHOW_SHARE_KEY, VIEW_KEY, VIEW_TYPE, createDeviceType } from '../index.ts'
@@ -59,6 +59,8 @@ bundle.list.bindLeftSideMode(leftMode)
const rightMode = computed(() => (isMobile.value ? 'drawer' : 'push'))
// 左栏为抽屉即手机端
provide(DEVICE_KEY, createDeviceType(leftMode))
+// 挤压态下文件预览与左侧栏互相让位
+bindFilePreviewLeftSide(bundle.rightSidebar, bundle.list.leftSideOpen, () => leftMode.value === 'push')
const closeDrawers = () => {
if (leftMode.value === 'drawer') bundle.list.leftSideOpen.value = false
@@ -87,9 +89,13 @@ watch([() => bundle.list.currentChatId.value, () => bundle.list.composerResetSig
diff --git a/ui/src/conversation-panel/view/portal/index.vue b/ui/src/conversation-panel/view/portal/index.vue
index 3164ef5367e..40b022ba1c0 100644
--- a/ui/src/conversation-panel/view/portal/index.vue
+++ b/ui/src/conversation-panel/view/portal/index.vue
@@ -13,7 +13,7 @@ import { PORTAL_CONVERSATION_LIST_KEY } from '../../left-sidebar/portal-conversa
import PortalConversationList from '../../left-sidebar/portal-conversation-list/index.vue'
import PortalApplicationPanel from '../../main/portal-application-panel/index.vue'
import PortalChatPanel from '../../main/portal-chat-panel/index.vue'
-import { RIGHT_SIDEBAR_KEY } from '../../right-sidebar/index'
+import { RIGHT_SIDEBAR_KEY, bindFilePreviewLeftSide } from '../../right-sidebar/index'
import RightSidebar from '../../right-sidebar/index.vue'
import { createChatUserProfileGetter } from '../chat/index'
import { CHAT_USER_PROFILE_KEY, DEVICE_KEY, SHOW_SHARE_KEY, VIEW_KEY, VIEW_TYPE, createDeviceType } from '../index.ts'
@@ -60,6 +60,8 @@ bundle.list.bindLeftSideMode(leftMode)
const rightMode = computed(() => (isMobile.value ? 'drawer' : 'push'))
// 左栏为抽屉即手机端
provide(DEVICE_KEY, createDeviceType(leftMode))
+// 挤压态下文件预览与左侧栏互相让位
+bindFilePreviewLeftSide(bundle.rightSidebar, bundle.list.leftSideOpen, () => leftMode.value === 'push')
const closeDrawers = () => {
if (leftMode.value === 'drawer') bundle.list.leftSideOpen.value = false
@@ -89,9 +91,13 @@ watch([() => bundle.list.currentChatId.value, () => bundle.list.composerResetSig