Improve the conversation process

This commit is contained in:
Rafi
2023-04-04 19:16:07 +08:00
parent 16c9b0e230
commit 3e3283029d
14 changed files with 152 additions and 99 deletions

View File

@@ -3,7 +3,7 @@ export const getDefaultConversationData = () => {
const { $i18n } = useNuxtApp()
return {
id: null,
topic: $i18n.t('defaultConversationTitle'),
topic: null,
messages: [],
loadingMessages: false,
}
@@ -18,7 +18,15 @@ export const getConversations = async () => {
}
export const createNewConversation = () => {
navigateTo('/')
const route = useRoute()
const { $i18n } = useNuxtApp()
const currentConversation = useConversation()
currentConversation.value = Object.assign(getDefaultConversationData(), {
topic: $i18n.t('newConversation')
})
if (route.path !== '/') {
return navigateTo('/')
}
}
@@ -38,12 +46,17 @@ export const genTitle = async (conversationId) => {
}
})
if (!error.value) {
const route = useRoute()
const conversations = useConversations()
const currentConversation = useConversation()
let index = conversations.value.findIndex(item => item.id === conversationId)
if (index === -1) {
index = 0
}
conversations.value[index].topic = data.value.title
if (route.path === '/') {
currentConversation.value.topic = data.value.title
}
return data.value.title
}
return null
@@ -58,18 +71,18 @@ const transformData = (list) => {
return result;
}
export const loadSettings = async () => {
const settings = useSettings()
export const getSystemSettings = async () => {
const { data, error } = await useAuthFetch('/api/chat/settings/', {
method: 'GET'
method: 'GET',
})
if (!error.value) {
settings.value = transformData(data.value)
return transformData(data.value)
}
return {}
}
export const fetchUser = async () => {
return useFetch('/api/account/user/')
return useMyFetch('/api/account/user/')
}
export const setUser = (userData) => {