mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-26 01:51:40 +00:00
[PhotonClient] Vite and Typescript complete refactor (#884)
This commit is contained in:
43
photon-client/src/main.ts
Normal file
43
photon-client/src/main.ts
Normal 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");
|
||||
Reference in New Issue
Block a user