@tencentcloud/ai-desk-customer-vue 0.1.0
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/.code.yml +17 -0
- package/.eslintignore +6 -0
- package/.stylelintrc.json +40 -0
- package/CHANGELOG.md +5 -0
- package/README.md +12 -0
- package/adapter-vue-web.ts +73 -0
- package/adapter-vue.ts +10 -0
- package/assets/audio-before-delete.svg +4 -0
- package/assets/audio-blue.png +0 -0
- package/assets/audio-bubble-blue.svg +3 -0
- package/assets/audio-bubble-red.svg +3 -0
- package/assets/audio-delete.svg +10 -0
- package/assets/audio.svg +6 -0
- package/assets/back.svg +16 -0
- package/assets/background_mobile.png +0 -0
- package/assets/camera-uni.png +0 -0
- package/assets/close-quote-icon.svg +3 -0
- package/assets/customer_avatar.png +0 -0
- package/assets/customer_avatar_mobile.png +0 -0
- package/assets/dialog-close.png +0 -0
- package/assets/double-arrow.svg +1 -0
- package/assets/download.svg +6 -0
- package/assets/emoji.png +0 -0
- package/assets/face-uni.png +0 -0
- package/assets/face.png +0 -0
- package/assets/file-h5.png +0 -0
- package/assets/files.png +0 -0
- package/assets/form-dialog-bg.png +0 -0
- package/assets/icon-arrow-left.svg +7 -0
- package/assets/icon-close.svg +6 -0
- package/assets/iconRight.svg +3 -0
- package/assets/icon_form.png +0 -0
- package/assets/icon_form_filled.png +0 -0
- package/assets/icon_question.png +0 -0
- package/assets/icon_refresh.png +0 -0
- package/assets/icon_success.png +0 -0
- package/assets/imRobotGuess.svg +4 -0
- package/assets/image-uni.png +0 -0
- package/assets/image.png +0 -0
- package/assets/keyboard_icon.png +0 -0
- package/assets/loading.png +0 -0
- package/assets/more-uni.png +0 -0
- package/assets/more_tools.png +0 -0
- package/assets/msg-audio.svg +1 -0
- package/assets/msg-copy.svg +30 -0
- package/assets/msg-del.svg +33 -0
- package/assets/msg-quote.svg +8 -0
- package/assets/msg-revoke.svg +29 -0
- package/assets/radio-check.png +0 -0
- package/assets/radio-uncheck.png +0 -0
- package/assets/radio.svg +6 -0
- package/assets/refresh.svg +4 -0
- package/assets/rotate-left.svg +7 -0
- package/assets/rotate-right.svg +7 -0
- package/assets/star.png +0 -0
- package/assets/starLine.png +0 -0
- package/assets/translate.svg +12 -0
- package/assets/video-play.png +0 -0
- package/assets/video-uni.png +0 -0
- package/assets/video.png +0 -0
- package/assets/zoom-in.svg +9 -0
- package/assets/zoom-out.svg +9 -0
- package/components/CustomerServiceChat/chat-header/index-web.vue +141 -0
- package/components/CustomerServiceChat/emoji-config/custom-emoji.ts +15 -0
- package/components/CustomerServiceChat/emoji-config/default-emoji.ts +114 -0
- package/components/CustomerServiceChat/emoji-config/index.ts +140 -0
- package/components/CustomerServiceChat/emoji-config/locales/en.ts +66 -0
- package/components/CustomerServiceChat/emoji-config/locales/zh_cn.ts +66 -0
- package/components/CustomerServiceChat/index-web.vue +250 -0
- package/components/CustomerServiceChat/message-input/index-web.vue +214 -0
- package/components/CustomerServiceChat/message-input/index.ts +2 -0
- package/components/CustomerServiceChat/message-input/message-input-button.vue +95 -0
- package/components/CustomerServiceChat/message-input/message-input-editor-web.vue +884 -0
- package/components/CustomerServiceChat/message-input/message-input-file-web.ts +38 -0
- package/components/CustomerServiceChat/message-input/message-input-quote/index.vue +204 -0
- package/components/CustomerServiceChat/message-input-toolbar/emoji-dialog-mobile/emoji-dialog-mobile.vue +145 -0
- package/components/CustomerServiceChat/message-input-toolbar/emoji-picker/emoji-picker-dialog.vue +180 -0
- package/components/CustomerServiceChat/message-input-toolbar/emoji-picker/index.ts +2 -0
- package/components/CustomerServiceChat/message-input-toolbar/emoji-picker/index.vue +90 -0
- package/components/CustomerServiceChat/message-input-toolbar/emoji-picker/style/h5.scss +26 -0
- package/components/CustomerServiceChat/message-input-toolbar/emoji-picker/style/index.scss +4 -0
- package/components/CustomerServiceChat/message-input-toolbar/emoji-picker/style/web.scss +55 -0
- package/components/CustomerServiceChat/message-input-toolbar/file-upload/index.ts +2 -0
- package/components/CustomerServiceChat/message-input-toolbar/file-upload/index.vue +77 -0
- package/components/CustomerServiceChat/message-input-toolbar/image-upload/index.ts +2 -0
- package/components/CustomerServiceChat/message-input-toolbar/image-upload/index.vue +185 -0
- package/components/CustomerServiceChat/message-input-toolbar/index-web.vue +191 -0
- package/components/CustomerServiceChat/message-input-toolbar/index.ts +2 -0
- package/components/CustomerServiceChat/message-input-toolbar/style/uni.scss +111 -0
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/index.vue +149 -0
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/style/color.scss +6 -0
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/style/h5.scss +20 -0
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/style/index.scss +5 -0
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/style/uni.scss +36 -0
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/style/web.scss +19 -0
- package/components/CustomerServiceChat/message-input-toolbar/video-upload/index.ts +2 -0
- package/components/CustomerServiceChat/message-input-toolbar/video-upload/index.vue +146 -0
- package/components/CustomerServiceChat/message-list/index-web.vue +712 -0
- package/components/CustomerServiceChat/message-list/link/index.ts +23 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-audio-web.vue +223 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-bubble-web.vue +504 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-custom.vue +5 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-face.vue +45 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-file.vue +151 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-image-web.vue +97 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-location.vue +34 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-quote/index-web.vue +286 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-quote/interface.ts +60 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-record/index.vue +139 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-text.vue +94 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-timestamp.vue +76 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-video-web.vue +319 -0
- package/components/CustomerServiceChat/message-list/message-elements/plugins/plugin-components/index.ts +9 -0
- package/components/CustomerServiceChat/message-list/message-elements/plugins/plugin-components/message-customer/index.ts +5 -0
- package/components/CustomerServiceChat/message-list/message-elements/plugins/plugin-components/message-customer/message-customer-service.vue +22 -0
- package/components/CustomerServiceChat/message-list/message-elements/plugins/plugin-components/message-plugin-layout-web.vue +133 -0
- package/components/CustomerServiceChat/message-list/message-elements/plugins/plugin-components/message-plugin-web.vue +83 -0
- package/components/CustomerServiceChat/message-list/message-elements/read-status/index.vue +193 -0
- package/components/CustomerServiceChat/message-list/message-elements/simple-message-list/index.vue +462 -0
- package/components/CustomerServiceChat/message-list/message-elements/simple-message-list/message-container.vue +105 -0
- package/components/CustomerServiceChat/message-list/message-elements/video-play.vue +59 -0
- package/components/CustomerServiceChat/message-list/message-tool/index-web.vue +312 -0
- package/components/CustomerServiceChat/message-list/message-tool/message-revoked.vue +63 -0
- package/components/CustomerServiceChat/message-list/scroll-button/index.vue +201 -0
- package/components/CustomerServiceChat/message-list/style/color.scss +32 -0
- package/components/CustomerServiceChat/message-list/style/h5.scss +16 -0
- package/components/CustomerServiceChat/message-list/style/index.scss +11 -0
- package/components/CustomerServiceChat/message-list/style/web.scss +180 -0
- package/components/CustomerServiceChat/style/common.scss +59 -0
- package/components/CustomerServiceChat/style/h5.scss +51 -0
- package/components/CustomerServiceChat/style/index.scss +12 -0
- package/components/CustomerServiceChat/style/uni.scss +13 -0
- package/components/CustomerServiceChat/style/web.scss +46 -0
- package/components/CustomerServiceChat/style/wx.scss +5 -0
- package/components/CustomerServiceChat/utils/conversationDraft.ts +86 -0
- package/components/CustomerServiceChat/utils/sendMessage.ts +140 -0
- package/components/common/Avatar/index.vue +148 -0
- package/components/common/BottomPopup/index.ts +3 -0
- package/components/common/BottomPopup/index.vue +160 -0
- package/components/common/BottomPopup/style/h5.scss +62 -0
- package/components/common/BottomPopup/style/index.scss +3 -0
- package/components/common/BottomPopup/style/modal.scss +5 -0
- package/components/common/Dialog/index.ts +3 -0
- package/components/common/Dialog/index.vue +120 -0
- package/components/common/Dialog/style/color.scss +43 -0
- package/components/common/Dialog/style/dialog.scss +4 -0
- package/components/common/Dialog/style/h5.scss +56 -0
- package/components/common/Dialog/style/web.scss +61 -0
- package/components/common/Drawer/index.vue +164 -0
- package/components/common/Icon.vue +83 -0
- package/components/common/ImagePreviewer/image-item-web.vue +42 -0
- package/components/common/ImagePreviewer/index-web.vue +682 -0
- package/components/common/ImagePreviewer/index.ts +3 -0
- package/components/common/Overlay/index.vue +126 -0
- package/components/common/ProgressMessage/index.vue +95 -0
- package/components/common/RadioSelect/index.vue +59 -0
- package/components/common/RichText/LICENSE +21 -0
- package/components/common/RichText/README.md +244 -0
- package/components/common/RichText/dist/mp-alipay/index.acss +1 -0
- package/components/common/RichText/dist/mp-alipay/index.axml +1 -0
- package/components/common/RichText/dist/mp-alipay/index.js +8 -0
- package/components/common/RichText/dist/mp-alipay/index.json +1 -0
- package/components/common/RichText/dist/mp-alipay/node/node.acss +1 -0
- package/components/common/RichText/dist/mp-alipay/node/node.axml +1 -0
- package/components/common/RichText/dist/mp-alipay/node/node.js +1 -0
- package/components/common/RichText/dist/mp-alipay/node/node.json +1 -0
- package/components/common/RichText/dist/mp-alipay/parser.js +1 -0
- package/components/common/RichText/dist/mp-baidu/index.css +1 -0
- package/components/common/RichText/dist/mp-baidu/index.js +8 -0
- package/components/common/RichText/dist/mp-baidu/index.json +1 -0
- package/components/common/RichText/dist/mp-baidu/index.swan +1 -0
- package/components/common/RichText/dist/mp-baidu/node/node.css +1 -0
- package/components/common/RichText/dist/mp-baidu/node/node.js +1 -0
- package/components/common/RichText/dist/mp-baidu/node/node.json +1 -0
- package/components/common/RichText/dist/mp-baidu/node/node.swan +1 -0
- package/components/common/RichText/dist/mp-baidu/parser.js +1 -0
- package/components/common/RichText/dist/mp-qq/index.js +8 -0
- package/components/common/RichText/dist/mp-qq/index.json +1 -0
- package/components/common/RichText/dist/mp-qq/index.qml +1 -0
- package/components/common/RichText/dist/mp-qq/index.qss +1 -0
- package/components/common/RichText/dist/mp-qq/node/node.js +1 -0
- package/components/common/RichText/dist/mp-qq/node/node.json +1 -0
- package/components/common/RichText/dist/mp-qq/node/node.qml +1 -0
- package/components/common/RichText/dist/mp-qq/node/node.qss +1 -0
- package/components/common/RichText/dist/mp-qq/parser.js +1 -0
- package/components/common/RichText/dist/mp-toutiao/index.js +8 -0
- package/components/common/RichText/dist/mp-toutiao/index.json +1 -0
- package/components/common/RichText/dist/mp-toutiao/index.ttml +1 -0
- package/components/common/RichText/dist/mp-toutiao/index.ttss +1 -0
- package/components/common/RichText/dist/mp-toutiao/node/node.js +1 -0
- package/components/common/RichText/dist/mp-toutiao/node/node.json +1 -0
- package/components/common/RichText/dist/mp-toutiao/node/node.ttml +1 -0
- package/components/common/RichText/dist/mp-toutiao/node/node.ttss +1 -0
- package/components/common/RichText/dist/mp-toutiao/parser.js +1 -0
- package/components/common/RichText/dist/mp-weixin/index.js +8 -0
- package/components/common/RichText/dist/mp-weixin/index.json +1 -0
- package/components/common/RichText/dist/mp-weixin/index.wxml +1 -0
- package/components/common/RichText/dist/mp-weixin/index.wxss +1 -0
- package/components/common/RichText/dist/mp-weixin/node/node.js +1 -0
- package/components/common/RichText/dist/mp-weixin/node/node.json +1 -0
- package/components/common/RichText/dist/mp-weixin/node/node.wxml +1 -0
- package/components/common/RichText/dist/mp-weixin/node/node.wxss +1 -0
- package/components/common/RichText/dist/mp-weixin/parser.js +1 -0
- package/components/common/RichText/dist/uni-app/components/mp-html/mp-html.vue +498 -0
- package/components/common/RichText/dist/uni-app/components/mp-html/node/node.vue +587 -0
- package/components/common/RichText/dist/uni-app/components/mp-html/parser.js +1393 -0
- package/components/common/RichText/dist/uni-app/static/app-plus/mp-html/js/handler.js +1 -0
- package/components/common/RichText/dist/uni-app/static/app-plus/mp-html/js/uni.webview.min.js +1 -0
- package/components/common/RichText/dist/uni-app/static/app-plus/mp-html/local.html +1 -0
- package/components/common/RichText/docs/.nojekyll +0 -0
- package/components/common/RichText/docs/index.html +50 -0
- package/components/common/RichText/docs/lib/docsify.min.js +1 -0
- package/components/common/RichText/docs/lib/prism-bash.min.js +1 -0
- package/components/common/RichText/docs/lib/search.min.js +1 -0
- package/components/common/RichText/docs/lib/vue.css +858 -0
- package/components/common/RichText/gulpfile.js +113 -0
- package/components/common/RichText/lint.js +63 -0
- package/components/common/RichText/package.json +74 -0
- package/components/common/RichText/plugins/README.md +2 -0
- package/components/common/RichText/plugins/audio/README.md +25 -0
- package/components/common/RichText/plugins/audio/build.js +11 -0
- package/components/common/RichText/plugins/audio/context.js +7 -0
- package/components/common/RichText/plugins/audio/index.js +34 -0
- package/components/common/RichText/plugins/audio/miniprogram/audio.js +189 -0
- package/components/common/RichText/plugins/audio/miniprogram/audio.json +3 -0
- package/components/common/RichText/plugins/audio/miniprogram/audio.wxml +17 -0
- package/components/common/RichText/plugins/audio/miniprogram/audio.wxss +127 -0
- package/components/common/RichText/plugins/audio/miniprogram/build.js +3 -0
- package/components/common/RichText/plugins/audio/uni-app/audio.vue +269 -0
- package/components/common/RichText/plugins/audio/uni-app/build.js +3 -0
- package/components/common/RichText/plugins/card/README.md +30 -0
- package/components/common/RichText/plugins/card/build.js +14 -0
- package/components/common/RichText/plugins/card/index.js +7 -0
- package/components/common/RichText/plugins/card/miniprogram/build.js +3 -0
- package/components/common/RichText/plugins/card/miniprogram/card.js +26 -0
- package/components/common/RichText/plugins/card/miniprogram/card.json +3 -0
- package/components/common/RichText/plugins/card/miniprogram/card.wxml +9 -0
- package/components/common/RichText/plugins/card/miniprogram/card.wxss +55 -0
- package/components/common/RichText/plugins/card/uni-app/build.js +3 -0
- package/components/common/RichText/plugins/card/uni-app/card.vue +122 -0
- package/components/common/RichText/plugins/editable/README.md +137 -0
- package/components/common/RichText/plugins/editable/config.js +15 -0
- package/components/common/RichText/plugins/editable/miniprogram/build.js +813 -0
- package/components/common/RichText/plugins/editable/miniprogram/index.js +551 -0
- package/components/common/RichText/plugins/editable/uni-app/build.js +744 -0
- package/components/common/RichText/plugins/editable/uni-app/index.js +553 -0
- package/components/common/RichText/plugins/emoji/README.md +15 -0
- package/components/common/RichText/plugins/emoji/index.js +203 -0
- package/components/common/RichText/plugins/highlight/README.md +26 -0
- package/components/common/RichText/plugins/highlight/config.js +5 -0
- package/components/common/RichText/plugins/highlight/index.js +96 -0
- package/components/common/RichText/plugins/highlight/miniprogram/build.js +88 -0
- package/components/common/RichText/plugins/highlight/prism.css +125 -0
- package/components/common/RichText/plugins/highlight/prism.min.js +7 -0
- package/components/common/RichText/plugins/highlight/uni-app/build.js +88 -0
- package/components/common/RichText/plugins/img-cache/README.md +24 -0
- package/components/common/RichText/plugins/img-cache/build.js +16 -0
- package/components/common/RichText/plugins/img-cache/index.js +138 -0
- package/components/common/RichText/plugins/latex/README.md +16 -0
- package/components/common/RichText/plugins/latex/build.js +14 -0
- package/components/common/RichText/plugins/latex/index.js +77 -0
- package/components/common/RichText/plugins/latex/katex.css +1070 -0
- package/components/common/RichText/plugins/latex/katex.min.js +1 -0
- package/components/common/RichText/plugins/markdown/README.md +17 -0
- package/components/common/RichText/plugins/markdown/index.js +34 -0
- package/components/common/RichText/plugins/markdown/marked.min.js +6 -0
- package/components/common/RichText/plugins/markdown/miniprogram/build.js +70 -0
- package/components/common/RichText/plugins/markdown/uni-app/build.js +68 -0
- package/components/common/RichText/plugins/search/README.md +46 -0
- package/components/common/RichText/plugins/search/miniprogram/index.js +137 -0
- package/components/common/RichText/plugins/search/uni-app/index.js +132 -0
- package/components/common/RichText/plugins/style/README.md +30 -0
- package/components/common/RichText/plugins/style/index.js +129 -0
- package/components/common/RichText/plugins/style/parser.js +175 -0
- package/components/common/RichText/plugins/template/README.md +2 -0
- package/components/common/RichText/plugins/template/build.js +65 -0
- package/components/common/RichText/plugins/template/index.js +67 -0
- package/components/common/RichText/plugins/txv-video/README.md +18 -0
- package/components/common/RichText/plugins/txv-video/build.js +3 -0
- package/components/common/RichText/plugins/txv-video/index.js +46 -0
- package/components/common/RichText/plugins/txv-video/miniprogram/build.js +6 -0
- package/components/common/RichText/plugins/txv-video/uni-app/build.js +3 -0
- package/components/common/RichText/src/miniprogram/index.js +396 -0
- package/components/common/RichText/src/miniprogram/index.json +6 -0
- package/components/common/RichText/src/miniprogram/index.wxml +7 -0
- package/components/common/RichText/src/miniprogram/index.wxss +13 -0
- package/components/common/RichText/src/miniprogram/node/node.js +247 -0
- package/components/common/RichText/src/miniprogram/node/node.json +6 -0
- package/components/common/RichText/src/miniprogram/node/node.wxml +112 -0
- package/components/common/RichText/src/miniprogram/node/node.wxss +164 -0
- package/components/common/RichText/src/miniprogram/parser.js +1269 -0
- package/components/common/RichText/src/uni-app/components/mp-html/mp-html.vue +498 -0
- package/components/common/RichText/src/uni-app/components/mp-html/node/node.vue +585 -0
- package/components/common/RichText/src/uni-app/components/mp-html/parser.js +1393 -0
- package/components/common/RichText/src/uni-app/static/app-plus/mp-html/js/handler.js +254 -0
- package/components/common/RichText/src/uni-app/static/app-plus/mp-html/js/uni.webview.min.js +1 -0
- package/components/common/RichText/src/uni-app/static/app-plus/mp-html/local.html +33 -0
- package/components/common/RichText/tools/config.js +82 -0
- package/components/common/RichText/tools/converter.js +205 -0
- package/components/common/RichText/tools/ifdef.js +115 -0
- package/components/common/RichText/tools/minifier.js +40 -0
- package/components/common/RichText/tools/plugin.js +248 -0
- package/components/common/Toast/index-web.ts +122 -0
- package/components/common/Toast/index-web.vue +178 -0
- package/components/common/Toast/type.ts +8 -0
- package/components/common/common.scss +59 -0
- package/components/customer-icon.vue +56 -0
- package/components/message-branch.vue +120 -0
- package/components/message-customer-service.vue +114 -0
- package/components/message-form/form-branch.vue +68 -0
- package/components/message-form/form-input.vue +242 -0
- package/components/message-form/index.vue +80 -0
- package/components/message-multi-branch/branch-pc.vue +79 -0
- package/components/message-multi-branch/index.vue +60 -0
- package/components/message-multi-form/component-mobile/form-popup.vue +37 -0
- package/components/message-multi-form/component-mobile/input-mobile.vue +102 -0
- package/components/message-multi-form/component-mobile/label-mobile.vue +32 -0
- package/components/message-multi-form/component-mobile/radios-mobile.vue +161 -0
- package/components/message-multi-form/component-pc/input-pc.vue +93 -0
- package/components/message-multi-form/component-pc/label-pc.vue +33 -0
- package/components/message-multi-form/component-pc/radio-pc.vue +98 -0
- package/components/message-multi-form/form-mobile.vue +385 -0
- package/components/message-multi-form/form-pc.vue +184 -0
- package/components/message-multi-form/index.vue +61 -0
- package/components/message-product-card.vue +129 -0
- package/components/message-rating/index.vue +56 -0
- package/components/message-rating/message-rating-number.vue +247 -0
- package/components/message-rating/message-rating-star.vue +237 -0
- package/components/message-rich-text.vue +155 -0
- package/components/message-robot-welcome.vue +181 -0
- package/components/message-stream.vue +109 -0
- package/constant.ts +122 -0
- package/excluded-list.txt +6 -0
- package/index.ts +30 -0
- package/index.vue +60 -0
- package/interface.ts +176 -0
- package/logger/index.ts +12 -0
- package/logger/main.ts +120 -0
- package/package.json +62 -0
- package/script/fileCopy.js +60 -0
- package/script/syncVersion.js +35 -0
- package/server.ts +128 -0
- package/styles/common.scss +116 -0
- package/tsconfig.json +34 -0
- package/typings.d.ts +20 -0
- package/utils/chatStorage.ts +70 -0
- package/utils/copy-web.ts +141 -0
- package/utils/enableSampleTaskStatus.ts +8 -0
- package/utils/env.ts +15 -0
- package/utils/index.ts +59 -0
- package/utils/utils.ts +162 -0
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="containerClassNameList">
|
|
3
|
+
<div
|
|
4
|
+
:class="{
|
|
5
|
+
'control-reverse': message.flow === 'out',
|
|
6
|
+
}"
|
|
7
|
+
>
|
|
8
|
+
<!-- message-bubble-container -->
|
|
9
|
+
<div class="message-bubble-content">
|
|
10
|
+
<div
|
|
11
|
+
class="message-bubble-main-content"
|
|
12
|
+
:class="[message.flow === 'in' ? '' : 'reverse']"
|
|
13
|
+
>
|
|
14
|
+
<Avatar
|
|
15
|
+
v-if="isPC"
|
|
16
|
+
useSkeletonAnimation
|
|
17
|
+
:url="message.flow=== 'in'? (message.avatar || customerAvatar) : (message.avatar || '')"
|
|
18
|
+
/>
|
|
19
|
+
<main
|
|
20
|
+
:class="['message-body',message.flow==='out' && 'message-body-reverse']"
|
|
21
|
+
@click.stop
|
|
22
|
+
>
|
|
23
|
+
<div
|
|
24
|
+
v-if="
|
|
25
|
+
isPC
|
|
26
|
+
"
|
|
27
|
+
class="message-body-nick-name"
|
|
28
|
+
>
|
|
29
|
+
{{ props.content.showName }}
|
|
30
|
+
</div>
|
|
31
|
+
<div
|
|
32
|
+
:class="[
|
|
33
|
+
'message-body-main',
|
|
34
|
+
message.flow === 'out' && 'message-body-main-reverse',
|
|
35
|
+
]"
|
|
36
|
+
>
|
|
37
|
+
<div
|
|
38
|
+
:class="[
|
|
39
|
+
'blink',
|
|
40
|
+
'message-body-content',
|
|
41
|
+
message.flow === 'out' ? 'content-out' : 'content-in',
|
|
42
|
+
message.hasRiskContent && 'content-has-risk',
|
|
43
|
+
isNoPadding ? 'content-no-padding' : '',
|
|
44
|
+
isNoPadding && isBlink ? 'blink-shadow' : '',
|
|
45
|
+
!isNoPadding && isBlink ? 'blink-content' : '',
|
|
46
|
+
isMultiBranchMsg?'multi-branch-message':'',
|
|
47
|
+
isPC ? '':'body-mobile',
|
|
48
|
+
]"
|
|
49
|
+
>
|
|
50
|
+
<MessageQuote
|
|
51
|
+
v-if="isH5"
|
|
52
|
+
:class="message.flow === 'out' ? 'reverse' : 'flex-row'"
|
|
53
|
+
:message="message"
|
|
54
|
+
@blinkMessage="blinkMessage"
|
|
55
|
+
@scrollTo="scrollTo"
|
|
56
|
+
/>
|
|
57
|
+
<div class="content-main">
|
|
58
|
+
<img
|
|
59
|
+
v-if="
|
|
60
|
+
(message.type === TYPES.MSG_IMAGE ||
|
|
61
|
+
message.type === TYPES.MSG_VIDEO) &&
|
|
62
|
+
message.hasRiskContent
|
|
63
|
+
"
|
|
64
|
+
:class="[
|
|
65
|
+
'message-risk-replace',
|
|
66
|
+
!isPC && 'message-risk-replace-h5',
|
|
67
|
+
]"
|
|
68
|
+
:src="riskImageReplaceUrl"
|
|
69
|
+
>
|
|
70
|
+
<template v-else>
|
|
71
|
+
<slot name="messageElement" />
|
|
72
|
+
<slot name="TUIEmojiPlugin" />
|
|
73
|
+
</template>
|
|
74
|
+
</div>
|
|
75
|
+
<!-- Risk Content Tips -->
|
|
76
|
+
<div
|
|
77
|
+
v-if="message.hasRiskContent"
|
|
78
|
+
class="content-has-risk-tips"
|
|
79
|
+
>
|
|
80
|
+
{{ riskContentText }}
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
<!-- audio unplay mark -->
|
|
84
|
+
<div
|
|
85
|
+
v-if="isDisplayUnplayMark"
|
|
86
|
+
class="audio-unplay-mark"
|
|
87
|
+
/>
|
|
88
|
+
<!-- Send Fail Icon -->
|
|
89
|
+
<div
|
|
90
|
+
v-if="message.status === 'fail' || message.hasRiskContent"
|
|
91
|
+
class="message-label fail"
|
|
92
|
+
@click="resendMessage()"
|
|
93
|
+
>
|
|
94
|
+
!
|
|
95
|
+
</div>
|
|
96
|
+
<!-- Loading Icon -->
|
|
97
|
+
<Icon
|
|
98
|
+
v-if="
|
|
99
|
+
message.status === 'unSend' &&
|
|
100
|
+
needLoadingIconMessageType.includes(message.type)
|
|
101
|
+
"
|
|
102
|
+
class="message-label loading-circle"
|
|
103
|
+
:file="loadingIcon"
|
|
104
|
+
:width="'15px'"
|
|
105
|
+
:height="'15px'"
|
|
106
|
+
/>
|
|
107
|
+
<!-- Read & Unread -->
|
|
108
|
+
<ReadStatus
|
|
109
|
+
class="message-label align-self-bottom"
|
|
110
|
+
:message="shallowCopyMessage(message)"
|
|
111
|
+
/>
|
|
112
|
+
</div>
|
|
113
|
+
</main>
|
|
114
|
+
</div>
|
|
115
|
+
<!-- message extra area -->
|
|
116
|
+
<div v-if="!isH5" class="message-bubble-extra-content">
|
|
117
|
+
<!-- extra: message quote -->
|
|
118
|
+
<MessageQuote
|
|
119
|
+
:class="message.flow === 'out' ? 'reverse' : 'flex-row'"
|
|
120
|
+
:message="message"
|
|
121
|
+
@blinkMessage="blinkMessage"
|
|
122
|
+
@scrollTo="scrollTo"
|
|
123
|
+
/>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
</template>
|
|
129
|
+
|
|
130
|
+
<script lang="ts" setup>
|
|
131
|
+
import vue from '../../../../adapter-vue';
|
|
132
|
+
import TUIChatEngine, {
|
|
133
|
+
TUITranslateService,
|
|
134
|
+
IMessageModel,
|
|
135
|
+
} from '@tencentcloud/chat-uikit-engine';
|
|
136
|
+
import Icon from '../../../common/Icon.vue';
|
|
137
|
+
import ReadStatus from './read-status/index.vue';
|
|
138
|
+
import MessageQuote from './message-quote/index-web.vue';
|
|
139
|
+
import Avatar from '../../../common/Avatar/index.vue';
|
|
140
|
+
import loadingIcon from '../../../../assets/loading.png';
|
|
141
|
+
import customerAvatar from '../../../../assets/customer_avatar.png';
|
|
142
|
+
import { shallowCopyMessage } from '../../../../utils/utils';
|
|
143
|
+
import { isPC,isH5 } from '../../../../utils/env';
|
|
144
|
+
const { computed, toRefs } = vue;
|
|
145
|
+
|
|
146
|
+
interface IProps {
|
|
147
|
+
messageItem: IMessageModel;
|
|
148
|
+
content?: any;
|
|
149
|
+
classNameList?: string[];
|
|
150
|
+
blinkMessageIDList?: string[];
|
|
151
|
+
isAudioPlayed?: boolean | undefined;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
interface IEmits {
|
|
155
|
+
(e: 'resendMessage'): void;
|
|
156
|
+
(e: 'blinkMessage', messageID: string): void;
|
|
157
|
+
// Only for uniapp
|
|
158
|
+
(e: 'scrollTo', scrollHeight: number): void;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const emits = defineEmits<IEmits>();
|
|
162
|
+
|
|
163
|
+
const props = withDefaults(defineProps<IProps>(), {
|
|
164
|
+
messageItem: () => ({} as IMessageModel),
|
|
165
|
+
content: () => ({}),
|
|
166
|
+
isAudioPlayed: false,
|
|
167
|
+
blinkMessageIDList: () => [],
|
|
168
|
+
classNameList: () => [],
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const TYPES = TUIChatEngine.TYPES;
|
|
172
|
+
const riskImageReplaceUrl
|
|
173
|
+
= 'https://web.sdk.qcloud.com/component/TUIKit/assets/has_risk_default.png';
|
|
174
|
+
const needLoadingIconMessageType = [
|
|
175
|
+
TYPES.MSG_LOCATION,
|
|
176
|
+
TYPES.MSG_TEXT,
|
|
177
|
+
TYPES.MSG_CUSTOM,
|
|
178
|
+
TYPES.MSG_MERGER,
|
|
179
|
+
TYPES.MSG_FACE,
|
|
180
|
+
];
|
|
181
|
+
|
|
182
|
+
const { blinkMessageIDList, messageItem: message } = toRefs(props);
|
|
183
|
+
|
|
184
|
+
const isDisplayUnplayMark = computed<boolean>(() => {
|
|
185
|
+
return (
|
|
186
|
+
message.value.flow === 'in'
|
|
187
|
+
&& message.value.status === 'success'
|
|
188
|
+
&& message.value.type === TYPES.MSG_AUDIO
|
|
189
|
+
&& !props.isAudioPlayed
|
|
190
|
+
);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
const containerClassNameList = computed(() => {
|
|
194
|
+
return ['message-bubble', ...props.classNameList];
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// When an emoji is deleted, the `reactionList` will update the corresponding emoji's `totalUserCount`.
|
|
198
|
+
const hasEmojiReaction = computed(() => {
|
|
199
|
+
return message.value?.reactionList.some(
|
|
200
|
+
(item: any) => item.totalUserCount !== 0,
|
|
201
|
+
);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
const isMultiBranchMsg = computed(()=>{
|
|
205
|
+
if(message.value?.type == "TIMCustomElem"){
|
|
206
|
+
if(JSON.parse(message.value.payload.data).src == '32'){
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return false;
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
const isNoPadding = computed(() => {
|
|
217
|
+
return (
|
|
218
|
+
!hasEmojiReaction.value
|
|
219
|
+
&& [TYPES.MSG_IMAGE, TYPES.MSG_VIDEO, TYPES.MSG_MERGER].includes(
|
|
220
|
+
message.value.type,
|
|
221
|
+
)
|
|
222
|
+
);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
const riskContentText = computed<string>(() => {
|
|
226
|
+
let content = TUITranslateService.t('TUIChat.涉及敏感内容') + ', ';
|
|
227
|
+
if (message.value.flow === 'out') {
|
|
228
|
+
content += TUITranslateService.t('TUIChat.发送失败');
|
|
229
|
+
} else {
|
|
230
|
+
content += TUITranslateService.t(
|
|
231
|
+
message.value.type === TYPES.MSG_AUDIO
|
|
232
|
+
? 'TUIChat.无法收听'
|
|
233
|
+
: 'TUIChat.无法查看',
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
return content;
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
const isBlink = computed(() => {
|
|
240
|
+
if (message.value?.ID) {
|
|
241
|
+
return blinkMessageIDList?.value?.includes(message.value.ID);
|
|
242
|
+
}
|
|
243
|
+
return false;
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
function resendMessage() {
|
|
247
|
+
if (!message.value?.hasRiskContent) {
|
|
248
|
+
emits('resendMessage');
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function blinkMessage(messageID: string) {
|
|
253
|
+
emits('blinkMessage', messageID);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function scrollTo(scrollHeight: number) {
|
|
257
|
+
emits('scrollTo', scrollHeight);
|
|
258
|
+
}
|
|
259
|
+
</script>
|
|
260
|
+
|
|
261
|
+
<style lang="scss" scoped>
|
|
262
|
+
* {
|
|
263
|
+
display: flex;
|
|
264
|
+
flex-direction: column;
|
|
265
|
+
min-width: 0;
|
|
266
|
+
box-sizing: border-box;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.message-bubble {
|
|
270
|
+
padding: 10px 15px;
|
|
271
|
+
display: flex;
|
|
272
|
+
flex-direction: row;
|
|
273
|
+
user-select: none;
|
|
274
|
+
-webkit-touch-callout: none;
|
|
275
|
+
-webkit-user-select: none;
|
|
276
|
+
-khtml-user-select: none;
|
|
277
|
+
-moz-user-select: none;
|
|
278
|
+
-ms-user-select: none;
|
|
279
|
+
|
|
280
|
+
&.multiple-selected {
|
|
281
|
+
background-color: #f0f0f0;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.multiple-select-radio {
|
|
285
|
+
margin-right: 12px;
|
|
286
|
+
flex: 0 0 auto;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.control-reverse {
|
|
290
|
+
flex: 1 1 auto;
|
|
291
|
+
flex-direction: row-reverse;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.message-bubble-main-content {
|
|
295
|
+
display: flex;
|
|
296
|
+
flex-direction: row;
|
|
297
|
+
|
|
298
|
+
.message-avatar {
|
|
299
|
+
display: block;
|
|
300
|
+
width: 36px;
|
|
301
|
+
height: 36px;
|
|
302
|
+
border-radius: 5px;
|
|
303
|
+
flex: 0 0 auto;
|
|
304
|
+
}
|
|
305
|
+
.message-body {
|
|
306
|
+
display: flex;
|
|
307
|
+
flex: 0 1 auto;
|
|
308
|
+
flex-direction: column;
|
|
309
|
+
align-items: flex-start;
|
|
310
|
+
margin: 0 8px;
|
|
311
|
+
|
|
312
|
+
&-reverse {
|
|
313
|
+
align-items: flex-end;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.message-body-nick-name {
|
|
317
|
+
display: block;
|
|
318
|
+
margin-bottom: 4px;
|
|
319
|
+
font-size: 12px;
|
|
320
|
+
color: #999;
|
|
321
|
+
max-width: 150px;
|
|
322
|
+
overflow: hidden;
|
|
323
|
+
text-overflow: ellipsis;
|
|
324
|
+
white-space: nowrap;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.message-body-main {
|
|
328
|
+
max-width: 100%;
|
|
329
|
+
display: flex;
|
|
330
|
+
flex-direction: row;
|
|
331
|
+
min-width: 0;
|
|
332
|
+
box-sizing: border-box;
|
|
333
|
+
|
|
334
|
+
&-reverse {
|
|
335
|
+
flex-direction: row-reverse;
|
|
336
|
+
align-items: flex-end;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.audio-unplay-mark {
|
|
340
|
+
flex: 0 0 auto;
|
|
341
|
+
width: 5px;
|
|
342
|
+
height: 5px;
|
|
343
|
+
border-radius: 50%;
|
|
344
|
+
background-color: #f00;
|
|
345
|
+
margin: 5px;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.message-body-content {
|
|
349
|
+
display: flex;
|
|
350
|
+
flex-direction: column;
|
|
351
|
+
min-width: 0;
|
|
352
|
+
box-sizing: border-box;
|
|
353
|
+
padding: 16px;
|
|
354
|
+
font-size: 14px;
|
|
355
|
+
color: #000;
|
|
356
|
+
letter-spacing: 0;
|
|
357
|
+
word-wrap: break-word;
|
|
358
|
+
word-break: break-all;
|
|
359
|
+
position: relative;
|
|
360
|
+
|
|
361
|
+
.content-main {
|
|
362
|
+
box-sizing: border-box;
|
|
363
|
+
display: flex;
|
|
364
|
+
flex-direction: column;
|
|
365
|
+
flex-shrink: 0;
|
|
366
|
+
align-content: flex-start;
|
|
367
|
+
border: 0 solid black;
|
|
368
|
+
margin: 0;
|
|
369
|
+
padding: 0;
|
|
370
|
+
min-width: 0;
|
|
371
|
+
|
|
372
|
+
.message-risk-replace {
|
|
373
|
+
width: 130px;
|
|
374
|
+
height: 130px;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.content-has-risk-tips {
|
|
379
|
+
font-size: 12px;
|
|
380
|
+
color: #fa5151;
|
|
381
|
+
font-family: PingFangSC-Regular;
|
|
382
|
+
margin-top: 5px;
|
|
383
|
+
border-top: 1px solid #e5c7c7;
|
|
384
|
+
padding-top: 5px;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
.content-in {
|
|
390
|
+
background: #f3f4f7;
|
|
391
|
+
border-radius: 0 10px 10px;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.body-mobile {
|
|
395
|
+
background-color: #fff;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.multi-branch-message {
|
|
399
|
+
background-color: transparent;
|
|
400
|
+
border-radius: 0 10px 10px;
|
|
401
|
+
padding: 0px;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.content-out {
|
|
405
|
+
background: linear-gradient(26deg, #1C66E5 2.07%, #03C8FD 152.75%);
|
|
406
|
+
color:#fff;
|
|
407
|
+
border-radius: 10px 0 10px 10px;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
.content-no-padding {
|
|
411
|
+
padding: 0;
|
|
412
|
+
background: transparent;
|
|
413
|
+
border-radius: 10px;
|
|
414
|
+
overflow: hidden;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
.content-no-padding.content-has-risk {
|
|
418
|
+
padding: 12px;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
.content-has-risk {
|
|
422
|
+
background: rgba(250, 81, 81, 0.16);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.blink-shadow {
|
|
426
|
+
@keyframes shadow-blink {
|
|
427
|
+
50% {
|
|
428
|
+
box-shadow: rgba(255, 156, 25, 1) 0 0 10px 0;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
box-shadow: rgba(255, 156, 25, 0) 0 0 10px 0;
|
|
433
|
+
animation: shadow-blink 1s linear 3;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
.blink-content {
|
|
437
|
+
@keyframes reference-blink {
|
|
438
|
+
50% {
|
|
439
|
+
background-color: #ff9c19;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
animation: reference-blink 1s linear 3;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
.message-label {
|
|
447
|
+
align-self: flex-end;
|
|
448
|
+
font-family: PingFangSC-Regular;
|
|
449
|
+
font-size: 12px;
|
|
450
|
+
color: #b6b8ba;
|
|
451
|
+
word-break: keep-all;
|
|
452
|
+
flex: 0 0 auto;
|
|
453
|
+
margin: 0 8px;
|
|
454
|
+
|
|
455
|
+
&.fail {
|
|
456
|
+
width: 15px;
|
|
457
|
+
height: 15px;
|
|
458
|
+
border-radius: 15px;
|
|
459
|
+
background: red;
|
|
460
|
+
color: #fff;
|
|
461
|
+
display: flex;
|
|
462
|
+
justify-content: center;
|
|
463
|
+
align-items: center;
|
|
464
|
+
cursor: pointer;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
&.loading-circle {
|
|
468
|
+
opacity: 0;
|
|
469
|
+
animation: circle-loading 2s linear 1s infinite;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
@keyframes circle-loading {
|
|
473
|
+
0% {
|
|
474
|
+
transform: rotate(0);
|
|
475
|
+
opacity: 1;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
100% {
|
|
479
|
+
opacity: 1;
|
|
480
|
+
transform: rotate(360deg);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
.align-self-bottom {
|
|
486
|
+
align-self: flex-end;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
.reverse {
|
|
493
|
+
display: flex;
|
|
494
|
+
flex-direction: row-reverse;
|
|
495
|
+
justify-content: flex-start;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.message-bubble-extra-content {
|
|
499
|
+
display: flex;
|
|
500
|
+
flex-direction: column;
|
|
501
|
+
align-items: flex-end;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
</style>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="message-image">
|
|
3
|
+
<img
|
|
4
|
+
mode="aspectFit"
|
|
5
|
+
class="message-image"
|
|
6
|
+
:src="url"
|
|
7
|
+
>
|
|
8
|
+
</div>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script lang="ts" setup>
|
|
12
|
+
import vue from '../../../../adapter-vue';
|
|
13
|
+
import { CUSTOM_BIG_EMOJI_URL } from '../../emoji-config';
|
|
14
|
+
const { ref, onMounted } = vue;
|
|
15
|
+
|
|
16
|
+
const props = defineProps({
|
|
17
|
+
content: {
|
|
18
|
+
type: Object,
|
|
19
|
+
default: () => ({}),
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const url = ref(props.content.url);
|
|
24
|
+
|
|
25
|
+
onMounted(() => {
|
|
26
|
+
if (props.content.type === 'custom') {
|
|
27
|
+
if (!CUSTOM_BIG_EMOJI_URL) {
|
|
28
|
+
console.warn(
|
|
29
|
+
'CUSTOM_BIG_EMOJI_URL is required for custom emoji, please check your CUSTOM_BIG_EMOJI_URL.',
|
|
30
|
+
);
|
|
31
|
+
} else {
|
|
32
|
+
url.value = CUSTOM_BIG_EMOJI_URL + props.content.name;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<style lang="scss" scoped>
|
|
39
|
+
@import "../../style/common";
|
|
40
|
+
|
|
41
|
+
.message-image {
|
|
42
|
+
width: 80px;
|
|
43
|
+
height: 80px;
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="['file-message-montainer',messageItem.flow === 'in'?'file-in' :'']"
|
|
4
|
+
:title="TUITranslateService.t('TUIChat.单击下载')"
|
|
5
|
+
@click="download"
|
|
6
|
+
>
|
|
7
|
+
<Icon
|
|
8
|
+
:file="files"
|
|
9
|
+
class="file-icon"
|
|
10
|
+
/>
|
|
11
|
+
<div>
|
|
12
|
+
<div>{{ props.content.name }}</div>
|
|
13
|
+
<div>{{ props.content.size }}</div>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script lang="ts" setup>
|
|
19
|
+
import vue from '../../../../adapter-vue';
|
|
20
|
+
import {
|
|
21
|
+
TUITranslateService,
|
|
22
|
+
IMessageModel,
|
|
23
|
+
} from '@tencentcloud/chat-uikit-engine';
|
|
24
|
+
import Icon from '../../../common/Icon.vue';
|
|
25
|
+
import files from '../../../../assets/files.png';
|
|
26
|
+
import { isUniFrameWork,isWeChat } from '../../../../utils/env';
|
|
27
|
+
import type { IFileMessageContent } from '../../../../interface';
|
|
28
|
+
const { withDefaults } = vue;
|
|
29
|
+
|
|
30
|
+
const props = withDefaults(
|
|
31
|
+
defineProps<{
|
|
32
|
+
content: IFileMessageContent;
|
|
33
|
+
messageItem: IMessageModel;
|
|
34
|
+
}>(),
|
|
35
|
+
{
|
|
36
|
+
content: () => ({} as IFileMessageContent),
|
|
37
|
+
messageItem: () => ({} as IMessageModel),
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const download = () => {
|
|
42
|
+
if (props.messageItem.hasRiskContent || props.messageItem.flow === 'out') {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// If the browser supports fetch, use blob to download, so as to avoid the browser clicking the a tag and jumping to the preview of the new page
|
|
47
|
+
if (!isUniFrameWork && (window as any)?.fetch) {
|
|
48
|
+
const option = {
|
|
49
|
+
mode: 'cors',
|
|
50
|
+
headers: new Headers({
|
|
51
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
52
|
+
}),
|
|
53
|
+
} as RequestInit;
|
|
54
|
+
fetch(props.content.url, option)
|
|
55
|
+
.then(res => res.blob())
|
|
56
|
+
.then((blob) => {
|
|
57
|
+
const a = document.createElement('a');
|
|
58
|
+
const url = window.URL.createObjectURL(blob);
|
|
59
|
+
a.href = url;
|
|
60
|
+
a.download = props.content.name;
|
|
61
|
+
a.click();
|
|
62
|
+
});
|
|
63
|
+
} else if(isWeChat){
|
|
64
|
+
console.log("isWechat",props.content.url)
|
|
65
|
+
|
|
66
|
+
wx.downloadFile({
|
|
67
|
+
url: props.content.url,
|
|
68
|
+
filePath: wx.env.USER_DATA_PATH + '/' + props.content.name,
|
|
69
|
+
success: function (res) {
|
|
70
|
+
var filePath = res.filePath;
|
|
71
|
+
const lastIndex = filePath.lastIndexOf('.');
|
|
72
|
+
const fileType = filePath.substring(lastIndex + 1);
|
|
73
|
+
console.log(fileType)
|
|
74
|
+
wx.openDocument({
|
|
75
|
+
filePath: filePath,
|
|
76
|
+
showMenu:true,
|
|
77
|
+
fileType:fileType,
|
|
78
|
+
success: function (res) {
|
|
79
|
+
console.log('打开文档成功');
|
|
80
|
+
},
|
|
81
|
+
fail:function(){
|
|
82
|
+
console.log("fail")
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}else if(isUniFrameWork){
|
|
88
|
+
const lastIndex = props.content.url.lastIndexOf('.');
|
|
89
|
+
const fileType = props.content.url.substring(lastIndex + 1);
|
|
90
|
+
uni.downloadFile({
|
|
91
|
+
url:props.content.url,
|
|
92
|
+
success:function(res){
|
|
93
|
+
if(res.statusCode == 200){
|
|
94
|
+
console.log(res)
|
|
95
|
+
const tempFilePaths = res.tempFilePath;
|
|
96
|
+
uni.showToast({
|
|
97
|
+
title: '下载成功'+tempFilePaths,
|
|
98
|
+
icon: 'success',
|
|
99
|
+
duration: 2000
|
|
100
|
+
});
|
|
101
|
+
console.log(tempFilePaths);
|
|
102
|
+
uni.openDocument({
|
|
103
|
+
filePath: tempFilePaths,
|
|
104
|
+
fileType: fileType,
|
|
105
|
+
success: function () {
|
|
106
|
+
console.log('打开文档成功');
|
|
107
|
+
},
|
|
108
|
+
fail: function () {
|
|
109
|
+
console.log('打开文档失败');
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
// uni.openDocument({
|
|
116
|
+
// filePath: tempFilePaths[0],
|
|
117
|
+
// fileType: 'pdf',
|
|
118
|
+
// success: function () {
|
|
119
|
+
// console.log('打开文档成功');
|
|
120
|
+
// },
|
|
121
|
+
// fail: function () {
|
|
122
|
+
// console.log('打开文档失败');
|
|
123
|
+
// }
|
|
124
|
+
// });
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
else {
|
|
128
|
+
console.log("no window here")
|
|
129
|
+
const a = document.createElement('a');
|
|
130
|
+
a.href = props.content.url;
|
|
131
|
+
a.target = '_blank';
|
|
132
|
+
a.download = props.content.name;
|
|
133
|
+
a.click();
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
</script>
|
|
137
|
+
<style lang="scss" scoped>
|
|
138
|
+
@import "../../style/common";
|
|
139
|
+
.file-in{
|
|
140
|
+
cursor: pointer;
|
|
141
|
+
}
|
|
142
|
+
.file-message-montainer {
|
|
143
|
+
display: flex;
|
|
144
|
+
flex-direction: row;
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
.file-icon {
|
|
148
|
+
margin: auto 8px;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
</style>
|