Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
business-assistant
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 6c091b7f
authored
Oct 11, 2022
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修复路由方法
1 parent
55dfdcb6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
30 deletions
router/router.js
router/routerBefore.js
router/wxOnAppRoute.js
router/router.js
View file @
6c091b7
...
...
@@ -2,8 +2,7 @@ const _routeHooks = Symbol('_routeHooks')
const
_query
=
Symbol
(
'_query'
)
const
_routerList
=
Symbol
(
'_routerList'
)
import
{
generateRoutList
,
wxOnAppRouteFn
generateRoutList
}
from
'./wxOnAppRoute.js'
import
{
getNavigationBarTitleText
...
...
@@ -80,10 +79,13 @@ class Router {
/**只传页面名 默认跳转当前包下的页面,相同名称默认第一个 */
if
(
!
_name
&&
!
last_name
)
name
=
_parent
const
routerMapItem
=
this
[
_routerList
].
find
(
item
=>
{
if
(
last_name
)
{
return
item
.
parent
===
parent
&&
item
.
name
===
last_name
&&
item
.
subPages
===
name
}
else
{
return
item
.
parent
===
parent
&&
item
.
name
===
name
if
(
route
.
includes
(
'/'
))
return
item
.
url
===
route
else
{
if
(
last_name
)
{
return
item
.
parent
===
parent
&&
item
.
name
===
last_name
&&
item
.
subPages
===
name
}
else
{
return
item
.
parent
===
parent
&&
item
.
name
===
name
}
}
})
if
(
!
routerMapItem
)
{
...
...
@@ -172,7 +174,6 @@ class Router {
if
(
Object
.
keys
(
data
).
length
!==
0
)
data
.
on
(
'getData'
,
res
=>
callBack
(
res
))
}
onRoute
(
fn
)
{
console
.
log
(
fn
)
this
[
_routeHooks
].
push
(
fn
)
return
()
=>
{
const
i
=
list
.
indexOf
(
fn
)
...
...
router/routerBefore.js
View file @
6c091b7
...
...
@@ -5,7 +5,6 @@
/**处理前置钩子逻辑 */
const
routerBefore
=
(
next
)
=>
{
// console.log("处理前置钩子逻辑");
next
();
};
/**处理后置钩子逻辑 */
...
...
@@ -33,4 +32,4 @@ Page = function (options) {
OldPage
(
options
);
};
export
default
routerBefore
;
export
default
routerBefore
;
\ No newline at end of file
router/wxOnAppRoute.js
View file @
6c091b7
...
...
@@ -17,27 +17,6 @@ import {
* @param {*} obj.setNavigationBarTitleText
* @param {*} obj.getRouterList
*/
/**有问题,query一直为空 */
export
const
wxOnAppRouteFn
=
(
obj
,
a
)
=>
{
wx
.
onAppRoute
&&
wx
.
onAppRoute
(
e
=>
{
let
thisPage
=
obj
.
getPageInstance
()
if
(
thisPage
)
{
obj
.
setNavigationBarTitleText
(
thisPage
)
let
onRoute
=
thisPage
.
onRoute
typeof
onRoute
===
'function'
&&
onRoute
(
obj
.
query
)
}
obj
.
routeHooks
.
forEach
(
fn
=>
{
try
{
typeof
fn
===
'function'
&&
fn
(
e
,
obj
.
query
,
obj
.
routerList
)
}
catch
(
err
)
{
console
.
log
(
err
)
}
})
obj
.
query
=
{}
})
}
/**
* 生成特定格式路由
*
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment