mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 23:56:42 +08:00
feat:近期搜索记忆
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "moviepilot",
|
"name": "moviepilot",
|
||||||
"version": "1.9.3",
|
"version": "1.9.3-1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"bin": "dist/service.js",
|
"bin": "dist/service.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -18,11 +18,34 @@ const router = useRouter()
|
|||||||
const emit = defineEmits(['close'])
|
const emit = defineEmits(['close'])
|
||||||
|
|
||||||
// 搜索词
|
// 搜索词
|
||||||
const searchWord = ref(null)
|
const searchWord = ref<string | null>(null)
|
||||||
|
|
||||||
// ref
|
// ref
|
||||||
const searchWordInput = ref<HTMLElement | null>(null)
|
const searchWordInput = ref<HTMLElement | null>(null)
|
||||||
|
|
||||||
|
// 近期搜索词条
|
||||||
|
const recentSearches = ref<string[]>([])
|
||||||
|
|
||||||
|
// 保存近期搜索到本地
|
||||||
|
function saveRecentSearches(keyword: string) {
|
||||||
|
if (!keyword) return
|
||||||
|
if (recentSearches.value.includes(keyword)) return
|
||||||
|
recentSearches.value.unshift(keyword)
|
||||||
|
localStorage.setItem('MP_RecentSearches', JSON.stringify(recentSearches.value))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从本地加载近期搜索
|
||||||
|
function loadRecentSearches() {
|
||||||
|
const recentSearchesStr = localStorage.getItem('MP_RecentSearches')
|
||||||
|
if (recentSearchesStr) {
|
||||||
|
recentSearches.value = JSON.parse(recentSearchesStr)
|
||||||
|
// 只保留最近的 5 条
|
||||||
|
if (recentSearches.value.length > 5) {
|
||||||
|
recentSearches.value = recentSearches.value.slice(0, 5)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 所有菜单功能
|
// 所有菜单功能
|
||||||
function getMenus(): NavMenu[] {
|
function getMenus(): NavMenu[] {
|
||||||
let menus: NavMenu[] = []
|
let menus: NavMenu[] = []
|
||||||
@@ -143,6 +166,7 @@ const matchedSubscribeItems = computed(() => {
|
|||||||
function searchMedia(searchType: string) {
|
function searchMedia(searchType: string) {
|
||||||
// 搜索类型 media/person
|
// 搜索类型 media/person
|
||||||
if (!searchWord.value) return
|
if (!searchWord.value) return
|
||||||
|
saveRecentSearches(searchWord.value)
|
||||||
router.push({
|
router.push({
|
||||||
path: '/browse/media/search',
|
path: '/browse/media/search',
|
||||||
query: {
|
query: {
|
||||||
@@ -156,6 +180,7 @@ function searchMedia(searchType: string) {
|
|||||||
// 跳转到种子搜索页面
|
// 跳转到种子搜索页面
|
||||||
function searchTorrent() {
|
function searchTorrent() {
|
||||||
if (!searchWord.value) return
|
if (!searchWord.value) return
|
||||||
|
saveRecentSearches(searchWord.value)
|
||||||
router.push({
|
router.push({
|
||||||
path: '/resource',
|
path: '/resource',
|
||||||
query: {
|
query: {
|
||||||
@@ -169,10 +194,11 @@ function searchTorrent() {
|
|||||||
// 跳转到历史记录页面
|
// 跳转到历史记录页面
|
||||||
function searchHistory() {
|
function searchHistory() {
|
||||||
if (!searchWord.value) return
|
if (!searchWord.value) return
|
||||||
|
saveRecentSearches(searchWord.value)
|
||||||
router.push({
|
router.push({
|
||||||
path: '/history',
|
path: '/history',
|
||||||
query: {
|
query: {
|
||||||
search: searchWord.value
|
search: searchWord.value,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
emit('close')
|
emit('close')
|
||||||
@@ -222,6 +248,7 @@ onMounted(() => {
|
|||||||
}, 500)
|
}, 500)
|
||||||
fetchInstalledPlugins()
|
fetchInstalledPlugins()
|
||||||
fetchSubscribes()
|
fetchSubscribes()
|
||||||
|
loadRecentSearches()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
@@ -268,13 +295,7 @@ onMounted(() => {
|
|||||||
</VHover>
|
</VHover>
|
||||||
<VHover>
|
<VHover>
|
||||||
<template #default="hover">
|
<template #default="hover">
|
||||||
<VListItem
|
<VListItem prepend-icon="mdi-account-search" link v-bind="hover.props" @click="searchMedia('person')">
|
||||||
prepend-icon="mdi-account-search"
|
|
||||||
density="compact"
|
|
||||||
link
|
|
||||||
v-bind="hover.props"
|
|
||||||
@click="searchMedia('person')"
|
|
||||||
>
|
|
||||||
<VListItemTitle>
|
<VListItemTitle>
|
||||||
搜索 <span class="font-bold">{{ searchWord }}</span> 相关的【演职人员】 ...
|
搜索 <span class="font-bold">{{ searchWord }}</span> 相关的【演职人员】 ...
|
||||||
</VListItemTitle>
|
</VListItemTitle>
|
||||||
@@ -286,13 +307,7 @@ onMounted(() => {
|
|||||||
</VHover>
|
</VHover>
|
||||||
<VHover>
|
<VHover>
|
||||||
<template #default="hover">
|
<template #default="hover">
|
||||||
<VListItem
|
<VListItem prepend-icon="mdi-search-web" link v-bind="hover.props" @click="searchTorrent">
|
||||||
prepend-icon="mdi-search-web"
|
|
||||||
density="compact"
|
|
||||||
link
|
|
||||||
v-bind="hover.props"
|
|
||||||
@click="searchTorrent"
|
|
||||||
>
|
|
||||||
<VListItemTitle>
|
<VListItemTitle>
|
||||||
搜索 <span class="font-bold">{{ searchWord }}</span> 相关的【站点资源】 ...
|
搜索 <span class="font-bold">{{ searchWord }}</span> 相关的【站点资源】 ...
|
||||||
</VListItemTitle>
|
</VListItemTitle>
|
||||||
@@ -304,13 +319,7 @@ onMounted(() => {
|
|||||||
</VHover>
|
</VHover>
|
||||||
<VHover>
|
<VHover>
|
||||||
<template #default="hover">
|
<template #default="hover">
|
||||||
<VListItem
|
<VListItem prepend-icon="mdi-history" link v-bind="hover.props" @click="searchHistory">
|
||||||
prepend-icon="mdi-history"
|
|
||||||
density="compact"
|
|
||||||
link
|
|
||||||
v-bind="hover.props"
|
|
||||||
@click="searchHistory"
|
|
||||||
>
|
|
||||||
<VListItemTitle>
|
<VListItemTitle>
|
||||||
搜索 <span class="font-bold">{{ searchWord }}</span> 相关的【历史记录】 ...
|
搜索 <span class="font-bold">{{ searchWord }}</span> 相关的【历史记录】 ...
|
||||||
</VListItemTitle>
|
</VListItemTitle>
|
||||||
@@ -386,6 +395,23 @@ onMounted(() => {
|
|||||||
<div v-else>
|
<div v-else>
|
||||||
<!-- 默认 -->
|
<!-- 默认 -->
|
||||||
<VCardText>
|
<VCardText>
|
||||||
|
<VRow v-if="recentSearches.length > 0">
|
||||||
|
<VCol cols="12">
|
||||||
|
<p class="custom-letter-spacing text-sm text-disabled text-uppercase py-2 px-4 mb-0">最近搜索</p>
|
||||||
|
<div class="px-3">
|
||||||
|
<VChip
|
||||||
|
v-for="(word, index) in recentSearches"
|
||||||
|
:key="index"
|
||||||
|
class="me-2"
|
||||||
|
variant="tonal"
|
||||||
|
@click="searchWord = word"
|
||||||
|
label
|
||||||
|
>
|
||||||
|
{{ word }}
|
||||||
|
</VChip>
|
||||||
|
</div>
|
||||||
|
</VCol>
|
||||||
|
</VRow>
|
||||||
<VRow>
|
<VRow>
|
||||||
<VCol cols="12" md="6">
|
<VCol cols="12" md="6">
|
||||||
<p class="custom-letter-spacing text-sm text-disabled text-uppercase py-2 px-4 mb-0">常用功能</p>
|
<p class="custom-letter-spacing text-sm text-disabled text-uppercase py-2 px-4 mb-0">常用功能</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user