mirror of
https://gitee.com/dromara/electron-egg.git
synced 2026-05-15 04:02:10 +08:00
36 lines
621 B
JavaScript
36 lines
621 B
JavaScript
/**
|
|
*
|
|
* @type {{foo(*)}}
|
|
*/
|
|
'use strict';
|
|
module.exports = {
|
|
isMobile() {
|
|
const deviceAgent = this.get('user-agent').toLowerCase();
|
|
const agentID = deviceAgent.match(/(iphone|ipod|ipad|android)/);
|
|
if (agentID) {
|
|
// 手机访问
|
|
return true;
|
|
}
|
|
// 电脑访问
|
|
return false;
|
|
},
|
|
success(msg, data, total) {
|
|
this.body = {
|
|
success: true,
|
|
msg,
|
|
result: data,
|
|
total,
|
|
};
|
|
},
|
|
failure(msg, data) {
|
|
this.body = {
|
|
success: false,
|
|
msg,
|
|
result: data,
|
|
};
|
|
},
|
|
async infoPage(msg) {
|
|
await this.render('500', { msg });
|
|
},
|
|
};
|