diff --git a/components/i/SearchHistory.vue b/components/i/SearchHistory.vue
index 1b31a0fc1e6eaca34ea929f9c4e4b94758f5d988..734c0f1da4d995c0a0fc0ed66cd458263811eba0 100644
--- a/components/i/SearchHistory.vue
+++ b/components/i/SearchHistory.vue
@@ -27,6 +27,7 @@
@click="handleClickItem"
>
{{ item.title }}
+ 删除
@@ -59,6 +60,7 @@
@click="handleClose"
>
{{ item.title }}
+ 删除
@@ -69,11 +71,28 @@ const emits = defineEmits(['sign', 'clear'])
const Layout = inject('Layout')
const { $isSignIn } = useUserStore()
const searchHistory = ref([])
+const isOpenHistory = ref(false)
+const query = ref('')
function handleClear () {
emits('clear')
+ handleRemoveRecords()
+}
+function handleRemoveRecordItem (id) {
+ searchHistory.value = searchHistory.value.filter(item => item.c_id !== id)
+ handleRemoveRecords([id])
+}
+function handleRemoveRecords (ids) {
+ if (!ids) {
+ ids = searchHistory.value.map(item => item.c_id)
+ }
+ useRequest('/v1/chat/completion/remove', {
+ method: 'post',
+ body: ids,
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ })
}
-const isOpenHistory = ref(false)
-const query = ref('')
function handleOpen () {
if (!$isSignIn) emits('sign')
else {
diff --git a/composables/useRequest.js b/composables/useRequest.js
index 9f9ce1e4470e73b9b30f343ecc04f1897763ad13..c5e4f7fe8145d3a7b2e64606885e9b8712d1a34d 100644
--- a/composables/useRequest.js
+++ b/composables/useRequest.js
@@ -25,7 +25,10 @@ const request = async (url, options = {}) => {
console.log('[ResponseError]', request)
}
}
-
+ if (options && options.headers) {
+ Object.assign(config.headers, options.headers)
+ delete options.headers
+ }
return useFetch(fullUrl, Object.assign(config, options));
}
diff --git a/pages/search/[id].vue b/pages/search/[id].vue
index 5e19f8aefd8073d770a8c4782f34f4b9549bda16..46f690569a8f01ca8cc0baa63203ac63d8482785 100644
--- a/pages/search/[id].vue
+++ b/pages/search/[id].vue
@@ -252,8 +252,11 @@ function initSearchItemInfo (info) {
}
function initSearchRecords (records) {
data.value = records.map(item => {
- const { answer, actions } = item
+ let { answer, actions } = item
const historyItem = { article: answer, desLoading: false, searchLoading: false, ansLoading: false }
+ // todo ?action为啥成了string?
+ actions = typeof actions === 'string' ? JSON.parse(actions) : actions
+ console.log(actions)
// 处理搜索过程
actions && actions.forEach(child => {
const childAction = child.action