-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
25 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,41 @@ | ||
import { createApp, h } from 'vue'; | ||
import {createApp, h} from 'vue'; | ||
import singleSpaVue from 'single-spa-vue'; | ||
import App from './App.vue'; | ||
import KeyCloakService from "@/services/keycloak"; | ||
import router from './router'; | ||
|
||
|
||
import 'bootstrap/dist/css/bootstrap.min.css'; | ||
import 'bootstrap-icons/font/bootstrap-icons.css'; | ||
import 'bootstrap'; | ||
import store from './services/store'; | ||
|
||
let vueLifecycles: any; | ||
let config: any; | ||
|
||
// Fetch the config.json file before initializing the app | ||
export const bootstrap = async () => { | ||
try { | ||
const response = await fetch('/config.json'); | ||
config = await response.json(); | ||
|
||
// Create the app after the config is loaded | ||
const app = createApp(App); | ||
|
||
// Add the config to global properties so it can be accessed in components | ||
app.config.globalProperties.$config = config; | ||
const app = createApp(App); | ||
|
||
vueLifecycles = singleSpaVue({ | ||
createApp: () => app, | ||
appOptions: { | ||
render() { | ||
return h(App); | ||
}, | ||
}, | ||
}); | ||
const vueLifecycles = singleSpaVue({ | ||
createApp: () => app, | ||
appOptions: { | ||
render() { | ||
return h(App); | ||
}, | ||
}, | ||
}); | ||
|
||
app.use(router); | ||
app.use(store); | ||
app.use(router); | ||
app.use(store); | ||
|
||
// Initialize Keycloak with loaded config if necessary | ||
return new Promise((resolve) => { | ||
const onAuthenticatedCallback = () => { | ||
console.log('Authenticated!'); | ||
resolve(vueLifecycles.bootstrap); | ||
}; | ||
KeyCloakService.CallLogin(onAuthenticatedCallback); | ||
}); | ||
} catch (error) { | ||
console.error('Failed to load config.json:', error); | ||
throw new Error('Configuration loading failed'); | ||
} | ||
}; | ||
|
||
// Export mount and unmount for single-spa lifecycle | ||
export const mount = async () => { | ||
if (vueLifecycles) { | ||
return vueLifecycles.mount(); | ||
} | ||
console.error('Vue lifecycles not initialized'); | ||
export const bootstrap = async () => { | ||
return new Promise((resolve) => { | ||
const onAuthenticatedCallback = () => { | ||
console.log('Authenticated!'); | ||
resolve(vueLifecycles.bootstrap); | ||
}; | ||
|
||
KeyCloakService.CallLogin(onAuthenticatedCallback); | ||
}); | ||
}; | ||
|
||
export const unmount = async () => { | ||
if (vueLifecycles) { | ||
return vueLifecycles.unmount(); | ||
} | ||
console.error('Vue lifecycles not initialized'); | ||
}; | ||
export const mount = vueLifecycles.mount; | ||
export const unmount = vueLifecycles.unmount; |