提交 09ba6446 编写于 作者: D DebugIsFalse

Merge branch 'main' of gitcode.com:git_bot/ai-fe

<template>
<header class="sticky top-0 z-10 bg-white dark:bg-black w-full flex flex-col">
<div class="w-full p-2 justify-end sm:justify-between items-center flex">
<div class="hidden md:flex">
<div class="flex items-center gap-2" v-if="repo">
<UIcon name="i-simple-icons-github" />{{ repo }}
</div>
</div>
<div class="flex-grow justify-center items-center space-x-2 hidden sm:flex">
<UTooltip text="点击修改标题" v-if="!isEditTitle">
<div @click="handleFocusTitle">{{ editTitle }}</div>
......@@ -79,7 +84,6 @@
</div>
<UDivider />
</header>
</template>
<script setup>
const toast = useToast()
......@@ -93,6 +97,10 @@ const props = defineProps({
isPublic: {
type: Boolean,
default: false
},
repo: {
type: String,
default: ''
}
})
const state = reactive({
......
......@@ -2,7 +2,13 @@
<div class="w-full items-center flex flex-col">
<IException v-if="historyStatus !== 200" :code="historyStatus" />
<template v-else>
<iSearchHeader ref="refHeader" :query="state.title" :is-public="state.isPublic" @update-query="handleUpdateQuery" />
<iSearchHeader
ref="refHeader"
:query="state.title"
:is-public="state.isPublic"
:repo="state.repo"
@update-query="handleUpdateQuery"
/>
<div class="container min-h-svh max-w-screen-lg flex flex-col space-y-6 p-6 mb-6 pb-0" id="scrollElement">
<template v-for="(item, index) in data" :key="index">
<div class="grid">
......@@ -249,7 +255,6 @@ const handleCreateAiTitle = () => {
if (currentCollection) {
state.title = currentCollection.title
$updateSearchHistory(currentCollection)
}
}, 2000)
}
......
......@@ -3,11 +3,16 @@ import { useStorage } from '@vueuse/core'
const searchHistory = useStorage('search-history', '')
const maxLength = 50
export const useSearchStore = defineStore('search', () => {
const $searchHistory = computed(() => searchHistory.value ? JSON.parse(searchHistory.value) : [])
function $setSearchHistory (item) {
const history = searchHistory.value ? JSON.parse(searchHistory.value) : []
const findIndex = history.findIndex(i => i.c_id === item.c_id)
if (history.length >= maxLength) history.splice(0, 1)
if (findIndex >= 0) history.splice(findIndex, 1)
history.push(item)
searchHistory.value = JSON.stringify(history)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册