Browse Source

漏提api文件

main
pixel 5 years ago
parent
commit
d00be180c8
  1. 16
      QMPlusVuePage/src/api/fileUploadAndDownload.js
  2. 19
      QMPlusVuePage/src/utils/downloadImg.js

16
QMPlusVuePage/src/api/fileUploadAndDownload.js

@ -0,0 +1,16 @@
import service from '@/utils/request'
// @Tags FileUploadAndDownload
// @Summary 分页文件列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body modelInterface.PageInfo true "分页获取文件户列表"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /fileUploadAndDownload/getFileList [post]
export const getFileList = (data) => {
return service({
url: "/fileUploadAndDownload/getFileList",
method: "post",
data
})
}

19
QMPlusVuePage/src/utils/downloadImg.js

@ -0,0 +1,19 @@
export const downloadImage = (imgsrc, name) => { //下载图片地址和图片名
var image = new Image();
image.setAttribute("crossOrigin", "anonymous");
image.onload = function() {
var canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
var context = canvas.getContext("2d");
context.drawImage(image, 0, 0, image.width, image.height);
var url = canvas.toDataURL("image/png"); //得到图片的base64编码数据
var a = document.createElement("a"); // 生成一个a元素
var event = new MouseEvent("click"); // 创建一个单击事件
a.download = name || "photo"; // 设置图片名称
a.href = url; // 将生成的URL设置为a.href属性
a.dispatchEvent(event); // 触发a的单击事件
};
image.src = imgsrc;
}
Loading…
Cancel
Save