Support vite base URL

This commit is contained in:
fk 2023-12-26 21:11:55 +01:00
parent 63ead7afb7
commit 1a530dddf0
7 changed files with 20 additions and 10 deletions

View file

@ -1,6 +1,7 @@
<!DOCTYPE html>
<html style="background: #0f0f0f" lang="en" >
<head>
<base href="%BASE_URL%"/>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />

View file

@ -49,7 +49,7 @@ export default {
mounted() {
//TODO: Add Server Side check
if (this.getAuthToken()) {
this.$router.push("/");
this.$router.push(import.meta.env.BASE_URL);
}
},
activated() {
@ -67,7 +67,7 @@ export default {
}).then(resp => {
if (resp.token) {
this.setPreference("authToken" + this.hashCode(this.authApiUrl()), resp.token);
window.location = "/"; // done to bypass cache
window.location = import.meta.env.BASE_URL; // done to bypass cache
} else alert(resp.error);
});
},

View file

@ -131,7 +131,7 @@ export default {
searchText: "",
suggestionsVisible: false,
showTopNav: false,
homePagePath: "/",
homePagePath: import.meta.env.BASE_URL,
registrationDisabled: false,
};
},

View file

@ -1,7 +1,11 @@
<script setup>
const homeUrl = import.meta.env.BASE_URL;
</script>
<template>
<div class="min-h-[88vh] flex flex-col items-center justify-center">
<h1 class="font-bold !text-9xl">404</h1>
<h2 v-t="'info.page_not_found'" class="!text-2xl" />
<a v-t="'actions.back_to_home'" class="btn mt-16" href="/" />
<a v-t="'actions.back_to_home'" class="btn mt-16" :href="homeUrl" />
</div>
</template>

View file

@ -655,14 +655,14 @@ export default {
// reset the auth token
localStorage.removeItem("authToken" + this.hashCode(this.authApiUrl()));
// redirect to trending page
window.location = "/";
window.location = import.meta.env.BASE_URL;
},
resetPreferences() {
this.showConfirmResetPrefsDialog = false;
// clear the local storage
localStorage.clear();
// redirect to the home page
window.location = "/";
window.location = import.meta.env.BASE_URL;
},
async invalidateSession() {
this.fetchJson(this.authApiUrl() + "/logout", null, {

View file

@ -81,7 +81,7 @@ export default {
mounted() {
//TODO: Add Server Side check
if (this.getAuthToken()) {
this.$router.push("/");
this.$router.push(import.meta.env.BASE_URL);
}
},
activated() {
@ -107,7 +107,7 @@ export default {
}).then(resp => {
if (resp.token) {
this.setPreference("authToken" + this.hashCode(this.authApiUrl()), resp.token);
window.location = "/"; // done to bypass cache
window.location = import.meta.env.BASE_URL; // done to bypass cache
} else alert(resp.error);
});
},

View file

@ -23,7 +23,12 @@ export default {
};
},
mounted() {
if (this.$route.path == "/" && this.getPreferenceString("homepage", "trending") == "feed") return;
if (
this.$route.path == import.meta.env.BASE_URL &&
this.getPreferenceString("homepage", "trending") == "feed"
) {
return;
}
let region = this.getPreferenceString("region", "US");
this.fetchTrending(region).then(videos => {
@ -35,7 +40,7 @@ export default {
activated() {
document.title = this.$t("titles.trending") + " - Piped";
if (this.videos.length > 0) this.updateWatched(this.videos);
if (this.$route.path == "/") {
if (this.$route.path == import.meta.env.BASE_URL) {
let homepage = this.getHomePage(this);
if (homepage !== undefined) this.$router.push(homepage);
}