All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 2m26s
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
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))
|
|
}
|
|
})
|