[PhotonClient] Vite and Typescript complete refactor (#884)

This commit is contained in:
Sriman Achanta
2023-08-21 01:51:35 -04:00
committed by GitHub
parent 8397b43bef
commit f623e4a1cc
119 changed files with 11821 additions and 19318 deletions

43
photon-client/src/main.ts Normal file
View File

@@ -0,0 +1,43 @@
import Vue from "vue";
import App from "@/App.vue";
import { createPinia, PiniaVuePlugin } 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 as PhotonClientRuntimeMode) {
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
Vue.use(PiniaVuePlugin);
new Vue({
router,
vuetify,
pinia: createPinia(),
provide: {
backendHost: backendHost,
backendHostname: backendHostname
},
render: (h) => h(App)
}).$mount("#app");