mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-12 00:15:48 +01:00
✨ Add switch option to open search box result in same tab #476
This makes it easier to search when homer is set as the default for a new tab. Co-authored-by: Momcilo Bajalovic <momcilobajalovic@Momcilos-Air.lan>
This commit is contained in:
@@ -153,20 +153,22 @@ export default function SearchBar(props: any) {
|
||||
}}
|
||||
onSubmit={form.onSubmit((values) => {
|
||||
const query = values.query.trim();
|
||||
const open_in = config.settings.searchNewTab ? '_blank' : '_self';
|
||||
setTimeout(() => {
|
||||
form.setValues({ query: '' });
|
||||
switch (query.substring(0, 3)) {
|
||||
case '!yt':
|
||||
window.open(`https://www.youtube.com/results?search_query=${query.substring(3)}`);
|
||||
window.open(`https://www.youtube.com/results?search_query=${query.substring(3)}`, open_in);
|
||||
break;
|
||||
case '!t ':
|
||||
window.open(`https://www.torrentdownloads.me/search/?search=${query.substring(3)}`);
|
||||
window.open(`https://www.torrentdownloads.me/search/?search=${query.substring(3)}`, open_in);
|
||||
break;
|
||||
case '!os':
|
||||
break;
|
||||
default:
|
||||
window.open(
|
||||
`${queryUrl.includes('%s') ? queryUrl.replace('%s', query) : `${queryUrl}${query}`}`
|
||||
`${queryUrl.includes('%s') ? queryUrl.replace('%s', query) : `${queryUrl}${query}`}`,
|
||||
open_in
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user