index.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10" class="mb8">
  4. <el-col :span="1.5">
  5. <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleExportHtml">导出 HTML</el-button>
  6. <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleExportWord">导出 Word</el-button>
  7. <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleExportMarkdown">导出 Markdown</el-button>
  8. </el-col>
  9. </el-row>
  10. <!-- 展示文档 -->
  11. <div v-loading="loading" :style="'height:'+ height">
  12. <iframe :src="src" frameborder="no" style="width: 100%;height: 100%" scrolling="auto" />
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. import { exportHtml, exportWord, exportMarkdown} from "@/api/infra/dbDoc";
  18. export default {
  19. name: "DBDoc",
  20. data() {
  21. return {
  22. height: document.documentElement.clientHeight - 94.5 + "px;",
  23. loading: true,
  24. src: undefined,
  25. };
  26. },
  27. mounted: function() {
  28. setTimeout(() => {
  29. this.loading = false;
  30. }, 230);
  31. const that = this;
  32. window.onresize = function temp() {
  33. that.height = document.documentElement.clientHeight - 94.5 + "px;";
  34. };
  35. },
  36. created() {
  37. // 加载 Html,进行预览
  38. exportHtml().then(response => {
  39. let blob = new Blob([response], {type : 'text/html'});
  40. this.src = window.URL.createObjectURL(blob);
  41. })
  42. },
  43. methods: {
  44. /** 处理导出 HTML */
  45. handleExportHtml() {
  46. exportHtml().then(response => {
  47. this.downloadHtml(response, '数据库文档.html');
  48. })
  49. },
  50. /** 处理导出 Word */
  51. handleExportWord() {
  52. exportWord().then(response => {
  53. this.downloadWord(response, '数据库文档.doc');
  54. })
  55. },
  56. /** 处理导出 Markdown */
  57. handleExportMarkdown() {
  58. exportMarkdown().then(response => {
  59. this.downloadMarkdown(response, '数据库文档.md');
  60. })
  61. }
  62. }
  63. };
  64. </script>