vue-wiguet-chatweb 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/store/index.d.ts +3 -2
- package/dist/style.css +1 -1
- package/dist/vue-wiguet-chatweb.js +3171 -2460
- package/dist/vue-wiguet-chatweb.umd.cjs +9 -11
- package/package.json +2 -3
- package/src/components/Chat.vue +63 -19
- package/src/components/ChatMessage.vue +5 -5
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "vue-wiguet-chatweb",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.4",
|
4
4
|
"type": "module",
|
5
5
|
"files": [
|
6
6
|
"dist",
|
@@ -35,8 +35,7 @@
|
|
35
35
|
"socket.io-client": "^4.7.2",
|
36
36
|
"vite-plugin-dts": "^3.4.0",
|
37
37
|
"vue": "^3.3.4",
|
38
|
-
"vue-rabbit-frontend": "^0.0.15"
|
39
|
-
"vuex": "^4.1.0"
|
38
|
+
"vue-rabbit-frontend": "^0.0.15"
|
40
39
|
},
|
41
40
|
"devDependencies": {
|
42
41
|
"@types/node": "^20.4.6",
|
package/src/components/Chat.vue
CHANGED
@@ -14,8 +14,8 @@
|
|
14
14
|
<button type="submit">
|
15
15
|
<IconUser/>
|
16
16
|
</button>
|
17
|
-
<div class="jl-inputgroup">
|
18
|
-
<input v-model="message" class="jl2-input" required/>
|
17
|
+
<div class="jl-inputgroup-chat">
|
18
|
+
<input v-model="message" class="jl2-input-chat" required/>
|
19
19
|
<button type="submit">
|
20
20
|
<IconSend/>
|
21
21
|
</button>
|
@@ -29,20 +29,21 @@
|
|
29
29
|
<script setup lang="ts">
|
30
30
|
import { ref, onMounted, computed } from 'vue';
|
31
31
|
import ChatMessage from './ChatMessage.vue';
|
32
|
-
import { useStore } from 'vuex';
|
32
|
+
//import { useStore } from 'vuex';
|
33
33
|
import { RabbitMQService } from 'vue-rabbit-frontend'
|
34
34
|
import IconClose from './IconClose.vue'
|
35
35
|
import IconSend from './IconSend.vue'
|
36
36
|
import IconUser from './IconUser.vue'
|
37
|
-
|
37
|
+
import {syncVirtualHostCentral,sendMessageByAppAndPhone,messagesByAppAndPhone} from '../store'
|
38
38
|
///STORE
|
39
|
-
const store = useStore()
|
39
|
+
//const store = useStore()
|
40
40
|
//DATA
|
41
41
|
const app = ref('webchat')
|
42
42
|
const deviceSelect = ref('76177719')
|
43
43
|
const rabbitMQServiceListen:any = ref(null);
|
44
44
|
const message:any = ref(null);
|
45
45
|
const messages:any = ref([]);
|
46
|
+
const virtualHost:any = ref({virtualhost:''});
|
46
47
|
|
47
48
|
const props = defineProps({
|
48
49
|
toggleChat:{ type: Function, required: true },
|
@@ -57,13 +58,34 @@ const removeNumPrefix = (num:string) => {
|
|
57
58
|
return num;
|
58
59
|
}
|
59
60
|
|
61
|
+
const messagesContainer = ref<HTMLElement | null>(null);
|
62
|
+
|
63
|
+
const scrollToBottom = () => {
|
64
|
+
if (messagesContainer.value) {
|
65
|
+
messagesContainer.value.scrollTop = messagesContainer.value.scrollHeight;
|
66
|
+
}
|
67
|
+
};
|
68
|
+
|
60
69
|
const submitMessage = async (event:any) => {
|
61
70
|
event.preventDefault();
|
62
|
-
const {virtualHost} = store.state
|
63
|
-
|
71
|
+
//const {virtualHost} = store.state
|
72
|
+
const {virtualhost} = virtualHost.value
|
73
|
+
// await store.dispatch('sendMessageByAppAndPhone',{
|
74
|
+
// token:props.tokenAuth,
|
75
|
+
// data:{
|
76
|
+
// virtualHost:virtualHost.value,
|
77
|
+
// queue:`widget_chat_${sessionStorage.getItem('tabBrowser')}`,//`${selectDetailtChat.value.app}_${queueUniqueUser.value}`,
|
78
|
+
// device:'00000000',
|
79
|
+
// phone:removeNumPrefix(deviceSelect.value),
|
80
|
+
// app:app.value,
|
81
|
+
// message: message.value,
|
82
|
+
// widget:true
|
83
|
+
// }
|
84
|
+
// })
|
85
|
+
await sendMessageByAppAndPhone({
|
64
86
|
token:props.tokenAuth,
|
65
87
|
data:{
|
66
|
-
virtualHost:
|
88
|
+
virtualHost:virtualhost,
|
67
89
|
queue:`widget_chat_${sessionStorage.getItem('tabBrowser')}`,//`${selectDetailtChat.value.app}_${queueUniqueUser.value}`,
|
68
90
|
device:'00000000',
|
69
91
|
phone:removeNumPrefix(deviceSelect.value),
|
@@ -73,6 +95,7 @@ const submitMessage = async (event:any) => {
|
|
73
95
|
}
|
74
96
|
})
|
75
97
|
message.value = null
|
98
|
+
scrollToBottom()
|
76
99
|
}
|
77
100
|
|
78
101
|
|
@@ -80,8 +103,16 @@ const getMessagesByApp = async (param:{resetConnection:boolean}) => {
|
|
80
103
|
if(param.resetConnection)
|
81
104
|
disconnectMsRabbit();
|
82
105
|
connectMsRabbit();
|
83
|
-
const messagesParse = [];
|
84
|
-
await store.dispatch('messagesByAppAndPhone', {
|
106
|
+
// const messagesParse = [];
|
107
|
+
// await store.dispatch('messagesByAppAndPhone', {
|
108
|
+
// token:props.tokenAuth,
|
109
|
+
// data:{
|
110
|
+
// phone:props.phoneUser,
|
111
|
+
// app:app.value,
|
112
|
+
// device:null
|
113
|
+
// }
|
114
|
+
// });
|
115
|
+
const getMessages = await messagesByAppAndPhone({
|
85
116
|
token:props.tokenAuth,
|
86
117
|
data:{
|
87
118
|
phone:props.phoneUser,
|
@@ -89,23 +120,29 @@ const getMessagesByApp = async (param:{resetConnection:boolean}) => {
|
|
89
120
|
device:null
|
90
121
|
}
|
91
122
|
});
|
92
|
-
const messagesData = store.getters.get_messages_chat;
|
123
|
+
//const messagesData = store.getters.get_messages_chat;
|
124
|
+
const messagesData = getMessages
|
125
|
+
console.log(messagesData)
|
93
126
|
if (messagesData) {
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
127
|
+
|
128
|
+
messages.value = messagesData;
|
129
|
+
|
130
|
+
// for (const msg of messagesData) {
|
131
|
+
// messagesParse.push(...msg.messages);
|
132
|
+
// }
|
133
|
+
// messages.value = messagesParse;
|
98
134
|
}
|
99
135
|
};
|
100
136
|
|
101
137
|
const connectMsRabbit = (app:any = 'webchat') => {
|
102
|
-
const {virtualHost} = store.state
|
138
|
+
//const {virtualHost} = store.state
|
139
|
+
const {virtualhost} = virtualHost.value
|
103
140
|
let data = sessionStorage.getItem('tabBrowser');
|
104
141
|
if(!data){
|
105
142
|
let tab = Date.now();
|
106
143
|
sessionStorage.setItem('tabBrowser', `${tab}`)
|
107
144
|
}
|
108
|
-
rabbitMQServiceListen.value = new RabbitMQService(`${
|
145
|
+
rabbitMQServiceListen.value = new RabbitMQService(`${virtualhost}`,`widget_chat_${sessionStorage.getItem('tabBrowser')}`);
|
109
146
|
rabbitMQServiceListen.value.connect();
|
110
147
|
rabbitMQServiceListen.value.subscribe(async () => {
|
111
148
|
await getMessagesByApp({resetConnection:false});
|
@@ -121,14 +158,21 @@ const disconnectMsRabbit = () => {
|
|
121
158
|
onMounted(async () => {
|
122
159
|
await getMessagesByApp({resetConnection:false})
|
123
160
|
const virtualHostUniqueUser = `WIDGET_CHAT_${props.phoneUser}`
|
124
|
-
await store.dispatch('syncVirtualHostCentral',{
|
161
|
+
// await store.dispatch('syncVirtualHostCentral',{
|
162
|
+
// token:props.tokenAuth,
|
163
|
+
// data:{
|
164
|
+
// virtualHost:virtualHostUniqueUser
|
165
|
+
// }
|
166
|
+
// })
|
167
|
+
virtualHost.value = await syncVirtualHostCentral({
|
125
168
|
token:props.tokenAuth,
|
126
169
|
data:{
|
127
170
|
virtualHost:virtualHostUniqueUser
|
128
171
|
}
|
129
172
|
})
|
173
|
+
console.log(virtualHost.value)
|
130
174
|
connectMsRabbit()
|
131
|
-
|
175
|
+
scrollToBottom()
|
132
176
|
});
|
133
177
|
</script>
|
134
178
|
|
@@ -4,16 +4,16 @@
|
|
4
4
|
<div class="bubble" :class="self ? 'left' : 'right'">
|
5
5
|
<div :class="self ? 'content-left' : 'content-right'">
|
6
6
|
<div class="message">
|
7
|
-
{{ message.dataMessage }}
|
7
|
+
{{ message.messages.dataMessage }}
|
8
8
|
</div>
|
9
9
|
<div class="detail-message flex justify-content-between">
|
10
|
-
<span class="mr-5" v-if="message.user?.nombreCompleto">
|
11
|
-
{{ textCapitalize(message.user.nombreCompleto) }}
|
10
|
+
<span class="mr-5" v-if="message.messages.user?.nombreCompleto">
|
11
|
+
{{ textCapitalize(message.messages.user.nombreCompleto) }}
|
12
12
|
</span>
|
13
13
|
<span class="mr-5" v-else>
|
14
14
|
</span>
|
15
15
|
<span>
|
16
|
-
{{ formatTimeAPDate(message.createdAt) }}
|
16
|
+
{{ formatTimeAPDate(message.messages.createdAt) }}
|
17
17
|
</span>
|
18
18
|
</div>
|
19
19
|
</div>
|
@@ -29,7 +29,7 @@ const props = defineProps({
|
|
29
29
|
});
|
30
30
|
|
31
31
|
const self = computed(() => {
|
32
|
-
return props.message.responseOrigin;
|
32
|
+
return props.message.messages.responseOrigin;
|
33
33
|
});
|
34
34
|
|
35
35
|
</script>
|