@aochuang/client-sdk 1.0.278
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/README.md +93 -0
- package/common/avatar/avatar.vue +86 -0
- package/common/avatar/index.js +3 -0
- package/common/badge/badge.vue +105 -0
- package/common/badge/index.js +3 -0
- package/common/context-menu/context-menu-box.vue +61 -0
- package/common/context-menu/context-menu-group.vue +162 -0
- package/common/context-menu/context-menu-item.vue +179 -0
- package/common/context-menu/context-menu.vue +201 -0
- package/common/context-menu/index.js +3 -0
- package/common/context-menu/utils.js +138 -0
- package/common/friend-avatar/default.svg +1 -0
- package/common/friend-avatar/friend-avatar.vue +29 -0
- package/common/friend-avatar/index.js +3 -0
- package/common/image/index.js +3 -0
- package/common/index.js +17 -0
- package/common/room-avatar/default.svg +6 -0
- package/common/room-avatar/index.js +3 -0
- package/common/room-avatar/room-avatar.vue +29 -0
- package/common/scroll-load-more/index.js +3 -0
- package/common/scroll-load-more/scroll-load-more.vue +195 -0
- package/common/user-avatar/default.svg +1 -0
- package/common/user-avatar/index.js +3 -0
- package/common/user-avatar/user-avatar.vue +29 -0
- package/components/account-select/account-select-skeleton.vue +56 -0
- package/components/account-select/account-select.vue +205 -0
- package/components/account-select/all.svg +1 -0
- package/components/account-select/index.js +3 -0
- package/components/chat-editor/MENTION_TOKEN_SUMMARY.md +74 -0
- package/components/chat-editor/chat-editor-button/chat-editor-button.vue +78 -0
- package/components/chat-editor/chat-editor-suggestions/chat-editor-suggestions.vue +329 -0
- package/components/chat-editor/chat-editor-toolbar/chat-editor-toolbar-item.vue +28 -0
- package/components/chat-editor/chat-editor-toolbar/chat-editor-toolbar.vue +17 -0
- package/components/chat-editor/chat-editor.vue +933 -0
- package/components/chat-editor/index.js +12 -0
- package/components/chat-editor/utils.js +189 -0
- package/components/chat-friend-profile/chat-friend-profile.vue +118 -0
- package/components/chat-friend-profile/index.js +3 -0
- package/components/chat-layout/chat-layout.vue +71 -0
- package/components/chat-layout/index.js +3 -0
- package/components/chat-panel/chat-panel-box.vue +350 -0
- package/components/chat-panel/chat-panel-chat.vue +121 -0
- package/components/chat-panel/chat-panel-chats.vue +674 -0
- package/components/chat-panel/chat-panel-empty.vue +32 -0
- package/components/chat-panel/chat-panel-increment.vue +80 -0
- package/components/chat-panel/chat-panel-inner-msg.vue +25 -0
- package/components/chat-panel/chat-panel-loading.vue +29 -0
- package/components/chat-panel/chat-panel-nearest.vue +136 -0
- package/components/chat-panel/chat-panel.vue +292 -0
- package/components/chat-panel/index.js +3 -0
- package/components/chat-panel/util.js +83 -0
- package/components/chat-room-profile/chat-room-profile.vue +103 -0
- package/components/chat-room-profile/index.js +3 -0
- package/components/contacts-friend-select/contacts-friend-select-skeleton.vue +41 -0
- package/components/contacts-friend-select/contacts-friend-select.vue +204 -0
- package/components/contacts-friend-select/index.js +3 -0
- package/components/contacts-group-select/contacts-group-select-item.vue +98 -0
- package/components/contacts-group-select/contacts-group-select-skeleton.vue +81 -0
- package/components/contacts-group-select/contacts-group-select.vue +396 -0
- package/components/contacts-group-select/index.js +3 -0
- package/components/contacts-room-select/contacts-room-select-skeleton.vue +41 -0
- package/components/contacts-room-select/contacts-room-select.vue +208 -0
- package/components/contacts-room-select/index.js +3 -0
- package/components/index.js +43 -0
- package/components/layout/index.js +3 -0
- package/components/layout/layout.vue +70 -0
- package/components/session-select/index.js +11 -0
- package/components/session-select/session-select-item-skeleton.vue +59 -0
- package/components/session-select/session-select-item.vue +190 -0
- package/components/session-select/session-select.vue +386 -0
- package/components/wechat-chat-control/calling/calling.vue +227 -0
- package/components/wechat-chat-control/calling/phone-fill.svg +1 -0
- package/components/wechat-chat-control/calling/vidicon-fill.svg +1 -0
- package/components/wechat-chat-control/channel-live/channel-live.vue +198 -0
- package/components/wechat-chat-control/channel-live/quote-icon.svg +1 -0
- package/components/wechat-chat-control/channel-video/channel-video.vue +180 -0
- package/components/wechat-chat-control/channel-video/quote-icon.svg +1 -0
- package/components/wechat-chat-control/channel-video-card/channel-video-card.vue +139 -0
- package/components/wechat-chat-control/channel-video-card/quote-icon.svg +1 -0
- package/components/wechat-chat-control/company-card/company-card.vue +136 -0
- package/components/wechat-chat-control/company-card/quote-icon.svg +1 -0
- package/components/wechat-chat-control/custom-expression/custom-expression.vue +45 -0
- package/components/wechat-chat-control/empty/empty.vue +27 -0
- package/components/wechat-chat-control/file-url/file-url.vue +307 -0
- package/components/wechat-chat-control/file-url/icons/file-excel-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-info-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-music-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-pdf-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-ppt-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-settings-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-text-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-unknow-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-word-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/file-zip-line.svg +1 -0
- package/components/wechat-chat-control/file-url/icons/index.js +24 -0
- package/components/wechat-chat-control/image/image.vue +344 -0
- package/components/wechat-chat-control/image/index.js +1 -0
- package/components/wechat-chat-control/image/util.js +29 -0
- package/components/wechat-chat-control/index.js +104 -0
- package/components/wechat-chat-control/jx-sys-text/jx-sys-text.vue +28 -0
- package/components/wechat-chat-control/location/location.vue +179 -0
- package/components/wechat-chat-control/location/offline-bg.png +0 -0
- package/components/wechat-chat-control/member-change/member-change.vue +37 -0
- package/components/wechat-chat-control/music/icons/163.png +0 -0
- package/components/wechat-chat-control/music/icons/163.svg +12 -0
- package/components/wechat-chat-control/music/icons/default.png +0 -0
- package/components/wechat-chat-control/music/icons/default.svg +1 -0
- package/components/wechat-chat-control/music/icons/kuwo.png +0 -0
- package/components/wechat-chat-control/music/icons/qq.png +0 -0
- package/components/wechat-chat-control/music/icons/qq.svg +1 -0
- package/components/wechat-chat-control/music/music.vue +156 -0
- package/components/wechat-chat-control/music/utils.js +30 -0
- package/components/wechat-chat-control/quote-message/quote-message.vue +257 -0
- package/components/wechat-chat-control/real-time-position/icon.svg +1 -0
- package/components/wechat-chat-control/real-time-position/real-time-position.vue +57 -0
- package/components/wechat-chat-control/red-envelopes/quote-icon.svg +1 -0
- package/components/wechat-chat-control/red-envelopes/red-envelope.svg +1 -0
- package/components/wechat-chat-control/red-envelopes/red-envelopes.vue +168 -0
- package/components/wechat-chat-control/revoke-me-message/revoke-me-message.vue +41 -0
- package/components/wechat-chat-control/revoke-other-message/revoke-other-message.vue +41 -0
- package/components/wechat-chat-control/revoke-you-message/revoke-you-message.vue +41 -0
- package/components/wechat-chat-control/room-calling/phone-fill.svg +1 -0
- package/components/wechat-chat-control/room-calling/room-calling.vue +52 -0
- package/components/wechat-chat-control/room-calling/vidicon-fill.svg +1 -0
- package/components/wechat-chat-control/share-card/quote-icon.svg +1 -0
- package/components/wechat-chat-control/share-card/share-card.vue +140 -0
- package/components/wechat-chat-control/system/system.vue +122 -0
- package/components/wechat-chat-control/system-batch-message/system-batch-message.vue +28 -0
- package/components/wechat-chat-control/system-money/system-money.vue +39 -0
- package/components/wechat-chat-control/text/icons/icon.svg +6 -0
- package/components/wechat-chat-control/text/text.vue +164 -0
- package/components/wechat-chat-control/text-with-at/text-with-at.vue +88 -0
- package/components/wechat-chat-control/transfer/collection.svg +1 -0
- package/components/wechat-chat-control/transfer/quote-icon.svg +1 -0
- package/components/wechat-chat-control/transfer/red-transfer.svg +1 -0
- package/components/wechat-chat-control/transfer/refund.svg +1 -0
- package/components/wechat-chat-control/transfer/transfer.svg +1 -0
- package/components/wechat-chat-control/transfer/transfer.vue +263 -0
- package/components/wechat-chat-control/unknow/unknow.vue +21 -0
- package/components/wechat-chat-control/url/icons/link.svg +1 -0
- package/components/wechat-chat-control/url/icons/video.svg +6 -0
- package/components/wechat-chat-control/url/miniprogram.svg +1 -0
- package/components/wechat-chat-control/url/url-file.vue +47 -0
- package/components/wechat-chat-control/url/url-link.vue +169 -0
- package/components/wechat-chat-control/url/url-merge.vue +164 -0
- package/components/wechat-chat-control/url/url-miniprogram.vue +259 -0
- package/components/wechat-chat-control/url/url.vue +116 -0
- package/components/wechat-chat-control/util.js +234 -0
- package/components/wechat-chat-control/video/icons/video.svg +1 -0
- package/components/wechat-chat-control/video/video.vue +304 -0
- package/components/wechat-chat-control/voice/icons/voice.svg +1 -0
- package/components/wechat-chat-control/voice/voice.vue +464 -0
- package/components/wechat-chat-control/wechat-chat-control-config-item.vue +24 -0
- package/components/wechat-chat-control/wechat-chat-control-config-msg.vue +21 -0
- package/components/wechat-chat-control/wechat-chat-control-config.vue +57 -0
- package/components/wechat-chat-panel/chat-panel-chat-status/chat-panel-chat-status.vue +69 -0
- package/components/wechat-chat-panel/chat-panel-item.vue +695 -0
- package/components/wechat-chat-panel/chat-panel.vue +257 -0
- package/components/wechat-chat-panel/index.js +3 -0
- package/components/wework-chat-control/calling/calling.vue +223 -0
- package/components/wework-chat-control/calling/phone-fill.svg +1 -0
- package/components/wework-chat-control/calling/vidicon-fill.svg +1 -0
- package/components/wework-chat-control/channel-live/channel-live.vue +198 -0
- package/components/wework-chat-control/channel-live/quote-icon.svg +1 -0
- package/components/wework-chat-control/channel-video/channel-video.vue +180 -0
- package/components/wework-chat-control/channel-video/quote-icon.svg +1 -0
- package/components/wework-chat-control/company-card/company-card.vue +136 -0
- package/components/wework-chat-control/company-card/quote-icon.svg +1 -0
- package/components/wework-chat-control/custom-expression/custom-expression.vue +34 -0
- package/components/wework-chat-control/empty/empty.vue +27 -0
- package/components/wework-chat-control/expression/expression.vue +53 -0
- package/components/wework-chat-control/file-url/file-url.vue +247 -0
- package/components/wework-chat-control/file-url/icons/file-excel-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-info-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-music-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-pdf-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-ppt-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-settings-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-text-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-unknow-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-word-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/file-zip-line.svg +1 -0
- package/components/wework-chat-control/file-url/icons/index.js +24 -0
- package/components/wework-chat-control/image/image.vue +296 -0
- package/components/wework-chat-control/image/index.js +1 -0
- package/components/wework-chat-control/image/util.js +21 -0
- package/components/wework-chat-control/index.js +105 -0
- package/components/wework-chat-control/jx-sys-text/jx-sys-text.vue +28 -0
- package/components/wework-chat-control/link/link.vue +100 -0
- package/components/wework-chat-control/location/location.vue +181 -0
- package/components/wework-chat-control/location/offline-bg.png +0 -0
- package/components/wework-chat-control/red-envelopes/quote-icon.svg +1 -0
- package/components/wework-chat-control/red-envelopes/red-envelope.svg +1 -0
- package/components/wework-chat-control/red-envelopes/red-envelopes.vue +168 -0
- package/components/wework-chat-control/share-card/quote-icon.svg +1 -0
- package/components/wework-chat-control/share-card/share-card.vue +140 -0
- package/components/wework-chat-control/text/icons/icon.svg +6 -0
- package/components/wework-chat-control/text/text.vue +157 -0
- package/components/wework-chat-control/unknow/unknow.vue +21 -0
- package/components/wework-chat-control/url/icons/link.svg +1 -0
- package/components/wework-chat-control/url/icons/video.svg +6 -0
- package/components/wework-chat-control/url/miniprogram.svg +1 -0
- package/components/wework-chat-control/url/url-file.vue +37 -0
- package/components/wework-chat-control/url/url-link.vue +169 -0
- package/components/wework-chat-control/url/url-merge.vue +164 -0
- package/components/wework-chat-control/url/url-miniprogram.vue +248 -0
- package/components/wework-chat-control/url/url.vue +103 -0
- package/components/wework-chat-control/util.js +223 -0
- package/components/wework-chat-control/video/icons/video.svg +1 -0
- package/components/wework-chat-control/video/video.vue +304 -0
- package/components/wework-chat-control/voice/icons/voice.svg +1 -0
- package/components/wework-chat-control/voice/voice.vue +464 -0
- package/components/wework-chat-panel/chat-panel-controls/company-card/company-card.vue +35 -0
- package/components/wework-chat-panel/chat-panel-controls/expression/expression.vue +36 -0
- package/components/wework-chat-panel/chat-panel-controls/file-url/file-url.vue +35 -0
- package/components/wework-chat-panel/chat-panel-controls/image/image.vue +36 -0
- package/components/wework-chat-panel/chat-panel-controls/index.js +35 -0
- package/components/wework-chat-panel/chat-panel-controls/jx-sys-text/jx-sys-text.vue +28 -0
- package/components/wework-chat-panel/chat-panel-controls/link/link.vue +35 -0
- package/components/wework-chat-panel/chat-panel-controls/location/location.vue +35 -0
- package/components/wework-chat-panel/chat-panel-controls/text/text.vue +43 -0
- package/components/wework-chat-panel/chat-panel-controls/unkonw/unkonw.vue +39 -0
- package/components/wework-chat-panel/chat-panel-controls/video/video.vue +37 -0
- package/components/wework-chat-panel/chat-panel-controls/voice/voice.vue +35 -0
- package/components/wework-chat-panel/chat-panel-item.vue +650 -0
- package/components/wework-chat-panel/chat-panel.vue +163 -0
- package/components/wework-chat-panel/index.js +3 -0
- package/package.json +23 -0
- package/services/client-chat/client-chat-wechat/client-chat-account.js +426 -0
- package/services/client-chat/client-chat-wechat/client-chat-concats.js +1029 -0
- package/services/client-chat/client-chat-wechat/client-chat-draft.js +92 -0
- package/services/client-chat/client-chat-wechat/client-chat-message.js +588 -0
- package/services/client-chat/client-chat-wechat/client-chat-session-manage.js +67 -0
- package/services/client-chat/client-chat-wechat/client-chat-session.js +1048 -0
- package/services/client-chat/client-chat-wechat/client-chat-socket.js +215 -0
- package/services/client-chat/client-chat-wechat/client-chat.js +1065 -0
- package/services/client-chat/client-chat-wechat/index.js +3 -0
- package/services/client-chat/client-chat-wechat/utils.js +82 -0
- package/services/client-chat/client-chat-wework/client-chat-account.js +310 -0
- package/services/client-chat/client-chat-wework/client-chat-concats.js +772 -0
- package/services/client-chat/client-chat-wework/client-chat-message.js +278 -0
- package/services/client-chat/client-chat-wework/client-chat-session.js +929 -0
- package/services/client-chat/client-chat-wework/client-chat-socket.js +64 -0
- package/services/client-chat/client-chat-wework/client-chat.js +330 -0
- package/services/client-chat/client-chat-wework/index.js +3 -0
- package/services/client-chat/client-chat-wework/utils.js +82 -0
- package/services/index.js +10 -0
- package/services/socket/index.js +5 -0
- package/services/socket/socket.js +797 -0
- package/services/socket/utils.js +7 -0
- package/uni-common/account-portray/account-portray.vue +51 -0
- package/uni-common/account-select/account-select-item.vue +172 -0
- package/uni-common/account-select/account-select.vue +252 -0
- package/uni-common/all-friend-avatar/all-friend-avatar.vue +49 -0
- package/uni-common/friend-avatar/default.svg +1 -0
- package/uni-common/friend-avatar/friend-avatar.vue +27 -0
- package/uni-common/friend-avatar/index.js +3 -0
- package/uni-common/friend-loader/friend-loader.vue +53 -0
- package/uni-common/friend-portray/friend-portray.vue +56 -0
- package/uni-common/group-avatar/default.svg +1 -0
- package/uni-common/group-avatar/group-avatar.vue +18 -0
- package/uni-common/group-avatar/index.js +3 -0
- package/uni-common/room-avatar/default.svg +6 -0
- package/uni-common/room-avatar/index.js +3 -0
- package/uni-common/room-avatar/room-avatar.vue +27 -0
- package/uni-common/room-loader/room-loader.vue +53 -0
- package/uni-common/room-portray/room-portray.vue +56 -0
- package/uni-components/chat-control/calling/calling.vue +91 -0
- package/uni-components/chat-control/calling/phone-fill.svg +1 -0
- package/uni-components/chat-control/calling/vidicon-fill.svg +1 -0
- package/uni-components/chat-control/channel-video/channel-video.vue +89 -0
- package/uni-components/chat-control/channel-video-card/channel-video-card.vue +105 -0
- package/uni-components/chat-control/channel-video-live/channel-video-live.vue +92 -0
- package/uni-components/chat-control/chat-control-config-item/chat-control-config-item.vue +20 -0
- package/uni-components/chat-control/chat-control-config-item/index.js +3 -0
- package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-app.vue +25 -0
- package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-h5.vue +21 -0
- package/uni-components/chat-control/chat-control-config.vue +59 -0
- package/uni-components/chat-control/chat-control.vue +218 -0
- package/uni-components/chat-control/company-card/company-card.vue +123 -0
- package/uni-components/chat-control/const.js +28 -0
- package/uni-components/chat-control/expression/expression.vue +41 -0
- package/uni-components/chat-control/image/image.vue +68 -0
- package/uni-components/chat-control/index.js +89 -0
- package/uni-components/chat-control/location/location.vue +110 -0
- package/uni-components/chat-control/member-change/member-change.vue +32 -0
- package/uni-components/chat-control/quote-message/quote-message.vue +216 -0
- package/uni-components/chat-control/real-time-position/real-time-position.vue +62 -0
- package/uni-components/chat-control/redpacket/red-envelope.svg +1 -0
- package/uni-components/chat-control/redpacket/redpacket.vue +75 -0
- package/uni-components/chat-control/share-card/share-card.vue +101 -0
- package/uni-components/chat-control/system/system.vue +69 -0
- package/uni-components/chat-control/system-batch-message/system-batch-message.vue +30 -0
- package/uni-components/chat-control/system-text/system-text.vue +32 -0
- package/uni-components/chat-control/text/text.vue +67 -0
- package/uni-components/chat-control/text-with-at/text-with-at.vue +51 -0
- package/uni-components/chat-control/transfer/red-transfer.svg +1 -0
- package/uni-components/chat-control/transfer/transfer.vue +80 -0
- package/uni-components/chat-control/unkonw/unkonw.vue +37 -0
- package/uni-components/chat-control/url/icons/file-excel-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-info-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-music-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-pdf-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-ppt-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-settings-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-text-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-unknow-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-word-line.svg +1 -0
- package/uni-components/chat-control/url/icons/file-zip-line.svg +1 -0
- package/uni-components/chat-control/url/icons/index.js +24 -0
- package/uni-components/chat-control/url/miniprogram.svg +1 -0
- package/uni-components/chat-control/url/url-miniprogram.vue +116 -0
- package/uni-components/chat-control/url/url.vue +306 -0
- package/uni-components/chat-control/url-new/icons/file-excel-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-info-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-music-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-pdf-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-ppt-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-settings-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-text-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-unknow-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-word-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/file-zip-line.svg +1 -0
- package/uni-components/chat-control/url-new/icons/index.js +24 -0
- package/uni-components/chat-control/url-new/url-new.vue +110 -0
- package/uni-components/chat-control/utils.js +12 -0
- package/uni-components/chat-control/video/video.vue +156 -0
- package/uni-components/chat-control/voice/voice.vue +166 -0
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-collect.vue +84 -0
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-system.vue +28 -0
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet.vue +85 -0
- package/uni-components/chat-editor/chat-editor-func/chat-editor-func.vue +157 -0
- package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at-panel.vue +158 -0
- package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at.vue +61 -0
- package/uni-components/chat-editor/chat-editor-func-button/chat-editor-func-button.vue +58 -0
- package/uni-components/chat-editor/chat-editor-func-file/chat-editor-func-file.vue +54 -0
- package/uni-components/chat-editor/chat-editor-func-image/chat-editor-func-image.vue +42 -0
- package/uni-components/chat-editor/chat-editor-func-video/chat-editor-func-video.vue +42 -0
- package/uni-components/chat-editor/chat-editor-func-voice/chat-editor-func-voice.vue +25 -0
- package/uni-components/chat-editor/chat-editor-message-send/chat-editor-message-send.vue +158 -0
- package/uni-components/chat-editor/chat-editor-quote/chat-editor-quote.vue +75 -0
- package/uni-components/chat-editor/chat-editor.vue +257 -0
- package/uni-components/chat-editor/index.js +10 -0
- package/uni-components/chat-editor/util.js +65 -0
- package/uni-components/chat-panel/chat-panel-chats-box.vue +238 -0
- package/uni-components/chat-panel/chat-panel-chats-forward/chat-panel-chats-forward.vue +273 -0
- package/uni-components/chat-panel/chat-panel-chats-item.vue +578 -0
- package/uni-components/chat-panel/chat-panel-chats-status/chat-panel-chats-status.vue +71 -0
- package/uni-components/chat-panel/chat-panel-chats.vue +368 -0
- package/uni-components/chat-panel/chat-panel.vue +227 -0
- package/uni-components/contacts-group-select/contacts-group-select-item.vue +85 -0
- package/uni-components/contacts-group-select/contacts-group-select-panel.vue +119 -0
- package/uni-components/contacts-group-select/contacts-group-select.vue +150 -0
- package/utils/color.js +178 -0
- package/utils/data.js +11 -0
- package/utils/date.js +107 -0
- package/utils/event.js +3 -0
- package/utils/file.js +26 -0
- package/utils/index.js +5 -0
- package/utils/json.js +40 -0
- package/utils/log.js +243 -0
- package/utils/queue.js +97 -0
- package/utils/regexp.js +9 -0
- package/utils/string.js +66 -0
- package/utils/url.js +48 -0
- package/utils/util.js +130 -0
package/utils/log.js
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { unique } from './string'
|
|
2
|
+
import { parse } from './json'
|
|
3
|
+
import { formatDate } from './date'
|
|
4
|
+
|
|
5
|
+
function requestAnimationFrame (callback) {
|
|
6
|
+
if (typeof uni === 'object') {
|
|
7
|
+
return setTimeout(() => {
|
|
8
|
+
callback && callback()
|
|
9
|
+
}, 10)
|
|
10
|
+
} else {
|
|
11
|
+
return window.requestAnimationFrame(() => {
|
|
12
|
+
callback && callback()
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function cancelAnimationFrame (rafId) {
|
|
18
|
+
if (typeof uni === 'object') {
|
|
19
|
+
clearTimeout(rafId)
|
|
20
|
+
} else {
|
|
21
|
+
window.cancelAnimationFrame(rafId)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const LogManage = {
|
|
26
|
+
list: [],
|
|
27
|
+
add: (logInstance) => {
|
|
28
|
+
if (!(logInstance instanceof Log)) {
|
|
29
|
+
throw new Error('不是有效日志实例')
|
|
30
|
+
}
|
|
31
|
+
if (!this.list.some(v => v === logInstance)) {
|
|
32
|
+
throw new Error('日志实例已存在')
|
|
33
|
+
}
|
|
34
|
+
this.list.push(logInstance)
|
|
35
|
+
},
|
|
36
|
+
remove: (logInstance) => {
|
|
37
|
+
let index = -1
|
|
38
|
+
this.list.some((v, i) => {
|
|
39
|
+
if (v === logInstance) {
|
|
40
|
+
index = i
|
|
41
|
+
return true
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
if (index < 0) {
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
this.list.splice(index, 1)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default class Log {
|
|
52
|
+
|
|
53
|
+
prefix = 'log'
|
|
54
|
+
|
|
55
|
+
name = null
|
|
56
|
+
|
|
57
|
+
tempStore = []
|
|
58
|
+
|
|
59
|
+
beforeAddCallback = null
|
|
60
|
+
|
|
61
|
+
constructor (options) {
|
|
62
|
+
options = Object.assign({
|
|
63
|
+
name: null,
|
|
64
|
+
console: false, // 是否控制台打印
|
|
65
|
+
maxSize: 1024 * 1024 * 3 // 最多存3M的日志数据
|
|
66
|
+
}, options)
|
|
67
|
+
if (!options.name) {
|
|
68
|
+
throw new Error('必须指定日志的name名称')
|
|
69
|
+
}
|
|
70
|
+
if (LogManage.list.some(v => v.name === options.name)) {
|
|
71
|
+
throw new Error('已存在同名的日志实例')
|
|
72
|
+
}
|
|
73
|
+
this.options = options
|
|
74
|
+
this.maxSize = options.maxSize
|
|
75
|
+
this.name = options.name
|
|
76
|
+
this.validTime = options.validTime
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get storageKey () {
|
|
80
|
+
return this.prefix + '_' + this.name
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
onBeforeAdd (callback) {
|
|
84
|
+
this.beforeAddCallback = callback
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 新增日志到内存
|
|
89
|
+
*/
|
|
90
|
+
addLog (data) {
|
|
91
|
+
data = Object.assign({
|
|
92
|
+
group: this.defautGroup,
|
|
93
|
+
refererId: undefined, // 可以关联一个日志
|
|
94
|
+
content: null
|
|
95
|
+
}, data, {
|
|
96
|
+
createTime: formatDate(new Date())
|
|
97
|
+
})
|
|
98
|
+
data.id = unique(data.group)
|
|
99
|
+
if (this.beforeAddCallback && this.beforeAddCallback({
|
|
100
|
+
data
|
|
101
|
+
}) === false) {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
const size = JSON.stringify(data).length
|
|
105
|
+
data.size = size
|
|
106
|
+
this.tempStore.push(data)
|
|
107
|
+
if (this.tempStore.length > 5) {
|
|
108
|
+
this.publishLogData().then(null, err => {
|
|
109
|
+
console.log(err)
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
if (this.options.console) {
|
|
113
|
+
console.log(`【${this.name || 'operateLog'}】${JSON.stringify(data) || '--'}`)
|
|
114
|
+
}
|
|
115
|
+
return data
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* 清空本地日志
|
|
120
|
+
*/
|
|
121
|
+
clearLogData () {
|
|
122
|
+
return new Promise((resolve) => {
|
|
123
|
+
this.tempStore = []
|
|
124
|
+
if (typeof uni !== 'undefined') {
|
|
125
|
+
uni.removeStorageSync(this.storageKey)
|
|
126
|
+
} else {
|
|
127
|
+
window.localStorage.removeItem(this.storageKey)
|
|
128
|
+
}
|
|
129
|
+
resolve()
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
loadLogData () {
|
|
134
|
+
return new Promise((resolve, reject) => {
|
|
135
|
+
if (this._lastLoadLogDataRaf) {
|
|
136
|
+
this._lastLoadLogDataRaf.cancelFn()
|
|
137
|
+
}
|
|
138
|
+
let rafId = null
|
|
139
|
+
this._lastLoadLogDataRaf = {
|
|
140
|
+
cancelFn: () => {
|
|
141
|
+
cancelAnimationFrame(rafId)
|
|
142
|
+
this._lastLoadLogDataRaf = null
|
|
143
|
+
reject('cancel')
|
|
144
|
+
},
|
|
145
|
+
execFn: () => {
|
|
146
|
+
rafId = requestAnimationFrame(() => {
|
|
147
|
+
let localTempStore
|
|
148
|
+
if (typeof uni !== 'undefined') {
|
|
149
|
+
localTempStore = uni.getStorageSync(this.storageKey)
|
|
150
|
+
} else {
|
|
151
|
+
localTempStore = window.localStorage.getItem(this.storageKey)
|
|
152
|
+
}
|
|
153
|
+
if (localTempStore) {
|
|
154
|
+
localTempStore = parse(localTempStore)
|
|
155
|
+
if (Array.isArray(localTempStore)) {
|
|
156
|
+
let totalSize = 0
|
|
157
|
+
localTempStore = {
|
|
158
|
+
data: localTempStore.map(v => {
|
|
159
|
+
if (!v.size) {
|
|
160
|
+
v.size = JSON.stringify(v).length
|
|
161
|
+
}
|
|
162
|
+
totalSize += v.size
|
|
163
|
+
return v
|
|
164
|
+
})
|
|
165
|
+
}
|
|
166
|
+
localTempStore.size = totalSize
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (!localTempStore) {
|
|
170
|
+
localTempStore = {
|
|
171
|
+
size: 0,
|
|
172
|
+
data: []
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// 自清理一下
|
|
176
|
+
if (this._lastLoadLogDataRaf) {
|
|
177
|
+
cancelAnimationFrame(this._lastLoadLogDataRaf)
|
|
178
|
+
this._lastLoadLogDataRaf = null
|
|
179
|
+
}
|
|
180
|
+
resolve(localTempStore)
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
this._lastLoadLogDataRaf.execFn()
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
publishLogData () {
|
|
189
|
+
return new Promise((resolve, reject) => {
|
|
190
|
+
if (this._lastPublishLogDataRaf) {
|
|
191
|
+
this._lastPublishLogDataRaf.cancelFn()
|
|
192
|
+
}
|
|
193
|
+
let rafId = null
|
|
194
|
+
this._lastPublishLogDataRaf = {
|
|
195
|
+
cancelFn: () => {
|
|
196
|
+
cancelAnimationFrame(rafId)
|
|
197
|
+
this._lastPublishLogDataRaf = null
|
|
198
|
+
reject('cancel')
|
|
199
|
+
},
|
|
200
|
+
execFn: () => {
|
|
201
|
+
if (!this.tempStore || !this.tempStore.length) {
|
|
202
|
+
return resolve()
|
|
203
|
+
}
|
|
204
|
+
rafId = requestAnimationFrame(() => {
|
|
205
|
+
this.loadLogData().then((localTempStore) => {
|
|
206
|
+
const allData = [].concat(this.tempStore, localTempStore.data)
|
|
207
|
+
const nextLocalStore = {
|
|
208
|
+
size: 0,
|
|
209
|
+
data: []
|
|
210
|
+
}
|
|
211
|
+
allData.some((item, index) => {
|
|
212
|
+
if (item.size + nextLocalStore.size >= this.maxSize) {
|
|
213
|
+
return true
|
|
214
|
+
}
|
|
215
|
+
nextLocalStore.data.push(item)
|
|
216
|
+
nextLocalStore.size = nextLocalStore.size + item.size
|
|
217
|
+
})
|
|
218
|
+
if (typeof uni !== 'undefined') {
|
|
219
|
+
uni.setStorageSync(this.storageKey, nextLocalStore)
|
|
220
|
+
} else {
|
|
221
|
+
window.localStorage.setItem(this.storageKey, JSON.stringify(nextLocalStore))
|
|
222
|
+
}
|
|
223
|
+
this.tempStore = []
|
|
224
|
+
// 自清理一下
|
|
225
|
+
if (this._lastPublishLogDataRaf) {
|
|
226
|
+
cancelAnimationFrame(this._lastPublishLogDataRaf)
|
|
227
|
+
this._lastPublishLogDataRaf = null
|
|
228
|
+
}
|
|
229
|
+
resolve()
|
|
230
|
+
}, reject)
|
|
231
|
+
})
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
this._lastPublishLogDataRaf.execFn()
|
|
235
|
+
})
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
exportLogData () {
|
|
239
|
+
return this.publishLogData().then(() => {
|
|
240
|
+
return this.loadLogData()
|
|
241
|
+
})
|
|
242
|
+
}
|
|
243
|
+
}
|
package/utils/queue.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { unique } from './string'
|
|
2
|
+
import { createPromise } from './util'
|
|
3
|
+
|
|
4
|
+
/***
|
|
5
|
+
* 创建一个串行执行队列
|
|
6
|
+
*/
|
|
7
|
+
export function createSerialQueue (options) {
|
|
8
|
+
options = Object.assign({
|
|
9
|
+
spanTime: 1000 * 5 // 每个任务间隔时间,因为后端有节流控制,这里稍微加点时间间隔
|
|
10
|
+
}, options)
|
|
11
|
+
const queue = []
|
|
12
|
+
let _timer
|
|
13
|
+
let _lastExecTime = null
|
|
14
|
+
return {
|
|
15
|
+
add (taskFn) {
|
|
16
|
+
if (typeof taskFn !== 'function') {
|
|
17
|
+
throw new Error('不是一个函数')
|
|
18
|
+
}
|
|
19
|
+
if (queue.some(v => v.fn === taskFn)) {
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
const ps = createPromise()
|
|
23
|
+
const item = {
|
|
24
|
+
id: unique(),
|
|
25
|
+
status: 'normal',
|
|
26
|
+
fn: () => {
|
|
27
|
+
if (item.status === 'loading' || item.status === 'destroyed') {
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
item.status = 'loading'
|
|
31
|
+
const rs = taskFn()
|
|
32
|
+
if (rs && rs.then) {
|
|
33
|
+
rs.then(ps.resolve, ps.reject).finally(() => {
|
|
34
|
+
_lastExecTime = Date.now()
|
|
35
|
+
item.status = 'complete'
|
|
36
|
+
})
|
|
37
|
+
} else {
|
|
38
|
+
_lastExecTime = Date.now()
|
|
39
|
+
item.status = 'complete'
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
queue.push(item)
|
|
44
|
+
this.check(queue.length - 1)
|
|
45
|
+
return ps
|
|
46
|
+
},
|
|
47
|
+
remove (taskFn) {
|
|
48
|
+
let index = -1
|
|
49
|
+
queue.some((v, i) => {
|
|
50
|
+
if (v.fn === taskFn) {
|
|
51
|
+
index = i
|
|
52
|
+
return true
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
if (index < 0) {
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
queue[index].status = 'destroyed'
|
|
59
|
+
queue.splice(index, 1)
|
|
60
|
+
this.check()
|
|
61
|
+
},
|
|
62
|
+
clear () {
|
|
63
|
+
if (!queue || !queue.length) {
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
for (let i = queue.length - 1; i >= 0; i--) {
|
|
67
|
+
this.remove(queue[i].fn)
|
|
68
|
+
}
|
|
69
|
+
clearTimeout(_timer)
|
|
70
|
+
_lastExecTime = null
|
|
71
|
+
},
|
|
72
|
+
check () {
|
|
73
|
+
// 把执行完的清理一下
|
|
74
|
+
for (let i = queue.length - 1; i >= 0; i--) {
|
|
75
|
+
if (queue[i].status === 'complete') {
|
|
76
|
+
queue.splice(i, 1)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (!_lastExecTime || ((Date.now() - _lastExecTime) > options.spanTime * 2)) {
|
|
80
|
+
if (queue[0] && queue[0].status === 'normal') {
|
|
81
|
+
Promise.all([queue[0].fn()]).finally(() => {
|
|
82
|
+
this.check()
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
clearTimeout(_timer)
|
|
87
|
+
_timer = setTimeout(() => {
|
|
88
|
+
if (queue[0] && queue[0].status === 'normal') {
|
|
89
|
+
Promise.all([queue[0].fn()]).finally(() => {
|
|
90
|
+
this.check()
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
}, options.spanTime)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
package/utils/regexp.js
ADDED
package/utils/string.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import shajs from 'sha.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 生成会话id
|
|
5
|
+
* @param accountId - 客服id
|
|
6
|
+
* @param targetId - wechatFriendId | wechatChatroomId
|
|
7
|
+
*/
|
|
8
|
+
export function createSessionId (accountId, targetId) {
|
|
9
|
+
if (!accountId || !targetId) {
|
|
10
|
+
return
|
|
11
|
+
}
|
|
12
|
+
return shajs('sha1').update(`${accountId}${targetId}`).digest('hex')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let num = Date.now()
|
|
16
|
+
export function unique () {
|
|
17
|
+
num++
|
|
18
|
+
return num
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function firstLetterUpperCase(string) {
|
|
22
|
+
if (!string) {
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
return string.charAt(0).toUpperCase() + string.slice(1)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function html2Escape (sHtml) {
|
|
29
|
+
return (sHtml || '').replace(/[<>]/g, (c) => {
|
|
30
|
+
return {
|
|
31
|
+
'<': '<',
|
|
32
|
+
'>': '>'
|
|
33
|
+
}[c]
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function copyText (text) {
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
uni.setClipboardData({
|
|
40
|
+
data: text,
|
|
41
|
+
success: () => {
|
|
42
|
+
resolve()
|
|
43
|
+
},
|
|
44
|
+
fail: err => {
|
|
45
|
+
reject(err)
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function unUnicode (str) {
|
|
52
|
+
if (!str) {
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
/* eslint-disable */
|
|
56
|
+
return str.replace(/&#(x)?([^&]{1,5});?/g, function (a, b, c, d) {
|
|
57
|
+
return unescape(`%${c}`)
|
|
58
|
+
})
|
|
59
|
+
/* eslint-enable */
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let number = Date.now()
|
|
63
|
+
export function unqiue () {
|
|
64
|
+
++number
|
|
65
|
+
return 'u-' + number
|
|
66
|
+
}
|
package/utils/url.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import qs from 'query-string'
|
|
2
|
+
|
|
3
|
+
export function getUrlParams (url, options) {
|
|
4
|
+
if (!url) {
|
|
5
|
+
const pageHref = window.location.href
|
|
6
|
+
const searchIndex = pageHref.indexOf('?')
|
|
7
|
+
if (searchIndex >= 0) {
|
|
8
|
+
url = pageHref.substr(searchIndex)
|
|
9
|
+
// http://localhost:8082/?tenantId=yangyutest&_layout=left#/admin/app/workchat/livecode?_layout=left&_mode=module&tenantId=yangyutest
|
|
10
|
+
return url.split('#').reduce((rs, search) => {
|
|
11
|
+
const hashQuery = search.indexOf('?')
|
|
12
|
+
if (hashQuery >= 0) {
|
|
13
|
+
search = search.substr(hashQuery)
|
|
14
|
+
rs = Object.assign({}, rs, qs.parse(search, options))
|
|
15
|
+
}
|
|
16
|
+
return rs
|
|
17
|
+
}, {})
|
|
18
|
+
} else {
|
|
19
|
+
return {}
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
return qs.parse(url, options)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 解析url字符串
|
|
28
|
+
*/
|
|
29
|
+
let aElement = null
|
|
30
|
+
export function parseUrl (url) {
|
|
31
|
+
if (!aElement) {
|
|
32
|
+
aElement = document.createElement('a')
|
|
33
|
+
}
|
|
34
|
+
aElement.href = url
|
|
35
|
+
const ds = aElement.hostname.split('.')
|
|
36
|
+
return {
|
|
37
|
+
protocol: aElement.protocol.replace(':', ''),
|
|
38
|
+
host: aElement.hostname,
|
|
39
|
+
port: aElement.port,
|
|
40
|
+
query: aElement.search,
|
|
41
|
+
params: getUrlParams(aElement.search),
|
|
42
|
+
hash: aElement.hash.replace('#', ''),
|
|
43
|
+
domain: ds[ds.length - 2],
|
|
44
|
+
/* eslint-disable */
|
|
45
|
+
path: aElement.pathname.replace(/^([^\/])/, '/$1')
|
|
46
|
+
/* eslint-enable */
|
|
47
|
+
}
|
|
48
|
+
}
|
package/utils/util.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
export function createPromise () {
|
|
2
|
+
let psReject, psResolve, isTry = false, _timer
|
|
3
|
+
const ps = new Promise((resolve, reject) => {
|
|
4
|
+
isTry = true
|
|
5
|
+
clearTimeout(_timer)
|
|
6
|
+
psResolve = resolve
|
|
7
|
+
psReject = reject
|
|
8
|
+
})
|
|
9
|
+
ps.reject = psReject
|
|
10
|
+
ps.resolve = psResolve
|
|
11
|
+
_timer = setTimeout(() => {
|
|
12
|
+
if (isTry) {
|
|
13
|
+
return
|
|
14
|
+
}
|
|
15
|
+
psReject('timeout')
|
|
16
|
+
}, 1000 * 60)
|
|
17
|
+
return ps
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function isEmptyObject (obj) {
|
|
21
|
+
if (!obj) {
|
|
22
|
+
return true
|
|
23
|
+
}
|
|
24
|
+
for (let key in obj) {
|
|
25
|
+
if (obj.hasOwnProperty(key)) {
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return true
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 轮循加载
|
|
34
|
+
*/
|
|
35
|
+
export function createPollRequest (requestFn, spanTime = 5 * 1000, timeout = 60 * 1000) {
|
|
36
|
+
let _stop = false
|
|
37
|
+
let _timer = null
|
|
38
|
+
let _reject = null
|
|
39
|
+
function stop () {
|
|
40
|
+
if (_stop) {
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
_stop = true
|
|
44
|
+
clearTimeout(_timer)
|
|
45
|
+
if (_reject) {
|
|
46
|
+
_reject('stop')
|
|
47
|
+
_reject = null
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function start () {
|
|
51
|
+
return loopFn()
|
|
52
|
+
}
|
|
53
|
+
function loopFn () {
|
|
54
|
+
let countdown = timeout
|
|
55
|
+
return new Promise((resolve, reject) => {
|
|
56
|
+
let settled = false
|
|
57
|
+
const done = (res) => {
|
|
58
|
+
if (settled) {
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
settled = true
|
|
62
|
+
_stop = true
|
|
63
|
+
clearTimeout(_timer)
|
|
64
|
+
_reject = null
|
|
65
|
+
resolve(res)
|
|
66
|
+
}
|
|
67
|
+
const fail = (err) => {
|
|
68
|
+
if (settled) {
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
settled = true
|
|
72
|
+
_stop = true
|
|
73
|
+
clearTimeout(_timer)
|
|
74
|
+
_reject = null
|
|
75
|
+
reject(err)
|
|
76
|
+
}
|
|
77
|
+
_reject = fail
|
|
78
|
+
const nextFn = () => {
|
|
79
|
+
if (_stop) {
|
|
80
|
+
fail('stop')
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
if (countdown <= 0) {
|
|
84
|
+
fail('timeout')
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
countdown = countdown - spanTime
|
|
88
|
+
let requestPromise
|
|
89
|
+
try {
|
|
90
|
+
requestPromise = requestFn({
|
|
91
|
+
done (res) {
|
|
92
|
+
if (_stop || settled) {
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
done(res)
|
|
96
|
+
},
|
|
97
|
+
fail (err) {
|
|
98
|
+
if (_stop || settled) {
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
fail(err)
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
} catch (err) {
|
|
105
|
+
requestPromise = Promise.reject(err)
|
|
106
|
+
}
|
|
107
|
+
Promise.resolve(requestPromise).then(() => {
|
|
108
|
+
if (_stop || settled) {
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
_timer = setTimeout(() => {
|
|
112
|
+
nextFn()
|
|
113
|
+
}, spanTime)
|
|
114
|
+
}, () => {
|
|
115
|
+
if (_stop || settled) {
|
|
116
|
+
return
|
|
117
|
+
}
|
|
118
|
+
_timer = setTimeout(() => {
|
|
119
|
+
nextFn()
|
|
120
|
+
}, spanTime)
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
nextFn()
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
start,
|
|
128
|
+
stop
|
|
129
|
+
}
|
|
130
|
+
}
|