From 2fcb54b57661a935cbe650610e31929e4af9dbfd Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 14 Mar 2021 00:58:39 +0800 Subject: [PATCH] 增加数据库文档的 html、word、markdown 的导出 --- ruoyi-ui/src/api/infra/dbDoc.js | 16 ++++++++++++++++ ruoyi-ui/src/main.js | 8 +++++++- ruoyi-ui/src/utils/ruoyi.js | 15 +++++++++++++++ ruoyi-ui/src/views/tool/dbDoc/index.vue | 42 +++++++++++++++++++++++++++++++++++++----- src/main/java/cn/iocoder/dashboard/modules/infra/controller/doc/InfDbDocController.java | 20 ++++++-------------- 5 files changed, 81 insertions(+), 20 deletions(-) diff --git a/ruoyi-ui/src/api/infra/dbDoc.js b/ruoyi-ui/src/api/infra/dbDoc.js index de54981..015c6d7 100644 --- a/ruoyi-ui/src/api/infra/dbDoc.js +++ b/ruoyi-ui/src/api/infra/dbDoc.js @@ -8,3 +8,19 @@ export function exportHtml() { responseType: 'blob' }) } + +export function exportWord() { + return request({ + url: '/infra/db-doc/export-word', + method: 'get', + responseType: 'blob' + }) +} + +export function exportMarkdown() { + return request({ + url: '/infra/db-doc/export-markdown', + method: 'get', + responseType: 'blob' + }) +} diff --git a/ruoyi-ui/src/main.js b/ruoyi-ui/src/main.js index 91556bf..e1f067f 100644 --- a/ruoyi-ui/src/main.js +++ b/ruoyi-ui/src/main.js @@ -25,7 +25,10 @@ import { download, handleTree, downloadExcel, - downloadZip + downloadWord, + downloadZip, + downloadHtml, + downloadMarkdown, } from "@/utils/ruoyi"; import Pagination from "@/components/Pagination"; // 自定义表格工具扩展 @@ -48,6 +51,9 @@ Vue.prototype.getDictDataLabel = getDictDataLabel Vue.prototype.DICT_TYPE = DICT_TYPE Vue.prototype.download = download Vue.prototype.downloadExcel = downloadExcel +Vue.prototype.downloadWord = downloadWord +Vue.prototype.downloadHtml = downloadHtml +Vue.prototype.downloadMarkdown = downloadMarkdown Vue.prototype.downloadZip = downloadZip Vue.prototype.handleTree = handleTree diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js index 17f235f..82f8aec 100644 --- a/ruoyi-ui/src/utils/ruoyi.js +++ b/ruoyi-ui/src/utils/ruoyi.js @@ -120,11 +120,26 @@ export function downloadExcel(data, fileName) { download0(data, fileName, 'application/vnd.ms-excel'); } +// 下载 Word 方法 +export function downloadWord(data, fileName) { + download0(data, fileName, 'application/msword'); +} + // 下载 Zip 方法 export function downloadZip(data, fileName) { download0(data, fileName, 'application/zip'); } +// 下载 Html 方法 +export function downloadHtml(data, fileName) { + download0(data, fileName, 'text/html'); +} + +// 下载 Markdown 方法 +export function downloadMarkdown(data, fileName) { + download0(data, fileName, 'text/markdown'); +} + function download0(data, fileName, mineType) { // 创建 blob let blob = new Blob([data], {type: mineType}); diff --git a/ruoyi-ui/src/views/tool/dbDoc/index.vue b/ruoyi-ui/src/views/tool/dbDoc/index.vue index e0c7156..274d137 100644 --- a/ruoyi-ui/src/views/tool/dbDoc/index.vue +++ b/ruoyi-ui/src/views/tool/dbDoc/index.vue @@ -1,10 +1,21 @@