1
0
mirror of https://github.com/TeamPiped/Piped.git synced 2024-12-13 22:00:28 +05:30

Use a router link for opening the home page

This commit is contained in:
Bnyro 2023-07-07 18:02:01 +02:00
parent f1f3b8e149
commit bd21e72370
3 changed files with 18 additions and 11 deletions

View File

@ -1,8 +1,14 @@
<template> <template>
<nav class="flex flex-wrap items-center justify-center px-2 sm:px-4 pb-2.5 w-full relative"> <nav class="flex flex-wrap items-center justify-center px-2 sm:px-4 pb-2.5 w-full relative">
<div class="flex-1 flex justify-start"> <div class="flex-1 flex justify-start">
<span class="flex font-bold text-3xl items-center font-sans cursor-pointer" @click="openHomePage(this)" <router-link class="flex font-bold text-3xl items-center font-sans" :to="homePagePath"
><img alt="logo" src="/img/icons/logo.svg" height="32" width="32" class="w-10 mr-[-0.6rem]" />iped</span ><img
alt="logo"
src="/img/icons/logo.svg"
height="32"
width="32"
class="w-10 mr-[-0.6rem]"
/>iped</router-link
> >
</div> </div>
<div class="lt-md:hidden search-container"> <div class="lt-md:hidden search-container">
@ -122,12 +128,14 @@ export default {
searchText: "", searchText: "",
suggestionsVisible: false, suggestionsVisible: false,
showTopNav: false, showTopNav: false,
homePagePath: "/",
}; };
}, },
mounted() { mounted() {
const query = new URLSearchParams(window.location.search).get("search_query"); const query = new URLSearchParams(window.location.search).get("search_query");
if (query) this.onSearchTextChange(query); if (query) this.onSearchTextChange(query);
this.focusOnSearchBar(); this.focusOnSearchBar();
this.homePagePath = this.getHomePage(this);
}, },
computed: { computed: {
shouldShowLogin(_this) { shouldShowLogin(_this) {

View File

@ -34,7 +34,10 @@ export default {
activated() { activated() {
document.title = this.$t("titles.trending") + " - Piped"; document.title = this.$t("titles.trending") + " - Piped";
if (this.videos.length > 0) this.updateWatched(this.videos); if (this.videos.length > 0) this.updateWatched(this.videos);
if (this.$route.path == "/") this.openHomePage(this); if (this.$route.path == "/") {
let homepage = this.getHomePage(this);
if (homepage !== undefined) this.$router.push(homepage);
}
}, },
methods: { methods: {
async fetchTrending(region) { async fetchTrending(region) {

View File

@ -532,19 +532,15 @@ const mixin = {
}, },
}); });
}, },
openHomePage(_this) { getHomePage(_this) {
let route;
switch (_this.getPreferenceString("homepage", "trending")) { switch (_this.getPreferenceString("homepage", "trending")) {
case "trending": case "trending":
route = "/trending"; return "/trending";
break;
case "feed": case "feed":
route = "/feed"; return "/feed";
break;
default: default:
break; return undefined;
} }
if (route !== undefined) _this.$router.push(route);
}, },
}, },
computed: { computed: {