@aochuang/client-sdk 1.0.309 → 1.0.312
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/common/context-menu/context-menu.vue +130 -25
- package/components/chat-editor/chat-editor-button/chat-editor-button.vue +8 -2
- package/components/chat-editor/chat-editor-suggestions/chat-editor-suggestions.vue +16 -1
- package/components/chat-panel/chat-panel-box.vue +1 -1
- package/components/chat-panel/chat-panel-chat.vue +1 -1
- package/components/chat-panel/chat-panel-chats.vue +28 -23
- package/components/chat-panel/chat-panel.vue +3 -0
- package/components/wechat-chat-panel/chat-panel.vue +8 -6
- package/package.json +1 -1
|
@@ -36,16 +36,114 @@
|
|
|
36
36
|
</div>
|
|
37
37
|
</template>
|
|
38
38
|
<script>
|
|
39
|
-
import UiContextMenuBox from './context-menu-box'
|
|
40
|
-
import UiContextMenuGroup from './context-menu-group'
|
|
41
|
-
import UiContextMenuItem from './context-menu-item'
|
|
39
|
+
import UiContextMenuBox from './context-menu-box'
|
|
40
|
+
import UiContextMenuGroup from './context-menu-group'
|
|
41
|
+
import UiContextMenuItem from './context-menu-item'
|
|
42
|
+
import { isMobile } from '@aochuang/common/utils/browse.js'
|
|
42
43
|
|
|
43
|
-
import {
|
|
44
|
-
getOptimalCoordinate,
|
|
45
|
-
getWindowRect,
|
|
46
|
-
createRectByXY,
|
|
47
|
-
getElementRect
|
|
48
|
-
} from './utils.js'
|
|
44
|
+
import {
|
|
45
|
+
getOptimalCoordinate,
|
|
46
|
+
getWindowRect,
|
|
47
|
+
createRectByXY,
|
|
48
|
+
getElementRect
|
|
49
|
+
} from './utils.js'
|
|
50
|
+
|
|
51
|
+
let mobileContextMenuMountCount = 0
|
|
52
|
+
let longPressTimer = null
|
|
53
|
+
let longPressStart = null
|
|
54
|
+
let longPressTriggered = false
|
|
55
|
+
|
|
56
|
+
function clearLongPressTimer () {
|
|
57
|
+
clearTimeout(longPressTimer)
|
|
58
|
+
longPressTimer = null
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function handleDocumentTouchStart (event) {
|
|
62
|
+
if (event.touches.length !== 1) {
|
|
63
|
+
clearLongPressTimer()
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
const touch = event.touches[0]
|
|
67
|
+
longPressStart = {
|
|
68
|
+
target: event.target,
|
|
69
|
+
clientX: touch.clientX,
|
|
70
|
+
clientY: touch.clientY
|
|
71
|
+
}
|
|
72
|
+
longPressTriggered = false
|
|
73
|
+
clearLongPressTimer()
|
|
74
|
+
longPressTimer = setTimeout(() => {
|
|
75
|
+
if (!longPressStart || !longPressStart.target) {
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
longPressTriggered = true
|
|
79
|
+
longPressStart.target.dispatchEvent(new MouseEvent('contextmenu', {
|
|
80
|
+
bubbles: true,
|
|
81
|
+
cancelable: true,
|
|
82
|
+
clientX: longPressStart.clientX,
|
|
83
|
+
clientY: longPressStart.clientY
|
|
84
|
+
}))
|
|
85
|
+
}, 500)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function handleDocumentTouchMove (event) {
|
|
89
|
+
const touch = event.touches[0]
|
|
90
|
+
if (!longPressStart || !touch) {
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
if (Math.abs(touch.clientX - longPressStart.clientX) > 10 || Math.abs(touch.clientY - longPressStart.clientY) > 10) {
|
|
94
|
+
clearLongPressTimer()
|
|
95
|
+
longPressStart = null
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function handleDocumentTouchEnd (event) {
|
|
100
|
+
clearLongPressTimer()
|
|
101
|
+
longPressStart = null
|
|
102
|
+
if (longPressTriggered) {
|
|
103
|
+
event.preventDefault()
|
|
104
|
+
longPressTriggered = false
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function handleDocumentTouchCancel () {
|
|
109
|
+
clearLongPressTimer()
|
|
110
|
+
longPressStart = null
|
|
111
|
+
longPressTriggered = false
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function handleDocumentContextMenu (event) {
|
|
115
|
+
event.preventDefault()
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function addMobileContextMenuListeners () {
|
|
119
|
+
mobileContextMenuMountCount++
|
|
120
|
+
if (mobileContextMenuMountCount !== 1) {
|
|
121
|
+
return
|
|
122
|
+
}
|
|
123
|
+
window.document.addEventListener('touchstart', handleDocumentTouchStart, { passive: true })
|
|
124
|
+
window.document.addEventListener('touchmove', handleDocumentTouchMove, { passive: true })
|
|
125
|
+
window.document.addEventListener('touchend', handleDocumentTouchEnd, { passive: false })
|
|
126
|
+
window.document.addEventListener('touchcancel', handleDocumentTouchCancel, { passive: true })
|
|
127
|
+
window.document.addEventListener('contextmenu', handleDocumentContextMenu)
|
|
128
|
+
window.document.documentElement.classList.add('ui-context-menu-mobile')
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function removeMobileContextMenuListeners () {
|
|
132
|
+
mobileContextMenuMountCount--
|
|
133
|
+
if (mobileContextMenuMountCount > 0) {
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
mobileContextMenuMountCount = 0
|
|
137
|
+
clearLongPressTimer()
|
|
138
|
+
longPressStart = null
|
|
139
|
+
longPressTriggered = false
|
|
140
|
+
window.document.removeEventListener('touchstart', handleDocumentTouchStart)
|
|
141
|
+
window.document.removeEventListener('touchmove', handleDocumentTouchMove)
|
|
142
|
+
window.document.removeEventListener('touchend', handleDocumentTouchEnd)
|
|
143
|
+
window.document.removeEventListener('touchcancel', handleDocumentTouchCancel)
|
|
144
|
+
window.document.removeEventListener('contextmenu', handleDocumentContextMenu)
|
|
145
|
+
window.document.documentElement.classList.remove('ui-context-menu-mobile')
|
|
146
|
+
}
|
|
49
147
|
|
|
50
148
|
export default {
|
|
51
149
|
name: 'UiContextMenu',
|
|
@@ -93,10 +191,12 @@ export default {
|
|
|
93
191
|
return this.innerData.filter(v => !v.divided)
|
|
94
192
|
}
|
|
95
193
|
},
|
|
96
|
-
mounted () {
|
|
97
|
-
window.document.addEventListener('mousewheel', this.handleDocumentMouseWheel)
|
|
98
|
-
window.document.addEventListener('mousedown', this.handleDocumentMouseDown)
|
|
99
|
-
|
|
194
|
+
mounted () {
|
|
195
|
+
window.document.addEventListener('mousewheel', this.handleDocumentMouseWheel)
|
|
196
|
+
window.document.addEventListener('mousedown', this.handleDocumentMouseDown)
|
|
197
|
+
if (isMobile()) {
|
|
198
|
+
addMobileContextMenuListeners()
|
|
199
|
+
}
|
|
100
200
|
},
|
|
101
201
|
watch: {
|
|
102
202
|
value: {
|
|
@@ -105,9 +205,9 @@ export default {
|
|
|
105
205
|
val ? this.open(this.left, this.top) : this.close()
|
|
106
206
|
}
|
|
107
207
|
}
|
|
108
|
-
},
|
|
109
|
-
methods: {
|
|
110
|
-
handleGroupClick () {
|
|
208
|
+
},
|
|
209
|
+
methods: {
|
|
210
|
+
handleGroupClick () {
|
|
111
211
|
this.close()
|
|
112
212
|
},
|
|
113
213
|
handleGroupItemClick ({ item }) {
|
|
@@ -175,16 +275,21 @@ export default {
|
|
|
175
275
|
this.activeSubItem = null
|
|
176
276
|
this.$emit('input', false)
|
|
177
277
|
}
|
|
178
|
-
},
|
|
179
|
-
|
|
180
|
-
window.document.removeEventListener('mousewheel', this.handleDocumentMouseWheel)
|
|
181
|
-
window.document.removeEventListener('mousedown', this.handleDocumentMouseDown)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
278
|
+
},
|
|
279
|
+
beforeDestroy () {
|
|
280
|
+
window.document.removeEventListener('mousewheel', this.handleDocumentMouseWheel)
|
|
281
|
+
window.document.removeEventListener('mousedown', this.handleDocumentMouseDown)
|
|
282
|
+
if (isMobile()) {
|
|
283
|
+
removeMobileContextMenuListeners()
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
185
287
|
</script>
|
|
186
|
-
<style>
|
|
187
|
-
.ui-context-menu
|
|
288
|
+
<style>
|
|
289
|
+
.ui-context-menu-mobile {
|
|
290
|
+
-webkit-touch-callout: none;
|
|
291
|
+
}
|
|
292
|
+
.ui-context-menu * {
|
|
188
293
|
box-sizing: content-box;
|
|
189
294
|
}
|
|
190
295
|
.ui-context-menu{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<ui-tooltip :disabled="!tips" :content="tips">
|
|
2
|
+
<ui-tooltip :disabled="!tips || isMobile" :content="tips">
|
|
3
3
|
<div class="sdk-chat-editor-button" :class="{'is-active': active}" @click.stop="handleClick">
|
|
4
4
|
<template v-if="loading">
|
|
5
5
|
<ui-loading size="mini"></ui-loading>
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
</template>
|
|
19
19
|
<script>
|
|
20
20
|
import { Tooltip as UiTooltip, Loading as UiLoading } from '@aochuang/common/components'
|
|
21
|
+
import { isMobile } from '@aochuang/common/utils/browse.js'
|
|
21
22
|
|
|
22
23
|
export default {
|
|
23
24
|
name: 'SdkChatEditorButton',
|
|
@@ -25,6 +26,11 @@ export default {
|
|
|
25
26
|
UiLoading,
|
|
26
27
|
UiTooltip
|
|
27
28
|
},
|
|
29
|
+
data () {
|
|
30
|
+
return {
|
|
31
|
+
isMobile: isMobile()
|
|
32
|
+
}
|
|
33
|
+
},
|
|
28
34
|
props: {
|
|
29
35
|
tips: {
|
|
30
36
|
type: String
|
|
@@ -75,4 +81,4 @@ export default {
|
|
|
75
81
|
height: 100%;
|
|
76
82
|
vertical-align: top;
|
|
77
83
|
}
|
|
78
|
-
</style>
|
|
84
|
+
</style>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
3
|
class="sdk-chat-editor-suggestions"
|
|
4
|
+
:class="{'is-mobile': isMobile}"
|
|
4
5
|
v-if="isShow"
|
|
5
6
|
>
|
|
6
7
|
<div class="sdk-chat-editor-suggestions__head">
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
</template>
|
|
50
51
|
<script>
|
|
51
52
|
import { Loading as UiLoading } from '@aochuang/common/components'
|
|
53
|
+
import { isMobile } from '@aochuang/common/utils/browse.js'
|
|
52
54
|
|
|
53
55
|
export default {
|
|
54
56
|
name: 'SdkChatEditorSuggestions',
|
|
@@ -73,7 +75,8 @@ export default {
|
|
|
73
75
|
data () {
|
|
74
76
|
return {
|
|
75
77
|
closed: false,
|
|
76
|
-
focusId: null
|
|
78
|
+
focusId: null,
|
|
79
|
+
isMobile: isMobile()
|
|
77
80
|
}
|
|
78
81
|
},
|
|
79
82
|
computed: {
|
|
@@ -227,6 +230,18 @@ export default {
|
|
|
227
230
|
display: flex;
|
|
228
231
|
flex-direction: column;
|
|
229
232
|
}
|
|
233
|
+
.sdk-chat-editor-suggestions.is-mobile {
|
|
234
|
+
box-sizing: border-box;
|
|
235
|
+
width: 100%;
|
|
236
|
+
min-width: 0;
|
|
237
|
+
max-width: none;
|
|
238
|
+
}
|
|
239
|
+
.sdk-chat-editor-suggestions.is-mobile .sdk-chat-editor-suggestions__body {
|
|
240
|
+
overflow-x: hidden;
|
|
241
|
+
}
|
|
242
|
+
.sdk-chat-editor-suggestions.is-mobile .sdk-chat-editor-suggestions__foot {
|
|
243
|
+
flex-wrap: wrap;
|
|
244
|
+
}
|
|
230
245
|
.sdk-chat-editor-suggestions__head{
|
|
231
246
|
line-height: 24px;
|
|
232
247
|
padding: 4px 12px;
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
<div class="sdk-chat-panel-box__foot-row" v-if="inner_foot_vnode">
|
|
36
36
|
<component :is="inner_foot_vnode"></component>
|
|
37
37
|
</div>
|
|
38
|
-
<div class="sdk-chat-panel-box__foot-row" v-if="$slots.foot">
|
|
38
|
+
<div class="sdk-chat-panel-box__foot-row" v-if="$slots.foot || $scopedSlots.foot">
|
|
39
39
|
<slot name="foot"></slot>
|
|
40
40
|
</div>
|
|
41
41
|
<div class="sdk-chat-panel-box__foot-row is-last">
|
|
@@ -18,31 +18,35 @@
|
|
|
18
18
|
@range="handleIncrementRangeMore"
|
|
19
19
|
></chat-panel-increment>
|
|
20
20
|
<template v-if="dataType === 'array'">
|
|
21
|
-
<
|
|
21
|
+
<template
|
|
22
22
|
v-for="item in data"
|
|
23
|
-
:key="'chat_' + item[keyField]"
|
|
24
|
-
:dir="handleisSenderMethod(item) ? 'right' : 'left'"
|
|
25
|
-
:class="handleChatClassMethod(item)"
|
|
26
|
-
:id="item[keyField]"
|
|
27
|
-
:item="item"
|
|
28
|
-
:render-control="renderControl"
|
|
29
|
-
:fetch-user-method="fetchUserMethod"
|
|
30
|
-
:ref="'chat_' + item[keyField]"
|
|
31
|
-
:show-context-btn="showContextBtn"
|
|
32
|
-
:msg-time-field="msgTimeField"
|
|
33
|
-
@view-context="handleViewContextClick(item)"
|
|
34
|
-
@contextmenu="handleChatContextMenu(item, $event)"
|
|
35
23
|
>
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
24
|
+
<slot name="chat-before" :item="item"></slot>
|
|
25
|
+
<chat-panel-chat
|
|
26
|
+
:key="'chat_' + item[keyField]"
|
|
27
|
+
:dir="handleisSenderMethod(item) ? 'right' : 'left'"
|
|
28
|
+
:class="handleChatClassMethod(item)"
|
|
29
|
+
:id="item[keyField]"
|
|
30
|
+
:item="item"
|
|
31
|
+
:render-control="renderControl"
|
|
32
|
+
:fetch-user-method="fetchUserMethod"
|
|
33
|
+
:ref="'chat_' + item[keyField]"
|
|
34
|
+
:show-context-btn="showContextBtn"
|
|
35
|
+
:msg-time-field="msgTimeField"
|
|
36
|
+
@view-context="handleViewContextClick(item)"
|
|
37
|
+
@contextmenu="handleChatContextMenu(item, $event)"
|
|
38
|
+
>
|
|
39
|
+
<template slot="chat" slot-scope="scope">
|
|
40
|
+
<slot name="chat" v-bind="scope"></slot>
|
|
41
|
+
</template>
|
|
42
|
+
<template slot-scope="scope" slot="chat-foot">
|
|
43
|
+
<slot name="chat-foot" v-bind="scope"></slot>
|
|
44
|
+
</template>
|
|
45
|
+
<template slot-scope="scope" slot="chat-append">
|
|
46
|
+
<slot name="chat-append" v-bind="scope"></slot>
|
|
47
|
+
</template>
|
|
48
|
+
</chat-panel-chat>
|
|
49
|
+
</template>
|
|
46
50
|
</template>
|
|
47
51
|
<template v-else>
|
|
48
52
|
<template v-for="day in data">
|
|
@@ -52,6 +56,7 @@
|
|
|
52
56
|
<template
|
|
53
57
|
v-for="item in milliseconds"
|
|
54
58
|
>
|
|
59
|
+
<slot name="chat-before" :item="item"></slot>
|
|
55
60
|
<chat-panel-chat
|
|
56
61
|
:key="'chat_' + item[keyField]"
|
|
57
62
|
:dir="handleisSenderMethod(item) ? 'right' : 'left'"
|
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
@view-context="handleChatsViewContext"
|
|
32
32
|
@chat-contextmenu="handleChatContext"
|
|
33
33
|
>
|
|
34
|
+
<template slot="chat-before" slot-scope="scope">
|
|
35
|
+
<slot name="chat-before" v-bind="scope"></slot>
|
|
36
|
+
</template>
|
|
34
37
|
<template slot="chat" slot-scope="scope">
|
|
35
38
|
<slot name="chat" v-bind="scope"></slot>
|
|
36
39
|
</template>
|
|
@@ -14,14 +14,16 @@
|
|
|
14
14
|
<template slot="filter">
|
|
15
15
|
<slot name="filter"></slot>
|
|
16
16
|
</template>
|
|
17
|
+
<template slot="chat-before" slot-scope="{ item }">
|
|
18
|
+
<div
|
|
19
|
+
v-if="handleShowTimeDivider(item)"
|
|
20
|
+
class="sdk-wechat-chat-panel__time"
|
|
21
|
+
>
|
|
22
|
+
{{ formatMessageTime(parseMessageTime(item.wechatTime)) }}
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
17
25
|
<template slot="chat" slot-scope="{ item, dir }">
|
|
18
26
|
<div class="sdk-wechat-chat-panel__item">
|
|
19
|
-
<div
|
|
20
|
-
v-if="handleShowTimeDivider(item)"
|
|
21
|
-
class="sdk-wechat-chat-panel__time"
|
|
22
|
-
>
|
|
23
|
-
{{ formatMessageTime(parseMessageTime(item.wechatTime)) }}
|
|
24
|
-
</div>
|
|
25
27
|
<chat-panel-item
|
|
26
28
|
:item="item"
|
|
27
29
|
:dir="dir"
|