Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-activity-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
毕凯
9 years ago
Commit
3f432c89ddb29697347cd1f3b37f0988f0ffdc53
1 parent
87c92a81
修改向模板注入变量方法
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
8 deletions
app.js
util/error.js
app.js
View file @
3f432c8
...
...
@@ -49,12 +49,7 @@ app.use(session({
}));
// 向模板注入变量
app
.
use
(
function
(
req
,
res
,
next
)
{
// TODO: 优化
res
.
locals
.
devEnv
=
app
.
get
(
'env'
)
===
'development'
;
next
();
});
app
.
locals
.
devEnv
=
app
.
get
(
'env'
)
===
'development'
;
// 加载路由
app
.
use
(
'/'
,
require
(
'./router'
));
...
...
@@ -69,7 +64,7 @@ app.use(function(req, res) {
// 捕获全局错误, 开发环境返回错误详情
app
.
use
(
function
(
err
,
req
,
res
)
{
if
(
app
.
get
(
'env'
)
===
'development'
)
{
if
(
app
.
locals
.
devEnv
)
{
console
.
log
(
err
);
}
else
{
err
=
{};
...
...
util/error.js
View file @
3f432c8
...
...
@@ -8,7 +8,7 @@ exports.apiError = (err) => {
// 控制返回到页面的错误信息
exports
.
webError
=
(
err
,
res
)
=>
{
if
(
res
.
locals
.
isDevelop
)
{
if
(
res
.
app
.
locals
.
devEnv
)
{
console
.
log
(
err
);
}
else
{
err
=
{};
...
...
Please
register
or
login
to post a comment