mirror of
https://github.com/TeamPiped/Piped.git
synced 2026-09-15 17:23:45 +00:00
Add useConfig composable.
This commit is contained in:
@@ -42,20 +42,14 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { fetchJson, apiUrl } from "@/composables/useApi.js";
|
||||
import { computed } from "vue";
|
||||
import { useConfig } from "@/composables/useConfig.js";
|
||||
|
||||
const donationHref = ref(null);
|
||||
const statusPageHref = ref(null);
|
||||
const privacyPolicyHref = ref(null);
|
||||
const { config } = useConfig();
|
||||
|
||||
onMounted(() => {
|
||||
fetchJson(apiUrl() + "/config").then(config => {
|
||||
donationHref.value = config?.donationUrl;
|
||||
statusPageHref.value = config?.statusPageUrl;
|
||||
privacyPolicyHref.value = config?.privacyPolicyUrl;
|
||||
});
|
||||
});
|
||||
const donationHref = computed(() => config.value?.donationUrl);
|
||||
const statusPageHref = computed(() => config.value?.statusPageUrl);
|
||||
const privacyPolicyHref = computed(() => config.value?.privacyPolicyUrl);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -145,8 +145,9 @@ import { useRouter, useRoute } from "vue-router";
|
||||
import SearchSuggestions from "./SearchSuggestions.vue";
|
||||
import ClearButton from "./ui/ClearButton.vue";
|
||||
import hotkeys from "hotkeys-js";
|
||||
import { fetchJson, authApiUrl, getAuthToken } from "@/composables/useApi.js";
|
||||
import { getAuthToken } from "@/composables/useApi.js";
|
||||
import { getPreferenceBoolean, getPreferenceString } from "@/composables/usePreferences.js";
|
||||
import { useConfig } from "@/composables/useConfig.js";
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
@@ -157,7 +158,9 @@ const searchSuggestions = ref(null);
|
||||
const searchText = ref("");
|
||||
const suggestionsVisible = ref(false);
|
||||
const showTopNav = ref(false);
|
||||
const registrationDisabled = ref(false);
|
||||
|
||||
const { authConfig } = useConfig();
|
||||
const registrationDisabled = computed(() => authConfig.value?.registrationDisabled === true);
|
||||
|
||||
const shouldShowLogin = computed(() => {
|
||||
return getAuthToken() == null;
|
||||
@@ -224,12 +227,6 @@ function onSearchTextChange(text) {
|
||||
searchText.value = text;
|
||||
}
|
||||
|
||||
async function fetchAuthConfig() {
|
||||
fetchJson(authApiUrl() + "/config").then(config => {
|
||||
registrationDisabled.value = config?.registrationDisabled === true;
|
||||
});
|
||||
}
|
||||
|
||||
function onSearchClick(e) {
|
||||
submitSearch(e);
|
||||
}
|
||||
@@ -248,7 +245,6 @@ function submitSearch(e) {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchAuthConfig();
|
||||
updateSearchTextFromURLSearchParams();
|
||||
focusOnSearchBar();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user