hookehuyr

写法调整优化

/*
* @Date: 2022-05-18 22:56:08
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-06-18 22:07:50
* @LastEditTime: 2022-06-27 23:49:43
* @FilePath: /tswj/src/api/fn.js
* @Description: 文件描述
*/
......@@ -37,7 +37,11 @@ export const fn = (api) => {
})
}
// 七牛返回格式
/**
* 七牛返回格式
* @param {*} api
* @returns
*/
export const uploadFn = (api) => {
return api
.then(res => {
......
/*
* @Date: 2022-05-16 17:21:45
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-06-29 06:19:41
* @FilePath: /tswj/src/utils/generateRoute.js
* @Description: 文件描述
*/
/**
* 生成动态路由
*/
import _ from 'lodash'
import asyncRoutes from "../mock/routes"
// 根据后台返回的路径,生成页面的组件模版
......@@ -23,33 +29,25 @@ asyncRoutes.forEach(route => {
children
} = route
router.path = path
redirect && (router.redirect = redirect)
name && (router.name = name)
router.component = loadView(component)
if (redirect !== null) {
router.redirect = redirect
}
if (keepAlive !== null) {
router.keepAlive = keepAlive
}
keepAlive && (router.keepAlive = keepAlive)
meta && (router.meta = meta)
if (children && children instanceof Array && children.length > 0) {
router.children = formatRoutes(children)
}
if (name !== null) {
router.name = name
}
if (meta !== null) {
router.meta = meta
}
router.path = path
formatRoutesArr.push(router)
})
export const generateRoute = (to) => {
let router = ''
_.each(formatRoutesArr, item => {
formatRoutesArr.forEach(item => {
if (item.path === to.path) {
router = item
}
})
return _.assign(to, router)
return { ...to, ...router }
}
......