1 import { type App
as AppType
, createApp
} from
'vue'
2 import ToastPlugin from
'vue-toast-notification'
3 import type { ConfigurationData
} from
'@/types'
4 import { router
} from
'@/router'
5 import { UIClient
, getFromLocalStorage
, setToLocalStorage
} from
'@/composables'
6 import App from
'@/App.vue'
7 import 'vue-toast-notification/dist/theme-bootstrap.css'
9 const app
= createApp(App
)
11 const initializeApp
= (app
: AppType
, config
: ConfigurationData
) => {
12 app
.config
.errorHandler
= (error
, instance
, info
) => {
13 console
.error('Error:', error
)
14 console
.info('Vue instance:', instance
)
15 console
.info('Error info:', info
)
16 // TODO: add code for UI notifications or other error handling logic
18 if (!Array.isArray(config
.uiServer
)) {
19 config
.uiServer
= [config
.uiServer
]
21 if (app
.config
.globalProperties
.$configuration
== null) {
22 app
.config
.globalProperties
.$configuration
= config
24 if (!Array.isArray(app
.config
.globalProperties
.$templates
)) {
25 app
.config
.globalProperties
.$templates
= []
27 if (!Array.isArray(app
.config
.globalProperties
.$chargingStations
)) {
28 app
.config
.globalProperties
.$chargingStations
= []
31 getFromLocalStorage
<number | undefined>('uiServerConfigurationIndex', undefined) == null ||
32 getFromLocalStorage
<number>('uiServerConfigurationIndex', 0) >
33 app
.config
.globalProperties
.$configuration
.uiServer
.length
- 1
35 setToLocalStorage
<number>('uiServerConfigurationIndex', 0)
37 if (app
.config
.globalProperties
.$uiClient
== null) {
38 app
.config
.globalProperties
.$uiClient
= UIClient
.getInstance(
39 app
.config
.globalProperties
.$configuration
.uiServer
[
40 getFromLocalStorage
<number>('uiServerConfigurationIndex', 0)
44 app
.use(router
).use(ToastPlugin
).mount('#app')
50 // TODO: add code for UI notifications or other error handling logic
51 console
.error('Failed to fetch app configuration')
57 initializeApp(app
, config
)
60 // TODO: add code for UI notifications or other error handling logic
61 console
.error('Error at deserializing JSON app configuration:', error
)
65 // TODO: add code for UI notifications or other error handling logic
66 console
.error('Error at fetching app configuration:', error
)