mirror of
https://github.com/BewlyBewly/BewlyBewly.git
synced 2025-04-14 13:15:29 +00:00
feat(settings): search bar link opening behavior
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
import { onKeyStroke, useDebounceFn } from '@vueuse/core'
|
||||
import DOMPurify from 'dompurify'
|
||||
|
||||
import { settings } from '~/logic'
|
||||
import api from '~/utils/api'
|
||||
import { findLeafActiveElement } from '~/utils/element'
|
||||
import { isHomePage } from '~/utils/main'
|
||||
|
||||
import type { HistoryItem, SuggestionItem, SuggestionResponse } from './searchHistoryProvider'
|
||||
import {
|
||||
@@ -75,7 +77,15 @@ const handleInput = useDebounceFn(() => {
|
||||
|
||||
async function navigateToSearchResultPage(keyword: string) {
|
||||
if (keyword) {
|
||||
window.open(`//search.bilibili.com/all?keyword=${encodeURIComponent(keyword)}`, '_blank')
|
||||
let target = '_blank'
|
||||
if (settings.value.searchBarLinkOpenMode === 'currentTabIfNotHomepage')
|
||||
target = isHomePage() ? '_blank' : '_self'
|
||||
else if (settings.value.searchBarLinkOpenMode === 'currentTab')
|
||||
target = '_self'
|
||||
else if (settings.value.searchBarLinkOpenMode === 'newTab')
|
||||
target = '_blank'
|
||||
|
||||
window.open(`//search.bilibili.com/all?keyword=${encodeURIComponent(keyword)}`, target)
|
||||
const searchItem = {
|
||||
value: keyword,
|
||||
timestamp: Number(new Date()),
|
||||
@@ -382,7 +392,6 @@ async function handleClearSearchHistory() {
|
||||
|
||||
@mixin search-content-item {
|
||||
--uno: "px-4 py-2 w-full rounded-$bew-radius duration-300 cursor-pointer not-first:mt-1 tracking-wider hover:bg-$bew-fill-2";
|
||||
--uno: "hover:shadow-[var(--bew-shadow-1),var(--bew-shadow-edge-glow-1)]";
|
||||
}
|
||||
|
||||
#search-history {
|
||||
|
||||
@@ -29,18 +29,18 @@ const langOptions = computed(() => {
|
||||
]
|
||||
})
|
||||
|
||||
const topBarLinkOpenModeOptions = computed(() => {
|
||||
const openModeOptions = computed(() => {
|
||||
return [
|
||||
{
|
||||
label: t('settings.top_bar_link_opening_behavior_opt.current_tab'),
|
||||
label: t('settings.link_opening_behavior_opt.current_tab'),
|
||||
value: 'currentTab',
|
||||
},
|
||||
{
|
||||
label: t('settings.top_bar_link_opening_behavior_opt.current_tab_if_not_homepage'),
|
||||
label: t('settings.link_opening_behavior_opt.current_tab_if_not_homepage'),
|
||||
value: 'currentTabIfNotHomepage',
|
||||
},
|
||||
{
|
||||
label: t('settings.top_bar_link_opening_behavior_opt.new_tab'),
|
||||
label: t('settings.link_opening_behavior_opt.new_tab'),
|
||||
value: 'newTab',
|
||||
},
|
||||
]
|
||||
@@ -49,11 +49,11 @@ const topBarLinkOpenModeOptions = computed(() => {
|
||||
const videoCardOpenModeOptions = computed(() => {
|
||||
return [
|
||||
{
|
||||
label: t('settings.video_card_link_opening_behavior_opt.drawer'),
|
||||
label: t('settings.link_opening_behavior_opt.drawer'),
|
||||
value: 'drawer',
|
||||
},
|
||||
{
|
||||
label: t('settings.video_card_link_opening_behavior_opt.new_tab'),
|
||||
label: t('settings.link_opening_behavior_opt.new_tab'),
|
||||
value: 'newTab',
|
||||
},
|
||||
]
|
||||
@@ -114,7 +114,7 @@ watch(() => settings.value.language, (newValue) => {
|
||||
|
||||
<SettingsItemGroup :title="$t('settings.group_link_opening_behavior')">
|
||||
<SettingsItem :title="$t('settings.top_bar_link_opening_behavior')">
|
||||
<Select v-model="settings.topBarLinkOpenMode" :options="topBarLinkOpenModeOptions" w="full" />
|
||||
<Select v-model="settings.topBarLinkOpenMode" :options="openModeOptions" w="full" />
|
||||
</SettingsItem>
|
||||
<SettingsItem :title="$t('settings.video_card_link_opening_behavior')">
|
||||
<Select
|
||||
@@ -123,6 +123,13 @@ watch(() => settings.value.language, (newValue) => {
|
||||
w="full"
|
||||
/>
|
||||
</SettingsItem>
|
||||
<SettingsItem :title="$t('settings.search_bar_link_opening_behavior')">
|
||||
<Select
|
||||
v-model="settings.searchBarLinkOpenMode"
|
||||
:options="openModeOptions"
|
||||
w="full"
|
||||
/>
|
||||
</SettingsItem>
|
||||
</SettingsItemGroup>
|
||||
|
||||
<SettingsItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user