项目历史
This commit is contained in:
@@ -55,6 +55,8 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { getProjectList } from '@/api/agent'
|
||||
import { FormatDate } from '@/utils/tools'
|
||||
const { t: $t } = useI18n()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -66,40 +68,36 @@
|
||||
globalStore.setHomeLeftNavCollapse(!isCollapse.value)
|
||||
}
|
||||
const showHistory = ref(true)
|
||||
const historyList = ref([
|
||||
{
|
||||
title: true,
|
||||
name: $t('Home.today')
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
name: 'Conversation Item 1'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Conversation Item 2'
|
||||
},
|
||||
{
|
||||
title: true,
|
||||
name: $t('Home.yesterday')
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'Conversation Item 3'
|
||||
},
|
||||
{
|
||||
title: true,
|
||||
name: $t('Home.earlierChat')
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: 'Conversation Item 4'
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: 'Conversation Item 5'
|
||||
|
||||
const todayList = ref([])
|
||||
const yesterdayList = ref([])
|
||||
const earlierChatList = ref([])
|
||||
const historyList = computed(() => {
|
||||
const list = []
|
||||
if (todayList.value.length > 0) {
|
||||
list.push({
|
||||
title: true,
|
||||
name: $t('Home.today')
|
||||
})
|
||||
list.push(...todayList.value)
|
||||
}
|
||||
])
|
||||
if (yesterdayList.value.length > 0) {
|
||||
list.push({
|
||||
title: true,
|
||||
name: $t('Home.yesterday')
|
||||
})
|
||||
list.push(...yesterdayList.value)
|
||||
}
|
||||
if (earlierChatList.value.length > 0) {
|
||||
list.push({
|
||||
title: true,
|
||||
name: $t('Home.earlierChat')
|
||||
})
|
||||
list.push(...earlierChatList.value)
|
||||
}
|
||||
return list
|
||||
})
|
||||
|
||||
const onCreateProject = () => {
|
||||
router.push({ name: 'mainInput' })
|
||||
}
|
||||
@@ -113,7 +111,7 @@
|
||||
}
|
||||
}
|
||||
const onClickHistoryItem = (item: any) => {
|
||||
router.push({ name: 'test', params: { id: item.id } })
|
||||
router.push({ name: 'agent', params: { id: item.id } })
|
||||
}
|
||||
const onRenameHistoryItem = (item: any) => {
|
||||
// const index = historyList.value.findIndex((i: any) => i.id == item.id)
|
||||
@@ -121,12 +119,37 @@
|
||||
// }
|
||||
}
|
||||
const onDeleteHistoryItem = (item: any) => {
|
||||
console.log(item)
|
||||
const index = historyList.value.findIndex((i: any) => i.id == item.id)
|
||||
if (index != -1) {
|
||||
historyList.value.splice(index, 1)
|
||||
}
|
||||
// const index = historyList.value.findIndex((i: any) => i.id == item.id)
|
||||
// if (index != -1) {
|
||||
// historyList.value.splice(index, 1)
|
||||
// }
|
||||
}
|
||||
|
||||
const GetProjectList = async () => {
|
||||
const res = await getProjectList({
|
||||
page: 1,
|
||||
size: 100
|
||||
})
|
||||
const str = 'yyyyMMdd'
|
||||
const today = FormatDate(Date.now(), str)
|
||||
const yesterday = FormatDate(Date.now() - 24 * 60 * 60 * 1000, str)
|
||||
todayList.value = []
|
||||
yesterdayList.value = []
|
||||
earlierChatList.value = []
|
||||
const list = res.records || []
|
||||
list.forEach((item: any) => {
|
||||
const obj = { ...item }
|
||||
const date = FormatDate(obj.createTime * 1000, str)
|
||||
if (date == today) {
|
||||
todayList.value.push(obj)
|
||||
} else if (date == yesterday) {
|
||||
yesterdayList.value.push(obj)
|
||||
} else {
|
||||
earlierChatList.value.push(obj)
|
||||
}
|
||||
})
|
||||
}
|
||||
GetProjectList()
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
Reference in New Issue
Block a user