feat: add option to use explore page for search

This commit is contained in:
TAKAHASHI Shuuji 2025-02-08 16:14:13 +09:00
parent fed57014af
commit d13bd450ac
4 changed files with 14 additions and 12 deletions

View file

@ -27,6 +27,7 @@ export interface PreferencesSettings {
enableDataSaving: boolean enableDataSaving: boolean
enablePinchToZoom: boolean enablePinchToZoom: boolean
useStarFavoriteIcon: boolean useStarFavoriteIcon: boolean
useExplorePageForSearch: boolean
zenMode: boolean zenMode: boolean
experimentalVirtualScroller: boolean experimentalVirtualScroller: boolean
experimentalGitHubCards: boolean experimentalGitHubCards: boolean
@ -83,6 +84,7 @@ export const DEFAULT__PREFERENCES_SETTINGS: PreferencesSettings = {
enableDataSaving: false, enableDataSaving: false,
enablePinchToZoom: false, enablePinchToZoom: false,
useStarFavoriteIcon: false, useStarFavoriteIcon: false,
useExplorePageForSearch: false,
zenMode: false, zenMode: false,
experimentalVirtualScroller: true, experimentalVirtualScroller: true,
experimentalGitHubCards: true, experimentalGitHubCards: true,

View file

@ -561,6 +561,7 @@
"label": "Preferences", "label": "Preferences",
"optimize_for_low_performance_device": "Optimize for low performance device", "optimize_for_low_performance_device": "Optimize for low performance device",
"title": "Experimental Features", "title": "Experimental Features",
"use_explore_page_for_search": "Use Explore page for Search",
"use_star_favorite_icon": "Use star favorite icon", "use_star_favorite_icon": "Use star favorite icon",
"user_picker": "User Picker", "user_picker": "User Picker",
"user_picker_description": "Displays all avatars of logged accounts in the bottom-left so you can switch quickly between them.", "user_picker_description": "Displays all avatars of logged accounts in the bottom-left so you can switch quickly between them.",

View file

@ -3,19 +3,7 @@ import type { CommonRouteTabOption } from '~/types'
const { t } = useI18n() const { t } = useI18n()
const search = ref<{ input?: HTMLInputElement }>()
const route = useRoute()
watchEffect(() => {
if (isMediumOrLargeScreen && route.name === 'explore' && search.value?.input)
search.value?.input?.focus()
})
onActivated(() =>
search.value?.input?.focus(),
)
onDeactivated(() => search.value?.input?.blur())
const userSettings = useUserSettings() const userSettings = useUserSettings()
const tabs = computed<CommonRouteTabOption[]>(() => [ const tabs = computed<CommonRouteTabOption[]>(() => [
{ {
to: isHydrated.value ? `/${currentServer.value}/explore` : '/explore', to: isHydrated.value ? `/${currentServer.value}/explore` : '/explore',
@ -37,6 +25,8 @@ const tabs = computed<CommonRouteTabOption[]>(() => [
disabled: !isHydrated.value || !currentUser.value, disabled: !isHydrated.value || !currentUser.value,
}, },
]) ])
const useExplorePageForSearch = usePreferences('useExplorePageForSearch')
</script> </script>
<template> <template>
@ -49,6 +39,9 @@ const tabs = computed<CommonRouteTabOption[]>(() => [
</template> </template>
<template #header> <template #header>
<div v-if="useExplorePageForSearch" px2 mt3>
<SearchWidget v-if="isHydrated" m-1 />
</div>
<CommonRouteTabs replace :options="tabs" /> <CommonRouteTabs replace :options="tabs" />
</template> </template>
<NuxtPage v-if="isHydrated" /> <NuxtPage v-if="isHydrated" />

View file

@ -78,6 +78,12 @@ const userSettings = useUserSettings()
> >
{{ $t('settings.preferences.use_star_favorite_icon') }} {{ $t('settings.preferences.use_star_favorite_icon') }}
</SettingsToggleItem> </SettingsToggleItem>
<SettingsToggleItem
:checked="getPreferences(userSettings, 'useExplorePageForSearch')"
@click="togglePreferences('useExplorePageForSearch')"
>
{{ $t('settings.preferences.use_explore_page_for_search') }}
</SettingsToggleItem>
</section> </section>
<section> <section>
<h2 px6 py4 mt2 font-bold text-xl flex="~ gap-1" items-center> <h2 px6 py4 mt2 font-bold text-xl flex="~ gap-1" items-center>