1
This commit is contained in:
17
src/index.js
17
src/index.js
@@ -12,6 +12,21 @@ import uiTool from './utils/uiTool'
|
||||
import http from './utils/http'
|
||||
import * as tools from './utils/tools'
|
||||
|
||||
// 文件下载工具
|
||||
const funTool = {
|
||||
downloadFile: (res, fileName) => {
|
||||
const blob = new Blob([res.data || res])
|
||||
const downloadElement = document.createElement('a')
|
||||
const href = window.URL.createObjectURL(blob)
|
||||
downloadElement.href = href
|
||||
downloadElement.download = fileName || new Date().getTime() + '.csv'
|
||||
document.body.appendChild(downloadElement)
|
||||
downloadElement.click()
|
||||
document.body.removeChild(downloadElement)
|
||||
window.URL.revokeObjectURL(href)
|
||||
}
|
||||
}
|
||||
|
||||
import storeModules, { userModule, appModule } from './store'
|
||||
|
||||
import routerConfig, { createBaseRoutes, setupRouterGuards } from './router'
|
||||
@@ -64,6 +79,7 @@ class AdminFramework {
|
||||
this.tools = tools
|
||||
this.uiTool = uiTool
|
||||
this.http = http
|
||||
this.funTool = funTool
|
||||
|
||||
this.storeModules = storeModules
|
||||
this.userModule = userModule
|
||||
@@ -316,6 +332,7 @@ export {
|
||||
tools,
|
||||
uiTool,
|
||||
http,
|
||||
funTool,
|
||||
|
||||
storeModules,
|
||||
userModule,
|
||||
|
||||
Reference in New Issue
Block a user