diff --git a/components/i/SearchHistory.vue b/components/i/SearchHistory.vue index eaa2b8f736af157247a4053f96a63c87b1e01d72..a6c2c81b7b098962c4a499ea3c71c55478764610 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 23c9cc24f3c37bc1aacff125deb5cc5af342d828..23a4ce296532361781df715531ceedebaabe25c2 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 0aa69b7748e0c7bb3985d0ffdf086cb72d5ae05c..6d1c2e9b127fa73d3867bd7df734f7cddc20d35e 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) => {