Files
admin-ui/src/views/home/index.vue

113 lines
2.8 KiB
Vue
Raw Normal View History

2025-11-20 09:10:35 +08:00
<template>
2026-05-26 16:01:13 +08:00
<div class="home-chat-container">
2026-05-26 17:58:23 +08:00
<Sidebar
:active-menu="activeMenu"
:active-history-id="activeHistoryId"
:history-list="historyList"
@menu-change="handleMenuChange"
@new-chat="handleCreateHistory"
@select-history="handleSelectHistory"
@delete-history="handleDeleteHistory"
/>
2026-05-26 16:01:13 +08:00
<div class="main-wrapper">
<MainContent :active-menu="activeMenu" />
<InputBar @send="handleSend" />
</div>
2025-11-20 09:10:35 +08:00
</div>
</template>
2026-05-26 16:01:13 +08:00
<script setup lang="ts">
import { ref } from 'vue';
import { Clock, Plus, Delete } from '@element-plus/icons-vue';
import { ElMessage } from 'element-plus';
import Sidebar from './components/Sidebar.vue';
import MainContent from './components/MainContent.vue';
import InputBar from './components/InputBar.vue';
interface HistoryItem {
id: number;
title: string;
time: string;
}
const activeMenu = ref('chat');
const activeHistoryId = ref(1);
const historyList = ref<HistoryItem[]>([
{ id: 1, title: '首页风格优化方案', time: '刚刚' },
{ id: 2, title: '模型配置逻辑检查', time: '今天 11:20' },
{ id: 3, title: '技能管理模块梳理', time: '昨天' },
{ id: 4, title: '快捷回复产品设计', time: '2 天前' },
]);
const handleMenuChange = (menu: string) => {
activeMenu.value = menu;
};
const handleSend = (_message: string) => {
// 预留发送逻辑
2025-11-20 09:10:35 +08:00
};
2026-05-26 16:01:13 +08:00
const handleSelectHistory = (id: number) => {
activeHistoryId.value = id;
activeMenu.value = 'chat';
ElMessage.success('已切换会话');
};
const handleCreateHistory = () => {
const id = Date.now();
historyList.value.unshift({
id,
title: `新会话 ${historyList.value.length + 1}`,
time: '刚刚',
});
activeHistoryId.value = id;
activeMenu.value = 'chat';
ElMessage.success('已新建会话');
};
const handleDeleteHistory = (id: number) => {
const idx = historyList.value.findIndex((item) => item.id === id);
if (idx < 0) return;
historyList.value.splice(idx, 1);
if (activeHistoryId.value === id && historyList.value.length) {
activeHistoryId.value = historyList.value[0].id;
}
ElMessage.success('已删除会话');
};
2025-11-20 09:10:35 +08:00
</script>
<style scoped lang="scss">
2026-05-26 16:01:13 +08:00
.home-chat-container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
2025-11-20 09:10:35 +08:00
overflow: hidden;
2026-05-26 16:01:13 +08:00
background:
radial-gradient(1200px 460px at 65% -140px, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0) 68%),
linear-gradient(180deg, #f7faff 0%, #f4f7fc 100%);
}
.main-wrapper {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
min-width: 0;
position: relative;
&::before {
content: '';
position: absolute;
inset: 0;
pointer-events: none;
background:
linear-gradient(180deg, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 28%),
radial-gradient(1000px 380px at 10% 110%, rgba(99, 102, 241, 0.08) 0%, rgba(99, 102, 241, 0) 72%);
2025-11-20 09:10:35 +08:00
}
2026-05-26 16:01:13 +08:00
}
2025-11-20 09:10:35 +08:00
</style>