mirror of
https://github.com/Chanzhaoyu/chatgpt-web.git
synced 2025-07-27 00:33:52 +00:00
feat: 多会话基础逻辑梳理
This commit is contained in:
@@ -1,33 +1,23 @@
|
||||
<script setup lang='ts'>
|
||||
import { ref } from 'vue'
|
||||
import { NButton, NLayoutSider } from 'naive-ui'
|
||||
import type { HistoryChatProps } from '../../types'
|
||||
import List from './List.vue'
|
||||
import Footer from './Footer.vue'
|
||||
import { useAppStore } from '@/store'
|
||||
import { useAppStore, useHistoryStore } from '@/store'
|
||||
|
||||
const appStore = useAppStore()
|
||||
const historyStore = useHistoryStore()
|
||||
|
||||
const collapsed = ref(appStore.siderCollapsed ?? false)
|
||||
|
||||
const history = ref<HistoryChatProps[]>([])
|
||||
|
||||
function handleAdd() {
|
||||
history.value.push({
|
||||
title: 'New chat',
|
||||
edit: false,
|
||||
historyStore.addHistory({
|
||||
title: '',
|
||||
isEdit: false,
|
||||
data: [],
|
||||
})
|
||||
}
|
||||
|
||||
function handleEdit(index: number) {
|
||||
history.value[index].edit = true
|
||||
}
|
||||
|
||||
function handleDelete(index: number) {
|
||||
history.value.splice(index, 1)
|
||||
}
|
||||
|
||||
function handleCollapsed() {
|
||||
collapsed.value = !collapsed.value
|
||||
appStore.setSiderCollapsed(collapsed.value)
|
||||
@@ -51,7 +41,7 @@ function handleCollapsed() {
|
||||
New chat
|
||||
</NButton>
|
||||
</div>
|
||||
<List :data="history" @edit="handleEdit" @delete="handleDelete" />
|
||||
<List />
|
||||
</main>
|
||||
<Footer />
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user