feat: Agregar widget de chat del asistente printerCentral
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 2m26s
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 2m26s
This commit is contained in:
44
app/plugins/agents-widget.client.ts
Normal file
44
app/plugins/agents-widget.client.ts
Normal file
@@ -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))
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user