1 import 'vue-toast-notification/dist/theme-bootstrap.css'
3 import { type App
as AppType
, createApp
, ref
} from
'vue'
4 import ToastPlugin from
'vue-toast-notification'
6 import App from
'@/App.vue'
7 import { getFromLocalStorage
, setToLocalStorage
, UIClient
} from
'@/composables'
8 import { router
} from
'@/router'
9 import type { ChargingStationData
, ConfigurationData
, UIServerConfigurationSection
} from
'@/types'
11 const app
= createApp(App
)
13 const initializeApp
= (app
: AppType
, config
: ConfigurationData
) => {
14 app
.config
.errorHandler
= (error
, instance
, info
) => {
15 console
.error('Error:', error
)
16 console
.info('Vue instance:', instance
)
17 console
.info('Error info:', info
)
18 // TODO: add code for UI notifications or other error handling logic
20 if (!Array.isArray(config
.uiServer
)) {
21 config
.uiServer
= [config
.uiServer
]
23 if (app
.config
.globalProperties
.$configuration
== null) {
24 app
.config
.globalProperties
.$configuration
= ref
<ConfigurationData
>(config
)
26 if (!Array.isArray(app
.config
.globalProperties
.$templates
?.value
)) {
27 app
.config
.globalProperties
.$templates
= ref
<string[]>([])
29 if (!Array.isArray(app
.config
.globalProperties
.$chargingStations
?.value
)) {
30 app
.config
.globalProperties
.$chargingStations
= ref
<ChargingStationData
[]>([])
33 getFromLocalStorage
<number | undefined>('uiServerConfigurationIndex', undefined) == null ||
34 getFromLocalStorage
<number>('uiServerConfigurationIndex', 0) >
35 (app
.config
.globalProperties
.$configuration
.value
.uiServer
as UIServerConfigurationSection
[])
39 setToLocalStorage
<number>('uiServerConfigurationIndex', 0)
41 if (app
.config
.globalProperties
.$uiClient
== null) {
42 app
.config
.globalProperties
.$uiClient
= UIClient
.getInstance(
43 (app
.config
.globalProperties
.$configuration
.value
.uiServer
as UIServerConfigurationSection
[])[
44 getFromLocalStorage
<number>('uiServerConfigurationIndex', 0)
48 app
.use(router
).use(ToastPlugin
).mount('#app')
54 // TODO: add code for UI notifications or other error handling logic
55 console
.error('Failed to fetch app configuration')
61 initializeApp(app
, config
)
64 // TODO: add code for UI notifications or other error handling logic
65 console
.error('Error at deserializing JSON app configuration:', error
)
69 // TODO: add code for UI notifications or other error handling logic
70 console
.error('Error at fetching app configuration:', error
)