正在显示
20 个修改的文件
包含
70 行增加
和
82 行删除
| @@ -211,6 +211,7 @@ public class FileUtils | @@ -211,6 +211,7 @@ public class FileUtils | ||
| 211 | .append(percentEncodedFileName); | 211 | .append(percentEncodedFileName); |
| 212 | 212 | ||
| 213 | response.setHeader("Content-disposition", contentDispositionValue.toString()); | 213 | response.setHeader("Content-disposition", contentDispositionValue.toString()); |
| 214 | + response.setHeader("download-filename", percentEncodedFileName); | ||
| 214 | } | 215 | } |
| 215 | 216 | ||
| 216 | /** | 217 | /** |
| @@ -107,8 +107,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter | @@ -107,8 +107,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter | ||
| 107 | "/**/*.js", | 107 | "/**/*.js", |
| 108 | "/profile/**" | 108 | "/profile/**" |
| 109 | ).permitAll() | 109 | ).permitAll() |
| 110 | - .antMatchers("/common/download**").anonymous() | ||
| 111 | - .antMatchers("/common/download/resource**").anonymous() | ||
| 112 | .antMatchers("/swagger-ui.html").anonymous() | 110 | .antMatchers("/swagger-ui.html").anonymous() |
| 113 | .antMatchers("/swagger-resources/**").anonymous() | 111 | .antMatchers("/swagger-resources/**").anonymous() |
| 114 | .antMatchers("/webjars/**").anonymous() | 112 | .antMatchers("/webjars/**").anonymous() |
| @@ -567,7 +567,7 @@ export default { | @@ -567,7 +567,7 @@ export default { | ||
| 567 | this.exportLoading = true; | 567 | this.exportLoading = true; |
| 568 | return export${BusinessName}(queryParams); | 568 | return export${BusinessName}(queryParams); |
| 569 | }).then(response => { | 569 | }).then(response => { |
| 570 | - this.download(response.msg); | 570 | + this.#[[$download]]#.name(response.msg); |
| 571 | this.exportLoading = false; | 571 | this.exportLoading = false; |
| 572 | }).catch(() => {}); | 572 | }).catch(() => {}); |
| 573 | } | 573 | } |
| @@ -17,7 +17,7 @@ import './assets/icons' // icon | @@ -17,7 +17,7 @@ import './assets/icons' // icon | ||
| 17 | import './permission' // permission control | 17 | import './permission' // permission control |
| 18 | import { getDicts } from "@/api/system/dict/data"; | 18 | import { getDicts } from "@/api/system/dict/data"; |
| 19 | import { getConfigKey } from "@/api/system/config"; | 19 | import { getConfigKey } from "@/api/system/config"; |
| 20 | -import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/ruoyi"; | 20 | +import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/ruoyi"; |
| 21 | // 分页组件 | 21 | // 分页组件 |
| 22 | import Pagination from "@/components/Pagination"; | 22 | import Pagination from "@/components/Pagination"; |
| 23 | // 自定义表格工具组件 | 23 | // 自定义表格工具组件 |
| @@ -43,7 +43,6 @@ Vue.prototype.resetForm = resetForm | @@ -43,7 +43,6 @@ Vue.prototype.resetForm = resetForm | ||
| 43 | Vue.prototype.addDateRange = addDateRange | 43 | Vue.prototype.addDateRange = addDateRange |
| 44 | Vue.prototype.selectDictLabel = selectDictLabel | 44 | Vue.prototype.selectDictLabel = selectDictLabel |
| 45 | Vue.prototype.selectDictLabels = selectDictLabels | 45 | Vue.prototype.selectDictLabels = selectDictLabels |
| 46 | -Vue.prototype.download = download | ||
| 47 | Vue.prototype.handleTree = handleTree | 46 | Vue.prototype.handleTree = handleTree |
| 48 | 47 | ||
| 49 | // 全局组件挂载 | 48 | // 全局组件挂载 |
ruoyi-ui/src/plugins/download.js
0 → 100644
| 1 | +import { saveAs } from 'file-saver' | ||
| 2 | +import axios from 'axios' | ||
| 3 | +import { getToken } from '@/utils/auth' | ||
| 4 | + | ||
| 5 | +const baseURL = process.env.VUE_APP_BASE_API | ||
| 6 | + | ||
| 7 | +export default { | ||
| 8 | + name(name, isDelete = true) { | ||
| 9 | + var url = baseURL + "/common/download?fileName=" + encodeURI(name) + "&delete=" + isDelete | ||
| 10 | + axios({ | ||
| 11 | + method: 'get', | ||
| 12 | + url: url, | ||
| 13 | + responseType: 'blob', | ||
| 14 | + headers: { 'Authorization': 'Bearer ' + getToken() } | ||
| 15 | + }).then(res => { | ||
| 16 | + const blob = new Blob([res.data]) | ||
| 17 | + this.saveAs(blob, decodeURI(res.headers['download-filename'])) | ||
| 18 | + }) | ||
| 19 | + }, | ||
| 20 | + resource(resource) { | ||
| 21 | + var url = baseURL + "/common/download/resource?resource=" + encodeURI(resource); | ||
| 22 | + axios({ | ||
| 23 | + method: 'get', | ||
| 24 | + url: url, | ||
| 25 | + responseType: 'blob', | ||
| 26 | + headers: { 'Authorization': 'Bearer ' + getToken() } | ||
| 27 | + }).then(res => { | ||
| 28 | + const blob = new Blob([res.data]) | ||
| 29 | + this.saveAs(blob, decodeURI(res.headers['download-filename'])) | ||
| 30 | + }) | ||
| 31 | + }, | ||
| 32 | + zip(url, name) { | ||
| 33 | + var url = baseURL + url | ||
| 34 | + axios({ | ||
| 35 | + method: 'get', | ||
| 36 | + url: url, | ||
| 37 | + responseType: 'blob', | ||
| 38 | + headers: { 'Authorization': 'Bearer ' + getToken() } | ||
| 39 | + }).then(res => { | ||
| 40 | + const blob = new Blob([res.data], { type: 'application/zip' }) | ||
| 41 | + this.saveAs(blob, name) | ||
| 42 | + }) | ||
| 43 | + }, | ||
| 44 | + saveAs(text, name, opts) { | ||
| 45 | + saveAs(text, name, opts); | ||
| 46 | + } | ||
| 47 | +} | ||
| 48 | + |
| 1 | import cache from './cache' | 1 | import cache from './cache' |
| 2 | import modal from './modal' | 2 | import modal from './modal' |
| 3 | +import download from './download' | ||
| 3 | 4 | ||
| 4 | export default { | 5 | export default { |
| 5 | install(Vue) { | 6 | install(Vue) { |
| @@ -7,5 +8,7 @@ export default { | @@ -7,5 +8,7 @@ export default { | ||
| 7 | Vue.prototype.$cache = cache | 8 | Vue.prototype.$cache = cache |
| 8 | // 模态框对象 | 9 | // 模态框对象 |
| 9 | Vue.prototype.$modal = modal | 10 | Vue.prototype.$modal = modal |
| 11 | + // 下载文件 | ||
| 12 | + Vue.prototype.$download = download | ||
| 10 | } | 13 | } |
| 11 | } | 14 | } |
| @@ -3,8 +3,6 @@ | @@ -3,8 +3,6 @@ | ||
| 3 | * Copyright (c) 2019 ruoyi | 3 | * Copyright (c) 2019 ruoyi |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | -const baseURL = process.env.VUE_APP_BASE_API | ||
| 7 | - | ||
| 8 | // 日期格式化 | 6 | // 日期格式化 |
| 9 | export function parseTime(time, pattern) { | 7 | export function parseTime(time, pattern) { |
| 10 | if (arguments.length === 0 || !time) { | 8 | if (arguments.length === 0 || !time) { |
| @@ -95,11 +93,6 @@ export function selectDictLabels(datas, value, separator) { | @@ -95,11 +93,6 @@ export function selectDictLabels(datas, value, separator) { | ||
| 95 | return actions.join('').substring(0, actions.join('').length - 1); | 93 | return actions.join('').substring(0, actions.join('').length - 1); |
| 96 | } | 94 | } |
| 97 | 95 | ||
| 98 | -// 通用下载方法 | ||
| 99 | -export function download(fileName) { | ||
| 100 | - window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true; | ||
| 101 | -} | ||
| 102 | - | ||
| 103 | // 字符串格式化(%s ) | 96 | // 字符串格式化(%s ) |
| 104 | export function sprintf(str) { | 97 | export function sprintf(str) { |
| 105 | var args = arguments, flag = true, i = 1; | 98 | var args = arguments, flag = true, i = 1; |
ruoyi-ui/src/utils/zipdownload.js
已删除
100644 → 0
| 1 | -import axios from 'axios' | ||
| 2 | -import { getToken } from '@/utils/auth' | ||
| 3 | - | ||
| 4 | -const mimeMap = { | ||
| 5 | - xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', | ||
| 6 | - zip: 'application/zip' | ||
| 7 | -} | ||
| 8 | - | ||
| 9 | -const baseUrl = process.env.VUE_APP_BASE_API | ||
| 10 | -export function downLoadZip(str, filename) { | ||
| 11 | - var url = baseUrl + str | ||
| 12 | - axios({ | ||
| 13 | - method: 'get', | ||
| 14 | - url: url, | ||
| 15 | - responseType: 'blob', | ||
| 16 | - headers: { 'Authorization': 'Bearer ' + getToken() } | ||
| 17 | - }).then(res => { | ||
| 18 | - resolveBlob(res, mimeMap.zip) | ||
| 19 | - }) | ||
| 20 | -} | ||
| 21 | -/** | ||
| 22 | - * 解析blob响应内容并下载 | ||
| 23 | - * @param {*} res blob响应内容 | ||
| 24 | - * @param {String} mimeType MIME类型 | ||
| 25 | - */ | ||
| 26 | -export function resolveBlob(res, mimeType) { | ||
| 27 | - const aLink = document.createElement('a') | ||
| 28 | - var blob = new Blob([res.data], { type: mimeType }) | ||
| 29 | - // //从response的headers中获取filename, 后端response.setHeader("Content-disposition", "attachment; filename=xxxx.docx") 设置的文件名; | ||
| 30 | - var patt = new RegExp('filename=([^;]+\\.[^\\.;]+);*') | ||
| 31 | - var contentDisposition = decodeURI(res.headers['content-disposition']) | ||
| 32 | - var result = patt.exec(contentDisposition) | ||
| 33 | - var fileName = result[1] | ||
| 34 | - fileName = fileName.replace(/\"/g, '') | ||
| 35 | - aLink.style.display = 'none' | ||
| 36 | - aLink.href = URL.createObjectURL(blob) | ||
| 37 | - aLink.setAttribute('download', fileName) // 设置下载文件名称 | ||
| 38 | - document.body.appendChild(aLink) | ||
| 39 | - aLink.click() | ||
| 40 | - URL.revokeObjectURL(aLink.href);//清除引用 | ||
| 41 | - document.body.removeChild(aLink); | ||
| 42 | -} |
| @@ -515,7 +515,7 @@ export default { | @@ -515,7 +515,7 @@ export default { | ||
| 515 | this.exportLoading = true; | 515 | this.exportLoading = true; |
| 516 | return exportJob(queryParams); | 516 | return exportJob(queryParams); |
| 517 | }).then(response => { | 517 | }).then(response => { |
| 518 | - this.download(response.msg); | 518 | + this.$download.name(response.msg); |
| 519 | this.exportLoading = false; | 519 | this.exportLoading = false; |
| 520 | }).catch(() => {}); | 520 | }).catch(() => {}); |
| 521 | } | 521 | } |
| @@ -298,7 +298,7 @@ export default { | @@ -298,7 +298,7 @@ export default { | ||
| 298 | this.exportLoading = true; | 298 | this.exportLoading = true; |
| 299 | return exportJobLog(queryParams); | 299 | return exportJobLog(queryParams); |
| 300 | }).then(response => { | 300 | }).then(response => { |
| 301 | - this.download(response.msg); | 301 | + this.$download.name(response.msg); |
| 302 | this.exportLoading = false; | 302 | this.exportLoading = false; |
| 303 | }).catch(() => {}); | 303 | }).catch(() => {}); |
| 304 | } | 304 | } |
| @@ -221,7 +221,7 @@ export default { | @@ -221,7 +221,7 @@ export default { | ||
| 221 | this.exportLoading = true; | 221 | this.exportLoading = true; |
| 222 | return exportLogininfor(queryParams); | 222 | return exportLogininfor(queryParams); |
| 223 | }).then(response => { | 223 | }).then(response => { |
| 224 | - this.download(response.msg); | 224 | + this.$download.name(response.msg); |
| 225 | this.exportLoading = false; | 225 | this.exportLoading = false; |
| 226 | }).catch(() => {}); | 226 | }).catch(() => {}); |
| 227 | } | 227 | } |
| @@ -308,7 +308,7 @@ export default { | @@ -308,7 +308,7 @@ export default { | ||
| 308 | this.exportLoading = true; | 308 | this.exportLoading = true; |
| 309 | return exportOperlog(queryParams); | 309 | return exportOperlog(queryParams); |
| 310 | }).then(response => { | 310 | }).then(response => { |
| 311 | - this.download(response.msg); | 311 | + this.$download.name(response.msg); |
| 312 | this.exportLoading = false; | 312 | this.exportLoading = false; |
| 313 | }).catch(() => {}); | 313 | }).catch(() => {}); |
| 314 | } | 314 | } |
| @@ -339,7 +339,7 @@ export default { | @@ -339,7 +339,7 @@ export default { | ||
| 339 | this.exportLoading = true; | 339 | this.exportLoading = true; |
| 340 | return exportConfig(queryParams); | 340 | return exportConfig(queryParams); |
| 341 | }).then(response => { | 341 | }).then(response => { |
| 342 | - this.download(response.msg); | 342 | + this.$download.name(response.msg); |
| 343 | this.exportLoading = false; | 343 | this.exportLoading = false; |
| 344 | }).catch(() => {}); | 344 | }).catch(() => {}); |
| 345 | }, | 345 | }, |
| @@ -385,7 +385,7 @@ export default { | @@ -385,7 +385,7 @@ export default { | ||
| 385 | this.exportLoading = true; | 385 | this.exportLoading = true; |
| 386 | return exportData(queryParams); | 386 | return exportData(queryParams); |
| 387 | }).then(response => { | 387 | }).then(response => { |
| 388 | - this.download(response.msg); | 388 | + this.$download.name(response.msg); |
| 389 | this.exportLoading = false; | 389 | this.exportLoading = false; |
| 390 | }).catch(() => {}); | 390 | }).catch(() => {}); |
| 391 | } | 391 | } |
| @@ -343,7 +343,7 @@ export default { | @@ -343,7 +343,7 @@ export default { | ||
| 343 | this.exportLoading = true; | 343 | this.exportLoading = true; |
| 344 | return exportType(queryParams); | 344 | return exportType(queryParams); |
| 345 | }).then(response => { | 345 | }).then(response => { |
| 346 | - this.download(response.msg); | 346 | + this.$download.name(response.msg); |
| 347 | this.exportLoading = false; | 347 | this.exportLoading = false; |
| 348 | }).catch(() => {}); | 348 | }).catch(() => {}); |
| 349 | }, | 349 | }, |
| @@ -310,7 +310,7 @@ export default { | @@ -310,7 +310,7 @@ export default { | ||
| 310 | this.exportLoading = true; | 310 | this.exportLoading = true; |
| 311 | return exportPost(queryParams); | 311 | return exportPost(queryParams); |
| 312 | }).then(response => { | 312 | }).then(response => { |
| 313 | - this.download(response.msg); | 313 | + this.$download.name(response.msg); |
| 314 | this.exportLoading = false; | 314 | this.exportLoading = false; |
| 315 | }).catch(() => {}); | 315 | }).catch(() => {}); |
| 316 | } | 316 | } |
| @@ -618,7 +618,7 @@ export default { | @@ -618,7 +618,7 @@ export default { | ||
| 618 | this.exportLoading = true; | 618 | this.exportLoading = true; |
| 619 | return exportRole(queryParams); | 619 | return exportRole(queryParams); |
| 620 | }).then(response => { | 620 | }).then(response => { |
| 621 | - this.download(response.msg); | 621 | + this.$download.name(response.msg); |
| 622 | this.exportLoading = false; | 622 | this.exportLoading = false; |
| 623 | }).catch(() => {}); | 623 | }).catch(() => {}); |
| 624 | } | 624 | } |
| @@ -648,7 +648,7 @@ export default { | @@ -648,7 +648,7 @@ export default { | ||
| 648 | this.exportLoading = true; | 648 | this.exportLoading = true; |
| 649 | return exportUser(queryParams); | 649 | return exportUser(queryParams); |
| 650 | }).then(response => { | 650 | }).then(response => { |
| 651 | - this.download(response.msg); | 651 | + this.$download.name(response.msg); |
| 652 | this.exportLoading = false; | 652 | this.exportLoading = false; |
| 653 | }).catch(() => {}); | 653 | }).catch(() => {}); |
| 654 | }, | 654 | }, |
| @@ -660,7 +660,7 @@ export default { | @@ -660,7 +660,7 @@ export default { | ||
| 660 | /** 下载模板操作 */ | 660 | /** 下载模板操作 */ |
| 661 | importTemplate() { | 661 | importTemplate() { |
| 662 | importTemplate().then(response => { | 662 | importTemplate().then(response => { |
| 663 | - this.download(response.msg); | 663 | + this.$download.name(response.msg); |
| 664 | }); | 664 | }); |
| 665 | }, | 665 | }, |
| 666 | // 文件上传中处理 | 666 | // 文件上传中处理 |
| @@ -137,23 +137,13 @@ | @@ -137,23 +137,13 @@ | ||
| 137 | 137 | ||
| 138 | <script> | 138 | <script> |
| 139 | import draggable from 'vuedraggable' | 139 | import draggable from 'vuedraggable' |
| 140 | -import { saveAs } from 'file-saver' | ||
| 141 | import beautifier from 'js-beautify' | 140 | import beautifier from 'js-beautify' |
| 142 | import ClipboardJS from 'clipboard' | 141 | import ClipboardJS from 'clipboard' |
| 143 | import render from '@/utils/generator/render' | 142 | import render from '@/utils/generator/render' |
| 144 | import RightPanel from './RightPanel' | 143 | import RightPanel from './RightPanel' |
| 145 | -import { | ||
| 146 | - inputComponents, | ||
| 147 | - selectComponents, | ||
| 148 | - layoutComponents, | ||
| 149 | - formConf | ||
| 150 | -} from '@/utils/generator/config' | ||
| 151 | -import { | ||
| 152 | - exportDefault, beautifierConf, isNumberStr, titleCase | ||
| 153 | -} from '@/utils/index' | ||
| 154 | -import { | ||
| 155 | - makeUpHtml, vueTemplate, vueScript, cssStyle | ||
| 156 | -} from '@/utils/generator/html' | 144 | +import { inputComponents, selectComponents, layoutComponents, formConf } from '@/utils/generator/config' |
| 145 | +import { beautifierConf, titleCase } from '@/utils/index' | ||
| 146 | +import { makeUpHtml, vueTemplate, vueScript, cssStyle } from '@/utils/generator/html' | ||
| 157 | import { makeUpJs } from '@/utils/generator/js' | 147 | import { makeUpJs } from '@/utils/generator/js' |
| 158 | import { makeUpCss } from '@/utils/generator/css' | 148 | import { makeUpCss } from '@/utils/generator/css' |
| 159 | import drawingDefalut from '@/utils/generator/drawingDefalut' | 149 | import drawingDefalut from '@/utils/generator/drawingDefalut' |
| @@ -161,7 +151,6 @@ import logo from '@/assets/logo/logo.png' | @@ -161,7 +151,6 @@ import logo from '@/assets/logo/logo.png' | ||
| 161 | import CodeTypeDialog from './CodeTypeDialog' | 151 | import CodeTypeDialog from './CodeTypeDialog' |
| 162 | import DraggableItem from './DraggableItem' | 152 | import DraggableItem from './DraggableItem' |
| 163 | 153 | ||
| 164 | -const emptyActiveData = { style: {}, autosize: {} } | ||
| 165 | let oldActiveId | 154 | let oldActiveId |
| 166 | let tempActiveData | 155 | let tempActiveData |
| 167 | 156 | ||
| @@ -287,7 +276,7 @@ export default { | @@ -287,7 +276,7 @@ export default { | ||
| 287 | execDownload(data) { | 276 | execDownload(data) { |
| 288 | const codeStr = this.generateCode() | 277 | const codeStr = this.generateCode() |
| 289 | const blob = new Blob([codeStr], { type: 'text/plain;charset=utf-8' }) | 278 | const blob = new Blob([codeStr], { type: 'text/plain;charset=utf-8' }) |
| 290 | - saveAs(blob, data.fileName) | 279 | + this.$download.saveAs(blob, data.fileName) |
| 291 | }, | 280 | }, |
| 292 | execCopy(data) { | 281 | execCopy(data) { |
| 293 | document.getElementById('copyNode').click() | 282 | document.getElementById('copyNode').click() |
| @@ -180,7 +180,6 @@ | @@ -180,7 +180,6 @@ | ||
| 180 | <script> | 180 | <script> |
| 181 | import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen"; | 181 | import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen"; |
| 182 | import importTable from "./importTable"; | 182 | import importTable from "./importTable"; |
| 183 | -import { downLoadZip } from "@/utils/zipdownload"; | ||
| 184 | import hljs from "highlight.js/lib/highlight"; | 183 | import hljs from "highlight.js/lib/highlight"; |
| 185 | import "highlight.js/styles/github-gist.css"; | 184 | import "highlight.js/styles/github-gist.css"; |
| 186 | hljs.registerLanguage("java", require("highlight.js/lib/languages/java")); | 185 | hljs.registerLanguage("java", require("highlight.js/lib/languages/java")); |
| @@ -270,7 +269,7 @@ export default { | @@ -270,7 +269,7 @@ export default { | ||
| 270 | this.$modal.msgSuccess("成功生成到自定义路径:" + row.genPath); | 269 | this.$modal.msgSuccess("成功生成到自定义路径:" + row.genPath); |
| 271 | }); | 270 | }); |
| 272 | } else { | 271 | } else { |
| 273 | - downLoadZip("/tool/gen/batchGenCode?tables=" + tableNames, "ruoyi"); | 272 | + this.$download.zip("/tool/gen/batchGenCode?tables=" + tableNames, "ruoyi"); |
| 274 | } | 273 | } |
| 275 | }, | 274 | }, |
| 276 | /** 同步数据库操作 */ | 275 | /** 同步数据库操作 */ |
-
请 注册 或 登录 后发表评论