Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
tswj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2022-06-29 06:28:50 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
07c4e49e3034624ce98470efbb3185d8c9440287
07c4e49e
1 parent
0ecf7ee1
写法调整优化
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
18 deletions
src/api/fn.js
src/utils/generateRoute.js
src/api/fn.js
View file @
07c4e49
/*
* @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
=>
{
...
...
src/utils/generateRoute.js
View file @
07c4e49
/*
* @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
}
}
...
...
Please
register
or
login
to post a comment