Browse Source

发送文件

master
xie.bx 3 years ago
parent
commit
d60e95955d
  1. 5
      im-platform/src/main/resources/application.yml
  2. 18
      im-ui/src/components/chat/MessageItem.vue
  3. 4
      im-ui/src/components/common/FileUpload.vue
  4. 1
      im-ui/src/view/Chat.vue

5
im-platform/src/main/resources/application.yml

@ -14,6 +14,11 @@ spring:
port: 6379 port: 6379
database: 1 database: 1
servlet:
multipart:
max-file-size: 50MB
max-request-size: 50MB
mybatis-plus: mybatis-plus:
configuration: configuration:
# 是否开启自动驼峰命名规则(camel case)映射,即从经典数据库列名 A_COLUMN(下划线命名) 到经典 Java 属性名 aColumn(驼峰命名) 的类似映射 # 是否开启自动驼峰命名规则(camel case)映射,即从经典数据库列名 A_COLUMN(下划线命名) 到经典 Java 属性名 aColumn(驼峰命名) 的类似映射

18
im-ui/src/components/chat/MessageItem.vue

@ -19,17 +19,16 @@
<span title="发送失败" v-show="loadFail" @click="handleSendFail" class="send-fail el-icon-warning"></span> <span title="发送失败" v-show="loadFail" @click="handleSendFail" class="send-fail el-icon-warning"></span>
</div> </div>
<div class="im-msg-file" v-if="msgInfo.type==2"> <div class="im-msg-file" v-if="msgInfo.type==2">
<div class="im-file-box"> <div class="im-file-box" v-loading="loading">
<div class="im-file-info"> <div class="im-file-info">
<el-link class="im-file-name" underline="true" target="_blank" type="primary" :href="data.url">{{data.name}}</el-link> <el-link class="im-file-name" :underline="true" target="_blank" type="primary" :href="data.url">{{data.name}}</el-link>
<div class="im-file-size">{{fileSize}}</div> <div class="im-file-size">{{fileSize}}</div>
</div> </div>
<div class="im-file-icon"> <div class="im-file-icon">
<span type="primary" class="el-icon-document"></span> <span type="primary" class="el-icon-document"></span>
</div> </div>
</div> </div>
<span title="发送失败" v-show="loadFail" @click="handleSendFail" class="send-fail el-icon-warning"></span>
</div> </div>
</div> </div>
</div> </div>
@ -66,7 +65,7 @@
}, },
methods:{ methods:{
handleSendFail(){ handleSendFail(){
this.$message.error("该文件已上传失败,目前不支持自动重新发送,建议手动重新发送") this.$message.error("该文件已发送失败,目前不支持自动重新发送,建议手动重新发送")
} }
}, },
computed:{ computed:{
@ -171,7 +170,7 @@
} }
.send-fail{ .send-fail{
color: red; color: #e60c0c;
font-size: 30px; font-size: 30px;
cursor: pointer; cursor: pointer;
margin: 0 20px; margin: 0 20px;
@ -213,6 +212,13 @@
} }
} }
.send-fail{
color: #e60c0c;
font-size: 30px;
cursor: pointer;
margin: 0 20px;
}
} }
} }
} }

4
im-ui/src/components/common/FileUpload.vue

@ -3,6 +3,7 @@
:accept="fileTypes==null?'':fileTypes.join(',')" :accept="fileTypes==null?'':fileTypes.join(',')"
:show-file-list="false" :show-file-list="false"
:on-success="handleSuccess" :on-success="handleSuccess"
:on-error="handleError"
:before-upload="beforeUpload"> :before-upload="beforeUpload">
<slot></slot> <slot></slot>
</el-upload> </el-upload>
@ -44,6 +45,9 @@
this.$emit("fail", res, file); this.$emit("fail", res, file);
} }
}, },
handleError(err,file){
this.$emit("fail", err, file);
},
beforeUpload(file) { beforeUpload(file) {
// //
if(this.fileTypes && this.fileTypes.length > 0){ if(this.fileTypes && this.fileTypes.length > 0){

1
im-ui/src/view/Chat.vue

@ -190,7 +190,6 @@
content: JSON.stringify(data), content: JSON.stringify(data),
loadStatus: "ok" loadStatus: "ok"
} }
console.log(info);
this.$store.commit("handleFileUpload", info); this.$store.commit("handleFileUpload", info);
}) })
}, },

Loading…
Cancel
Save