Files
PhotonVision/photon-client/src/main.ts
Sam Freund 2372e110f9 TypeCheck Frontend (#2394)
We recently had an error that would've been caught by type checking in the frontend (see #2393). This PR implements type checking so that future errors will be caught.

Additionally, this PR contains miscellaneous frontend cleanup that's tangentially related to type-checking.
2026-05-05 15:24:19 +00:00

48 lines
1.2 KiB
TypeScript

import { h, createApp } from "vue";
import App from "@/App.vue";
import { createPinia } from "pinia";
import router from "@/router";
import vuetify from "@/plugins/vuetify";
import axios from "axios";
type PhotonClientRuntimeMode = "production" | "development" | "local-network-development";
const runtimeMode: PhotonClientRuntimeMode = process.env.NODE_ENV as PhotonClientRuntimeMode;
let backendHost: string;
let backendHostname: string;
switch (runtimeMode) {
case "development":
backendHost = `${location.hostname}:5800`;
backendHostname = location.hostname;
break;
case "local-network-development":
backendHost = "photonvision.local:5800";
backendHostname = "photonvision.local";
break;
case "production":
backendHost = location.host;
backendHostname = location.hostname;
break;
}
axios.defaults.baseURL = `http://${backendHost}/api`;
// Handle Plugins
const pinia = createPinia();
const app = createApp({
router,
vuetify,
pinia: createPinia(),
provide: {
backendHost: backendHost,
backendHostname: backendHostname
},
render: () => h(App)
});
app.use(pinia);
app.use(vuetify);
app.use(router);
app.mount("#app");