Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-boutique-work-wechat
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c4ea6a59
authored
Apr 08, 2026
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix 路由跳转处理
1 parent
29cc0abe
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
4 deletions
router/router.js
router/routers.js
router/router.js
View file @
c4ea6a5
...
@@ -2,6 +2,14 @@ const _routeHooks = Symbol('_routeHooks')
...
@@ -2,6 +2,14 @@ const _routeHooks = Symbol('_routeHooks')
const
_query
=
Symbol
(
'_query'
)
const
_query
=
Symbol
(
'_query'
)
const
_routerList
=
Symbol
(
'_routerList'
)
const
_routerList
=
Symbol
(
'_routerList'
)
import
util
from
'../utils/util.js'
import
util
from
'../utils/util.js'
/** 与 tabBar 等处一致:去掉前导 /、.html 后缀,避免开发与真机 path 形态不一致导致 find 失败 */
function
normalizeRoutePath
(
p
)
{
if
(
p
==
null
||
p
===
''
)
return
''
return
String
(
p
)
.
replace
(
/^
\/
+/
,
''
)
.
replace
(
/
\.
html$/i
,
''
)
}
const
generateRoutList
=
routerList
=>
{
const
generateRoutList
=
routerList
=>
{
let
_routerList
=
routerList
let
_routerList
=
routerList
try
{
try
{
...
@@ -28,9 +36,17 @@ class Router {
...
@@ -28,9 +36,17 @@ class Router {
wx
.
onAppRoute
&&
wx
.
onAppRoute
&&
wx
.
onAppRoute
(
e
=>
{
wx
.
onAppRoute
(
e
=>
{
const
thisPage
=
this
.
getPageInstance
()
const
thisPage
=
this
.
getPageInstance
()
const
thisRouter
=
this
[
_routerList
].
find
(
item
=>
item
.
url
===
`/
${
e
.
path
}
`
)
const
routeKey
=
normalizeRoutePath
(
e
.
path
)
// console.log(thisRouter)
const
thisRouter
=
this
[
_routerList
].
find
(
if
(
thisRouter
.
isTab
)
{
item
=>
normalizeRoutePath
(
item
.
url
)
===
routeKey
)
try
{
const
app
=
typeof
getApp
===
'function'
?
getApp
()
:
null
if
(
!
thisRouter
&&
app
&&
app
.
globalData
&&
app
.
globalData
.
routeDebug
)
{
console
.
warn
(
'[router] onAppRoute 未命中'
,
e
.
path
,
'normalized:'
,
routeKey
)
}
}
catch
(
err
)
{
}
if
(
thisRouter
?.
isTab
)
{
wx
.
showTabBar
({
wx
.
showTabBar
({
success
(
result
)
{
success
(
result
)
{
// console.log(result)
// console.log(result)
...
...
router/routers.js
View file @
c4ea6a5
export
default
__wxConfig
.
pages
.
map
(
item
=>
({
function
collectWxPagePaths
()
{
const
main
=
__wxConfig
.
pages
||
[]
const
subPkgs
=
__wxConfig
.
subPackages
||
__wxConfig
.
subpackages
||
[]
const
subPaths
=
subPkgs
.
flatMap
(
pkg
=>
{
const
root
=
(
pkg
.
root
||
''
).
replace
(
/
\/
$/
,
''
)
return
(
pkg
.
pages
||
[]).
map
(
p
=>
{
const
page
=
String
(
p
||
''
).
replace
(
/^
\/
/
,
''
)
return
root
?
`
${
root
}
/
${
page
}
`
:
page
})
})
return
[...
main
,
...
subPaths
]
}
export
default
collectWxPagePaths
().
map
(
item
=>
({
url
:
`/
${
item
}
`
,
url
:
`/
${
item
}
`
,
name
:
item
.
split
(
'/'
).
pop
(),
name
:
item
.
split
(
'/'
).
pop
(),
parent
:
item
.
split
(
'/'
)[
0
]
parent
:
item
.
split
(
'/'
)[
0
]
...
...
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