首页布局更新

This commit is contained in:
2026-06-15 16:52:51 +08:00
parent 10519e7500
commit 536ad8386c
2 changed files with 212 additions and 204 deletions

View File

@@ -13,7 +13,7 @@
<div class="history-title">历史对话</div> <div class="history-title">历史对话</div>
<div class="history-list"> <div class="history-list">
<div <div
v-for="item in historyList" v-for="item in visibleHistory"
:key="item.id" :key="item.id"
class="history-item" class="history-item"
:class="{ active: activeHistoryId === item.id }" :class="{ active: activeHistoryId === item.id }"
@@ -31,12 +31,56 @@
</div> </div>
</div> </div>
</div> </div>
<div class="workspace-section">
<div class="workspace-title">工作流</div>
<div class="workspace-tree-wrap" v-loading="treeLoading">
<el-empty v-if="!treeLoading && treeNodes.length === 0" description="暂无作品数据" />
<el-tree
v-else
:data="treeNodes"
node-key="id"
:props="treeProps"
:highlight-current="true"
:expand-on-click-node="true"
>
<template #default="{ data }">
<div
class="tree-node"
:class="[
data.nodeType === 'date' ? 'level-date' :
data.nodeType === 'contentType' ? 'level-flow' : 'level-file',
data.fileType ? data.fileType.replace(/\//g, ' ').split(' ')[0] : ''
]"
>
<span class="ellipsis">{{ data.label }}</span>
<div v-if="data.nodeType === 'title' && data.fileUrl" class="tree-node-actions">
<el-button type="primary" link size="small" @click.stop="handlePreviewNode(data)"> 预览 </el-button>
<el-button type="primary" link size="small" @click.stop="handleDownloadNode(data)"> 下载 </el-button>
</div>
</div>
</template>
</el-tree>
</div>
</div>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue';
import { Plus, Delete } from '@element-plus/icons-vue'; import { Plus, Delete } from '@element-plus/icons-vue';
interface TreeNode {
id: string;
label: string;
nodeType: string;
children?: TreeNode[];
fileUrl?: string;
workflowId?: number | string;
fileType?: string;
sessionId?: string;
}
interface HistoryItem { interface HistoryItem {
id: number; id: number;
title: string; title: string;
@@ -47,6 +91,8 @@ interface Props {
activeMenu: string; activeMenu: string;
activeHistoryId: number; activeHistoryId: number;
historyList: HistoryItem[]; historyList: HistoryItem[];
treeNodes: TreeNode[];
treeLoading: boolean;
} }
interface Emits { interface Emits {
@@ -54,22 +100,22 @@ interface Emits {
(e: 'new-chat'): void; (e: 'new-chat'): void;
(e: 'select-history', id: number): void; (e: 'select-history', id: number): void;
(e: 'delete-history', id: number): void; (e: 'delete-history', id: number): void;
(e: 'preview-node', data: TreeNode): void;
(e: 'download-node', data: TreeNode): void;
} }
defineProps<Props>(); const props = defineProps<Props>();
const emit = defineEmits<Emits>(); const emit = defineEmits<Emits>();
const handleNewChat = () => { const treeProps = { children: 'children', label: 'label' };
emit('new-chat');
};
const handleSelectHistory = (id: number) => { const visibleHistory = computed(() => props.historyList);
emit('select-history', id);
};
const handleDeleteHistory = (id: number) => { const handleNewChat = () => emit('new-chat');
emit('delete-history', id); const handleSelectHistory = (id: number) => emit('select-history', id);
}; const handleDeleteHistory = (id: number) => emit('delete-history', id);
const handlePreviewNode = (data: TreeNode) => emit('preview-node', data);
const handleDownloadNode = (data: TreeNode) => emit('download-node', data);
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@@ -113,12 +159,11 @@ const handleDeleteHistory = (id: number) => {
} }
.history-section { .history-section {
flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin-top: 8px; margin-top: 8px;
min-height: 0; padding-bottom: 8px;
background: linear-gradient(180deg, rgba(249, 251, 255, 0.5) 0%, rgba(249, 251, 255, 0.9) 100%); border-bottom: 1px solid rgba(59, 130, 246, 0.08);
} }
.history-title { .history-title {
@@ -131,8 +176,8 @@ const handleDeleteHistory = (id: number) => {
} }
.history-list { .history-list {
flex: 1; padding: 0 8px 4px;
padding: 0 8px 10px; max-height: 255px;
overflow-y: auto; overflow-y: auto;
scrollbar-width: none; scrollbar-width: none;
-ms-overflow-style: none; -ms-overflow-style: none;
@@ -204,4 +249,146 @@ const handleDeleteHistory = (id: number) => {
font-size: 11px; font-size: 11px;
color: #94a3b8; color: #94a3b8;
} }
.workspace-section {
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
margin-top: 8px;
}
.workspace-title {
padding: 4px 12px 8px;
font-size: 11px;
font-weight: 600;
color: #64748b;
text-transform: uppercase;
letter-spacing: 0.8px;
}
.workspace-tree-wrap {
flex: 1;
padding: 0 8px 12px;
overflow-y: auto;
scrollbar-width: none;
-ms-overflow-style: none;
&::-webkit-scrollbar {
display: none;
}
:deep(.el-tree) {
background: transparent;
.el-tree-node {
padding: 4px 0;
}
.el-tree-node__content {
height: 38px;
line-height: 38px;
border-radius: 8px;
margin: 2px 0;
backdrop-filter: blur(8px);
transition: all 0.2s ease;
&:hover {
border-width: 2px;
transform: translateX(2px);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
}
.el-tree-node.is-current > .el-tree-node__content {
border-width: 2px;
box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
}
.el-tree-node__expand-icon {
color: rgba(59, 130, 246, 0.7);
}
}
:deep(.level-date) .el-tree-node__content {
height: 42px;
background: linear-gradient(135deg, rgba(59, 130, 246, 0.20) 0%, rgba(59, 130, 246, 0.05) 100%);
border: 1px solid rgba(59, 130, 246, 0.28);
font-weight: 600;
}
:deep(.level-flow) .el-tree-node__content {
margin-left: 8px;
background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(139, 92, 246, 0.03) 100%);
border: 1px solid rgba(139, 92, 246, 0.18);
}
:deep(.level-file.image) .el-tree-node__content,
:deep(.level-file.jpg) .el-tree-node__content,
:deep(.level-file.png) .el-tree-node__content,
:deep(.level-file.gif) .el-tree-node__content {
margin-left: 16px;
background: linear-gradient(135deg, rgba(16, 185, 129, 0.18) 0%, rgba(16, 185, 129, 0.04) 100%);
border: 1px solid rgba(16, 185, 129, 0.15);
}
:deep(.level-file.video) .el-tree-node__content,
:deep(.level-file.mp4) .el-tree-node__content,
:deep(.level-file.webm) .el-tree-node__content {
margin-left: 16px;
background: linear-gradient(135deg, rgba(245, 158, 11, 0.18) 0%, rgba(245, 158, 11, 0.04) 100%);
border: 1px solid rgba(245, 158, 11, 0.15);
}
:deep(.level-file.audio) .el-tree-node__content,
:deep(.level-file.mp3) .el-tree-node__content,
:deep(.level-file.wav) .el-tree-node__content {
margin-left: 16px;
background: linear-gradient(135deg, rgba(236, 72, 153, 0.18) 0%, rgba(236, 72, 153, 0.04) 100%);
border: 1px solid rgba(236, 72, 153, 0.15);
}
:deep(.level-file.text) .el-tree-node__content,
:deep(.level-file.md) .el-tree-node__content,
:deep(.level-file.txt) .el-tree-node__content,
:deep(.level-file.markdown) .el-tree-node__content {
margin-left: 16px;
background: linear-gradient(135deg, rgba(79, 70, 229, 0.18) 0%, rgba(79, 70, 229, 0.04) 100%);
border: 1px solid rgba(79, 70, 229, 0.15);
}
:deep(.level-file:not(.image):not(.video):not(.audio):not(.text)) .el-tree-node__content {
margin-left: 16px;
background: linear-gradient(135deg, rgba(100, 116, 139, 0.15) 0%, rgba(100, 116, 139, 0.04) 100%);
border: 1px solid rgba(100, 116, 139, 0.15);
}
}
.tree-node {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
gap: 6px;
.ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 13px;
font-weight: 500;
color: #1e293b;
}
.tree-node-actions {
flex-shrink: 0;
.el-button {
font-size: 11px;
padding: 2px 4px;
margin: 0;
line-height: 1;
}
}
}
</style> </style>

View File

@@ -4,50 +4,21 @@
:active-menu="activeMenu" :active-menu="activeMenu"
:active-history-id="activeHistoryId" :active-history-id="activeHistoryId"
:history-list="historyList" :history-list="historyList"
:tree-nodes="treeNodes"
:tree-loading="treeLoading"
@menu-change="handleMenuChange" @menu-change="handleMenuChange"
@new-chat="handleCreateHistory" @new-chat="handleCreateHistory"
@select-history="handleSelectHistory" @select-history="handleSelectHistory"
@delete-history="handleDeleteHistory" @delete-history="handleDeleteHistory"
@preview-node="previewNode"
@download-node="downloadNode"
/> />
<div class="main-wrapper"> <div class="main-wrapper">
<MainContent :active-menu="activeMenu" /> <MainContent :active-menu="activeMenu" />
<InputBar @send="handleSend" /> <InputBar @send="handleSend" />
</div> </div>
<!-- 右侧工作空间树形结构 -->
<div class="workspace-panel">
<div class="workspace-tree-wrap" v-loading="treeLoading">
<el-empty v-if="!treeLoading && treeNodes.length === 0" description="暂无作品数据" />
<el-tree
v-else
:data="treeNodes"
node-key="id"
:props="treeProps"
default-expand-all
:highlight-current="true"
:expand-on-click-node="true"
@node-click="handleTreeNodeClick"
>
<template #default="{ data }">
<div
class="tree-node"
:class="[
data.nodeType === 'date' ? 'level-date' :
data.nodeType === 'contentType' ? 'level-flow' : 'level-file',
data.fileType ? data.fileType.replace(/\\/g, ' ').split(' ')[0] : ''
]"
>
<span class="ellipsis">{{ data.label }}</span>
<div v-if="data.nodeType === 'title' && data.fileUrl" class="tree-node-actions">
<el-button type="primary" link size="small" @click.stop="previewNode(data)"> 预览 </el-button>
<el-button type="primary" link size="small" @click.stop="downloadNode(data)"> 下载 </el-button>
</div>
</div>
</template>
</el-tree>
</div>
</div>
<!-- 预览弹窗 - 放在外层避免被右侧容器限制宽度 --> <!-- 预览弹窗 -->
<el-dialog v-model="previewDialogVisible" title="预览" width="95%" top="2vh" :close-on-click-modal="false" destroy-on-close> <el-dialog v-model="previewDialogVisible" title="预览" width="95%" top="2vh" :close-on-click-modal="false" destroy-on-close>
<div class="preview-container"> <div class="preview-container">
<el-image v-if="previewUrl && previewMode === 'image'" :src="previewUrl" fit="contain" style="width: 100%; height: 100%" /> <el-image v-if="previewUrl && previewMode === 'image'" :src="previewUrl" fit="contain" style="width: 100%; height: 100%" />
@@ -107,7 +78,6 @@ const historyList = ref<HistoryItem[]>([
{ id: 4, title: '快捷回复产品设计', time: '2 天前' }, { id: 4, title: '快捷回复产品设计', time: '2 天前' },
]); ]);
const treeProps = { children: 'children', label: 'label' };
const apiBaseUrl = (import.meta.env.VITE_API_URL || '').replace(/\/$/, ''); const apiBaseUrl = (import.meta.env.VITE_API_URL || '').replace(/\/$/, '');
const joinUrl = (b: string, p: string) => `${b.replace(/\/$/, '')}${p.startsWith('/') ? p : `/${p}`}`; const joinUrl = (b: string, p: string) => `${b.replace(/\/$/, '')}${p.startsWith('/') ? p : `/${p}`}`;
@@ -155,15 +125,15 @@ const mockTreeData: ExecutionTreeItem[] = [
flowName: '代码审查任务', flowName: '代码审查任务',
sessionId: 'session-1', sessionId: 'session-1',
items: [ items: [
{ label: '审查结果.md', content: 'https://placekitten.com/800/600', type: 'text/markdown' }, { label: '审查结果.md', content: 'https://placekitten.com/800/600', type: 'text/markdown', timestamp: '' },
{ label: '流程图.png', content: 'https://placekitten.com/800/600', type: 'image/png' }, { label: '流程图.png', content: 'https://placekitten.com/800/600', type: 'image/png', timestamp: '' },
], ],
}, },
{ {
Id: 2, Id: 2,
flowName: '需求分析', flowName: '需求分析',
sessionId: 'session-2', sessionId: 'session-2',
items: [{ label: '需求拆解.txt', content: '# 需求分析结果\n\n- 功能点一\n- 功能点二\n- 需要优化', type: 'text/plain' }], items: [{ label: '需求拆解.txt', content: '# 需求分析结果\n\n- 功能点一\n- 功能点二\n- 需要优化', type: 'text/plain', timestamp: '' }],
}, },
], ],
}, },
@@ -174,7 +144,7 @@ const mockTreeData: ExecutionTreeItem[] = [
Id: 3, Id: 3,
flowName: '生成演示视频', flowName: '生成演示视频',
sessionId: 'session-3', sessionId: 'session-3',
items: [{ label: '输出视频.mp4', content: 'https://www.w3schools.com/html/mov_bbb.mp4', type: 'video/mp4' }], items: [{ label: '输出视频.mp4', content: 'https://www.w3schools.com/html/mov_bbb.mp4', type: 'video/mp4', timestamp: '' }],
}, },
], ],
}, },
@@ -230,10 +200,6 @@ const downloadNode = (data: TreeNode) => {
document.body.removeChild(a); document.body.removeChild(a);
}; };
const handleTreeNodeClick = () => {
// 点击节点不需要额外操作
};
const handleMenuChange = (menu: string) => { const handleMenuChange = (menu: string) => {
activeMenu.value = menu; activeMenu.value = menu;
}; };
@@ -311,151 +277,6 @@ onMounted(() => {
} }
} }
/* 右侧工作空间面板 - 渐变玻璃风格 */
.workspace-panel {
width: 260px;
background: linear-gradient(
180deg,
rgba(255, 255, 255, 0.85) 0%,
rgba(249, 251, 255, 0.7) 50%,
rgba(235, 241, 252, 0.6) 100%
);
border-left: 1px solid rgba(59, 130, 246, 0.15);
display: flex;
flex-direction: column;
height: 100%;
box-shadow: -6px 0 35px rgba(59, 130, 246, 0.08);
backdrop-filter: blur(16px);
}
.workspace-tree-wrap {
flex: 1;
padding: 8px 8px 12px;
overflow-y: auto;
scrollbar-width: none;
-ms-overflow-style: none;
&::-webkit-scrollbar {
display: none;
}
:deep(.el-tree) {
background: transparent;
.el-tree-node {
padding: 4px 0;
}
// 一级节点(日期)- 蓝色渐变
:deep(.level-date) .el-tree-node__content {
height: 42px;
background: linear-gradient(135deg, rgba(59, 130, 246, 0.20) 0%, rgba(59, 130, 246, 0.05) 100%);
border: 1px solid rgba(59, 130, 246, 0.28);
font-weight: 600;
}
// 二级节点(工作流)- 紫色渐变
:deep(.level-flow) .el-tree-node__content {
margin-left: 8px;
background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(139, 92, 246, 0.03) 100%);
border: 1px solid rgba(139, 92, 246, 0.18);
}
// 三级节点(文件)- 根据文件类型区分颜色
:deep(.level-file.image) .el-tree-node__content,
:deep(.level-file.jpg) .el-tree-node__content,
:deep(.level-file.png) .el-tree-node__content,
:deep(.level-file.gif) .el-tree-node__content {
margin-left: 16px;
background: linear-gradient(135deg, rgba(16, 185, 129, 0.18) 0%, rgba(16, 185, 129, 0.04) 100%);
border: 1px solid rgba(16, 185, 129, 0.15);
}
:deep(.level-file.video) .el-tree-node__content,
:deep(.level-file.mp4) .el-tree-node__content,
:deep(.level-file.webm) .el-tree-node__content {
margin-left: 16px;
background: linear-gradient(135deg, rgba(245, 158, 11, 0.18) 0%, rgba(245, 158, 11, 0.04) 100%);
border: 1px solid rgba(245, 158, 11, 0.15);
}
:deep(.level-file.audio) .el-tree-node__content,
:deep(.level-file.mp3) .el-tree-node__content,
:deep(.level-file.wav) .el-tree-node__content {
margin-left: 16px;
background: linear-gradient(135deg, rgba(236, 72, 153, 0.18) 0%, rgba(236, 72, 153, 0.04) 100%);
border: 1px solid rgba(236, 72, 153, 0.15);
}
:deep(.level-file.text) .el-tree-node__content,
:deep(.level-file.md) .el-tree-node__content,
:deep(.level-file.txt) .el-tree-node__content,
:deep(.level-file.markdown) .el-tree-node__content {
margin-left: 16px;
background: linear-gradient(135deg, rgba(79, 70, 229, 0.18) 0%, rgba(79, 70, 229, 0.04) 100%);
border: 1px solid rgba(79, 70, 229, 0.15);
}
// 默认其他文件
:deep(.level-file:not(.image):not(.video):not(.audio):not(.text)) .el-tree-node__content {
margin-left: 16px;
background: linear-gradient(135deg, rgba(100, 116, 139, 0.15) 0%, rgba(100, 116, 139, 0.04) 100%);
border: 1px solid rgba(100, 116, 139, 0.15);
}
.el-tree-node__content {
height: 38px;
line-height: 38px;
border-radius: 8px;
margin: 2px 0;
backdrop-filter: blur(8px);
transition: all 0.2s ease;
&:hover {
border-width: 2px;
transform: translateX(2px);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
}
.el-tree-node.is-current > .el-tree-node__content {
border-width: 2px;
box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
}
.el-tree-node__expand-icon {
color: rgba(59, 130, 246, 0.7);
}
}
}
.tree-node {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
gap: 6px;
.ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 13px;
font-weight: 500;
color: #1e293b;
}
.tree-node-actions {
flex-shrink: 0;
.el-button {
font-size: 11px;
padding: 2px 4px;
margin: 0;
line-height: 1;
}
}
}
.preview-container { .preview-container {
max-height: 85vh; max-height: 85vh;
overflow: auto; overflow: auto;