1
This commit is contained in:
38
src/index.js
38
src/index.js
@@ -20,21 +20,6 @@ import uiTool from './utils/uiTool'
|
|||||||
import http from './utils/http'
|
import http from './utils/http'
|
||||||
import * as tools from './utils/tools'
|
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 storeModules, { userModule, appModule } from './store'
|
||||||
|
|
||||||
import { createBaseRoutes, setupRouterGuards } from './router'
|
import { createBaseRoutes, setupRouterGuards } from './router'
|
||||||
@@ -88,7 +73,6 @@ class AdminFramework {
|
|||||||
this.tools = tools
|
this.tools = tools
|
||||||
this.uiTool = uiTool
|
this.uiTool = uiTool
|
||||||
this.http = http
|
this.http = http
|
||||||
this.funTool = funTool
|
|
||||||
|
|
||||||
this.storeModules = storeModules
|
this.storeModules = storeModules
|
||||||
this.userModule = userModule
|
this.userModule = userModule
|
||||||
@@ -146,7 +130,6 @@ class AdminFramework {
|
|||||||
Vue.prototype.$http = http
|
Vue.prototype.$http = http
|
||||||
Vue.prototype.$tools = tools
|
Vue.prototype.$tools = tools
|
||||||
Vue.prototype.$uiTool = uiTool
|
Vue.prototype.$uiTool = uiTool
|
||||||
Vue.prototype.$funTool = funTool
|
|
||||||
Vue.prototype.$framework = this
|
Vue.prototype.$framework = this
|
||||||
|
|
||||||
this.registerGlobalComponents(Vue)
|
this.registerGlobalComponents(Vue)
|
||||||
@@ -436,7 +419,6 @@ export {
|
|||||||
tools,
|
tools,
|
||||||
uiTool,
|
uiTool,
|
||||||
http,
|
http,
|
||||||
funTool,
|
|
||||||
|
|
||||||
storeModules,
|
storeModules,
|
||||||
userModule,
|
userModule,
|
||||||
@@ -445,25 +427,5 @@ export {
|
|||||||
createBaseRoutes,
|
createBaseRoutes,
|
||||||
setupRouterGuards,
|
setupRouterGuards,
|
||||||
|
|
||||||
HomePage,
|
|
||||||
SysLog,
|
|
||||||
SysParamSetup,
|
|
||||||
SysRole,
|
|
||||||
SysUser,
|
|
||||||
SysControl,
|
|
||||||
SysMenu,
|
|
||||||
SysTitle,
|
|
||||||
|
|
||||||
LoginPage,
|
|
||||||
Page401,
|
|
||||||
Page404,
|
|
||||||
Page500,
|
|
||||||
|
|
||||||
Main,
|
|
||||||
ParentView,
|
|
||||||
|
|
||||||
systemApi,
|
|
||||||
systemHighApi,
|
|
||||||
|
|
||||||
AdminFramework
|
AdminFramework
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,23 @@ export default class uiTool {
|
|||||||
// 从映射表中查找
|
// 从映射表中查找
|
||||||
return componentMap[normalizedPath] || componentMap[componentPath]
|
return componentMap[normalizedPath] || componentMap[componentPath]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件下载工具
|
||||||
|
* @param {Object|Blob} res - 响应数据或Blob对象
|
||||||
|
* @param {String} fileName - 文件名(可选,默认为时间戳.csv)
|
||||||
|
*/
|
||||||
|
static 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)
|
||||||
|
}
|
||||||
static setRem() {
|
static setRem() {
|
||||||
let whdef = 100 / 1920
|
let whdef = 100 / 1920
|
||||||
let bodyWidth = document.body.clientWidth
|
let bodyWidth = document.body.clientWidth
|
||||||
|
|||||||
Reference in New Issue
Block a user