made it so you can pick a search engine

This commit is contained in:
KevinWh0 2024-06-12 13:35:37 +02:00
parent 4893efae0f
commit c87ed51311
7 changed files with 73 additions and 4 deletions

View file

@ -13,6 +13,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { ref } from 'vue';
import { i18n } from '@/i18n.js';
import { defaultStore } from '@/store';
const props = defineProps<{
q: string;
@ -21,9 +22,10 @@ const props = defineProps<{
const query = ref(props.q);
const search = () => {
const sp = new URLSearchParams();
sp.append('q', query.value);
window.open(`https://www.google.com/search?${sp.toString()}`, '_blank', 'noopener');
const searchQuery = encodeURIComponent(query.value);
const searchUrl = defaultStore.state.searchEngine.replace(/{query}|%s\b/g, searchQuery);
window.open(searchUrl, '_blank', 'noopener');
};
</script>