fix warnings on index page, use api host from env

This commit is contained in:
MiniDigger 2022-03-21 18:29:12 +01:00
parent 3e57dc4e3d
commit f4ce3faca7
6 changed files with 32 additions and 7 deletions

View File

@ -1 +1,2 @@
HANGAR_PUBLIC_HOST=http://localhost:3333
HANGAR_PROXY_HOST=http://localhost:8080

View File

@ -1 +1,2 @@
HANGAR_PUBLIC_HOST=https://hangar.benndorf.dev
HANGAR_PROXY_HOST=http://hangar_new_backend:8080

View File

@ -1,6 +1,9 @@
import type { AxiosInstance } from "axios";
import axios from "axios";
import { axiosLog } from "~/composables/useLog";
export const useAxios: AxiosInstance = axios.create({
baseURL: "http://localhost:3333",
});
const options = {
baseURL: import.meta.env.SSR ? import.meta.env.HANGAR_PROXY_HOST : import.meta.env.HANGAR_PUBLIC_HOST,
};
axiosLog("axios options", options);
export const useAxios: AxiosInstance = axios.create(options);

View File

@ -4,3 +4,4 @@ export const authLog = debug("hangar:auth");
export const fetchLog = debug("hangar:fetch");
export const initalStateLog = debug("hangar:initialState");
export const routePermLog = debug("hangar:routePerm");
export const axiosLog = debug("hangar:axios");

View File

@ -2,6 +2,7 @@
interface ImportMetaEnv {
readonly HANGAR_PUBLIC_HOST: string;
readonly HANGAR_PROXY_HOST: string;
}
interface ImportMeta {

View File

@ -9,6 +9,7 @@ import { handleRequestError } from "~/composables/useErrorHandling";
import { useContext } from "vite-ssr/vue";
import Card from "~/components/design/Card.vue";
import Container from "~/components/design/Container.vue";
import { ref } from "vue";
const i18n = useI18n();
@ -35,6 +36,13 @@ const versions = [
{ version: "1.16" },
];
const filters = ref({
versions: {},
categories: {},
platforms: {},
licences: {},
});
const ctx = useContext();
const projects = await useProjects().catch((e) => handleRequestError(e, ctx, i18n));
</script>
@ -87,28 +95,38 @@ const projects = await useProjects().catch((e) => handleRequestError(e, ctx, i18
<div class="versions">
<h3 class="font-bold">Minecraft versions</h3>
<div class="flex flex-col gap-2 max-h-30 overflow-auto">
<InputCheckbox v-for="version in versions" :key="version.version" :label="version.version" />
<InputCheckbox v-for="version in versions" :key="version.version" v-model="filters.versions[version.version]" :label="version.version" />
</div>
</div>
<hr />
<div class="categories">
<h3 class="font-bold">Categories</h3>
<div class="flex flex-col gap-2">
<InputCheckbox v-for="category in backendData.visibleCategories" :key="category.apiName" :label="i18n.t(category.title)" />
<InputCheckbox
v-for="category in backendData.visibleCategories"
:key="category.apiName"
v-model="filters.categories[category.apiName]"
:label="i18n.t(category.title)"
/>
</div>
</div>
<hr />
<div class="platforms">
<h3 class="font-bold">Platforms</h3>
<div class="flex flex-col gap-2">
<InputCheckbox v-for="platform in backendData.visiblePlatforms" :key="platform.enumName" :label="platform.name" />
<InputCheckbox
v-for="platform in backendData.visiblePlatforms"
:key="platform.enumName"
v-model="filters.platforms[platform.enumName]"
:label="platform.name"
/>
</div>
</div>
<hr />
<div class="licenses">
<h3 class="font-bold">Licenses</h3>
<div class="flex flex-col gap-2">
<InputCheckbox v-for="license in backendData.licenses" :key="license" :label="license" />
<InputCheckbox v-for="license in backendData.licenses" :key="license" v-model="filters.licences[license]" :label="license" />
</div>
</div>
</Card>