Răsfoiți Sursa

feat: 支持附件上传与接收

cuiyalong 7 luni în urmă
părinte
comite
80e23ac99f

+ 3 - 1
src/components/chart-container/index.vue

@@ -92,7 +92,9 @@ export default {
       list.forEach(v => {
         if (isJSON(v.content) || v.type === 3 || v.type === 4) { // type:3图片4附件
           try {
-            v.content = JSON.parse(v.content.replace(/"/g, '"'))
+            if (typeof v.content === 'string') {
+              v.content = JSON.parse(v.content.replace(/"/g, '"'))
+            }
           } catch (error) {}
         }
         // 需要处理个人信息

+ 1 - 1
src/components/chart-item/index.vue

@@ -25,7 +25,7 @@
             </div>
             <!-- 附件 -->
             <a v-else-if="type === 4" :title="content.filename" :href="content.fid ? content.ossurl + '/' + content.fid : content.ossurl" class="msg-box-content msg-file-box" target="_blank" :class="{ 'self-file': fool === 1 }"
-              @contextmenu.prevent.stop="rightClick($event)">
+              @contextmenu.prevent.stop="rightClick($event)" :download="content.filename">
               <div>
                 <p class="file-name">{{ content.filename }}</p>
                 <p class="file-size">{{ sizeFormatter(content.size) }}</p>

+ 1 - 1
src/views/ChatView.vue

@@ -43,7 +43,7 @@
                   <a v-else-if="item.title === '附件' || item.type === 4"
                     :href="item.content.fid ? item.content.ossurl + '/' + item.content.fid : item.content.ossurl"
                     class="msg-file-box" target="_blank" :class="{ 'self-file': item.fool === 1 }"
-                    @contextmenu.prevent.stop="rightClick($event, item)">
+                    @contextmenu.prevent.stop="rightClick($event, item)" :download="item.content.filename">
                     <div>
                       <p class="file-name">{{ item.content.filename }}</p>
                       <p class="file-size">{{ sizeFormatter(item.content.size) }}</p>

+ 5 - 3
src/views/CustomerServiceView.vue

@@ -175,7 +175,7 @@ export default {
     }),
     ...mapGetters('webSocket', ['socketMsg', 'socketStatus']),
     getActionList () {
-      return ['image']
+      return ['image', 'attach']
     },
     // 会话消息
     getMsgList () {
@@ -183,7 +183,9 @@ export default {
       list.forEach(v => {
         if (isJSON(v.content) || v.type >= 3) {
           try {
-            v.content = JSON.parse(v.content.replace(/&#34;/g, '"'))
+            if (typeof v.content === 'string') {
+              v.content = JSON.parse(v.content.replace(/&#34;/g, '"'))
+            }
           } catch (error) { console.log(error) }
         }
       })
@@ -969,7 +971,7 @@ export default {
         itemType: 5,
         link: '',
         fool: 1,
-        type: 3,
+        type: 4,
         content: JSON.stringify(data)
       }
       const socketParams = {

+ 1 - 1
src/views/CustomerView.vue

@@ -186,7 +186,7 @@ export default {
     // 聊天框操作配置项
     getActionList () {
       if (this.other.userType === 1) {
-        return ['image', 'rate']
+        return ['image', 'rate', 'attach']
       } else {
         return ['image', 'attach']
       }