|
|
@@ -14,6 +14,7 @@ import send from "@/assets/images/send.png";
|
|
|
import downFile from "@/assets/images/down-file.png";
|
|
|
import forwardFile from "@/assets/images/forward-file.png";
|
|
|
import sendFile from "@/assets/images/send-file.png";
|
|
|
+import myfile from '@/api/myfile/myfile'
|
|
|
import { parseTime } from "@/utils/ruoyi";
|
|
|
import store from "@/store";
|
|
|
import {
|
|
|
@@ -363,8 +364,9 @@ const forwardClick = async (indexs, docIds) => {
|
|
|
};
|
|
|
const forwardChangeMsg = async (val) => {};
|
|
|
//点击下载
|
|
|
-const downClick = async (fileId) => {
|
|
|
- location.href = `${import.meta.env.VITE_APP_BASE_API}/api/download/${fileId}`;
|
|
|
+const downClick = async (file) => {
|
|
|
+ // location.href = `${import.meta.env.VITE_APP_BASE_API}/api/download/${fileId}`;
|
|
|
+downLoadfile(file)
|
|
|
};
|
|
|
//搜索的点击事件
|
|
|
const SearchChat = () => {
|
|
|
@@ -381,6 +383,32 @@ const formatText = (text) => {
|
|
|
const formattedText = text.replace(/\n/g, "<br>");
|
|
|
return formattedText;
|
|
|
};
|
|
|
+ // 文件下载
|
|
|
+ const downLoadfile = (file)=>{
|
|
|
+ console.log('file',file);
|
|
|
+ myfile.fileDown(file.docId).then(res=>{
|
|
|
+ var reader = new FileReader();
|
|
|
+ reader.onloadend = function(event){
|
|
|
+ //event 就是你要的返回内容
|
|
|
+ //因为返回的报错格式是字符串,手动转换成对象,转换成功表示请求失败
|
|
|
+ //转换失败就意味着你拿到的result是文件流,那么直接手动下载就好
|
|
|
+ try{
|
|
|
+ let data = JSON.parse(event.target.result)
|
|
|
+ }catch(err){
|
|
|
+ const link = document.createElement('a'); // 创建a标签
|
|
|
+ let blob = new Blob([res]);
|
|
|
+ link.style.display = 'none';
|
|
|
+ link.href = URL.createObjectURL(blob); // 创建下载的链接
|
|
|
+ link.setAttribute('download',file.fileName); // 给下载后的文件命名
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click(); // 点击下载
|
|
|
+ document.body.removeChild(link); // 完成移除元素
|
|
|
+ window.URL.revokeObjectURL(link.href); // 释放blob对象
|
|
|
+ }
|
|
|
+ };
|
|
|
+ reader.readAsText(res);
|
|
|
+ })
|
|
|
+ }
|
|
|
// 滚动翻页========
|
|
|
onMounted(() => {
|
|
|
getMsgList();
|
|
|
@@ -668,7 +696,7 @@ onMounted(() => {
|
|
|
class="zhuanfa downf"
|
|
|
alt="下载"
|
|
|
v-if="record.isForward"
|
|
|
- @click="downClick(record.file.fileId)"
|
|
|
+ @click="downClick(record.file)"
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|