1
This commit is contained in:
@@ -210,8 +210,7 @@ class Http {
|
|||||||
let res = await axios.post(url, formData, config)
|
let res = await axios.post(url, formData, config)
|
||||||
filename = filename || res.headers['content-disposition'].split('filename=')[1].split(';')[0]
|
filename = filename || res.headers['content-disposition'].split('filename=')[1].split(';')[0]
|
||||||
|
|
||||||
// 开头和结尾去掉 中间不去掉
|
|
||||||
filename = filename.replace(/^[_-]+|[_-]+$/g, '')
|
|
||||||
|
|
||||||
// 直接下载
|
// 直接下载
|
||||||
if (is_down) {
|
if (is_down) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import http from './http'
|
|||||||
const componentMap = {}
|
const componentMap = {}
|
||||||
|
|
||||||
export default class uiTool {
|
export default class uiTool {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置组件映射表
|
* 设置组件映射表
|
||||||
* @param {Object} map - 组件映射对象
|
* @param {Object} map - 组件映射对象
|
||||||
@@ -12,7 +12,7 @@ export default class uiTool {
|
|||||||
static setComponentMap(map) {
|
static setComponentMap(map) {
|
||||||
Object.assign(componentMap, map)
|
Object.assign(componentMap, map)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据路径获取组件
|
* 根据路径获取组件
|
||||||
* @param {String} componentPath - 组件路径(如 "system/sys_user.vue")
|
* @param {String} componentPath - 组件路径(如 "system/sys_user.vue")
|
||||||
@@ -34,6 +34,9 @@ export default class uiTool {
|
|||||||
* @param {String} fileName - 文件名(可选,默认为时间戳.csv)
|
* @param {String} fileName - 文件名(可选,默认为时间戳.csv)
|
||||||
*/
|
*/
|
||||||
static downloadFile(res, fileName) {
|
static downloadFile(res, fileName) {
|
||||||
|
// 开头和结尾去掉 中间不去掉
|
||||||
|
fileName = fileName.replace(/^[_-]+|[_-]+$/g, '')
|
||||||
|
|
||||||
const blob = new Blob([res.data || res])
|
const blob = new Blob([res.data || res])
|
||||||
const downloadElement = document.createElement('a')
|
const downloadElement = document.createElement('a')
|
||||||
const href = window.URL.createObjectURL(blob)
|
const href = window.URL.createObjectURL(blob)
|
||||||
@@ -188,10 +191,10 @@ export default class uiTool {
|
|||||||
} else if (item.type === '页面' || item.type === '功能') {
|
} else if (item.type === '页面' || item.type === '功能') {
|
||||||
try {
|
try {
|
||||||
let componentPath = item.component
|
let componentPath = item.component
|
||||||
|
|
||||||
// 从组件映射表中获取组件
|
// 从组件映射表中获取组件
|
||||||
let component = uiTool.getComponent(componentPath)
|
let component = uiTool.getComponent(componentPath)
|
||||||
|
|
||||||
if (component) {
|
if (component) {
|
||||||
// 找到了对应的组件
|
// 找到了对应的组件
|
||||||
item.component = component
|
item.component = component
|
||||||
@@ -296,7 +299,7 @@ export default class uiTool {
|
|||||||
// 递归检查所有层级中是否有首页路由
|
// 递归检查所有层级中是否有首页路由
|
||||||
const hasHomeInRoutes = (routes) => {
|
const hasHomeInRoutes = (routes) => {
|
||||||
if (!routes || !Array.isArray(routes)) return false
|
if (!routes || !Array.isArray(routes)) return false
|
||||||
|
|
||||||
for (let route of routes) {
|
for (let route of routes) {
|
||||||
// 检查当前路由的 path
|
// 检查当前路由的 path
|
||||||
if (route.path === '/home' || route.path === 'home') {
|
if (route.path === '/home' || route.path === 'home') {
|
||||||
@@ -314,7 +317,7 @@ export default class uiTool {
|
|||||||
|
|
||||||
const homeRoute = mainRoute.children.find(r => r.path === '/home')
|
const homeRoute = mainRoute.children.find(r => r.path === '/home')
|
||||||
const hasHome = hasHomeInRoutes(curRoutes)
|
const hasHome = hasHomeInRoutes(curRoutes)
|
||||||
|
|
||||||
if (hasHome) {
|
if (hasHome) {
|
||||||
// 如果权限路由中有 home,使用权限路由的 home(不添加默认首页)
|
// 如果权限路由中有 home,使用权限路由的 home(不添加默认首页)
|
||||||
mainRoute.children = curRoutes
|
mainRoute.children = curRoutes
|
||||||
@@ -329,14 +332,14 @@ export default class uiTool {
|
|||||||
// 优先查找首页路由,如果没有则使用第一个菜单项
|
// 优先查找首页路由,如果没有则使用第一个菜单项
|
||||||
const findFirstRoute = (routes) => {
|
const findFirstRoute = (routes) => {
|
||||||
if (!routes || routes.length === 0) return null
|
if (!routes || routes.length === 0) return null
|
||||||
|
|
||||||
for (let route of routes) {
|
for (let route of routes) {
|
||||||
// 优先查找 /home 路由
|
// 优先查找 /home 路由
|
||||||
if (route.path === '/home' || route.path === 'home') {
|
if (route.path === '/home' || route.path === 'home') {
|
||||||
return route.path.startsWith('/') ? route.path : '/' + route.path
|
return route.path.startsWith('/') ? route.path : '/' + route.path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果没有 home,使用第一个页面路由
|
// 如果没有 home,使用第一个页面路由
|
||||||
for (let route of routes) {
|
for (let route of routes) {
|
||||||
if (route.type !== '菜单' && route.path) {
|
if (route.type !== '菜单' && route.path) {
|
||||||
@@ -348,7 +351,7 @@ export default class uiTool {
|
|||||||
if (childRoute) return childRoute
|
if (childRoute) return childRoute
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
快速开始.md
2
快速开始.md
@@ -168,7 +168,7 @@ this.$tools.formatDate(new Date())
|
|||||||
this.$tools.deepClone(obj)
|
this.$tools.deepClone(obj)
|
||||||
|
|
||||||
// 文件下载
|
// 文件下载
|
||||||
this.$funTool.downloadFile(response, 'filename.xlsx')
|
this.$uiTool.downloadFile(response, 'filename.xlsx')
|
||||||
|
|
||||||
// 配置信息
|
// 配置信息
|
||||||
this.$config.title
|
this.$config.title
|
||||||
|
|||||||
Reference in New Issue
Block a user