diff --git a/app/plugins/agents-widget.client.ts b/app/plugins/agents-widget.client.ts new file mode 100644 index 0000000..b76e0e6 --- /dev/null +++ b/app/plugins/agents-widget.client.ts @@ -0,0 +1,44 @@ +export default defineNuxtPlugin(() => { + const createWidget = () => { + // Verificar que el custom element esté registrado + if (!customElements.get('chat-widget')) { + setTimeout(createWidget, 100) + return + } + + // Verificar que no exista ya + if (document.querySelector('.floating-widget')) { + return + } + + // Crear contenedor flotante + const container = document.createElement('div') + container.className = 'floating-widget' + container.style.cssText = ` + position: fixed; + bottom: 24px; + right: 24px; + z-index: 9999; + ` + + // Crear el widget + const widget = document.createElement('chat-widget') + widget.setAttribute('api-url', 'https://gamdias.nucleoriofrio.com') + widget.setAttribute('agent-id', '808d524b-fc61-4f16-b7aa-a34ef4e7fe1b') + widget.setAttribute('app-id', 'printerCentral-app') + widget.setAttribute('user-id', 'printerCentral-user') + widget.setAttribute('title', 'Asistente printerCentral') + + // Aplicar color primario de printerCentral via CSS variable + widget.style.setProperty('--chat-primary', '#3f75d2') + + container.appendChild(widget) + document.body.appendChild(container) + } + + if (document.readyState === 'complete') { + setTimeout(createWidget, 100) + } else { + window.addEventListener('load', () => setTimeout(createWidget, 100)) + } +}) diff --git a/nuxt.config.ts b/nuxt.config.ts index b21234e..2921af0 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -28,6 +28,9 @@ export default defineNuxtConfig({ { name: 'apple-mobile-web-app-capable', content: 'yes' }, { name: 'mobile-web-app-capable', content: 'yes' }, { name: 'apple-mobile-web-app-status-bar-style', content: 'black-translucent' } + ], + script: [ + { src: 'https://gamdias.nucleoriofrio.com/widget.js', defer: true } ] } },