mirror of
https://github.com/PhotonVision/photonvision
synced 2026-07-04 03:11:40 +00:00
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.
48 lines
1.2 KiB
TypeScript
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");
|