first commit

This commit is contained in:
2026-02-26 09:32:03 +08:00
commit 36a8e4c51b
845 changed files with 116474 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
import {defineStore} from 'pinia'
type historyListType = {
text: string
time: number
}
export const useSearchStore = defineStore(
'searchStore',
() => {
const historyList = ref<historyListType[]>([])
function setHistoryList(keyword: string) {
const historyListCopy = [...historyList.value]
let index = historyListCopy.findIndex((item) => item.text === keyword)
if (index === 0) {
return
}
if (index > 0) {
historyListCopy.splice(index, 1)
historyListCopy.unshift({
text: keyword,
time: new Date().getTime(),
})
} else {
historyListCopy.unshift({
text: keyword,
time: new Date().getTime(),
})
}
historyList.value = historyListCopy
}
return {
historyList,
setHistoryList,
}
},
{
persist: true,
},
)