@aochuang/client-sdk 1.0.382 → 1.0.400

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.
Files changed (159) hide show
  1. package/components/chat-editor/chat-editor-suggestions/chat-editor-suggestions.vue +4 -40
  2. package/components/chat-editor/chat-editor.vue +5 -75
  3. package/components/index.js +6 -1
  4. package/components/session-select/session-select-item.vue +8 -9
  5. package/components/wechat-chat-control/location/location.vue +6 -14
  6. package/components/wework-chat-control/channel-card/channel-card.vue +144 -0
  7. package/components/wework-chat-control/channel-live/channel-live.vue +7 -2
  8. package/components/wework-chat-control/company-card/company-card.vue +1 -1
  9. package/components/wework-chat-control/custom-expression/custom-expression.vue +2 -1
  10. package/components/wework-chat-control/file-url/file-url.vue +34 -16
  11. package/components/wework-chat-control/image/image.vue +137 -2
  12. package/components/wework-chat-control/index.js +15 -7
  13. package/components/wework-chat-control/location/location.vue +3 -3
  14. package/components/wework-chat-control/merge-message/merge-message-panel.vue +63 -0
  15. package/components/wework-chat-control/merge-message/merge-message.vue +84 -0
  16. package/components/wework-chat-control/merge-message/util.js +59 -0
  17. package/components/wework-chat-control/metting/enterprise-wechat.png +0 -0
  18. package/components/wework-chat-control/metting/meeting-video.svg +4 -0
  19. package/components/wework-chat-control/metting/metting.vue +181 -0
  20. package/components/wework-chat-control/red-envelopes/red-envelopes.vue +3 -2
  21. package/components/wework-chat-control/text/text-default.vue +99 -0
  22. package/components/wework-chat-control/text/text-quote.vue +138 -0
  23. package/components/wework-chat-control/text/text.vue +27 -143
  24. package/components/wework-chat-control/url/url-channel-live.vue +53 -0
  25. package/components/wework-chat-control/url/url-miniprogram.vue +6 -7
  26. package/components/wework-chat-control/url/url.vue +26 -2
  27. package/components/wework-chat-control/util.js +30 -17
  28. package/components/wework-chat-control/video/video.vue +11 -3
  29. package/components/wework-chat-control/voice/voice.vue +14 -3
  30. package/components/wework-chat-control/wework-chat-control-config-item.vue +24 -0
  31. package/components/wework-chat-control/wework-chat-control-config-msg.vue +25 -0
  32. package/{uni-components/chat-control/chat-control-config.vue → components/wework-chat-control/wework-chat-control-config.vue} +16 -13
  33. package/components/wework-chat-panel/chat-panel-chat-status/chat-panel-chat-status.vue +120 -0
  34. package/components/wework-chat-panel/chat-panel-item.vue +70 -39
  35. package/components/wework-chat-panel/chat-panel.vue +96 -13
  36. package/package.json +10 -3
  37. package/services/client-chat/client-chat-wechat/client-chat-session.js +2 -8
  38. package/services/client-chat/client-chat-wework/client-chat-account.js +93 -1
  39. package/services/client-chat/client-chat-wework/client-chat-concats.js +104 -18
  40. package/services/client-chat/client-chat-wework/client-chat-message.js +268 -11
  41. package/services/client-chat/client-chat-wework/client-chat-session.js +271 -191
  42. package/services/client-chat/client-chat-wework/client-chat-socket.js +18 -2
  43. package/services/client-chat/client-chat-wework/client-chat.js +470 -85
  44. package/services/client-chat/client-chat-wework/docs/README.md +308 -0
  45. package/services/client-chat/client-chat-wework/utils.js +5 -5
  46. package/components/wework-chat-panel/chat-panel-controls/company-card/company-card.vue +0 -35
  47. package/components/wework-chat-panel/chat-panel-controls/expression/expression.vue +0 -36
  48. package/components/wework-chat-panel/chat-panel-controls/file-url/file-url.vue +0 -35
  49. package/components/wework-chat-panel/chat-panel-controls/image/image.vue +0 -36
  50. package/components/wework-chat-panel/chat-panel-controls/index.js +0 -35
  51. package/components/wework-chat-panel/chat-panel-controls/jx-sys-text/jx-sys-text.vue +0 -28
  52. package/components/wework-chat-panel/chat-panel-controls/link/link.vue +0 -35
  53. package/components/wework-chat-panel/chat-panel-controls/location/location.vue +0 -35
  54. package/components/wework-chat-panel/chat-panel-controls/text/text.vue +0 -43
  55. package/components/wework-chat-panel/chat-panel-controls/unkonw/unkonw.vue +0 -39
  56. package/components/wework-chat-panel/chat-panel-controls/video/video.vue +0 -37
  57. package/components/wework-chat-panel/chat-panel-controls/voice/voice.vue +0 -35
  58. package/uni-common/account-portray/account-portray.vue +0 -51
  59. package/uni-common/account-select/account-select-item.vue +0 -172
  60. package/uni-common/account-select/account-select.vue +0 -252
  61. package/uni-common/all-friend-avatar/all-friend-avatar.vue +0 -49
  62. package/uni-common/friend-avatar/default.svg +0 -1
  63. package/uni-common/friend-avatar/friend-avatar.vue +0 -27
  64. package/uni-common/friend-avatar/index.js +0 -3
  65. package/uni-common/friend-loader/friend-loader.vue +0 -53
  66. package/uni-common/friend-portray/friend-portray.vue +0 -56
  67. package/uni-common/group-avatar/default.svg +0 -1
  68. package/uni-common/group-avatar/group-avatar.vue +0 -18
  69. package/uni-common/group-avatar/index.js +0 -3
  70. package/uni-common/room-avatar/default.svg +0 -6
  71. package/uni-common/room-avatar/index.js +0 -3
  72. package/uni-common/room-avatar/room-avatar.vue +0 -27
  73. package/uni-common/room-loader/room-loader.vue +0 -53
  74. package/uni-common/room-portray/room-portray.vue +0 -56
  75. package/uni-components/chat-control/calling/calling.vue +0 -91
  76. package/uni-components/chat-control/calling/phone-fill.svg +0 -1
  77. package/uni-components/chat-control/calling/vidicon-fill.svg +0 -1
  78. package/uni-components/chat-control/channel-video/channel-video.vue +0 -89
  79. package/uni-components/chat-control/channel-video-card/channel-video-card.vue +0 -105
  80. package/uni-components/chat-control/channel-video-live/channel-video-live.vue +0 -92
  81. package/uni-components/chat-control/chat-control-config-item/chat-control-config-item.vue +0 -20
  82. package/uni-components/chat-control/chat-control-config-item/index.js +0 -3
  83. package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-app.vue +0 -25
  84. package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-h5.vue +0 -21
  85. package/uni-components/chat-control/chat-control.vue +0 -218
  86. package/uni-components/chat-control/company-card/company-card.vue +0 -123
  87. package/uni-components/chat-control/const.js +0 -28
  88. package/uni-components/chat-control/expression/expression.vue +0 -41
  89. package/uni-components/chat-control/image/image.vue +0 -68
  90. package/uni-components/chat-control/index.js +0 -89
  91. package/uni-components/chat-control/location/location.vue +0 -110
  92. package/uni-components/chat-control/member-change/member-change.vue +0 -32
  93. package/uni-components/chat-control/quote-message/quote-message.vue +0 -216
  94. package/uni-components/chat-control/real-time-position/real-time-position.vue +0 -62
  95. package/uni-components/chat-control/redpacket/red-envelope.svg +0 -1
  96. package/uni-components/chat-control/redpacket/redpacket.vue +0 -75
  97. package/uni-components/chat-control/share-card/share-card.vue +0 -101
  98. package/uni-components/chat-control/system/system.vue +0 -69
  99. package/uni-components/chat-control/system-batch-message/system-batch-message.vue +0 -30
  100. package/uni-components/chat-control/system-text/system-text.vue +0 -32
  101. package/uni-components/chat-control/text/text.vue +0 -67
  102. package/uni-components/chat-control/text-with-at/text-with-at.vue +0 -51
  103. package/uni-components/chat-control/transfer/red-transfer.svg +0 -1
  104. package/uni-components/chat-control/transfer/transfer.vue +0 -80
  105. package/uni-components/chat-control/unkonw/unkonw.vue +0 -37
  106. package/uni-components/chat-control/url/icons/file-excel-line.svg +0 -1
  107. package/uni-components/chat-control/url/icons/file-info-line.svg +0 -1
  108. package/uni-components/chat-control/url/icons/file-music-line.svg +0 -1
  109. package/uni-components/chat-control/url/icons/file-pdf-line.svg +0 -1
  110. package/uni-components/chat-control/url/icons/file-ppt-line.svg +0 -1
  111. package/uni-components/chat-control/url/icons/file-settings-line.svg +0 -1
  112. package/uni-components/chat-control/url/icons/file-text-line.svg +0 -1
  113. package/uni-components/chat-control/url/icons/file-unknow-line.svg +0 -1
  114. package/uni-components/chat-control/url/icons/file-word-line.svg +0 -1
  115. package/uni-components/chat-control/url/icons/file-zip-line.svg +0 -1
  116. package/uni-components/chat-control/url/icons/index.js +0 -24
  117. package/uni-components/chat-control/url/miniprogram.svg +0 -1
  118. package/uni-components/chat-control/url/url-miniprogram.vue +0 -116
  119. package/uni-components/chat-control/url/url.vue +0 -306
  120. package/uni-components/chat-control/url-new/icons/file-excel-line.svg +0 -1
  121. package/uni-components/chat-control/url-new/icons/file-info-line.svg +0 -1
  122. package/uni-components/chat-control/url-new/icons/file-music-line.svg +0 -1
  123. package/uni-components/chat-control/url-new/icons/file-pdf-line.svg +0 -1
  124. package/uni-components/chat-control/url-new/icons/file-ppt-line.svg +0 -1
  125. package/uni-components/chat-control/url-new/icons/file-settings-line.svg +0 -1
  126. package/uni-components/chat-control/url-new/icons/file-text-line.svg +0 -1
  127. package/uni-components/chat-control/url-new/icons/file-unknow-line.svg +0 -1
  128. package/uni-components/chat-control/url-new/icons/file-word-line.svg +0 -1
  129. package/uni-components/chat-control/url-new/icons/file-zip-line.svg +0 -1
  130. package/uni-components/chat-control/url-new/icons/index.js +0 -24
  131. package/uni-components/chat-control/url-new/url-new.vue +0 -110
  132. package/uni-components/chat-control/utils.js +0 -12
  133. package/uni-components/chat-control/video/video.vue +0 -156
  134. package/uni-components/chat-control/voice/voice.vue +0 -166
  135. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-collect.vue +0 -84
  136. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-system.vue +0 -28
  137. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet.vue +0 -85
  138. package/uni-components/chat-editor/chat-editor-func/chat-editor-func.vue +0 -157
  139. package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at-panel.vue +0 -158
  140. package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at.vue +0 -61
  141. package/uni-components/chat-editor/chat-editor-func-button/chat-editor-func-button.vue +0 -58
  142. package/uni-components/chat-editor/chat-editor-func-file/chat-editor-func-file.vue +0 -54
  143. package/uni-components/chat-editor/chat-editor-func-image/chat-editor-func-image.vue +0 -42
  144. package/uni-components/chat-editor/chat-editor-func-video/chat-editor-func-video.vue +0 -42
  145. package/uni-components/chat-editor/chat-editor-func-voice/chat-editor-func-voice.vue +0 -25
  146. package/uni-components/chat-editor/chat-editor-message-send/chat-editor-message-send.vue +0 -158
  147. package/uni-components/chat-editor/chat-editor-quote/chat-editor-quote.vue +0 -75
  148. package/uni-components/chat-editor/chat-editor.vue +0 -257
  149. package/uni-components/chat-editor/index.js +0 -10
  150. package/uni-components/chat-editor/util.js +0 -65
  151. package/uni-components/chat-panel/chat-panel-chats-box.vue +0 -238
  152. package/uni-components/chat-panel/chat-panel-chats-forward/chat-panel-chats-forward.vue +0 -273
  153. package/uni-components/chat-panel/chat-panel-chats-item.vue +0 -578
  154. package/uni-components/chat-panel/chat-panel-chats-status/chat-panel-chats-status.vue +0 -71
  155. package/uni-components/chat-panel/chat-panel-chats.vue +0 -368
  156. package/uni-components/chat-panel/chat-panel.vue +0 -227
  157. package/uni-components/contacts-group-select/contacts-group-select-item.vue +0 -85
  158. package/uni-components/contacts-group-select/contacts-group-select-panel.vue +0 -119
  159. package/uni-components/contacts-group-select/contacts-group-select.vue +0 -150
