From 2b9f340a2e68490c72d29780a782d4ec04cf5865 Mon Sep 17 00:00:00 2001 From: DebugIsFalse <511418503@qq.com> Date: Mon, 27 May 2024 16:36:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/i/Create.vue | 9 ++++++++- components/i/SearchHistory.vue | 7 +++---- composables/useRequest.js | 2 +- pages/search/[id].vue | 28 +++++++++++++--------------- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/components/i/Create.vue b/components/i/Create.vue index fd6ee85..e117557 100644 --- a/components/i/Create.vue +++ b/components/i/Create.vue @@ -54,7 +54,14 @@ const menuUI = { const handleSearch = async () => { if (loading.value || query.value === '') return loading.value = true - const { data } = await useRequest('/v1/chat/completion/create', { method: 'post' }) + const currentRepo = $repos.value.find(item => item.label === selectedRepo.value) + const { data } = await useRequest('/v1/chat/completion/create', { + method: 'post', + body: { + repo_path: currentRepo.url, + title: query.value + } + }) navigateTo(`/search/${data.value.data.c_id}`) emits('search') nextTick(() => { diff --git a/components/i/SearchHistory.vue b/components/i/SearchHistory.vue index 734c0f1..efc8ad1 100644 --- a/components/i/SearchHistory.vue +++ b/components/i/SearchHistory.vue @@ -87,10 +87,9 @@ function handleRemoveRecords (ids) { } useRequest('/v1/chat/completion/remove', { method: 'post', - body: ids, - headers: { - 'Content-Type': 'application/json' - } + body: ids + }).finally(() => { + navigateTo('/') }) } function handleOpen () { diff --git a/composables/useRequest.js b/composables/useRequest.js index ad6c5a9..6012c63 100644 --- a/composables/useRequest.js +++ b/composables/useRequest.js @@ -6,7 +6,7 @@ const request = async (url, options = {}) => { const config = { method: options.method || 'get', headers: { - 'Content-Type': 'application/x-www-form-urlencoded', + 'Content-Type': 'application/json', 'Authorization': token }, onRequest({ request, options }) { diff --git a/pages/search/[id].vue b/pages/search/[id].vue index ac3f94d..4d7a54c 100644 --- a/pages/search/[id].vue +++ b/pages/search/[id].vue @@ -2,13 +2,15 @@