Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
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
4c99a9be38dc50bf22456f12031383656d350f8d
1 parent
03f3d688
增加手机检测
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
app.js
doraemon/middleware/mobile-check.js
app.js
View file @
4c99a9b
...
...
@@ -78,12 +78,14 @@ const logger = require('./library/logger');
// dispatcher
try
{
const
mobileCheck
=
require
(
'./doraemon/middleware/mobile-check'
);
const
user
=
require
(
'./doraemon/middleware/user'
);
const
seo
=
require
(
'./doraemon/middleware/seo'
);
const
setYohoData
=
require
(
'./doraemon/middleware/set-yoho-data'
);
const
errorHanlder
=
require
(
'./doraemon/middleware/error-handler'
);
// YOHO 前置中间件
app
.
use
(
mobileCheck
());
app
.
use
(
setYohoData
());
app
.
use
(
user
());
app
.
use
(
seo
());
...
...
doraemon/middleware/mobile-check.js
0 → 100644
View file @
4c99a9b
/**
* 手机访问检测
*/
'use strict'
;
module
.
exports
=
()
=>
{
return
(
req
,
res
,
next
)
=>
{
let
isMobile
=
/
(
nokia|iphone|android|ipad|motorola|^mot
\-
|softbank|foma|docomo|kddi|up
\.
browser|up
\.
link|htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam
\-
|s
[
cg
]
h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte
\-
|longcos|pantech|gionee|^sie
\-
|portalmmm|jig
\s
browser|hiptop|^ucweb|^benq|haier|^lct|opera
\s
*mobi|opera
\*
mini|320x320|240x320|176x220
)
/i
.
test
(
req
.
get
(
'user-agent'
));
// eslint-disable-line
if
(
isMobile
)
{
return
res
.
redirect
(
`
//m.yohobuy.com${req.url}`);
}
next
();
};
};
...
...
Please
register
or
login
to post a comment