From 97649e4beedc0bcb52904adfc6b9ccc6081332fa Mon Sep 17 00:00:00 2001 From: Rafi Date: Thu, 30 Mar 2023 18:12:55 +0800 Subject: [PATCH] pass --- components/Conversation.vue | 267 ++++++++++++++++++++++++++++++++++ composables/states.js | 4 +- layouts/default.vue | 14 +- pages/index.vue | 275 +++--------------------------------- utils/helper.js | 14 +- 5 files changed, 300 insertions(+), 274 deletions(-) create mode 100644 components/Conversation.vue diff --git a/components/Conversation.vue b/components/Conversation.vue new file mode 100644 index 0000000..2360ff6 --- /dev/null +++ b/components/Conversation.vue @@ -0,0 +1,267 @@ + + + \ No newline at end of file diff --git a/composables/states.js b/composables/states.js index 8f041f7..77a5899 100644 --- a/composables/states.js +++ b/composables/states.js @@ -5,8 +5,8 @@ export const useCurrentModel = () => useState('currentModel', () => getCurrentMo export const useApiKey = () => useState('apiKey', () => getStoredApiKey()) -export const useConversion = () => useState('conversion', () => getDefaultConversionData()) +export const useConversation = () => useState('conversation', () => getDefaultConversationData()) -export const useConversions = () => useState('conversions', () => []) +export const useConversations = () => useState('conversations', () => []) export const useSettings = () => useState('settings', () => {}) \ No newline at end of file diff --git a/layouts/default.vue b/layouts/default.vue index 95291df..e44524c 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -22,8 +22,8 @@ const setLang = (lang) => { setLocale(lang) } -const conversations = useConversions() -const currentConversation = useConversion() +const conversations = useConversations() +const currentConversation = useConversation() const editingConversation = ref(null) const deletingConversationIndex = ref(null) @@ -54,7 +54,7 @@ const deleteConversation = async (index) => { deletingConversationIndex.value = null if (!error.value) { if (conversations.value[index].id === currentConversation.value.id) { - createNewConversion() + createNewConversation() } conversations.value.splice(index, 1) } @@ -78,7 +78,7 @@ const loadingConversations = ref(false) const loadConversations = async () => { loadingConversations.value = true - conversations.value = await getConversions() + conversations.value = await getConversations() loadingConversations.value = false } @@ -130,7 +130,7 @@ onMounted(async () => { block variant="outlined" prepend-icon="add" - @click="createNewConversion()" + @click="createNewConversation()" class="text-none" > {{ $t('newConversation') }} @@ -172,7 +172,7 @@ onMounted(async () => { {{ conversation.topic }} @@ -310,7 +310,7 @@ onMounted(async () => { diff --git a/pages/index.vue b/pages/index.vue index b472d2e..79a223c 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1,270 +1,29 @@ \ No newline at end of file diff --git a/utils/helper.js b/utils/helper.js index cfcc296..54813da 100644 --- a/utils/helper.js +++ b/utils/helper.js @@ -1,5 +1,5 @@ -export const getDefaultConversionData = () => { +export const getDefaultConversationData = () => { return { id: null, topic: null, @@ -8,7 +8,7 @@ export const getDefaultConversionData = () => { } } -export const getConversions = async () => { +export const getConversations = async () => { const { data, error } = await useAuthFetch('/api/chat/conversations/') if (!error.value) { return data.value @@ -16,13 +16,13 @@ export const getConversions = async () => { return [] } -export const createNewConversion = () => { - const conversation = useConversion() - conversation.value = getDefaultConversionData() +export const createNewConversation = () => { + const conversation = useConversation() + conversation.value = getDefaultConversationData() } export const openConversationMessages = async (currentConversation) => { - const conversation = useConversion() + const conversation = useConversation() conversation.value = Object.assign(conversation.value, currentConversation) conversation.value.loadingMessages = true const { data, error } = await useAuthFetch('/api/chat/messages/?conversationId=' + currentConversation.id) @@ -44,7 +44,7 @@ export const genTitle = async (conversationId) => { id: conversationId, topic: data.value.title, } - const conversations = useConversions() + const conversations = useConversations() // prepend to conversations conversations.value = [conversation, ...conversations.value] return data.value.title