From ae3bc2c42c265d3a7664ed50f48f6deccecdbaf1 Mon Sep 17 00:00:00 2001 From: DebugIsFalse <511418503@qq.com> Date: Mon, 27 May 2024 10:50:04 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=20=E6=90=9C=E7=B4=A2=E5=8E=86?= =?UTF-8?q?=E5=8F=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/i/SearchHistory.vue | 26 ++++++++------------------ composables/useRequest.js | 5 ++++- pages/search/[id].vue | 1 + 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/components/i/SearchHistory.vue b/components/i/SearchHistory.vue index eaa2b8f..a6c2c81 100644 --- a/components/i/SearchHistory.vue +++ b/components/i/SearchHistory.vue @@ -68,24 +68,7 @@ const emits = defineEmits(['sign', 'clear']) const Layout = inject('Layout') const { $isSignIn } = useUserStore() -const searchHistory = ref([ - { - title: 'Vue 的 v-model 怎么用', - url: 'c_20240521161631_C8miVoieSKGfgNGP?query=Vue%20的%20v-model%20怎么用&repo=keycloak' - }, - { - title: '帮我写一个爬虫,爬取豆瓣热门电影top250', - url: 'c_20240521161649_0LbyaJFKX6fyJYyA?query=帮我写一个爬虫,爬取豆瓣热门电影top250&repo=keycloak' - }, - { - title: 'grid 的 grid-template-columns 除了 minmax 和 repeat,还有哪些值', - url: 'c_20240521161709_LtiJL8thi5XuYLd6?query=grid%20的%20grid-template-columns%20除了%20minmax%20和%20repeat,还有哪些值&repo=keycloak' - }, - { - title: 'flex 各种布局的区别', - url: 'c_20240521161933_wxgXGKYhmfJe6QE0?query=flex%20各种布局的区别&repo=keycloak' - } -]) +const searchHistory = ref([]) function handleClear () { emits('clear') } @@ -103,4 +86,11 @@ function handleClose () { function handleClickItem () { Layout.handleCloseAside() } +async function getUserHistory () { + const { data, error } = await useRequest('/v1/chat/completion/list', { server: false }) + if (!error.value) { + searchHistory.value = data.value && data.value.data || [] + } +} +getUserHistory() diff --git a/composables/useRequest.js b/composables/useRequest.js index 23c9cc2..23a4ce2 100644 --- a/composables/useRequest.js +++ b/composables/useRequest.js @@ -1,11 +1,14 @@ +import { useStorage } from '@vueuse/core' const BASE_URL = 'https://gpu-pod656e861afe3d944d6b3ce77e-7862.node.inscode.run' const request = async (url, options = {}) => { + const token = useStorage('token') const fullUrl = BASE_URL + url const config = { method: options.method || 'get', headers: { - 'Content-Type': 'application/x-www-form-urlencoded' + 'Content-Type': 'application/x-www-form-urlencoded', + 'Authorization': token }, onRequest({ request, options }) { // 设置请求头 diff --git a/pages/search/[id].vue b/pages/search/[id].vue index 0aa69b7..6d1c2e9 100644 --- a/pages/search/[id].vue +++ b/pages/search/[id].vue @@ -211,6 +211,7 @@ const handleStopGenerate = () => { }) } const handleError = (event) => { + console.log(222) handleStopGenerate() } const fetchLinkedQuestion = (query) => { -- GitLab