Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-blk
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
1
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
shijian
8 years ago
Commit
eb5b3c5010bf10a35729d74c1531021fac2d72f6
1 parent
4b925071
ajax处理401
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
18 deletions
doraemon/middleware/error-handler.js
package.json
public/js/global.js
public/webpack.config.js
doraemon/middleware/error-handler.js
View file @
eb5b3c5
...
...
@@ -43,24 +43,8 @@ exports.serverError = () => {
if
(
req
.
xhr
)
{
return
res
.
status
(
401
).
json
(
err
);
}
else
if
(
req
.
yoho
.
isApp
)
{
if
(
err
.
lowVersion
)
{
return
res
.
render
(
'error/app-auth'
,
{
module
:
'common'
,
page
:
'app-update'
,
localCss
:
true
,
message
:
err
.
message
});
}
return
res
.
render
(
'error/app-auth'
,
{
module
:
'common'
,
page
:
'app-redirect-login'
,
message
:
'验证失败,请登录'
,
localCss
:
true
,
refer
:
err
.
refer
});
}
else
{
return
res
.
redirect
(
helpers
.
urlFormat
(
'/
signin.html
'
,
{
return
res
.
redirect
(
helpers
.
urlFormat
(
'/
passport/login
'
,
{
refer
:
req
.
originalUrl
}));
}
...
...
package.json
View file @
eb5b3c5
...
...
@@ -117,6 +117,7 @@
"yoho-jquery-placeholder"
:
"^2.3.1"
,
"yoho-jquery-qrcode"
:
"0.0.3"
,
"yoho-json2"
:
"^1.0.0"
,
"yoho-cookie"
:
"^1.2.0"
,
"yoho-slider"
:
"0.0.2"
}
}
\ No newline at end of file
...
...
public/js/global.js
0 → 100644
View file @
eb5b3c5
/**
* 全局引用js
* @author: feng.chen<feng.chen@yoho.cn>
* @date: 2017/03/15
*/
const
$
=
require
(
'yoho-jquery'
);
const
cookie
=
require
(
'yoho-cookie'
);
// 初始化
// 注册ajaxError处理服务端401状态
$
(
document
).
ajaxError
((
event
,
xhr
)
=>
{
if
(
xhr
.
status
===
401
)
{
cookie
.
remove
(
'_UID'
);
cookie
.
remove
(
'_TOKEN'
);
window
.
location
.
href
=
'/passport/login'
;
}
});
...
...
public/webpack.config.js
View file @
eb5b3c5
...
...
@@ -29,7 +29,8 @@ shelljs.ls(path.join(__dirname, '/js/**/*.page.js')).forEach((f) => {
'yoho-jquery-placeholder'
,
'yoho-jquery-qrcode'
,
'yoho-jquery-dotdotdot'
,
'xss'
'xss'
,
path
.
join
(
__dirname
,
'/js/global.js'
)
];
});
...
...
Please
register
or
login
to post a comment