diff --git a/src/views/test/download/downloadUtil.ts b/src/views/test/download/downloadUtil.ts new file mode 100644 index 0000000..c0abc67 --- /dev/null +++ b/src/views/test/download/downloadUtil.ts @@ -0,0 +1,27 @@ +export const downloadBlob = (blob: Blob, name: string) => { + // 创建一个下载链接并模拟点击 + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = name; + document.body.appendChild(a); + a.click(); + + // 清理 + document.body.removeChild(a); + URL.revokeObjectURL(url); +}; + +/** + * 导出图像 + * @param uri + * @param name + */ +export function downloadURI(uri: string, name: string) { + const link = document.createElement('a'); + link.download = name; + link.href = uri; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); +} diff --git a/src/views/test/download/index.vue b/src/views/test/download/index.vue new file mode 100644 index 0000000..be9df3f --- /dev/null +++ b/src/views/test/download/index.vue @@ -0,0 +1,52 @@ + + +