From 2373f756c12df9288016aeaa64551b48b09f7e0e Mon Sep 17 00:00:00 2001 From: djuarezgf Date: Mon, 14 Oct 2024 15:56:27 +0200 Subject: [PATCH] Test --- src/main.ts | 74 ++++++++++++++++++----------------------------------- 1 file changed, 25 insertions(+), 49 deletions(-) diff --git a/src/main.ts b/src/main.ts index 84569ea..ff7a02e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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;