web-component-gallery 1.1.25 → 1.1.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-component-gallery",
3
- "version": "1.1.25",
3
+ "version": "1.1.26",
4
4
  "description": "vue-library-ui组件库",
5
5
  "main": "dist/index.umd.js",
6
6
  "files": [
@@ -0,0 +1,74 @@
1
+ import { DateTime } from "luxon"
2
+
3
+ const state = {
4
+ messages: [],
5
+ myself: {},
6
+ participants: [],
7
+ chatTitle: '',
8
+ chatDescription: '',
9
+ placeholder: ''
10
+ }
11
+
12
+ const mutations = {
13
+ newMessage: (state, message) => {
14
+ message.timestamp = message.timestamp.toISO()
15
+ message.myself = message.participantId === state.myself.id
16
+ state.messages = [...state.messages, message]
17
+ },
18
+ setParticipants: (state, participants) => {
19
+ state.participants = participants
20
+ },
21
+ setMyself: (state, myself) => {
22
+ state.myself = myself
23
+ },
24
+ setMessages: (state, messages) => {
25
+ state.messages = messages.map(message => {
26
+ if(message.timestamp) (typeof message.timestamp == 'object') && (message.timestamp = DateTime.fromObject(message.timestamp).toISO())
27
+ else message.timestamp = DateTime.local().toISO()
28
+
29
+ if (!("myself" in message))
30
+ message.myself = message.participantId === state.myself.id
31
+ return message
32
+ })
33
+ },
34
+ setChatTitle: (state, title) => {
35
+ state.chatTitle = title
36
+ },
37
+ setChatDescription: (state, description) => {
38
+ state.chatDescription = description
39
+ },
40
+ setPlaceholder: (state, placeholder) => {
41
+ state.placeholder = placeholder
42
+ }
43
+ }
44
+
45
+ const getters = {
46
+ getParticipantById: (state) => (id) => {
47
+ let curr_participant
48
+ state.participants.forEach(participant => {
49
+ if (participant.id === id) {
50
+ curr_participant = participant
51
+ }
52
+ })
53
+
54
+ return curr_participant
55
+ },
56
+ messages: (state) => {
57
+ let messages = []
58
+ state.messages.forEach(message => {
59
+ let newMessage = {...message}
60
+ newMessage.timestamp = DateTime.fromISO(newMessage.timestamp)
61
+ messages.push(newMessage)
62
+ });
63
+ return messages
64
+ },
65
+ myself: (state) => {
66
+ return state.myself
67
+ }
68
+ }
69
+
70
+ export default {
71
+ state,
72
+ mutations,
73
+ getters
74
+ }