Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
store-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 8a8c0297
authored
Oct 12, 2022
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
配置图片全局路径 IMG_URL
1 parent
7051fa06
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
22 deletions
mixins/index.js
router/routerBefore.js
mixins/index.js
View file @
8a8c029
module
.
exports
=
{
}
\ No newline at end of file
\ No newline at end of file
module
.
exports
=
{}
router/routerBefore.js
View file @
8a8c029
import
{
IMG_URL
}
from
'~/utils/constantData'
/**
/**
* 执行路由前的准备工作
* 执行路由前的准备工作
*/
*/
/**处理前置钩子逻辑 */
/**处理前置钩子逻辑 */
const
routerBefore
=
(
next
)
=>
{
const
routerBefore
=
next
=>
{
// console.log("处理前置钩子逻辑");
// console.log("处理前置钩子逻辑");
// 配置图片全局路径
let
page
=
wx
.
$router
.
getPageInstance
()
page
&&
(
page
.
data
.
IMG_URL
=
IMG_URL
)
next
()
;
next
()
}
;
}
/**处理后置钩子逻辑 */
/**处理后置钩子逻辑 */
const
routerAfter
=
(
next
)
=>
{
const
routerAfter
=
next
=>
{
// console.log("处理后置钩子逻辑");
// console.log("处理后置钩子逻辑");
next
()
;
next
()
}
;
}
// 重写Page方法
// 重写Page方法
const
OldPage
=
Page
;
const
OldPage
=
Page
Page
=
function
(
options
)
{
Page
=
function
(
options
)
{
const
oldShow
=
options
.
onShow
;
const
oldShow
=
options
.
onShow
const
oldHide
=
options
.
onHide
;
const
oldHide
=
options
.
onHide
options
.
onShow
=
function
()
{
options
.
onShow
=
function
()
{
routerBefore
(()
=>
{
routerBefore
(()
=>
{
oldShow
.
apply
(
this
,
arguments
)
;
oldShow
.
apply
(
this
,
arguments
)
})
;
})
}
;
}
options
.
onHide
=
function
()
{
options
.
onHide
=
function
()
{
routerAfter
(()
=>
{
routerAfter
(()
=>
{
oldHide
.
apply
(
this
,
arguments
)
;
oldHide
.
apply
(
this
,
arguments
)
})
;
})
}
;
}
OldPage
(
options
)
;
OldPage
(
options
)
}
;
}
export
default
routerBefore
;
export
default
routerBefore
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