@@ -63,10 +63,10 @@ export default {
63
63
  return parse(this.content) || {}
64
64
  },
65
65
  title () {
66
- return this.nextContent.wish
66
+ return this.nextContent.content
67
67
  },
68
68
  description () {
69
- return ''
69
+ return this.nextContent.receiveText
70
70
  },
71
71
  category () {
72
72
  return '微红包'
@@ -105,6 +105,7 @@ export default {
105
105
  flex: 1;
106
106
  min-width: 0;
107
107
  line-height: 1.3em;
108
+ padding-top: 6px;
108
109
  }
109
110
  .sdk-wework-control-redpacket__title{
110
111
  line-height: 22px;
@@ -0,0 +1,99 @@
1
+ <template>
2
+ <div class="sdk-chat-wework-control-text" :class="['sdk-chat-wework-control-text--' + type]">
3
+ <div class="sdk-chat-wework-control-text__main">
4
+ <template v-if="hasScroll">
5
+ <ui-popover :value="showPopover" @input="handleShowPopoverChange">
6
+ <template slot="reference">
7
+ <div class="sdk-chat-wework-control-text__content" v-html="html" ref="popoverContent"></div>
8
+ </template>
9
+ <div class="sdk-chat-wework-control-text__popover" v-html="html" :style="{'width': popoverWidth}"></div>
10
+ </ui-popover>
11
+ </template>
12
+ <template v-else>
13
+ <div class="sdk-chat-wework-control-text__content" v-html="html" ref="content"></div>
14
+ </template>
15
+ </div>
16
+ </div>
17
+ </template>
18
+ <script>
19
+ import {Popover as UiPopover} from '@aochuang/common/components'
20
+ import {parseWechatEmoji} from '@aochuang/common/common/wechat-emoji'
21
+ import {html2Escape} from '../../../utils/string'
22
+
23
+ function parseTextContent (content) {
24
+ if (typeof content !== 'string') return content
25
+ try {
26
+ const data = JSON.parse(content)
27
+ return data && typeof data === 'object' ? data : content
28
+ } catch (e) {
29
+ return content
30
+ }
31
+ }
32
+
33
+ export default {
34
+ name: 'SdkChatControlTextDefault',
35
+ components: {UiPopover},
36
+ props: {
37
+ id: {type: String},
38
+ content: {type: [String, Object]},
39
+ type: {
40
+ type: String,
41
+ default: 'default',
42
+ validator (value) { return ['quote', 'default', 'thumb'].includes(value) }
43
+ },
44
+ formatter: {type: Function}
45
+ },
46
+ data () {
47
+ return {hasScroll: false, showPopover: false, popoverWidth: null}
48
+ },
49
+ computed: {
50
+ nextContent () { return parseTextContent(this.content) },
51
+ text () {
52
+ return this.nextContent && typeof this.nextContent === 'object' ? this.nextContent.text || '' : this.nextContent
53
+ },
54
+ html () {
55
+ let content = this.formatter ? this.formatter({content: this.nextContent}) : parseWechatEmoji(html2Escape(String(this.text || '')), false)
56
+ if (!content) return ''
57
+ content = String(content).replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, item => `<a href="${item}" target='_blank'>${item}</a>`)
58
+ return content.trim()
59
+ }
60
+ },
61
+ mounted () {
62
+ if (this.$refs.content) this.hasScroll = this.$refs.content.scrollHeight > this.$refs.content.clientHeight
63
+ },
64
+ methods: {
65
+ handleShowPopoverChange (visible) {
66
+ if (this.$refs.popoverContent && visible) this.popoverWidth = this.$refs.popoverContent.offsetWidth + 'px'
67
+ this.$nextTick(() => { this.showPopover = visible })
68
+ }
69
+ }
70
+ }
71
+ </script>
72
+ <style lang="less">
73
+ .sdk-chat-wework-control-text--default .sdk-chat-wework-control-text__main { padding: 10px; }
74
+ .sdk-chat-wework-control-text--quote .sdk-chat-wework-control-text__content {
75
+ display: -webkit-box;
76
+ -webkit-box-orient: vertical;
77
+ -webkit-line-clamp: 2;
78
+ overflow: hidden;
79
+ max-width: 420px;
80
+ }
81
+ .sdk-chat-wework-control-text--thumb {
82
+ background-color: #fff;
83
+ border: 1px solid #eee;
84
+ border-radius: 3px;
85
+ padding: 6px 10px;
86
+ }
87
+ .sdk-chat-wework-control-text--thumb .sdk-chat-wework-control-text__content {
88
+ display: -webkit-box;
89
+ -webkit-box-orient: vertical;
90
+ -webkit-line-clamp: 3;
91
+ overflow: hidden;
92
+ }
93
+ .sdk-chat-wework-control-text__main { white-space: pre-wrap; line-height: 1.5em; word-break: break-all; }
94
+ .sdk-chat-wework-control-text__main img { vertical-align: top; }
95
+ .sdk-chat-wework-control-text__main a { color: #4387ff; }
96
+ .sdk-chat-wework-control-text__main a:hover { color: #4387ff; text-decoration: underline; }
97
+ .sdk-chat-wework-control-text__popover { white-space: pre-wrap; line-height: 1.5em; word-break: break-all; padding: 10px; }
98
+ .sdk-chat-wework-control-text__popover img { vertical-align: top; }
99
+ </style>
@@ -0,0 +1,138 @@
1
+ <template>
2
+ <div class="sdk-chat-wework-control-text-quote" :class="['sdk-chat-wework-control-text-quote--' + type]">
3
+ <text-default :id="id" :content="mainContent" :type="type" :formatter="formatter"></text-default>
4
+ </div>
5
+ </template>
6
+ <script>
7
+ import {parse} from '../../../utils/json'
8
+ import {chatControls} from '../index'
9
+ import WeworkChatControlConfigMsg from '../wework-chat-control-config-msg.vue'
10
+ import TextDefault from './text-default.vue'
11
+
12
+ function parseQuoteContent (content) {
13
+ if (content && typeof content === 'object') return content
14
+ const parsed = parse(content, {})
15
+ if (!parsed || typeof parsed !== 'object' || !parsed.quote || typeof content !== 'string') return parsed
16
+ // JSON.parse converts large企微 message IDs to imprecise Numbers. Restore the
17
+ // original digit sequence before it is sent to the detail endpoint.
18
+ const match = content.match(/"messageId"\s*:\s*(?:"([^"]+)"|([0-9]+))/)
19
+ if (match) parsed.quote.messageId = match[1] || match[2]
20
+ return parsed
21
+ }
22
+
23
+ export default {
24
+ name: 'SdkChatControlTextQuote',
25
+ components: {TextDefault, WeworkChatControlConfigMsg},
26
+ props: {
27
+ id: {type: String},
28
+ content: {type: [String, Object]},
29
+ type: {type: String, default: 'default'},
30
+ formatter: {type: Function},
31
+ getQuoteMessage: {type: Function},
32
+ fetchQuoteUserMethod: {type: Function},
33
+ setChatBoxFootVnode: {type: Function}
34
+ },
35
+ data () { return {loading: false, quoteMessageData: null, quoteUserData: null, errorMsg: null} },
36
+ computed: {
37
+ contentObject () {
38
+ return parseQuoteContent(this.content)
39
+ },
40
+ quoteInfo () { return this.contentObject.quote || {} },
41
+ mainContent () {
42
+ const value = Object.assign({}, this.contentObject)
43
+ delete value.quote
44
+ return JSON.stringify(value)
45
+ },
46
+ quoteText () { return this.quoteInfo.text || '引用消息' },
47
+ quoteAuthor () {
48
+ const message = this.quoteMessageData || {}
49
+ if (this.quoteUserData && this.quoteUserData.name) {
50
+ return this.quoteUserData.name
51
+ }
52
+ if (!this.fetchQuoteUserMethod) {
53
+ return this.quoteInfo.sendName || message.userName || message.contactName || message.roomName || this.quoteInfo.sendId || '引用消息'
54
+ }
55
+ return this.quoteInfo.sendId || message.sendId || message.createBy || '引用消息'
56
+ },
57
+ quoteControl () {
58
+ return chatControls[this.quoteMessageData && this.quoteMessageData.msgType] || TextDefault
59
+ },
60
+ quoteFootComponent () {
61
+ return {
62
+ render: h => {
63
+ const content = [h('div', {class: 'sdk-chat-wework-control-text-quote__author'}, [this.quoteAuthor])]
64
+ if (this.loading) {
65
+ content.push(h('div', {class: 'sdk-chat-wework-control-text-quote__status'}, ['引用内容正在加载中...']))
66
+ } else if (this.quoteMessageData) {
67
+ content.push(h(WeworkChatControlConfigMsg, {
68
+ props: {msgData: this.quoteMessageData},
69
+ scopedSlots: {
70
+ default: ({configData}) => h(this.quoteControl, {
71
+ props: Object.assign({}, configData, {id: this.id + '_quote', content: this.quoteMessageData.content, type: 'quote'})
72
+ })
73
+ }
74
+ }))
75
+ } else {
76
+ content.push(h('div', {class: 'sdk-chat-wework-control-text-quote__content'}, [this.quoteText]))
77
+ if (this.errorMsg) content.push(h('div', {class: 'sdk-chat-wework-control-text-quote__status'}, [this.errorMsg]))
78
+ }
79
+ return h('div', {class: 'sdk-chat-wework-control-text-quote__box'}, content)
80
+ }
81
+ }
82
+ }
83
+ },
84
+ created () {
85
+ if (this.setChatBoxFootVnode) this.setChatBoxFootVnode(this.quoteFootComponent)
86
+ if (!this.getQuoteMessage || !this.quoteInfo.messageId || !this.quoteInfo.sendTime) {
87
+ this.errorMsg = '未找到引用消息内容,请在手机中确认'
88
+ return
89
+ }
90
+ this.loading = true
91
+ this.getQuoteMessage({
92
+ msgId: String(this.quoteInfo.messageId),
93
+ sendTime: this.quoteInfo.sendTime,
94
+ content: this.quoteInfo
95
+ }).then(data => {
96
+ this.quoteMessageData = data && data.data ? data.data : data
97
+ if (!this.quoteMessageData) {
98
+ this.errorMsg = '未找到引用消息内容,请在手机中确认'
99
+ return
100
+ }
101
+ return this.fetchQuoteUserData()
102
+ }).catch(() => {
103
+ this.errorMsg = '未找到引用消息内容,请在手机中确认'
104
+ }).finally(() => {
105
+ this.loading = false
106
+ this.refreshQuoteFoot()
107
+ })
108
+ },
109
+ methods: {
110
+ refreshQuoteFoot () {
111
+ if (this.setChatBoxFootVnode) {
112
+ this.setChatBoxFootVnode(this.quoteFootComponent)
113
+ }
114
+ },
115
+ fetchQuoteUserData () {
116
+ if (!this.fetchQuoteUserMethod || !this.quoteMessageData) {
117
+ return Promise.resolve()
118
+ }
119
+ return Promise.resolve(this.fetchQuoteUserMethod({
120
+ data: this.quoteMessageData
121
+ })).then(data => {
122
+ this.quoteUserData = data || null
123
+ }).catch(() => {
124
+ this.quoteUserData = null
125
+ }).finally(() => {
126
+ this.refreshQuoteFoot()
127
+ })
128
+ }
129
+ }
130
+ }
131
+ </script>
132
+ <style lang="less">
133
+ .sdk-chat-wework-control-text-quote { min-width: 0; }
134
+ .sdk-chat-wework-control-text-quote__box { margin: 10px 0 0; padding: 7px 8px; background: rgba(0, 0, 0, .06); border-radius: 3px; max-width: 420px; line-height: 1.5em; }
135
+ .sdk-chat-wework-control-text-quote__author { color: #999; word-break: break-all; }
136
+ .sdk-chat-wework-control-text-quote__content, .sdk-chat-wework-control-text-quote__status { white-space: pre-wrap; word-break: break-all; }
137
+ .sdk-chat-wework-control-text-quote__status { color: #999; font-size: 12px; }
138
+ </style>
@@ -1,157 +1,41 @@
1
1
  <template>
2
- <div
3
- class="sdk-chat-wework-control-text"
4
- :class="['sdk-chat-wework-control-text--' + type]"
5
- >
6
- <div class="sdk-chat-wework-control-text__main">
7
- <template v-if="hasScroll">
8
- <ui-popover
9
- :value="showPopover"
10
- @input="handleShowPopoverChange"
11
- >
12
- <template slot="reference">
13
- <div class="sdk-chat-wework-control-text__content"
14
- v-html="html"
15
- ref="popoverContent"
16
- ></div>
17
- </template>
18
- <div class="sdk-chat-wework-control-text__popover" v-html="html" :style="{'width': popoverWidth}"></div>
19
- </ui-popover>
20
- </template>
21
- <template v-else>
22
- <div class="sdk-chat-wework-control-text__content"
23
- v-html="html"
24
- ref="content"
25
- ></div>
26
- </template>
27
- </div>
28
- </div>
2
+ <component
3
+ :is="contentObject && contentObject.quote ? quoteComponent : defaultComponent"
4
+ v-bind="componentProps"
5
+ ></component>
29
6
  </template>
30
7
  <script>
31
- import { Popover as UiPopover } from '@aochuang/common/components'
32
- import { html2Escape } from '../../../utils/string'
8
+ import TextDefault from './text-default.vue'
9
+ import TextQuote from './text-quote.vue'
10
+
11
+ function parseContent (content) {
12
+ if (typeof content !== 'string') return content
13
+ try { return JSON.parse(content) } catch (e) { return content }
14
+ }
33
15
 
34
16
  export default {
35
17
  name: 'SdkChatControlText',
36
- components: {
37
- UiPopover
38
- },
18
+ components: {TextDefault, TextQuote},
19
+ inheritAttrs: false,
39
20
  props: {
40
- id: {
41
- type: String
42
- },
43
- content: {
44
- type: String
45
- },
46
- type: {
47
- type: String,
48
- default: 'default',
49
- validator (value) {
50
- return ['quote', 'default', 'thumb'].includes(value)
51
- }
52
- },
53
- formatter: {
54
- type: Function
55
- }
56
- },
57
- data () {
58
- return {
59
- hasScroll: false,
60
- showPopover: false,
61
- popoverWidth: null
62
- }
21
+ id: {type: String},
22
+ content: {type: [String, Object]},
23
+ type: {type: String, default: 'default'},
24
+ formatter: {type: Function},
25
+ getQuoteMessage: {type: Function},
26
+ fetchQuoteUserMethod: {type: Function},
27
+ setChatBoxFootVnode: {type: Function}
63
28
  },
64
29
  computed: {
65
- nextContent () {
66
- return this.content
67
- },
68
- text () {
69
- return this.nextContent
70
- },
71
- html () {
72
- let content = this.nextContent
73
- if (this.formatter) {
74
- content = this.formatter({
75
- content: this.nextContent
76
- })
77
- } else {
78
- content = html2Escape(content)
79
- }
80
- if (!content) {
81
- return ''
82
- }
83
- content = content.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, item => {
84
- return `<a href="${item}" target='_blank'>${item}</a>`
85
- })
86
- return content.trim()
87
- }
88
- },
89
- mounted () {
90
- if (this.$refs.content) {
91
- this.hasScroll = this.$refs.content.scrollHeight > this.$refs.content.clientHeight
92
- }
93
- },
94
- methods: {
95
- handleShowPopoverChange (visible) {
96
- if (this.$refs.popoverContent && visible) {
97
- this.popoverWidth = this.$refs.popoverContent.offsetWidth + 'px'
98
- }
99
- this.$nextTick(() => {
100
- this.showPopover = visible
30
+ contentObject () { return parseContent(this.content) },
31
+ defaultComponent () { return TextDefault },
32
+ quoteComponent () { return TextQuote },
33
+ componentProps () {
34
+ return Object.assign({}, this.$attrs, this.$props, {
35
+ getQuoteMessage: this.getQuoteMessage,
36
+ fetchQuoteUserMethod: this.fetchQuoteUserMethod
101
37
  })
102
38
  }
103
39
  }
104
40
  }
105
41
  </script>
106
- <style lang="less">
107
- .sdk-chat-wework-control-text--default {
108
- .sdk-chat-wework-control-text__main{
109
- padding: 10px;
110
- }
111
- }
112
- .sdk-chat-wework-control-text--quote {
113
- .sdk-chat-wework-control-text__content{
114
- display: -webkit-box;
115
- -webkit-box-orient: vertical;
116
- -webkit-line-clamp: 2; /* 限制显示3行 */
117
- overflow: hidden;
118
- max-width: 420px;
119
- }
120
- }
121
- .sdk-chat-wework-control-text--thumb {
122
- background-color: #fff;
123
- border: 1px solid #eee;
124
- border-radius: 3px;
125
- padding: 6px 10px;
126
- .sdk-chat-wework-control-text__content{
127
- display: -webkit-box;
128
- -webkit-box-orient: vertical;
129
- -webkit-line-clamp: 3; /* 限制显示3行 */
130
- overflow: hidden;
131
- }
132
- }
133
- .sdk-chat-wework-control-text__main{
134
- white-space: pre-wrap;
135
- line-height: 1.5em;
136
- word-break: break-all;
137
- img {
138
- vertical-align: top;
139
- }
140
- a {
141
- color: #4387ff;
142
- &:hover {
143
- color: #4387ff;
144
- text-decoration: underline;
145
- }
146
- }
147
- }
148
- .sdk-chat-wework-control-text__popover{
149
- white-space: pre-wrap;
150
- line-height: 1.5em;
151
- word-break: break-all;
152
- padding: 10px;
153
- img {
154
- vertical-align: top;
155
- }
156
- }
157
- </style>
@@ -0,0 +1,53 @@
1
+ <script>
2
+ import { parse } from '../../../utils/json'
3
+ import ChannelLive from '../channel-live/channel-live'
4
+
5
+ export default {
6
+ name: 'SdkWeworkControlUrlChannelLive',
7
+ props: {
8
+ id: {
9
+ type: String
10
+ },
11
+ content: {
12
+ type: [String, Object]
13
+ },
14
+ type: {
15
+ type: String,
16
+ default: 'default',
17
+ validator (value) {
18
+ return ['quote', 'default', 'thumb'].includes(value)
19
+ }
20
+ },
21
+ updateChatBoxProp: {
22
+ type: Function
23
+ }
24
+ },
25
+ computed: {
26
+ nextContent () {
27
+ return parse(this.content) || {}
28
+ },
29
+ channelLiveContent () {
30
+ return {
31
+ url: this.nextContent.url,
32
+ coverUrl: this.nextContent.imageUrl,
33
+ nickname: this.nextContent.desc,
34
+ desc: (this.nextContent.title || '').replace(/^\[视频号直播\]\s*/, '')
35
+ }
36
+ }
37
+ },
38
+ created () {
39
+ if (this.nextContent.url && this.updateChatBoxProp) {
40
+ this.updateChatBoxProp('href', this.nextContent.url)
41
+ }
42
+ },
43
+ render (h) {
44
+ return h(ChannelLive, {
45
+ props: {
46
+ id: this.id,
47
+ content: this.channelLiveContent,
48
+ type: this.type
49
+ }
50
+ })
51
+ }
52
+ }
53
+ </script>
@@ -50,7 +50,7 @@
50
50
  </div>
51
51
  </template>
52
52
  <script>
53
- import { parse, parseXml } from '../../../utils/json'
53
+ import { parse } from '../../../utils/json'
54
54
  import { formatOssPath } from '@aochuang/common/utils/oss'
55
55
 
56
56
  export default {
@@ -76,26 +76,25 @@ export default {
76
76
  return parse(this.content)
77
77
  },
78
78
  miniprogramData () {
79
- let data = null
80
79
  if (!this.nextContent) {
81
- return data
80
+ return {}
82
81
  }
83
82
  return this.nextContent
84
83
  },
85
84
  icon () {
86
- return this.miniprogramData.weappIconUrl
85
+ return formatOssPath(this.miniprogramData.iconUrl)
87
86
  },
88
87
  title () {
89
88
  return this.miniprogramData.title
90
89
  },
91
90
  url () {
92
- return this.miniprogramData.msg && this.miniprogramData.msg.appmsg ? this.miniprogramData.msg.appmsg.url : ''
91
+ return this.miniprogramData.url
93
92
  },
94
93
  desc () {
95
- return this.miniprogramData.appName
94
+ return this.miniprogramData.desc
96
95
  },
97
96
  cover () {
98
- return this.miniprogramData.thumbOssUrl
97
+ return formatOssPath(this.miniprogramData.resPath || this.miniprogramData.coverUrl)
99
98
  },
100
99
  border () {
101
100
  return !this.SdkChatPanelBox
@@ -4,6 +4,24 @@ import UrlMerge from './url-merge'
4
4
  import UrlMiniprogram from './url-miniprogram'
5
5
  import UrlFile from './url-file'
6
6
  import UrlLink from './url-link'
7
+ import UrlChannelLive from './url-channel-live'
8
+ import ChannelCard from '../channel-card/channel-card'
9
+
10
+ const CHANNEL_CARD_TITLE_PREFIX = '[视频号名片]'
11
+
12
+ function isChannelLiveUrl (url) {
13
+ try {
14
+ return new URL(url).hostname === 'channels.weixin.qq.com'
15
+ } catch (e) {
16
+ return false
17
+ }
18
+ }
19
+
20
+ function isChannelCardContent (content) {
21
+ return isChannelLiveUrl(content && content.url) &&
22
+ typeof content.title === 'string' &&
23
+ content.title.startsWith(CHANNEL_CARD_TITLE_PREFIX)
24
+ }
7
25
 
8
26
  export default {
9
27
  name: 'SdkChatPanelControlsUrl',
@@ -55,7 +73,7 @@ export default {
55
73
  beforeLoad: props.beforeLoadMergeMethod
56
74
  }
57
75
  })
58
- } else if (content.type === 2) {
76
+ } else if (content.contentType === 78) {
59
77
  return h(UrlMiniprogram, {
60
78
  props: {
61
79
  id: props.id,
@@ -88,7 +106,13 @@ export default {
88
106
  }
89
107
  }
90
108
  }
91
- return h(UrlLink, {
109
+ let component = UrlLink
110
+ if (isChannelCardContent(content)) {
111
+ component = ChannelCard
112
+ } else if (isChannelLiveUrl(content && content.url)) {
113
+ component = UrlChannelLive
114
+ }
115
+ return h(component, {
92
116
  props: {
93
117
  id: props.id,
94
118
  content,