diff --git a/src/api/generator.ts b/src/api/generator.ts index 4686ad22d59635dbb72ca25cb6b74301a39ecc23..dc10cdae3afed0c3f6f2922231dbef6e3468689c 100644 --- a/src/api/generator.ts +++ b/src/api/generator.ts @@ -38,6 +38,26 @@ class GeneratorAPI { method: "get", }); } + /** + * 下载 ZIP 文件 + * @param url + * @param fileName + */ + static downloadZip(tableName: string, fileName?: string) { + return request({ + url: `${GENERATOR_BASE_URL}/${tableName}/downloadZip`, + method: "get", + responseType: "blob", + }).then((res) => { + const blob = new Blob([res.data], { type: "application/zip" }); + const a = document.createElement("a"); + const url = window.URL.createObjectURL(blob); + a.href = url; + a.download = fileName || "下载文件.zip"; + a.click(); + window.URL.revokeObjectURL(url); + }); + } } export default GeneratorAPI; diff --git a/src/views/generator/index.vue b/src/views/generator/index.vue index fc4ae20c1bad75249664038c3270e1e3bf7361e7..a970af114e2ee84c0934e8ef1fca4c19a3e62807 100644 --- a/src/views/generator/index.vue +++ b/src/views/generator/index.vue @@ -1,12 +1,12 @@ @@ -223,9 +223,9 @@ @@ -296,18 +296,20 @@
- - + + + + 一键复制
@@ -317,21 +319,27 @@ -