hookehuyr

写法调整优化

1 /* 1 /*
2 * @Date: 2022-05-18 22:56:08 2 * @Date: 2022-05-18 22:56:08
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-06-18 22:07:50 4 + * @LastEditTime: 2022-06-27 23:49:43
5 * @FilePath: /tswj/src/api/fn.js 5 * @FilePath: /tswj/src/api/fn.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -37,7 +37,11 @@ export const fn = (api) => { ...@@ -37,7 +37,11 @@ export const fn = (api) => {
37 }) 37 })
38 } 38 }
39 39
40 -// 七牛返回格式 40 +/**
41 + * 七牛返回格式
42 + * @param {*} api
43 + * @returns
44 + */
41 export const uploadFn = (api) => { 45 export const uploadFn = (api) => {
42 return api 46 return api
43 .then(res => { 47 .then(res => {
......
1 +/*
2 + * @Date: 2022-05-16 17:21:45
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2022-06-29 06:19:41
5 + * @FilePath: /tswj/src/utils/generateRoute.js
6 + * @Description: 文件描述
7 + */
1 /** 8 /**
2 * 生成动态路由 9 * 生成动态路由
3 */ 10 */
4 -import _ from 'lodash'
5 import asyncRoutes from "../mock/routes" 11 import asyncRoutes from "../mock/routes"
6 12
7 // 根据后台返回的路径,生成页面的组件模版 13 // 根据后台返回的路径,生成页面的组件模版
...@@ -23,33 +29,25 @@ asyncRoutes.forEach(route => { ...@@ -23,33 +29,25 @@ asyncRoutes.forEach(route => {
23 children 29 children
24 } = route 30 } = route
25 31
32 + router.path = path
33 + redirect && (router.redirect = redirect)
34 + name && (router.name = name)
26 router.component = loadView(component) 35 router.component = loadView(component)
27 - if (redirect !== null) { 36 + keepAlive && (router.keepAlive = keepAlive)
28 - router.redirect = redirect 37 + meta && (router.meta = meta)
29 - }
30 - if (keepAlive !== null) {
31 - router.keepAlive = keepAlive
32 - }
33 if (children && children instanceof Array && children.length > 0) { 38 if (children && children instanceof Array && children.length > 0) {
34 router.children = formatRoutes(children) 39 router.children = formatRoutes(children)
35 } 40 }
36 - if (name !== null) {
37 - router.name = name
38 - }
39 - if (meta !== null) {
40 - router.meta = meta
41 - }
42 - router.path = path
43 41
44 formatRoutesArr.push(router) 42 formatRoutesArr.push(router)
45 }) 43 })
46 44
47 export const generateRoute = (to) => { 45 export const generateRoute = (to) => {
48 let router = '' 46 let router = ''
49 - _.each(formatRoutesArr, item => { 47 + formatRoutesArr.forEach(item => {
50 if (item.path === to.path) { 48 if (item.path === to.path) {
51 router = item 49 router = item
52 } 50 }
53 }) 51 })
54 - return _.assign(to, router) 52 + return { ...to, ...router }
55 } 53 }
......